Логика отчета + методы сохранения в Exel и Word.

This commit is contained in:
ksenianeva 2023-05-20 03:30:06 +04:00
parent e71d4a92b9
commit 42cbf59372
7 changed files with 128 additions and 17 deletions

View File

@ -128,7 +128,7 @@ namespace BankBusinessLogic.BusinessLogics
{
CurrencyId = currency.Id,
CurrencyName = currency.Name,
Transfers = new List<(int TransferId, float Amount)>(),
Transfers = new List<TransferViewModel>(),
};
var paymentsId = new List<int>();
foreach(var payment in payments)
@ -141,7 +141,7 @@ namespace BankBusinessLogic.BusinessLogics
{
if (paymentId == transfer.PaymentId)
{
record.Transfers.Add(new(transfer.Id, transfer.Amount));
record.Transfers.Add(transfer);
}
}
}
@ -160,6 +160,7 @@ namespace BankBusinessLogic.BusinessLogics
{
CurrencyPurchaseId = purchase.Id,
PurchaseDate = purchase.PurchaseDate,
CurrencyName = purchase.CurrencyName,
Payments = new List<(int PaymentId, string PaymentDate)>(),
};
var paymentsId = new List<int>();

View File

@ -69,21 +69,74 @@ namespace BankBusinessLogic.OfficePackage
rowIndex++;
}
rowIndex++;
}
//InsertCellInWorksheet(new ExcelCellParameters
//{
// ColumnName = "A",
// RowIndex = rowIndex,
// Text = "Итого",
// StyleInfo = ExcelStyleInfoType.Text
//});
//InsertCellInWorksheet(new ExcelCellParameters
//{
// ColumnName = "C",
// RowIndex = rowIndex,
// Text = pc.TotalCount.ToString(),
// StyleInfo = ExcelStyleInfoType.Text
//});
return SaveExcel();
}
public MemoryStream CreateBankOperatorReport(ExcelInfo info)
{
if (info.Currencies == null)
{
throw new ArgumentNullException("Данные для отчета не найдены!",
nameof(info.Currencies));
}
CreateExcel();
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var currency in info.Currencies)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Валюта № " + currency.CurrencyId,
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = currency.CurrencyName,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
foreach (var transfer in currency.Transfers)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = "Зачисление № " + transfer.Id,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "D",
RowIndex = rowIndex,
Text = transfer.Amount.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
rowIndex++;
}

View File

@ -52,6 +52,60 @@ namespace BankBusinessLogic.OfficePackage
}
return SaveWord(info);
}
public MemoryStream CreateBankOperatorDoc(WordInfo info)
{
if (info.Currencies == null)
{
throw new ArgumentNullException("Данные для отчета не найдены!",
nameof(info.Currencies));
}
CreateWord();
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var currency in info.Currencies)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ ("Зачисление по валюте: " + currency.CurrencyName+ ". ",
new WordTextProperties { Size = "24", Bold = true })},
TextProperties = new WordTextProperties
{
Size = "18",
JustificationType = WordJustificationType.Both
}
});
foreach (var transfer in currency.Transfers)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ ("Зачисление №" + transfer.Id + ". ",
new WordTextProperties { Size = "18", Bold = true }),
("Дата: " + transfer.TransferDateTime.ToString(),
new WordTextProperties { Size = "18", }),
("Сумма: " + transfer.Amount.ToString(),
new WordTextProperties
{ Size = "18", }) },
TextProperties = new WordTextProperties
{
Size = "18",
JustificationType = WordJustificationType.Both
}
});
}
}
return SaveWord(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>

View File

@ -12,5 +12,6 @@ namespace BankBusinessLogic.OfficePackage.HelperModels
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportPaymentCurrencyPurchaseViewModel>? Payments { get; set; }
public List<ReportCurrencyTransferViewModel>? Currencies { get; set; }
}
}

View File

@ -12,5 +12,6 @@ namespace BankBusinessLogic.OfficePackage.HelperModels
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportPaymentCurrencyPurchaseViewModel>? Payments { get; set; }
public List<ReportCurrencyTransferViewModel>? Currencies { get; set; }
}
}

View File

@ -10,6 +10,7 @@ namespace BankContracts.ViewModels
{
public int CurrencyPurchaseId { get; set; }
public DateTime PurchaseDate { get; set; }
public string CurrencyName { get; set; }
public List<(int PaymentId, string PaymentDate)> Payments { get; set; } = new();
}
}

View File

@ -10,6 +10,6 @@ namespace BankContracts.ViewModels
{
public int CurrencyId { get; set; }
public string CurrencyName { get; set; } = string.Empty;
public List<(int TransferId, float Amount)> Transfers { get; set; } = new();
public List<TransferViewModel> Transfers { get; set; } = new();
}
}