2024-05-30 16:07:54 +04:00
|
|
|
|
using ElectronicsShopBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ElectronicsShopBusinessLogic.OfficePackage
|
|
|
|
|
{
|
2024-05-31 19:49:56 +04:00
|
|
|
|
public abstract class AbstractSaveToExcelEmployee
|
|
|
|
|
{
|
2024-07-30 15:36:42 +04:00
|
|
|
|
public byte[]? CreateReport(ExcelInfoEmployee info)
|
2024-05-30 16:07:54 +04:00
|
|
|
|
{
|
|
|
|
|
CreateExcel(info);
|
|
|
|
|
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = 1,
|
|
|
|
|
Text = info.Title,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Title
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-30 15:36:42 +04:00
|
|
|
|
MergeCells(new ExcelMergeParameters {
|
2024-05-30 16:07:54 +04:00
|
|
|
|
CellFromName = "A1",
|
|
|
|
|
CellToName = "C1"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
uint rowIndex = 2;
|
2024-07-30 15:36:42 +04:00
|
|
|
|
foreach (var product in info.ListProduct) {
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
2024-05-30 16:07:54 +04:00
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
2024-07-30 15:36:42 +04:00
|
|
|
|
Text = product.ProductName,
|
2024-05-30 16:07:54 +04:00
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
2024-07-30 15:36:42 +04:00
|
|
|
|
foreach (var paymeant in product.Values) {
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "B",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Номер оплаты:",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = paymeant.PaymeantID.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "D",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "В количестве:",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "E",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = paymeant.ProducCount.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "F",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Статус оплаты:",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "G",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = paymeant.PaymeantStatus.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Итого:",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Title
|
|
|
|
|
});
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
2024-07-30 15:36:42 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters {
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = product.Total.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Title
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
2024-07-30 15:36:42 +04:00
|
|
|
|
var document = SaveExcel(info);
|
|
|
|
|
return document;
|
2024-05-30 16:07:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-31 19:49:56 +04:00
|
|
|
|
protected abstract void CreateExcel(ExcelInfoEmployee info);
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
|
|
|
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
|
|
|
|
|
|
|
|
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
|
|
|
|
|
2024-07-30 15:36:42 +04:00
|
|
|
|
protected abstract byte[]? SaveExcel(ExcelInfoEmployee info);
|
2024-05-30 16:07:54 +04:00
|
|
|
|
}
|
|
|
|
|
}
|