CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs

79 lines
3.0 KiB
C#
Raw Normal View History

using ElectronicsShopBusinessLogic.OfficePackage.HelperEnums;
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWordEmployee
{
2024-07-29 21:12:31 +04:00
public byte[]? CreateDoc(WordInfoEmployee info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
2024-08-01 16:03:03 +04:00
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { ($"С {info.DateFrom} по {info.DateTo}", new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var data in info.ListProduct) {
2024-07-29 21:12:31 +04:00
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { (data.ProductName, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var paymeant in data.Values) {
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { ($"Оплата №:{paymeant.PaymeantID} статус:{paymeant.PaymeantStatus}",
new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { ($"Итого:{data.Total}",
new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
2024-07-29 21:12:31 +04:00
}
2024-07-29 21:12:31 +04:00
var document = SaveWord(info);
return document;
}
2024-07-29 21:12:31 +04:00
// Создание doc-файла
protected abstract void CreateWord(WordInfoEmployee info);
2024-07-29 21:12:31 +04:00
// Создание абзаца с текстом
protected abstract void CreateParagraph(WordParagraph paragraph);
2024-07-29 21:12:31 +04:00
// Сохранение файла
protected abstract byte[]? SaveWord(WordInfoEmployee info);
}
}