80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using ElectronicsShopBusinessLogic.OfficePackage.HelperEnums;
|
||
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
|
||
using PdfSharp.Pdf;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace ElectronicsShopBusinessLogic.OfficePackage {
|
||
public abstract class AbstractSaveToPdfEmployee {
|
||
public PdfDocument CreateDoc (PdfInfoEmployee info) {
|
||
CreatePdf(info);
|
||
|
||
CreateParagraph(new PdfParagraph {
|
||
Text = info.Title,
|
||
Style = "NormalTitle",
|
||
alignmentType = PdfParagraphAlignmentType.Center,
|
||
});
|
||
CreateParagraph(new PdfParagraph {
|
||
Text = $"C {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||
Style = "Normal",
|
||
alignmentType = PdfParagraphAlignmentType.Right
|
||
});
|
||
|
||
foreach (var product in info.ListProduct) {
|
||
CreateParagraph(new PdfParagraph {
|
||
Text = product.ProductName,
|
||
Style = "Normal",
|
||
alignmentType = PdfParagraphAlignmentType.Left,
|
||
});
|
||
CreateTable(new List<string> { "2cm", "4cm", "4cm", "4cm", "2cm" });
|
||
|
||
CreateRow(new PdfRowParameters {
|
||
Text = new List<string> { "Оплата №", "Статус", "Количество товара", "Сумма", "ID Клиента" },
|
||
Style = "NormalTittle",
|
||
alignmentType = PdfParagraphAlignmentType.Center,
|
||
});
|
||
|
||
foreach (var paymeant in product.Values) {
|
||
CreateRow(new PdfRowParameters {
|
||
Text = new List<string> {
|
||
paymeant.PaymeantID.ToString(),
|
||
paymeant.PaymeantStatus.ToString(),
|
||
paymeant.ProducCount.ToString(),
|
||
paymeant.ProductSum.ToString(),
|
||
paymeant.ClientID.ToString(),
|
||
},
|
||
Style = "Normal",
|
||
alignmentType= PdfParagraphAlignmentType.Left,
|
||
});
|
||
}
|
||
CreateParagraph(new PdfParagraph {
|
||
Text = $"Итого: {product.Total}\t",
|
||
Style = "Normal",
|
||
alignmentType = PdfParagraphAlignmentType.Right
|
||
});
|
||
}
|
||
|
||
var document = SavePdf(info);
|
||
return document;
|
||
}
|
||
|
||
// Создание файла
|
||
protected abstract void CreatePdf(PdfInfoEmployee info);
|
||
|
||
// Создание параграфа с текстом
|
||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||
|
||
// Создание таблицы
|
||
protected abstract void CreateTable(List<string> columns);
|
||
|
||
// Создание и заполнение строки
|
||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||
|
||
// Сохранение файла
|
||
protected abstract PdfDocument SavePdf(PdfInfoEmployee info);
|
||
}
|
||
}
|