2024-06-24 18:53:31 +04:00
|
|
|
|
using BusinessLogic.BusinessLogic;
|
|
|
|
|
using BusinessLogic.OfficePackage.HelperEnums;
|
2024-06-24 18:08:53 +04:00
|
|
|
|
using BusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-06-25 13:14:23 +04:00
|
|
|
|
using System.Configuration;
|
2024-06-24 18:08:53 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BusinessLogic.OfficePackage
|
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractSaveToPdf
|
|
|
|
|
{
|
|
|
|
|
public void CreateDoc(PdfInfo info)
|
|
|
|
|
{
|
|
|
|
|
CreatePdf(info);
|
|
|
|
|
CreateParagraph(new PdfParagraph
|
|
|
|
|
{
|
2024-06-25 09:00:46 +04:00
|
|
|
|
Text = $"{info.Title}\nОт {DateTime.UtcNow}",
|
2024-06-24 18:08:53 +04:00
|
|
|
|
Style = "NormalTitle",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
|
|
|
});
|
2024-06-25 13:14:23 +04:00
|
|
|
|
string dateArriving = info.Supply.DateArriving.HasValue ? info.Supply.DateArriving.ToString() : "-";
|
|
|
|
|
string dateComplete = info.Supply.DateComplete.HasValue ? info.Supply.DateComplete.ToString() : "-";
|
2024-06-25 09:00:46 +04:00
|
|
|
|
CreateParagraph(new PdfParagraph
|
|
|
|
|
{
|
2024-06-25 13:14:23 +04:00
|
|
|
|
Text = $"Поставщик: {info.Supply.SupplierName}\nДата создания поставки: {info.Supply.Date}\nДата отправления поставки: {dateArriving}\nДата получения поставки: {dateComplete}\nСтатус: {info.Supply.Status}",
|
2024-06-25 09:00:46 +04:00
|
|
|
|
Style = "NormalTitle",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
|
|
|
|
});
|
|
|
|
|
CreateTable(new List<string> { "5cm", "10cm"});
|
2024-06-24 18:08:53 +04:00
|
|
|
|
CreateRow(new PdfRowParameters
|
|
|
|
|
{
|
2024-06-25 09:00:46 +04:00
|
|
|
|
Texts = new List<string> { "Id", "Информация" },
|
2024-06-24 18:08:53 +04:00
|
|
|
|
Style = "NormalTitle",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
|
|
|
});
|
|
|
|
|
CreateRow(new PdfRowParameters
|
|
|
|
|
{
|
2024-06-25 09:00:46 +04:00
|
|
|
|
Texts = new List<string> { info.Supply.Id.ToString(), info.Supply.Name, },
|
2024-06-24 18:08:53 +04:00
|
|
|
|
Style = "Normal",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|
|
|
|
});
|
|
|
|
|
CreateParagraph(new PdfParagraph
|
2024-06-25 09:00:46 +04:00
|
|
|
|
{
|
|
|
|
|
Text = "Товары",
|
|
|
|
|
Style = "NormalTitle",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
|
|
|
});
|
|
|
|
|
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
|
|
|
|
|
CreateRow(new PdfRowParameters
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во" },
|
|
|
|
|
Style = "NormalTitle",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
|
|
|
});
|
|
|
|
|
foreach (var product in info.Supply.Products.Values)
|
|
|
|
|
{
|
|
|
|
|
CreateRow(new PdfRowParameters
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<string> { product.Item1.Id.ToString(), product.Item1.Name, product.Item1.Price.ToString(), product.Item2.ToString() },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
CreateParagraph(new PdfParagraph
|
2024-06-24 18:08:53 +04:00
|
|
|
|
{
|
|
|
|
|
Text = $"Итого: {info.Supply.Price}",
|
|
|
|
|
Style = "Normal",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
|
|
|
|
});
|
|
|
|
|
SavePdf(info);
|
|
|
|
|
}
|
|
|
|
|
protected abstract void CreatePdf(PdfInfo info);
|
|
|
|
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
|
|
|
|
protected abstract void CreateTable(List<string> columns);
|
|
|
|
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
2024-06-25 09:00:46 +04:00
|
|
|
|
protected abstract void CreateImage(string path);
|
2024-06-24 18:08:53 +04:00
|
|
|
|
protected abstract void SavePdf(PdfInfo info);
|
|
|
|
|
}
|
|
|
|
|
}
|