From 4dee91c9a96a2b9f47ca648ef7e783fde1849175 Mon Sep 17 00:00:00 2001 From: Artyom_Yashin Date: Tue, 26 Mar 2024 22:17:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=87=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormReportComputerComponents.cs | 4 ++-- .../BusinessLogics/ReportLogic.cs | 19 ++++++++----------- .../OfficePackage/AbstractSaveToExcel.cs | 8 ++++---- .../OfficePackage/AbstractSaveToPdf.cs | 2 +- .../ReportComputerComponentViewModel.cs | 4 ++-- .../Implements/OrderStorage.cs | 4 ---- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/ComputersShop/ComputersShop/FormReportComputerComponents.cs b/ComputersShop/ComputersShop/FormReportComputerComponents.cs index fc0465a..87e3cb0 100644 --- a/ComputersShop/ComputersShop/FormReportComputerComponents.cs +++ b/ComputersShop/ComputersShop/FormReportComputerComponents.cs @@ -37,8 +37,8 @@ logger, IReportLogic logic) dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); - foreach (var listElem in elem.Computers) + dataGridView.Rows.Add(new object[] { elem.ComputerName, "", "" }); + foreach (var listElem in elem.Components) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } diff --git a/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs b/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs index b79d7ef..18182d4 100644 --- a/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -42,23 +42,20 @@ namespace ComputersShopBusinessLogic.BusinessLogics var components = _componentStorage.GetFullList(); var Computers = _ComputerStorage.GetFullList(); var list = new List(); - foreach (var component in components) + foreach (var computer in Computers) { var record = new ReportComputerComponentViewModel { - ComponentName = component.ComponentName, - Computers = new List>(), + ComputerName = computer.ComputerName, + Components = new List>(), TotalCount = 0 }; - foreach (var Computer in Computers) + foreach (var component in computer.ComputerComponents) { - if (Computer.ComputerComponents.ContainsKey(component.Id)) - { - record.Computers.Add(new Tuple(Computer.ComputerName, Computer.ComputerComponents[component.Id].Item2)); - record.TotalCount += - Computer.ComputerComponents[component.Id].Item2; - } + record.Components.Add(new Tuple(component.Value.Item1.ComponentName, component.Value.Item2)); + record.TotalCount += + component.Value.Item2; } list.Add(record); } diff --git a/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index d020261..7a5ca4f 100644 --- a/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -36,17 +36,17 @@ namespace ComputersShopBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.ComputerName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var Computer in pc.Computers) + foreach (var component in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = Computer.Item1, + Text = component.Item1, StyleInfo = ExcelStyleInfoType.TextWithBroder }); @@ -54,7 +54,7 @@ namespace ComputersShopBusinessLogic.OfficePackage { ColumnName = "C", RowIndex = rowIndex, - Text = Computer.Item2.ToString(), + Text = component.Item2.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBroder }); diff --git a/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 49d8f3c..73af023 100644 --- a/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/ComputersShop/ComputersShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -23,7 +23,7 @@ namespace ComputersShopBusinessLogic.OfficePackage { Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); CreateRow(new PdfRowParameters { Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус" }, diff --git a/ComputersShop/ComputersShopContracts/ViewModels/ReportComputerComponentViewModel.cs b/ComputersShop/ComputersShopContracts/ViewModels/ReportComputerComponentViewModel.cs index ebb4be3..c7a9829 100644 --- a/ComputersShop/ComputersShopContracts/ViewModels/ReportComputerComponentViewModel.cs +++ b/ComputersShop/ComputersShopContracts/ViewModels/ReportComputerComponentViewModel.cs @@ -8,8 +8,8 @@ namespace ComputersShopContracts.ViewModels { public class ReportComputerComponentViewModel { - public string ComponentName { get; set; } = string.Empty; + public string ComputerName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List> Computers { get; set; } = new(); + public List> Components { get; set; } = new(); } } diff --git a/ComputersShop/ComputersShopDatabaseImplement/Implements/OrderStorage.cs b/ComputersShop/ComputersShopDatabaseImplement/Implements/OrderStorage.cs index e33d0a0..c276aaa 100644 --- a/ComputersShop/ComputersShopDatabaseImplement/Implements/OrderStorage.cs +++ b/ComputersShop/ComputersShopDatabaseImplement/Implements/OrderStorage.cs @@ -23,10 +23,6 @@ namespace ComputersShopDatabaseImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) - { - return new(); - } using var context = new ComputersShopDatabase(); return context.Orders.Include(x => x.Computers) .Where(x => (