PIbd-22_Fedorenko_Puchkina_.../LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelClientsConsultation.cs

108 lines
3.8 KiB
C#

using LawFirmBusinessLogic.OfficePackages.HelperEnums;
using LawFirmBusinessLogic.OfficePackages.HelperModels;
using System.Runtime.CompilerServices;
namespace LawFirmBusinessLogic.OfficePackages
{
public abstract class AbstractSaveToExcelClientsConsultation
{
/// <summary>
/// Создание отчета
/// </summary>
/// <param name="info"></param>
public void CreateReport(ExcelClientsConsultationInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 2,
Text = "Клиент",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = 2,
Text = "Дата консультации",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = 2,
Text = "Цена консультации",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 4;
foreach (var vl in info.ClientsConsultation)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = vl.ClientFIO,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var cons in vl.Consultations)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = cons.ConsultationDate.ToShortDateString(),
StyleInfo =
ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = cons.Cost.ToString(),
StyleInfo =
ExcelStyleInfoType.Text
});
rowIndex++;
}
}
SaveExcel(info);
}
/// <summary>
/// Создание excel-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateExcel(ExcelClientsConsultationInfo info);
/// <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>
protected abstract void SaveExcel(ExcelClientsConsultationInfo info);
}
}