78 lines
3.1 KiB
C#
78 lines
3.1 KiB
C#
using BusinessLogic.BusinessLogic;
|
||
using BusinessLogic.OfficePackage.HelperEnums;
|
||
using BusinessLogic.OfficePackage.HelperModels;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
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
|
||
{
|
||
Text = $"{info.Title}\nОт {DateTime.UtcNow}",
|
||
Style = "NormalTitle",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
CreateParagraph(new PdfParagraph
|
||
{
|
||
Text = $"Поставщик: {info.Supply.SupplierName}\nДата создания поставки: {info.Supply.Date}\nСтатус: {info.Supply.Status}",
|
||
Style = "NormalTitle",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||
});
|
||
CreateTable(new List<string> { "5cm", "10cm"});
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { "Id", "Информация" },
|
||
Style = "NormalTitle",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { info.Supply.Id.ToString(), info.Supply.Name, },
|
||
Style = "Normal",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||
});
|
||
CreateParagraph(new PdfParagraph
|
||
{
|
||
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
|
||
{
|
||
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);
|
||
protected abstract void CreateImage(string path);
|
||
protected abstract void SavePdf(PdfInfo info);
|
||
}
|
||
}
|