CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs

103 lines
3.4 KiB
C#
Raw Normal View History

using ElectronicsShopBusinessLogic.OfficePackage.HelperEnums;
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
namespace ElectronicsShopBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcelEmployee
{
2024-07-30 15:36:42 +04:00
public byte[]? CreateReport(ExcelInfoEmployee info)
{
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 {
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
2024-07-30 15:36:42 +04:00
foreach (var product in info.ListProduct) {
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "A",
RowIndex = rowIndex,
2024-07-30 15:36:42 +04:00
Text = product.ProductName,
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-07-30 15:36:42 +04:00
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "C",
RowIndex = rowIndex,
Text = product.Total.ToString(),
StyleInfo = ExcelStyleInfoType.Title
});
rowIndex++;
}
2024-07-30 15:36:42 +04:00
var document = SaveExcel(info);
return document;
}
protected abstract void CreateExcel(ExcelInfoEmployee info);
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);
}
}