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 {
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;
}

View File

@ -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,6 +45,19 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
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 {
@ -59,6 +72,12 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
RowIndex = rowIndex,
Text = pp.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Title
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "D",
RowIndex = rowIndex,
Text = pp.PaymeantPrice.ToString(),
StyleInfo = ExcelStyleInfoType.Title
});
rowIndex++;
}

View File

@ -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; }
}
}