70 lines
3.7 KiB
C#
Raw Normal View History

using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
2024-05-28 14:34:16 +04:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopBusinessLogic.OfficePackage
2024-05-28 14:34:16 +04:00
{
public abstract class AbstractSaveToPdfImplementer
{
public void CreateDoc(PdfInfoImplementer info)
{
2024-05-28 15:31:13 +04:00
CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
//!!!МБ ТУТ НЕЛЬЗЯ ДРОБНЫЕ ЧИСЛА ИЛИ МОЖНО С ТОЧКОЙ
2024-05-28 19:40:32 +04:00
CreateTable(new List<string> { "2cm", "2.5cm", "2cm", "2cm", "2cm", "4cm", "2.5cm", "3.5cm", "3.5cm", "2.5cm" });
2024-05-28 14:34:16 +04:00
2024-05-28 15:31:13 +04:00
CreateRow(new PdfRowParameters
{
2024-05-28 19:40:32 +04:00
Texts = new List<string> { "ID заказа", "Дата заказа", "Сумма заказа", "Статус заказа", "ID заявки", "ФИО клиента", "Дата заявки", "Название сборки", "Категория сборки", "Цена сборки" },
2024-05-28 15:31:13 +04:00
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
2024-05-28 14:34:16 +04:00
2024-05-28 15:31:13 +04:00
foreach (var order in info.Orders)
{
2024-05-28 19:40:32 +04:00
//!!!СЮДА
if (order.RequestsAssemblies.Count < 1)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> {
order.OrderId.ToString(), order.DateCreateOrder.ToShortDateString(), order.OrderSum.ToString(), order.OrderStatus.ToString(),
"Заказ без заявок", "Неизвестно", "Неизвестно",
"Неизвестно", "Неизвестно", "0"
}
});
}
2024-05-28 15:31:13 +04:00
foreach (var request in order.RequestsAssemblies)
{
CreateRow(new PdfRowParameters
{
2024-05-28 19:40:32 +04:00
Texts = new List<string> { order.OrderId.ToString(), order.DateCreateOrder.ToShortDateString(), order.OrderSum.ToString(), order.OrderStatus.ToString(),
request.RequestId.ToString(), request.ClientFIO, request.DateRequest.ToShortDateString(),
2024-05-28 15:31:13 +04:00
string.IsNullOrEmpty(request.AssemblyName) ? "Сборка не привязана" : request.AssemblyName,
2024-05-28 19:40:32 +04:00
string.IsNullOrEmpty(request.AssemblyCategory) ? "Неизвестно" : request.AssemblyCategory,
2024-05-28 15:31:13 +04:00
request.AssemblyPrice.ToString()
2024-05-28 19:40:32 +04:00
}
//},
//Style = "Normal",
//ParagraphAlignment = PdfParagraphAlignmentType.Left
2024-05-28 15:31:13 +04:00
});
}
2024-05-28 14:34:16 +04:00
2024-05-28 15:31:13 +04:00
}
2024-05-28 14:34:16 +04:00
//CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
2024-05-28 15:31:13 +04:00
SavePdf(info);
2024-05-28 14:34:16 +04:00
}
protected abstract void CreatePdf(PdfInfoImplementer info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfoImplementer info);
}
}