Pdf report fix

This commit is contained in:
Илья Федотов 2024-07-27 14:58:51 +04:00
parent b364827c33
commit 2cc2797387
3 changed files with 39 additions and 51 deletions

View File

@ -55,7 +55,9 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
ProductName = product.Value.Item1.ProductName, ProductName = product.Value.Item1.ProductName,
Price = product.Value.Item1.Price, Price = product.Value.Item1.Price,
CostItemName = _costItemStorage.GetElement(new CostItemSearchModel { ID = product.Value.Item1.CostItemID })?.Name CostItemName = _costItemStorage.GetElement(new CostItemSearchModel { ID = product.Value.Item1.CostItemID })?.Name
?? "Отсутствует" ?? "Отсутствует",
PaymentID = paymeant.ID,
count = product.Value.Item2
}); });
} }
} }

View File

@ -25,62 +25,46 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
alignmentType = PdfParagraphAlignmentType.Right alignmentType = PdfParagraphAlignmentType.Right
}); });
CreateTable(new List<string> { "2cm", "6cm", "4cm", "6cm" }); List<int> PaymentsID = new List<int>();
//ТУТ КОСТЫЛЬ КАК взять номер заказа, в info его нема foreach (var pr in info.Products) {
CreateRow(new PdfRowParameters int id = pr.PaymentID;
{ if (PaymentsID.Contains(id) == false) {
Text = new List<string> {$"Заказ номер: Костыль " }, PaymentsID.Add(id);
Style = "NormalTittle", }
alignmentType = PdfParagraphAlignmentType.Center,
});
int StringsEnum = 0;
CreateRow(new PdfRowParameters
{
Text = new List<string> { "Номер", "Товар", "Цена", "Статья затрат" },
Style = "NormalTittle",
alignmentType = PdfParagraphAlignmentType.Center,
});
foreach (var products in info.Products)
{
if (products.ID == 1 && StringsEnum != 0)
{
// Криво считает сумму
CreateParagraph(new PdfParagraph
{
Text = $"Итого: {info.Products.Sum(x => x.Price)}\t",
Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Right
});
CreateTable(new List<string> { "2cm", "6cm", "4cm", "6cm" });
//ТУТ КОСТЫЛЬ КАК взять номер заказа, в info его нема
CreateRow(new PdfRowParameters
{
Text = new List<string> { $"Заказ номер: Костыль " },
Style = "NormalTittle",
alignmentType = PdfParagraphAlignmentType.Center,
});
} }
CreateRow(new PdfRowParameters foreach (int id in PaymentsID) {
{ CreateParagraph(new PdfParagraph {
Text = new List<string> { products.ID.ToString(), products.ProductName.ToString(), products.Price.ToString(), Text = $"Номер оплаты: {id}",
products.CostItemName.ToString()},
Style = "Normal", Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Left, alignmentType = PdfParagraphAlignmentType.Left,
}); });
StringsEnum++; CreateTable(new List<string> { "2cm", "4cm", "2cm", "2cm", "4cm" });
CreateRow(new PdfRowParameters {
Text = new List<string> { "Номер товара", "Товар", "Цена", "Количество", "Статья затрат" },
Style = "NormalTittle",
alignmentType = PdfParagraphAlignmentType.Center,
});
double sum = 0;
foreach (var products in info.Products) {
if (products.PaymentID == id) {
sum += products.Price * products.count;
CreateRow(new PdfRowParameters {
Text = new List<string> { products.ID.ToString(), products.ProductName.ToString(),
(products.Price * products.count).ToString(), products.count.ToString() ,products.CostItemName.ToString()},
Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Left,
});
}
} }
// Криво считает сумму
CreateParagraph(new PdfParagraph { CreateParagraph(new PdfParagraph {
Text = $"Итого: {info.Products.Sum(x => x.Price)}\t", Text = $"Итого: {sum}\t",
Style = "Normal", Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Right alignmentType = PdfParagraphAlignmentType.Right
}); });
}
var document = SavePdf(info); var document = SavePdf(info);
return document; return document;

View File

@ -12,6 +12,8 @@ namespace ElectronicsShopContracts.ViewModels
public int ID { get; set; } public int ID { get; set; }
public string ProductName { get; set; } = string.Empty; public string ProductName { get; set; } = string.Empty;
public double Price { get; set; } public double Price { get; set; }
public int count { get; set; }
public string CostItemName { get; set; } = string.Empty; public string CostItemName { get; set; } = string.Empty;
public int PaymentID { get; set; }
} }
} }