diff --git a/ComputersShop/ComputersShop/ComputersShopView.csproj b/ComputersShop/ComputersShop/ComputersShopView.csproj
index ee75c7f..d63b297 100644
--- a/ComputersShop/ComputersShop/ComputersShopView.csproj
+++ b/ComputersShop/ComputersShop/ComputersShopView.csproj
@@ -1,5 +1,13 @@
-
+
+ $(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB
+
+
+ $(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC
+
+
+ 10.0
+
WinExe
net6.0-windows
@@ -7,17 +15,20 @@
true
enable
-
+
-
Always
-
+
+
+ Always
+
+
all
@@ -25,8 +36,8 @@
+
-
@@ -34,5 +45,23 @@
-
+
+
+ $(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll
+ True
+
+
+ $(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll
+ True
+
+
+ $(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll
+ True
+
+
+
+ 3.1
+
+
+
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop/FormMain.Designer.cs b/ComputersShop/ComputersShop/FormMain.Designer.cs
index 47f36ae..ddd57a7 100644
--- a/ComputersShop/ComputersShop/FormMain.Designer.cs
+++ b/ComputersShop/ComputersShop/FormMain.Designer.cs
@@ -38,8 +38,11 @@
this.refbooksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.computersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.reportComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.reportComputerComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
@@ -119,7 +122,8 @@
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.refbooksToolStripMenuItem});
+ this.refbooksToolStripMenuItem,
+ this.reportsToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1256, 28);
@@ -138,17 +142,48 @@
// componentsToolStripMenuItem
//
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
- this.componentsToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.componentsToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.componentsToolStripMenuItem.Text = "Компоненты";
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
//
// computersToolStripMenuItem
//
this.computersToolStripMenuItem.Name = "computersToolStripMenuItem";
- this.computersToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.computersToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.computersToolStripMenuItem.Text = "Изделия";
this.computersToolStripMenuItem.Click += new System.EventHandler(this.ComputersToolStripMenuItem_Click);
//
+ // reportsToolStripMenuItem
+ //
+ this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.reportComponentsToolStripMenuItem,
+ this.reportComputerComponentsToolStripMenuItem,
+ this.reportOrdersToolStripMenuItem});
+ this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
+ this.reportsToolStripMenuItem.Size = new System.Drawing.Size(62, 24);
+ this.reportsToolStripMenuItem.Text = "Отчет";
+ //
+ // reportComponentsToolStripMenuItem
+ //
+ this.reportComponentsToolStripMenuItem.Name = "reportComponentsToolStripMenuItem";
+ this.reportComponentsToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
+ this.reportComponentsToolStripMenuItem.Text = "Список компонентов";
+ this.reportComponentsToolStripMenuItem.Click += new System.EventHandler(this.ReportComponentsToolStripMenuItem_Click);
+ //
+ // reportComputerComponentsToolStripMenuItem
+ //
+ this.reportComputerComponentsToolStripMenuItem.Name = "reportComputerComponentsToolStripMenuItem";
+ this.reportComputerComponentsToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
+ this.reportComputerComponentsToolStripMenuItem.Text = "Компоненты по изделиям";
+ this.reportComputerComponentsToolStripMenuItem.Click += new System.EventHandler(this.ReportComputerComponentsToolStripMenuItem_Click);
+ //
+ // reportOrdersToolStripMenuItem
+ //
+ this.reportOrdersToolStripMenuItem.Name = "reportOrdersToolStripMenuItem";
+ this.reportOrdersToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
+ this.reportOrdersToolStripMenuItem.Text = "Список заказов";
+ this.reportOrdersToolStripMenuItem.Click += new System.EventHandler(this.ReportOrdersToolStripMenuItem_Click);
+ //
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
@@ -164,6 +199,7 @@
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMain";
this.Text = "Продажа компьютеров";
+ this.Load += new System.EventHandler(this.FormMain_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
@@ -184,5 +220,9 @@
private ToolStripMenuItem refbooksToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem computersToolStripMenuItem;
+ private ToolStripMenuItem reportsToolStripMenuItem;
+ private ToolStripMenuItem reportComponentsToolStripMenuItem;
+ private ToolStripMenuItem reportComputerComponentsToolStripMenuItem;
+ private ToolStripMenuItem reportOrdersToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop/FormMain.cs b/ComputersShop/ComputersShop/FormMain.cs
index 2243e47..e47f50d 100644
--- a/ComputersShop/ComputersShop/FormMain.cs
+++ b/ComputersShop/ComputersShop/FormMain.cs
@@ -1,3 +1,4 @@
+using ComputersShopBusinessLogic.OfficePackage;
using ComputersShopContracts.BindingModels;
using ComputersShopContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
@@ -8,11 +9,13 @@ namespace ComputersShopView
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
+ private readonly IReportLogic _reportLogic;
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
+ _reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
@@ -137,5 +140,35 @@ namespace ComputersShopView
{
LoadData();
}
+
+ private void ReportComponentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
+ MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+
+ private void ReportComputerComponentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportComputerComponents));
+ if (service is FormReportComputerComponents form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void ReportOrdersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
+ if (service is FormReportOrders form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop/FormReportComputerComponents.Designer.cs b/ComputersShop/ComputersShop/FormReportComputerComponents.Designer.cs
new file mode 100644
index 0000000..0eb0089
--- /dev/null
+++ b/ComputersShop/ComputersShop/FormReportComputerComponents.Designer.cs
@@ -0,0 +1,122 @@
+namespace ComputersShopView
+{
+ partial class FormReportComputerComponents
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonSaveToExcel = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ColumnManufacture = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnSum = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonSaveToExcel
+ //
+ this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 23);
+ this.buttonSaveToExcel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonSaveToExcel.Name = "buttonSaveToExcel";
+ this.buttonSaveToExcel.Size = new System.Drawing.Size(215, 31);
+ this.buttonSaveToExcel.TabIndex = 3;
+ this.buttonSaveToExcel.Text = "Сохранить в Excel";
+ this.buttonSaveToExcel.UseVisualStyleBackColor = true;
+ this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnManufacture,
+ this.ColumnComponent,
+ this.ColumnCount,
+ this.ColumnSum});
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.dataGridView.Location = new System.Drawing.Point(0, 84);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(678, 540);
+ this.dataGridView.TabIndex = 2;
+ //
+ // ColumnManufacture
+ //
+ this.ColumnManufacture.HeaderText = "Изделие";
+ this.ColumnManufacture.MinimumWidth = 6;
+ this.ColumnManufacture.Name = "ColumnManufacture";
+ this.ColumnManufacture.Width = 125;
+ //
+ // ColumnComponent
+ //
+ this.ColumnComponent.HeaderText = "Компонент";
+ this.ColumnComponent.MinimumWidth = 6;
+ this.ColumnComponent.Name = "ColumnComponent";
+ this.ColumnComponent.Width = 125;
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.MinimumWidth = 6;
+ this.ColumnCount.Name = "ColumnCount";
+ this.ColumnCount.Width = 125;
+ //
+ // ColumnSum
+ //
+ this.ColumnSum.HeaderText = "Сумма";
+ this.ColumnSum.MinimumWidth = 6;
+ this.ColumnSum.Name = "ColumnSum";
+ this.ColumnSum.Width = 125;
+ //
+ // FormReportComputerComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(678, 624);
+ this.Controls.Add(this.buttonSaveToExcel);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormReportComputerComponents";
+ this.Text = "FormReportComputerComponents";
+ this.Load += new System.EventHandler(this.FormReportComputerComponents_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button buttonSaveToExcel;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ColumnManufacture;
+ private DataGridViewTextBoxColumn ColumnComponent;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private DataGridViewTextBoxColumn ColumnSum;
+ }
+}
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop/FormReportComputerComponents.cs b/ComputersShop/ComputersShop/FormReportComputerComponents.cs
new file mode 100644
index 0000000..819b510
--- /dev/null
+++ b/ComputersShop/ComputersShop/FormReportComputerComponents.cs
@@ -0,0 +1,71 @@
+using ComputersShopContracts.BindingModels;
+using ComputersShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace ComputersShopView
+{
+ public partial class FormReportComputerComponents : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportComputerComponents(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormReportComputerComponents_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetComputerComponent();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.ComputerName, "", "" });
+ foreach (var listElem in elem.Components)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2, listElem.Item3 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount, elem.TotalSum });
+ dataGridView.Rows.Add(Array.Empty