From a9ec52a3f72c76f36266f771ff29990c22390614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=A4=D0=B5=D0=B4=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Sat, 27 Jul 2024 13:38:35 +0400 Subject: [PATCH] Excel order --- .../BusinessLogic/ReportClientLogic.cs | 8 ++++-- .../AbstractSaveToExcelClient.cs | 25 ++++++++++++++++--- .../IReportClientLogic.cs | 2 +- .../ReportPaymeantProductsViewModel.cs | 3 ++- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs index 497dd80..f46fc83 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -89,14 +89,18 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic var record = new ReportPaymeantProductsViewModel { PaymeantID = paymeant.ID, Products = new(), - TotalCount = 0 + TotalCount = 0, + PaymeantPrice = paymeant.SumPayment, }; var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }) ?? throw new Exception("Ошибка полуения данных"); foreach (var product in order.ProductList) { - record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2)); + record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2, + _costItemStorage.GetElement (new CostItemSearchModel { ID = product.Value.Item1.CostItemID})?.Name ?? + throw new Exception("Ошиюак получения данных"), + product.Value.Item1.Price * product.Value.Item2)); record.TotalCount += product.Value.Item2; } diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs index b13ae29..ab3338c 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs @@ -31,7 +31,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var (Product, Count) in pp.Products) { + foreach (var (Product, Count, CostItem, Price) in pp.Products) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, @@ -45,7 +45,20 @@ namespace ElectronicsShopBusinessLogic.OfficePackage Text = Count.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBroder }); - rowIndex++; + + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "D", + RowIndex = rowIndex, + Text = CostItem, + StyleInfo = ExcelStyleInfoType.TextWithBroder, + }); + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "E", + RowIndex = rowIndex, + Text = Price.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder, + }); + rowIndex++; } InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "A", @@ -60,7 +73,13 @@ namespace ElectronicsShopBusinessLogic.OfficePackage Text = pp.TotalCount.ToString(), StyleInfo = ExcelStyleInfoType.Title }); - rowIndex++; + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "D", + RowIndex = rowIndex, + Text = pp.PaymeantPrice.ToString(), + StyleInfo = ExcelStyleInfoType.Title + }); + rowIndex++; } var documnet = SaveExcel(info); return documnet; diff --git a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs index f307e90..bd184bb 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportClientLogic.cs @@ -26,4 +26,4 @@ namespace ElectronicsShopContracts.BusinessLogicContracts // Отчет оплаченных товаров в .pdf PdfDocument SaveProductToPdfFile(ReportBindingModel model); } -} +} \ No newline at end of file diff --git a/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantProductsViewModel.cs b/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantProductsViewModel.cs index a49c6b5..6925d5c 100644 --- a/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantProductsViewModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportPaymeantProductsViewModel.cs @@ -8,6 +8,7 @@ namespace ElectronicsShopContracts.ViewModels { public class ReportPaymeantProductsViewModel { public int PaymeantID { get; set; } public int TotalCount { get; set; } - public List<(string Product, int count)> Products { get; set; } = new(); + public List<(string Product, int count, string CostItem, double Price)> Products { get; set; } = new(); + public double PaymeantPrice { get; set; } } }