diff --git a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index ee68173..0ad8d41 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -33,24 +33,24 @@ namespace ConfectioneryBusinessLogic.OfficePackage }); uint rowIndex = 2; - foreach (var pc in info.PastryComponents) + foreach (var pc in info.ShopPastries) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "A", RowIndex = rowIndex, - Text = pc.PastryName, + Text = pc.ShopName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var (Pastry, Count) in pc.Components) + foreach (var (Shop, Count) in pc.Pastries) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = Pastry, + Text = Shop, StyleInfo = ExcelStyleInfoType.TextWithBroder }); @@ -80,6 +80,21 @@ namespace ConfectioneryBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Загруженность", + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.Workload.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; } SaveExcel(info); diff --git a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 48d3340..431a532 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -6,7 +6,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List PastryComponents + public List ShopPastries { get; set; diff --git a/ConfectionaryBusinessLogic/ReportLogic.cs b/ConfectionaryBusinessLogic/ReportLogic.cs index 60df17c..453b0fa 100644 --- a/ConfectionaryBusinessLogic/ReportLogic.cs +++ b/ConfectionaryBusinessLogic/ReportLogic.cs @@ -10,8 +10,6 @@ namespace ConfectioneryBusinessLogic { public class ReportLogic : IReportLogic { - private readonly IComponentStorage _componentStorage; - private readonly IPastryStorage _pastryStorage; private readonly IOrderStorage _orderStorage; @@ -24,11 +22,10 @@ namespace ConfectioneryBusinessLogic private readonly AbstractSaveToPdf _saveToPdf; - public ReportLogic(IPastryStorage PastryStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage, + public ReportLogic(IPastryStorage PastryStorage, IOrderStorage orderStorage, IShopStorage shopStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _pastryStorage = PastryStorage; - _componentStorage = componentStorage; _orderStorage = orderStorage; _shopStorage = shopStorage; @@ -38,34 +35,34 @@ namespace ConfectioneryBusinessLogic } /// - /// Получение списка компонент с указанием, в каких изделиях используются + /// Получение списка магазинов с изделиями /// /// - public List GetPastryComponent() + public List GetShopPastries() { - var components = _componentStorage.GetFullList(); + var shops = _shopStorage.GetFullList(); var pastries = _pastryStorage.GetFullList(); - var list = new List(); + var list = new List(); - foreach (var pastry in pastries) + foreach (var shop in shops) { - var record = new ReportPastryComponentViewModel + var record = new ReportShopPastrytViewModel { - PastryName = pastry.PastryName, - Components = new List>(), + ShopName = shop.Name, + Pastries = new List>(), TotalCount = 0 }; - foreach (var component in components) + foreach (var pastry in pastries) { - if (pastry.PastryComponents.ContainsKey(component.Id)) + if (shop.Pastries.ContainsKey(pastry.Id)) { - record.Components.Add(new(component.ComponentName, pastry.PastryComponents[component.Id].Item2)); - record.TotalCount += pastry.PastryComponents[component.Id].Item2; + record.Pastries.Add(new(pastry.PastryName, shop.Pastries[pastry.Id].Item2)); + record.TotalCount += shop.Pastries[pastry.Id].Item2; } } - + record.Workload = record.TotalCount / (double)shop.MaxCountPastries; list.Add(record); } @@ -106,16 +103,16 @@ namespace ConfectioneryBusinessLogic } /// - /// Сохранение изделий с указаеним продуктов в файл-Excel + /// Сохранение магазинов с указаеним продуктов в файл-Excel /// /// - public void SavePastryComponentToExcelFile(ReportBindingModel model) + public void SaveShopPastryToExcelFile(ReportBindingModel model) { _saveToExcel.CreateReport(new ExcelInfo { FileName = model.FileName, - Title = "Список изделий", - PastryComponents = GetPastryComponent() + Title = "Список магазинов", + ShopPastries = GetShopPastries() }); } diff --git a/Confectionery/FormMain.Designer.cs b/Confectionery/FormMain.Designer.cs index 6cd32ba..be4ea31 100644 --- a/Confectionery/FormMain.Designer.cs +++ b/Confectionery/FormMain.Designer.cs @@ -35,7 +35,7 @@ ShopsToolStripMenuItem = new ToolStripMenuItem(); reportsToolStripMenuItem = new ToolStripMenuItem(); reportShopsToolStripMenuItem = new ToolStripMenuItem(); - pastryComponentsToolStripMenuItem = new ToolStripMenuItem(); + ShopPastriesToolStripMenuItem = new ToolStripMenuItem(); ordersToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); @@ -88,7 +88,7 @@ // // reportsToolStripMenuItem // - reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { reportShopsToolStripMenuItem, pastryComponentsToolStripMenuItem, ordersToolStripMenuItem }); + reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { reportShopsToolStripMenuItem, ShopPastriesToolStripMenuItem, ordersToolStripMenuItem }); reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; reportsToolStripMenuItem.Size = new Size(60, 20); reportsToolStripMenuItem.Text = "Отчеты"; @@ -96,21 +96,21 @@ // reportShopsToolStripMenuItem // reportShopsToolStripMenuItem.Name = "reportShopsToolStripMenuItem"; - reportShopsToolStripMenuItem.Size = new Size(215, 22); + reportShopsToolStripMenuItem.Size = new Size(202, 22); reportShopsToolStripMenuItem.Text = "Список магазинов"; reportShopsToolStripMenuItem.Click += ReportShopsToolStripMenuItem_Click; // - // pastryComponentsToolStripMenuItem + // ShopPastriesToolStripMenuItem // - pastryComponentsToolStripMenuItem.Name = "pastryComponentsToolStripMenuItem"; - pastryComponentsToolStripMenuItem.Size = new Size(215, 22); - pastryComponentsToolStripMenuItem.Text = "Изделия с компонентами"; - pastryComponentsToolStripMenuItem.Click += PastryComponentsToolStripMenuItem_Click; + ShopPastriesToolStripMenuItem.Name = "ShopPastriesToolStripMenuItem"; + ShopPastriesToolStripMenuItem.Size = new Size(202, 22); + ShopPastriesToolStripMenuItem.Text = "Магазины с изделиями"; + ShopPastriesToolStripMenuItem.Click += ShopPastriesToolStripMenuItem_Click; // // ordersToolStripMenuItem // ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; - ordersToolStripMenuItem.Size = new Size(215, 22); + ordersToolStripMenuItem.Size = new Size(202, 22); ordersToolStripMenuItem.Text = "Список заказов"; ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; // @@ -240,7 +240,7 @@ private ToolStripMenuItem componentToolStripMenuItem; private ToolStripMenuItem reportsToolStripMenuItem; private ToolStripMenuItem reportShopsToolStripMenuItem; - private ToolStripMenuItem pastryComponentsToolStripMenuItem; + private ToolStripMenuItem ShopPastriesToolStripMenuItem; private ToolStripMenuItem ordersToolStripMenuItem; private ToolStripMenuItem ShopsToolStripMenuItem; private Button buttonAddPastryInShop; diff --git a/Confectionery/FormMain.cs b/Confectionery/FormMain.cs index 6c01a25..24994e7 100644 --- a/Confectionery/FormMain.cs +++ b/Confectionery/FormMain.cs @@ -166,10 +166,10 @@ namespace ConfectioneryView } } - private void PastryComponentsToolStripMenuItem_Click(object sender, EventArgs e) + private void ShopPastriesToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents)); - if (service is FormReportPastryComponents form) + var service = Program.ServiceProvider?.GetService(typeof(FormReportShopPastries)); + if (service is FormReportShopPastries form) { form.ShowDialog(); } diff --git a/Confectionery/FormReportPastryComponents.Designer.cs b/Confectionery/FormReportShopPastries.Designer.cs similarity index 87% rename from Confectionery/FormReportPastryComponents.Designer.cs rename to Confectionery/FormReportShopPastries.Designer.cs index c03df90..cf92689 100644 --- a/Confectionery/FormReportPastryComponents.Designer.cs +++ b/Confectionery/FormReportShopPastries.Designer.cs @@ -1,6 +1,6 @@ namespace ConfectioneryView { - partial class FormReportPastryComponents + partial class FormReportShopPastries { /// /// Required designer variable. @@ -30,8 +30,8 @@ { dataGridView = new DataGridView(); buttonSaveToExcel = new Button(); + ColumnShop = new DataGridViewTextBoxColumn(); ColumnPastry = new DataGridViewTextBoxColumn(); - ColumnComponent = new DataGridViewTextBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -45,7 +45,7 @@ dataGridView.AllowUserToResizeRows = false; dataGridView.BackgroundColor = SystemColors.ControlLightLight; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnPastry, ColumnComponent, ColumnCount }); + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnPastry, ColumnCount }); dataGridView.Dock = DockStyle.Bottom; dataGridView.Location = new Point(0, 47); dataGridView.Margin = new Padding(4, 3, 4, 3); @@ -67,6 +67,13 @@ buttonSaveToExcel.UseVisualStyleBackColor = true; buttonSaveToExcel.Click += ButtonSaveToExcel_Click; // + // ColumnShop + // + ColumnShop.HeaderText = "Магазин"; + ColumnShop.Name = "ColumnShop"; + ColumnShop.ReadOnly = true; + ColumnShop.Width = 200; + // // ColumnPastry // ColumnPastry.HeaderText = "Изделие"; @@ -74,20 +81,13 @@ ColumnPastry.ReadOnly = true; ColumnPastry.Width = 200; // - // ColumnComponent - // - ColumnComponent.HeaderText = "Компонент"; - ColumnComponent.Name = "ColumnComponent"; - ColumnComponent.ReadOnly = true; - ColumnComponent.Width = 200; - // // ColumnCount // ColumnCount.HeaderText = "Количество"; ColumnCount.Name = "ColumnCount"; ColumnCount.ReadOnly = true; // - // FormReportPastryComponents + // FormReportShopPastries // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; @@ -95,9 +95,9 @@ Controls.Add(buttonSaveToExcel); Controls.Add(dataGridView); Margin = new Padding(4, 3, 4, 3); - Name = "FormReportPastryComponents"; + Name = "FormReportShopPastries"; Text = "Изделия с компонентами"; - Load += FormReportPastryComponents_Load; + Load += FormReportShopPastry_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } @@ -106,8 +106,8 @@ private System.Windows.Forms.DataGridView dataGridView; private System.Windows.Forms.Button buttonSaveToExcel; + private DataGridViewTextBoxColumn ColumnShop; private DataGridViewTextBoxColumn ColumnPastry; - private DataGridViewTextBoxColumn ColumnComponent; private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/Confectionery/FormReportPastryComponents.cs b/Confectionery/FormReportShopPastries.cs similarity index 81% rename from Confectionery/FormReportPastryComponents.cs rename to Confectionery/FormReportShopPastries.cs index 16d7a9a..53c7dc0 100644 --- a/Confectionery/FormReportPastryComponents.cs +++ b/Confectionery/FormReportShopPastries.cs @@ -13,35 +13,36 @@ using System.Windows.Forms; namespace ConfectioneryView { - public partial class FormReportPastryComponents : Form + public partial class FormReportShopPastries : Form { private readonly ILogger _logger; private readonly IReportLogic _logic; - public FormReportPastryComponents(ILogger logger, IReportLogic logic) + public FormReportShopPastries(ILogger logger, IReportLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormReportPastryComponents_Load(object sender, EventArgs e) + private void FormReportShopPastry_Load(object sender, EventArgs e) { try { - var dict = _logic.GetPastryComponent(); + var dict = _logic.GetShopPastries(); if (dict != null) { dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" }); - foreach (var listElem in elem.Components) + dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" }); + foreach (var listElem in elem.Pastries) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(new object[] { "Загруженность", "", Math.Round(elem.Workload * 100, 2).ToString() + "%" }); dataGridView.Rows.Add(Array.Empty()); } } @@ -61,7 +62,7 @@ namespace ConfectioneryView { try { - _logic.SavePastryComponentToExcelFile(new ReportBindingModel + _logic.SaveShopPastryToExcelFile(new ReportBindingModel { FileName = dialog.FileName }); diff --git a/Confectionery/FormReportPastryComponents.resx b/Confectionery/FormReportShopPastries.resx similarity index 100% rename from Confectionery/FormReportPastryComponents.resx rename to Confectionery/FormReportShopPastries.resx diff --git a/Confectionery/FormViewShops.cs b/Confectionery/FormViewShops.cs index 995d86e..419130c 100644 --- a/Confectionery/FormViewShops.cs +++ b/Confectionery/FormViewShops.cs @@ -28,7 +28,7 @@ namespace ConfectioneryView dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["Shops"].Visible = false; + dataGridView.Columns["Pastries"].Visible = false; dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } diff --git a/Confectionery/Program.cs b/Confectionery/Program.cs index e1ce227..68f2245 100644 --- a/Confectionery/Program.cs +++ b/Confectionery/Program.cs @@ -62,7 +62,7 @@ namespace ConfectioneryView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); } } diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IReportLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IReportLogic.cs index 22f0a4d..e503fec 100644 --- a/ConfectioneryContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/ConfectioneryContracts/BusinessLogicsContracts/IReportLogic.cs @@ -11,10 +11,10 @@ namespace ConfectioneryContracts.BusinessLogicsContracts public interface IReportLogic { /// - /// Получение списка компонент с указанием, в каких изделиях используются + /// Получение списка магазинов с указанием, в каких изделиях используются /// /// - List GetPastryComponent(); + List GetShopPastries(); /// /// Получение списка заказов за определенный период /// @@ -30,7 +30,7 @@ namespace ConfectioneryContracts.BusinessLogicsContracts /// Сохранение компонент с указаеним продуктов в файл-Excel /// /// - void SavePastryComponentToExcelFile(ReportBindingModel model); + void SaveShopPastryToExcelFile(ReportBindingModel model); /// /// Сохранение заказов в файл-Pdf /// diff --git a/ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs b/ConfectioneryContracts/ViewModels/ReportShopPastrytViewModel.cs similarity index 50% rename from ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs rename to ConfectioneryContracts/ViewModels/ReportShopPastrytViewModel.cs index f1df7d2..ead10c5 100644 --- a/ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs +++ b/ConfectioneryContracts/ViewModels/ReportShopPastrytViewModel.cs @@ -6,10 +6,11 @@ using System.Threading.Tasks; namespace ConfectioneryContracts.ViewModels { - public class ReportPastryComponentViewModel + public class ReportShopPastrytViewModel { - public string PastryName { get; set; } = string.Empty; + public string ShopName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List> Components { get; set; } = new(); + public List> Pastries { get; set; } = new(); + public double Workload { get; set; } } }