diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs
index f841985..849bbff 100644
--- a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs
+++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs
@@ -207,6 +207,7 @@
this.ShopsFurnituresToolStripMenuItem.Name = "ShopsFurnituresToolStripMenuItem";
this.ShopsFurnituresToolStripMenuItem.Size = new System.Drawing.Size(216, 22);
this.ShopsFurnituresToolStripMenuItem.Text = "Изделия в магазинах";
+ this.ShopsFurnituresToolStripMenuItem.Click += new System.EventHandler(this.ShopsFurnituresToolStripMenuItem_Click);
//
// OrderDateToolStripMenuItem
//
diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs
index eee9fe1..14d6c1d 100644
--- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs
+++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs
@@ -234,5 +234,14 @@ namespace FurnitureAssembly
MessageBoxIcon.Information);
}
}
+
+ private void ShopsFurnituresToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportShopFurnitures));
+ if (service is FormReportShopFurnitures form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportShopFurnitures.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReportShopFurnitures.Designer.cs
new file mode 100644
index 0000000..c07d679
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FormReportShopFurnitures.Designer.cs
@@ -0,0 +1,104 @@
+namespace FurnitureAssembly
+{
+ partial class FormReportShopFurnitures
+ {
+ ///
+ /// 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.Shop = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Furniture = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // ButtonSaveToExcel
+ //
+ this.ButtonSaveToExcel.Location = new System.Drawing.Point(12, 22);
+ this.ButtonSaveToExcel.Name = "ButtonSaveToExcel";
+ this.ButtonSaveToExcel.Size = new System.Drawing.Size(166, 27);
+ this.ButtonSaveToExcel.TabIndex = 1;
+ this.ButtonSaveToExcel.Text = "Сохранить в Excel";
+ this.ButtonSaveToExcel.UseVisualStyleBackColor = true;
+ this.ButtonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.Shop,
+ this.Furniture,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(12, 80);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(600, 358);
+ this.dataGridView.TabIndex = 2;
+ //
+ // Shop
+ //
+ this.Shop.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Shop.HeaderText = "Магазин";
+ this.Shop.Name = "Shop";
+ //
+ // Furniture
+ //
+ this.Furniture.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Furniture.HeaderText = "Изделие";
+ this.Furniture.Name = "Furniture";
+ //
+ // Count
+ //
+ this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+ this.Count.HeaderText = "Количество";
+ this.Count.Name = "Count";
+ this.Count.Width = 97;
+ //
+ // FormReportShopFurnitures
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(627, 450);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.ButtonSaveToExcel);
+ this.Name = "FormReportShopFurnitures";
+ this.Text = "Магазины с изделиями";
+ this.Load += new System.EventHandler(this.FormReportShopFurnitures_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button ButtonSaveToExcel;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn Shop;
+ private DataGridViewTextBoxColumn Furniture;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportShopFurnitures.cs b/FurnitureAssembly/FurnitureAssembly/FormReportShopFurnitures.cs
new file mode 100644
index 0000000..e4b3d87
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FormReportShopFurnitures.cs
@@ -0,0 +1,87 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContarcts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssembly
+{
+ public partial class FormReportShopFurnitures : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportShopFurnitures(ILogger logger, IReportLogic reportLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = reportLogic;
+ }
+
+ private void ButtonSaveToExcel_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog
+ {
+ Filter = "xlsx|*.xlsx"
+ };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ _logic.SaveShopFurnituresToExcelFile(new
+ ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ _logger.LogInformation("Сохранение списка магазинов с изделиями в них");
+
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения списка магазинов с изделиями в них");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void FormReportShopFurnitures_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetShopFurnitures();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
+ foreach (var listElem in elem.Furnitures)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty