57 lines
3.1 KiB
C#
57 lines
3.1 KiB
C#
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace GarmentFactoryBusinessLogic.OfficePackage
|
||
{
|
||
public abstract class AbstractSaveToPdfImplementer
|
||
{
|
||
public void CreateDoc(PdfInfoImplementer info)
|
||
{
|
||
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 });
|
||
//!!!МБ ТУТ НЕЛЬЗЯ ДРОБНЫЕ ЧИСЛА ИЛИ МОЖНО С ТОЧКОЙ
|
||
CreateTable(new List<string> { "1,5cm", "3cm", "3cm", "2,5cm", "1,5cm", "4cm", "3cm", "3cm", "3cm", "3cm" });
|
||
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { "ID заказа", "Дата заказа", "Стоимость заказа", "Статус заказа", "ID заявки", "ФИО клиента", "Дата заявки", "Название сборки", "Каетегория сборки", "Цена сборки" },
|
||
Style = "NormalTitle",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
|
||
foreach (var order in info.Orders)
|
||
{
|
||
foreach (var request in order.RequestsAssemblies)
|
||
{
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { order.OrderId.ToString(), order.DateCreateOrder.ToShortDateString(), order.OrderSum.ToString(), order.OrderStatus.ToString(),
|
||
request.RequestId.ToString(), request.ClientFIO, request.DateRequest.ToShortDateString(),
|
||
string.IsNullOrEmpty(request.AssemblyName) ? "Сборка не привязана" : request.AssemblyName,
|
||
string.IsNullOrEmpty(request.AssemblyCategory) ? "Неизвестная категория" : request.AssemblyCategory,
|
||
request.AssemblyPrice.ToString()
|
||
},
|
||
Style = "Normal",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||
});
|
||
}
|
||
|
||
}
|
||
//CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
||
|
||
SavePdf(info);
|
||
}
|
||
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);
|
||
}
|
||
}
|