78 lines
3.1 KiB
C#
78 lines
3.1 KiB
C#
|
using TravelAgencyBusinessLogic.OfficePackage.HelperEnums;
|
|||
|
using TravelAgencyBusinessLogic.OfficePackage.HelperModels;
|
|||
|
|
|||
|
namespace TravelAgencyBusinessLogic.OfficePackage
|
|||
|
{
|
|||
|
public abstract class AbstractSaveToPdf
|
|||
|
{
|
|||
|
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> { "2cm", "3cm", "3cm", "4cm", "3cm", "3cm"});
|
|||
|
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { "Тур", "Стоимость тура", "Дата тура", "Экскурсионная группа", "Количество участников", "Гид" },
|
|||
|
Style = "NormalTitle",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|||
|
});
|
|||
|
|
|||
|
foreach (var tour in info.Tours)
|
|||
|
{
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { tour.Tour.TourName, tour.Tour.Price.ToString(), tour.Tour.TourDate.ToShortDateString(), "", "", "" },
|
|||
|
Style = "Normal",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|||
|
});
|
|||
|
foreach(var excursionGroup in tour.ExcursionGroups)
|
|||
|
{
|
|||
|
CreateRow(new PdfRowParameters
|
|||
|
{
|
|||
|
Texts = new List<string> { "", "", "", excursionGroup.ExcursionGroupName, excursionGroup.ParticipantsAmount.ToString(), excursionGroup.GuideFIO},
|
|||
|
Style = "Normal",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
SavePdf(info);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Создание doc-файла
|
|||
|
/// </summary>
|
|||
|
/// <param name="info"></param>
|
|||
|
protected abstract void CreatePdf(PdfInfo info);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Создание параграфа с текстом
|
|||
|
/// </summary>
|
|||
|
/// <param name="title"></param>
|
|||
|
/// <param name="style"></param>
|
|||
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Создание таблицы
|
|||
|
/// </summary>
|
|||
|
/// <param name="title"></param>
|
|||
|
/// <param name="style"></param>
|
|||
|
protected abstract void CreateTable(List<string> columns);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Создание и заполнение строки
|
|||
|
/// </summary>
|
|||
|
/// <param name="rowParameters"></param>
|
|||
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Сохранение файла
|
|||
|
/// </summary>
|
|||
|
/// <param name="info"></param>
|
|||
|
protected abstract void SavePdf(PdfInfo info);
|
|||
|
}
|
|||
|
}
|