diff --git a/Bank/BankBusinessLogic/BusinessLogics/ReportLogic.cs b/Bank/BankBusinessLogic/BusinessLogics/ReportLogic.cs index e0c5fd1..e11fba6 100644 --- a/Bank/BankBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogics/ReportLogic.cs @@ -128,7 +128,7 @@ namespace BankBusinessLogic.BusinessLogics { CurrencyId = currency.Id, CurrencyName = currency.Name, - Transfers = new List<(int TransferId, float Amount)>(), + Transfers = new List(), }; var paymentsId = new List(); 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(); diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index b161605..8f4444f 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -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++; } diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 29777bf..79b63f1 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -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); + } /// /// Создание doc-файла /// diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index eda260d..6a55a9b 100644 --- a/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -12,5 +12,6 @@ namespace BankBusinessLogic.OfficePackage.HelperModels public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; public List? Payments { get; set; } + public List? Currencies { get; set; } } } diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index 166fc5e..e6439d0 100644 --- a/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -12,5 +12,6 @@ namespace BankBusinessLogic.OfficePackage.HelperModels public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; public List? Payments { get; set; } + public List? Currencies { get; set; } } } diff --git a/Bank/BankContracts/ViewModels/ReportCurrencyPurchasePaymentViewModel.cs b/Bank/BankContracts/ViewModels/ReportCurrencyPurchasePaymentViewModel.cs index e664a36..316a92b 100644 --- a/Bank/BankContracts/ViewModels/ReportCurrencyPurchasePaymentViewModel.cs +++ b/Bank/BankContracts/ViewModels/ReportCurrencyPurchasePaymentViewModel.cs @@ -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(); } } diff --git a/Bank/BankContracts/ViewModels/ReportCurrencyTransferViewModel.cs b/Bank/BankContracts/ViewModels/ReportCurrencyTransferViewModel.cs index 66dcf0c..7478d50 100644 --- a/Bank/BankContracts/ViewModels/ReportCurrencyTransferViewModel.cs +++ b/Bank/BankContracts/ViewModels/ReportCurrencyTransferViewModel.cs @@ -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 Transfers { get; set; } = new(); } }