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,
Price = product.Value.Item1.Price,
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
});
CreateTable(new List<string> { "2cm", "6cm", "4cm", "6cm" });
//ТУТ КОСТЫЛЬ КАК взять номер заказа, в info его нема
CreateRow(new PdfRowParameters
{
Text = new List<string> {$"Заказ номер: Костыль " },
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,
});
List<int> PaymentsID = new List<int>();
foreach (var pr in info.Products) {
int id = pr.PaymentID;
if (PaymentsID.Contains(id) == false) {
PaymentsID.Add(id);
}
}
CreateRow(new PdfRowParameters
{
Text = new List<string> { products.ID.ToString(), products.ProductName.ToString(), products.Price.ToString(),
products.CostItemName.ToString()},
foreach (int id in PaymentsID) {
CreateParagraph(new PdfParagraph {
Text = $"Номер оплаты: {id}",
Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Left,
});
StringsEnum++;
CreateTable(new List<string> { "2cm", "4cm", "2cm", "2cm", "4cm" });
}
// Криво считает сумму
CreateParagraph(new PdfParagraph {
Text = $"Итого: {info.Products.Sum(x => x.Price)}\t",
Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Right
});
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 {
Text = $"Итого: {sum}\t",
Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Right
});
}
var document = SavePdf(info);
return document;

View File

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