2024-05-30 16:07:54 +04:00
|
|
|
|
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
|
|
|
|
|
{
|
2024-05-31 19:49:56 +04:00
|
|
|
|
public abstract class AbstractSaveToWordEmployee
|
|
|
|
|
{
|
2024-07-29 21:12:31 +04:00
|
|
|
|
public byte[]? CreateDoc(WordInfoEmployee info)
|
2024-05-30 16:07:54 +04:00
|
|
|
|
{
|
|
|
|
|
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",
|
2024-08-03 23:12:04 +04:00
|
|
|
|
JustificationType = WordJustificationType.Center
|
2024-07-29 21:12:31 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
foreach (var paymeant in data.Values) {
|
|
|
|
|
CreateParagraph(new WordParagraph {
|
|
|
|
|
Texts = new List<(string, WordTextProperties)> { ($"Оплата №:{paymeant.PaymeantID} статус:{paymeant.PaymeantStatus}",
|
2024-08-03 23:12:04 +04:00
|
|
|
|
new WordTextProperties { Bold = false, Size = "24", }) },
|
2024-07-29 21:12:31 +04:00
|
|
|
|
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 {
|
2024-05-31 19:49:56 +04:00
|
|
|
|
Size = "24",
|
|
|
|
|
JustificationType = WordJustificationType.Both
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-07-29 21:12:31 +04:00
|
|
|
|
}
|
2024-05-31 19:49:56 +04:00
|
|
|
|
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
2024-07-29 21:12:31 +04:00
|
|
|
|
var document = SaveWord(info);
|
|
|
|
|
return document;
|
2024-05-30 16:07:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 21:12:31 +04:00
|
|
|
|
// Создание doc-файла
|
2024-05-31 19:49:56 +04:00
|
|
|
|
protected abstract void CreateWord(WordInfoEmployee info);
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
2024-07-29 21:12:31 +04:00
|
|
|
|
// Создание абзаца с текстом
|
2024-05-30 16:07:54 +04:00
|
|
|
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
|
|
|
|
2024-07-29 21:12:31 +04:00
|
|
|
|
// Сохранение файла
|
|
|
|
|
protected abstract byte[]? SaveWord(WordInfoEmployee info);
|
2024-05-30 16:07:54 +04:00
|
|
|
|
}
|
|
|
|
|
}
|