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 AbstractSaveToExcelClient
|
2024-05-30 16:07:54 +04:00
|
|
|
|
{
|
2024-05-31 19:49:56 +04:00
|
|
|
|
public void CreateReport(ExcelInfoClient info)
|
2024-05-30 16:07:54 +04:00
|
|
|
|
{
|
|
|
|
|
CreateExcel(info);
|
|
|
|
|
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = 1,
|
|
|
|
|
Text = info.Title,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Title
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MergeCells(new ExcelMergeParameters
|
|
|
|
|
{
|
|
|
|
|
CellFromName = "A1",
|
|
|
|
|
CellToName = "C1"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
uint rowIndex = 2;
|
2024-05-31 19:49:56 +04:00
|
|
|
|
foreach (var pc in info.Paymeants)
|
2024-05-30 16:07:54 +04:00
|
|
|
|
{
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
2024-05-31 19:49:56 +04:00
|
|
|
|
Text = pc.PaymeantName.ToString(),
|
2024-05-30 16:07:54 +04:00
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
|
|
|
|
|
2024-05-31 19:49:56 +04:00
|
|
|
|
foreach (var payment in pc.PaymeantsList)
|
2024-05-30 16:07:54 +04:00
|
|
|
|
{
|
2024-05-31 19:49:56 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "B",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = payment.PayOption.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = payment.SumPayment.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
|
|
|
});
|
|
|
|
|
//Не хорошо, что доступны ID а не название продукта, в идеале пофиксить надо
|
|
|
|
|
//Это AbstractSaveToExcelClient
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SaveExcel(info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание excel-файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
2024-05-31 19:49:56 +04:00
|
|
|
|
protected abstract void CreateExcel(ExcelInfoClient info);
|
2024-05-30 16:07:54 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Добавляем новую ячейку в лист
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cellParameters"></param>
|
|
|
|
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Объединение ячеек
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mergeParameters"></param>
|
|
|
|
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранение файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
2024-05-31 19:49:56 +04:00
|
|
|
|
protected abstract void SaveExcel(ExcelInfoClient info);
|
2024-05-30 16:07:54 +04:00
|
|
|
|
}
|
|
|
|
|
}
|