PIbd-22_Filippov_D.S._Cours.../VeterinaryBusinessLogic/OfficePackage/AbstractSaveToPdfOwner.cs
2024-05-30 07:33:38 +04:00

66 lines
2.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using VeterinaryBusinessLogic.OfficePackage.HelperEnums;
using VeterinaryBusinessLogic.OfficePackage.HelperModels;
namespace VeterinaryBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfOwner
{
public void CreateDoc(PdfInfo 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> { "4cm", "4cm", "4cm", "4cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата", "Животное", "Название визита", "Название рекомендации" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var pet in info.ReportVisitsDrugs)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", pet.PetName, "", "" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var visit in pet.Medicaments)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", "", visit.MedicationName, "", },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
}
foreach (var guidance in pet.Purchases)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { guidance.DateCreate.ToString(), "", "", guidance.PuchaseName },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
}
}
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);
}
}