2023-05-26 02:11:24 +04:00
|
|
|
|
using CarServiceBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using CarServiceBusinessLogic.OfficePackage.HelperModels;
|
2023-05-25 23:14:32 +04:00
|
|
|
|
|
2023-05-26 02:11:24 +04:00
|
|
|
|
namespace CarServiceBusinessLogic.OfficePackage
|
2023-05-25 23:14:32 +04:00
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractSaveToExcel
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание отчета
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
public void CreateReport(ExcelInfo info)
|
|
|
|
|
{
|
|
|
|
|
CreateExcel(info);
|
|
|
|
|
uint rowIndex = 1;
|
|
|
|
|
//создаём шапку
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Работа",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "B",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Номер заявки",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Дата заявки",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "D",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Заказчик",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "E",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Транспортное средство",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "F",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Гос. номер",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "G",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Количество работ",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
|
|
|
|
//заполняем информацию
|
|
|
|
|
foreach (var WWR in info.WorksWithRequests)
|
|
|
|
|
{
|
|
|
|
|
foreach (var RR in WWR.RepairRequests)
|
|
|
|
|
{
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = WWR.WorkName,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "B",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = RR.RepairRequestId.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = RR.RepairRequestDateCreated.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "D",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = RR.CustomerName,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "E",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = RR.VehicleName,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "F",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = RR.Plate,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "G",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = RR.WorksCount.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SaveExcel(info);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание excel-файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
protected abstract void CreateExcel(ExcelInfo 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(ExcelInfo info);
|
|
|
|
|
}
|
|
|
|
|
}
|