Excel order

This commit is contained in:
Илья Федотов 2024-07-27 13:38:35 +04:00
parent 44a14b6d77
commit a9ec52a3f7
4 changed files with 31 additions and 7 deletions

View File

@ -89,14 +89,18 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
var record = new ReportPaymeantProductsViewModel { var record = new ReportPaymeantProductsViewModel {
PaymeantID = paymeant.ID, PaymeantID = paymeant.ID,
Products = new(), Products = new(),
TotalCount = 0 TotalCount = 0,
PaymeantPrice = paymeant.SumPayment,
}; };
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }) var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID })
?? throw new Exception("Ошибка полуения данных"); ?? throw new Exception("Ошибка полуения данных");
foreach (var product in order.ProductList) { 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; record.TotalCount += product.Value.Item2;
} }

View File

@ -31,7 +31,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var (Product, Count) in pp.Products) { foreach (var (Product, Count, CostItem, Price) in pp.Products) {
InsertCellInWorksheet(new ExcelCellParameters { InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "B", ColumnName = "B",
RowIndex = rowIndex, RowIndex = rowIndex,
@ -45,7 +45,20 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
Text = Count.ToString(), Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder 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 { InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "A", ColumnName = "A",
@ -60,7 +73,13 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
Text = pp.TotalCount.ToString(), Text = pp.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Title StyleInfo = ExcelStyleInfoType.Title
}); });
rowIndex++; InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "D",
RowIndex = rowIndex,
Text = pp.PaymeantPrice.ToString(),
StyleInfo = ExcelStyleInfoType.Title
});
rowIndex++;
} }
var documnet = SaveExcel(info); var documnet = SaveExcel(info);
return documnet; return documnet;

View File

@ -8,6 +8,7 @@ namespace ElectronicsShopContracts.ViewModels {
public class ReportPaymeantProductsViewModel { public class ReportPaymeantProductsViewModel {
public int PaymeantID { get; set; } public int PaymeantID { get; set; }
public int TotalCount { 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; }
} }
} }