72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using CanteenBusinessLogic.OfficePackage.HelperEnums;
|
|||
|
using CanteenBusinessLogic.OfficePackage.HelperModels;
|
|||
|
|
|||
|
namespace CanteenBusinessLogic.OfficePackage
|
|||
|
{
|
|||
|
public abstract class AbstractSaveToPdf
|
|||
|
{
|
|||
|
public void CreateDoc(PdfInfo info)
|
|||
|
{
|
|||
|
CreatePdf(info);
|
|||
|
CreateParagraph(new PdfParagraph
|
|||
|
{
|
|||
|
Text = info.Title,
|
|||
|
Style = "NormalTitle"
|
|||
|
});
|
|||
|
CreateParagraph(new PdfParagraph
|
|||
|
{
|
|||
|
Text = $"с { info.DateAfter.ToShortDateString() } по { info.DateBefore.ToShortDateString() }", Style = "Normal"
|
|||
|
});
|
|||
|
CreateTable(new List<string> { "2cm", "2cm", "2cm", "5cm", "3cm", "3cm" });
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { "Дата обеда", "Стоимость обеда", "Заказ", "Повар"},
|
|||
|
Style = "NormalTitle",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|||
|
});
|
|||
|
foreach (var lunch in info.Lunches)
|
|||
|
{
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { lunch.DateCreate.ToShortDateString(), lunch.Sum.ToString(), "", ""},
|
|||
|
Style = "Normal",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|||
|
});
|
|||
|
|
|||
|
// Вывод заказов для каждого обеда
|
|||
|
foreach (var order in lunch.Orders)
|
|||
|
{
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { "", "", order.Id.ToString(), ""},
|
|||
|
Style = "Normal",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|||
|
});
|
|||
|
|
|||
|
// Вывод поваров для каждого заказа
|
|||
|
foreach (var cook in order.OrderCooks)
|
|||
|
{
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { "", "", "", cook.Value.FIO },
|
|||
|
Style = "Normal",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
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 SavePdf(PdfInfo info);
|
|||
|
}
|
|||
|
}
|