From 5ed47eea9e19a6b2732906a85e0a7397549aba6a Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 19 May 2023 13:04:22 +0400 Subject: [PATCH] Completed Excel for Client. --- .../BusinessLogics/ReportCashierLogic.cs | 8 +- .../BusinessLogics/ReportClientLogic.cs | 42 ++-- .../OfficePackage/AbstractSaveToExcel.cs | 126 ++++++++++++ .../AbstractSaveToExcelClient.cs | 51 ----- .../OfficePackage/AbstractSaveToPdfCashier.cs | 98 --------- .../OfficePackage/AbstractSaveToPdfClient.cs | 191 ------------------ .../HelperEnums/ExcelStyleInfoType.cs | 2 +- .../OfficePackage/HelperModels/ExcelInfo.cs | 8 +- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../OfficePackage/Implements/SaveToExcel.cs | 4 +- .../Implements/SaveToExcelCashier.cs | 32 --- .../OfficePackage/Implements/SaveToPdf.cs | 2 +- .../Controllers/HomeController.cs | 42 +++- .../Views/Home/CreateExcelReport.cshtml | 20 ++ .../Views/Shared/_Layout.cshtml | 43 ++-- .../BindingModels/ReportBindingModel.cs | 2 + .../ReportSupportBindingModel.cs | 3 + .../IReportClientLogic.cs | 8 +- .../Implements/MoneyTransferStorage.cs | 9 + .../Controllers/ReportController.cs | 10 +- .../BankYouBankruptRestAPI/Program.cs | 8 +- .../Отчёт_по_переводам | Bin 0 -> 3116 bytes .../Отчёт_по_переводам.xls | Bin 0 -> 3114 bytes 23 files changed, 278 insertions(+), 433 deletions(-) create mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs delete mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs delete mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs delete mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs delete mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs create mode 100644 BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateExcelReport.cshtml create mode 100644 BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам create mode 100644 BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам.xls diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs index 498ab2d..7c86c2b 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs @@ -21,16 +21,16 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics private readonly IClientStorage _clientStorage; - private readonly AbstractSaveToExcelCashier _saveToExcel; + private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWordCashier _saveToWord; - private readonly AbstractSaveToPdfClient _saveToPdf; + private readonly AbstractSaveToPdf _saveToPdf; //инициализируем поля класса через контейнер public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, - IClientStorage clientStorage, AbstractSaveToExcelCashier saveToExcel, - AbstractSaveToWordCashier saveToWord, AbstractSaveToPdfClient saveToPdf) + IClientStorage clientStorage, AbstractSaveToExcel saveToExcel, + AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf) { _moneyTransferStorage = moneyTransferStorage; _cashWithdrawalStorage = cashWithdrawalStorage; diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs index bf86b0d..2b2dae0 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs @@ -18,16 +18,21 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { private readonly ICreditingStorage _creditingStorage; private readonly IDebitingStorage _debitingStorage; + private readonly ICardStorage _cardStorage; + private readonly IMoneyTransferStorage _moneyTransferStorage; - private readonly AbstractSaveToExcelClient _saveToExcel; + private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWordClient _saveToWord; - private readonly AbstractSaveToPdfClient _saveToPdf; + private readonly AbstractSaveToPdf _saveToPdf; public ReportClientLogic(ICreditingStorage creditingStorage, IDebitingStorage debitingStorage, - AbstractSaveToExcelClient saveToExcel, AbstractSaveToWordClient saveToWord, AbstractSaveToPdfClient saveToPdf) + AbstractSaveToExcel saveToExcel, AbstractSaveToWordClient saveToWord, AbstractSaveToPdf saveToPdf, + ICardStorage cardStorage, IMoneyTransferStorage moneyTransferStorage) { _creditingStorage = creditingStorage; _debitingStorage = debitingStorage; + _cardStorage = cardStorage; + _moneyTransferStorage = moneyTransferStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; @@ -64,22 +69,31 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics }).ToList(); } - public void SaveCreditingToExcelFile(ReportBindingModel model) + public List? GetMoneyTransfer(ReportBindingModel model) { - throw new NotImplementedException(); + var accountId = _cardStorage.GetElement(new CardSearchModel + { + Id = model.CardId + }).AccountId; + + return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel + { + AccountPayeeId = accountId, + AccountSenderId = accountId + }); } - public void SaveCreditingToWordFile(ReportBindingModel model) + public void SaveToExcelFile(ReportBindingModel model) { - throw new NotImplementedException(); - } + _saveToExcel.CreateReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Список переводов денег", + MoneyTransfer = GetMoneyTransfer(model) + }); + } - public void SaveDebitingToExcelFile(ReportBindingModel model) - { - throw new NotImplementedException(); - } - - public void SaveDebitingToWordFile(ReportBindingModel model) + public void SaveToWordFile(ReportBindingModel model) { throw new NotImplementedException(); } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs new file mode 100644 index 0000000..03d58c1 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -0,0 +1,126 @@ +using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; +using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToExcel + { + //Создание отчета. Описание методов ниже + public void CreateReport(ExcelInfo info) + { + CreateExcel(info); + + //вставляет заголовок + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 1, + Text = info.Title, + StyleInfo = ExcelStyleInfoType.Title + }); + + //соединяет 3 ячейки для заголовка + MergeCells(new ExcelMergeParameters + { + CellFromName = "A1", + CellToName = "C1" + }); + + //номер строчки в докуметне + uint rowIndex = 2; + + foreach (var mt in info.MoneyTransfer) + { + //вставляет номер перевода + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Перевод №" + mt.Id, + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex++; + + //строчка с номером счёта отправителя + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = "Номер счёта отправителя: ", + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + + //вставка номера отправителя + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = mt.AccountSenderNumber, + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + + rowIndex++; + + //строчка с номером счёта получателя + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = "Номер счёта получателя: ", + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + + //вставка номера отправителя + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = mt.AccountPayeeNumber, + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + + rowIndex++; + + //Вставляет слово "Сумма перевода" + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Сумма перевода: ", + StyleInfo = ExcelStyleInfoType.Text + }); + + //подсчитывает общее кол-во заготовок в изделии + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = mt.Sum.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex++; + } + + SaveExcel(info); + } + + //Создание excel-файла + protected abstract void CreateExcel(ExcelInfo info); + + //Добавляем новую ячейку в лист + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + + //Объединение ячеек + protected abstract void MergeCells(ExcelMergeParameters excelParams); + + //Сохранение файла + protected abstract void SaveExcel(ExcelInfo info); + } +} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs deleted file mode 100644 index 8a267ac..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs +++ /dev/null @@ -1,51 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage -{ - public abstract class AbstractSaveToExcelClient - { - //Создание отчета. Описание методов ниже - public void CreateReport(ExcelInfo info) - { - 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; - - //TODO - - SaveExcel(info); - } - - //Создание excel-файла - protected abstract void CreateExcel(ExcelInfo info); - - //Добавляем новую ячейку в лист - protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); - - //Объединение ячеек - protected abstract void MergeCells(ExcelMergeParameters excelParams); - - //Сохранение файла - protected abstract void SaveExcel(ExcelInfo info); - } -} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs deleted file mode 100644 index 564617e..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs +++ /dev/null @@ -1,98 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage -{ - public abstract class AbstractSaveToPdfCashier - { - //публичный метод создания документа. Описание методов ниже - public void CreateDoc(PdfInfo info) - { - CreatePdf(info); - - CreateParagraph(new PdfParagraph - { - Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}", - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - CreateParagraph(new PdfParagraph - { - Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - //параграф с отчётом по выдаче наличных с карт - CreateParagraph(new PdfParagraph { Text = "Отчёт по выдаче наличных с карт", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - - CreateTable(new List { "3cm", "3cm", "5cm", "5cm" }); - - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер операции", "Номер счёта получателя", "Сумма операции", "Дата операции" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - foreach (var report in info.ReportCashWithdrawal) - { - CreateRow(new PdfRowParameters - { - Texts = new List { report.OperationId.ToString(), report.AccountPayeeNumber.ToString(), report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма снятий за период: {info.ReportCashWithdrawal.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); - - //параграф с отчётом по переводу денег со счёта на счёт - CreateParagraph(new PdfParagraph { Text = "Отчёт по денежным переводам между счетами", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - - CreateTable(new List { "3cm", "3cm", "3cm", "5cm", "5cm" }); - - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер операции", "Номер счёта отправителя", "Номер счёта получателя", "Сумма операции", "Дата операции" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - foreach (var report in info.ReportMoneyTransfer) - { - CreateRow(new PdfRowParameters - { - Texts = new List { report.OperationId.ToString(), report.AccountSenderNumber, report.AccountPayeeNumber, report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма переводов за период: {info.ReportMoneyTransfer.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); - - SavePdf(info); - } - - /// Создание pdf-файла - protected abstract void CreatePdf(PdfInfo info); - - /// Создание параграфа с текстом - protected abstract void CreateParagraph(PdfParagraph paragraph); - - /// Создание таблицы - protected abstract void CreateTable(List columns); - - /// Создание и заполнение строки - protected abstract void CreateRow(PdfRowParameters rowParameters); - - /// Сохранение файла - protected abstract void SavePdf(PdfInfo info); - } -} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs deleted file mode 100644 index 602a30f..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs +++ /dev/null @@ -1,191 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage -{ - public abstract class AbstractSaveToPdfClient - { - //публичный метод создания документа. Описание методов ниже - public void CreateDoc(PdfInfo info) - { - if(info.ForClient) - { - CreateDocClient(info); - } - else - { - CreateDocCashier(info); - } - } - - #region Отчёт для клиента - - public void CreateDocClient(PdfInfo info) - { - CreatePdf(info); - - CreateParagraph(new PdfParagraph - { - Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}", - - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - CreateParagraph(new PdfParagraph - { - Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - //параграф с отчётом на пополнения - CreateParagraph(new PdfParagraph { Text = "Отчёт по пополнениям", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - - CreateTable(new List { "3cm", "3cm", "5cm", "5cm" }); - - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер операции", "Номер карты", "Сумма", "Дата операции" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - foreach (var report in info.ReportCrediting) - { - CreateRow(new PdfRowParameters - { - Texts = new List { report.OperationId.ToString(), report.CardNumber, report.SumOperation.ToString(), report.DateComplite.ToString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - //подсчёт суммы операций на пополнение - CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма поступлений за период: {info.ReportCrediting.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); - - //отчёт с отчётом на снятие - CreateParagraph(new PdfParagraph { Text = "Отчёт по снятиям", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - - CreateTable(new List { "3cm", "3cm", "5cm", "5cm" }); - - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер операции", "Номер карты", "Сумма", "Дата операции" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - foreach (var report in info.ReportDebiting) - { - CreateRow(new PdfRowParameters - { - Texts = new List { report.OperationId.ToString(), report.CardNumber, report.SumOperation.ToString(), report.DateComplite.ToString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - //подсчёт суммы операций на пополнение - CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма снятий за период: {info.ReportDebiting.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); - - SavePdf(info); - } - - #endregion - - #region Отчёт для кассира - - //создание отчёта для кассира - public void CreateDocCashier(PdfInfo info) - { - CreatePdf(info); - - CreateParagraph(new PdfParagraph - { - Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}\nФИО клиента: {info.FullClientName}", - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - CreateParagraph(new PdfParagraph - { - Text = $"Расчётный период: с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - //параграф с отчётом по выдаче наличных с карт - CreateParagraph(new PdfParagraph { Text = "Отчёт по выдаче наличных со счёта", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - - CreateTable(new List { "3.5cm", "3.5cm", "5cm", "5cm" }); - - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер операции", "Номер счёта", "Сумма операции", "Дата операции" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - foreach (var report in info.ReportCashWithdrawal) - { - CreateRow(new PdfRowParameters - { - Texts = new List { report.OperationId.ToString(), report.AccountPayeeNumber, report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма снятий за период: {info.ReportCashWithdrawal.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); - - //параграф с отчётом по переводу денег со счёта на счёт - CreateParagraph(new PdfParagraph { Text = "Отчёт по денежным переводам между счетами", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - - CreateTable(new List { "3cm", "3cm", "3cm", "4cm", "4cm" }); - - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер операции", "Номер счёта отправителя", "Номер счёта получателя", "Сумма операции", "Дата операции" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - - foreach (var report in info.ReportMoneyTransfer) - { - CreateRow(new PdfRowParameters - { - Texts = new List { report.OperationId.ToString(), report.AccountSenderNumber, report.AccountPayeeNumber, report.SumOperation.ToString(), report.DateComplite.ToShortDateString(), }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - CreateParagraph(new PdfParagraph { Text = $"Итоговая сумма переводов за период: {info.ReportMoneyTransfer.Sum(x => x.SumOperation)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); - - SavePdf(info); - } - - #endregion - - /// Создание pdf-файла - protected abstract void CreatePdf(PdfInfo info); - - /// Создание параграфа с текстом - protected abstract void CreateParagraph(PdfParagraph paragraph); - - /// Создание таблицы - protected abstract void CreateTable(List columns); - - /// Создание и заполнение строки - protected abstract void CreateRow(PdfRowParameters rowParameters); - - /// Сохранение файла - protected abstract void SavePdf(PdfInfo info); - } -} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs index 619360a..805e9b0 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -16,6 +16,6 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperEnums Text, //текст в рамке - TextWithBroder + TextWithBorder } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index f470675..7480039 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -1,4 +1,5 @@ using BankYouBankruptContracts.ViewModels; +using BankYouBankruptContracts.ViewModels.Client.Default; using System; using System.Collections.Generic; using System.Linq; @@ -16,7 +17,10 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels //заголовок public string Title { get; set; } = string.Empty; - //список счетов для вывода и сохранения - public List Accounts { get; set; } = new(); + //список для отчёта клиента + public List MoneyTransfer { get; set; } = new(); + + //список для отчёта кассира + public List Debiting { get; set; } = new(); } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index c1329ac..c79d66f 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -14,7 +14,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - //список счетов для вывода и сохранения + //списки для формирования отчёта клиента public List Accounts { get; set; } = new(); } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index 960108d..2c1c9e9 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace BankYouBankruptBusinessLogic.OfficePackage.Implements { - public class SaveToExcel : AbstractSaveToExcelClient + public class SaveToExcel : AbstractSaveToExcel { private SpreadsheetDocument? _spreadsheetDocument; @@ -227,7 +227,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.Implements return styleInfo switch { ExcelStyleInfoType.Title => 2U, - ExcelStyleInfoType.TextWithBroder => 1U, + ExcelStyleInfoType.TextWithBorder => 1U, ExcelStyleInfoType.Text => 0U, _ => 0U, }; diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs deleted file mode 100644 index d7f0c1f..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToExcelCashier.cs +++ /dev/null @@ -1,32 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage.Implements -{ - public class SaveToExcelCashier : AbstractSaveToExcelCashier - { - protected override void CreateExcel(ExcelInfo info) - { - throw new NotImplementedException(); - } - - protected override void InsertCellInWorksheet(ExcelCellParameters excelParams) - { - throw new NotImplementedException(); - } - - protected override void MergeCells(ExcelMergeParameters excelParams) - { - throw new NotImplementedException(); - } - - protected override void SaveExcel(ExcelInfo info) - { - throw new NotImplementedException(); - } - } -} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index 20d671a..079c4b1 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace BankYouBankruptBusinessLogic.OfficePackage.Implements { //реализация астрактного класса создания pdf документа - public class SaveToPdf : AbstractSaveToPdfClient + public class SaveToPdf : AbstractSaveToPdf { private Document? _document; diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index 9a6829f..6ddd485 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -275,8 +275,45 @@ namespace BankYouBankruptClientApp.Controllers #endregion - #region Получение отчета по картам - [HttpGet] + #region Excel отчёт + + [HttpGet] + public IActionResult CreateExcelReport() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + + ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}"); + + return View(); + } + + [HttpPost] + public IActionResult CreateExcelReport(int cardId) + { + if (APIClient.Client == null) + { + throw new Exception("Не авторизованы"); + } + + //ViewBag.DataOfClientReport = APIClient.GetRequest($"api/Report/GetDataOfClientReport"); + + APIClient.PostRequest("api/Report/CreateExcelClient", new ReportSupportBindingModel() + { + CardId = cardId + }); + + ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}"); + + return View(); + } + + #endregion + + #region Получение отчета по картам + [HttpGet] public IActionResult ReportWithCards() { if (APIClient.Client == null) @@ -348,7 +385,6 @@ namespace BankYouBankruptClientApp.Controllers ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}"); - return View(); } diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateExcelReport.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateExcelReport.cshtml new file mode 100644 index 0000000..1d2e7b7 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateExcelReport.cshtml @@ -0,0 +1,20 @@ +@{ + ViewData["Title"] = "Создание Excel отчёта"; +} + +
+

Создание отчёта

+
+
+
+
Выберите карту:
+
+ +
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml index f7513f2..87ba87d 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml @@ -24,26 +24,29 @@ diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs index 3ec609b..41361f8 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs @@ -12,6 +12,8 @@ namespace BankYouBankruptContracts.BindingModels public int? ClientId { get; set; } + public int? CardId { get; set; } + public string? ClientFullName { get; set; } = string.Empty; public DateTime? DateFrom { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs index ffc875c..250ed7c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs @@ -14,5 +14,8 @@ namespace BankYouBankruptContracts.BindingModels public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } + + //для Excel отчёта клиента + public int? CardId { get; set; } } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs index b040377..1f47aa5 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs @@ -17,14 +17,10 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts List? GetDebiting(ReportBindingModel model); //Сохранение отчёта по картам в файл-Word - void SaveCreditingToWordFile(ReportBindingModel model); - - void SaveDebitingToWordFile(ReportBindingModel model); + void SaveToWordFile(ReportBindingModel model); //Сохранение отчёта по картам в файл-Excel - void SaveCreditingToExcelFile(ReportBindingModel model); - - void SaveDebitingToExcelFile(ReportBindingModel model); + void SaveToExcelFile(ReportBindingModel model); //Сохранение отчёта по картам в файл-Pdf ReportClientViewModelForHTML SaveClientReportToPdfFile(ReportBindingModel model); diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs index 868d64e..11ab323 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs @@ -35,6 +35,15 @@ namespace BankYouBankruptDatabaseImplement.Implements .Include(x => x.AccountSender) .ToList(); + if(model.AccountPayeeId.HasValue && model.AccountSenderId.HasValue && model.AccountPayeeId == model.AccountSenderId) + { + return result.Where(x => (x.AccountSenderId == model.AccountSenderId || x.AccountPayeeId == model.AccountPayeeId) + && x.AccountSender != null) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + if (model.AccountPayeeId.HasValue) result = result.Where(x => x.AccountPayeeId == model.AccountPayeeId).ToList(); if (model.AccountSenderId.HasValue) result = result.Where(x => x.AccountSenderId == model.AccountSenderId).ToList(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index 3b13f71..0154461 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -80,12 +80,16 @@ namespace BankYouBankruptRestAPI.Controllers } //передача данных из отчёта клиента - [HttpGet] - public ReportClientViewModelForHTML GetDataOfClientReport() + [HttpPost] + public void CreateExcelClient(ReportSupportBindingModel model) { try { - return _reportClientViewModelForHTML; + _reportClientLogic.SaveToExcelFile(new ReportBindingModel + { + FileName = "Отчёт_по_переводам", + CardId = model.CardId + }); } catch (Exception ex) { diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs index 4592562..4bfc224 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs @@ -40,12 +40,12 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); -//теперь общий -builder.Services.AddTransient(); +//общие классы формировани отчётов +builder.Services.AddTransient(); + +builder.Services.AddTransient(); -builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddControllers(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам new file mode 100644 index 0000000000000000000000000000000000000000..aa9fadc6a7ef73fa66204e91a9e42ccc3c4e2e0e GIT binary patch literal 3116 zcma)82{=^iA0A{zT(S8ewzyr?giLhD?YYlLuExd9j8=NdK`1S501K z{NNC(4?g;Vd29epkLvDpG7@b^p6#)^?y#B(B!!grxQa|Kgr$R0sIz?P!|3Pfo-&mh zeB0aOsOa?IXC9pMcRw!AE`8vg&I%eSJJ2qw&_1v6;=>7xn_U5`Y0tBR!&aA{rv6&e zrmYQ1gnj7^|K0vZQ=KM9TxzJ2n}>k(?IjiDo^3B8DGsCT0DucO0Kofg+eA`C0FJn` z>0caN@we23w^eS0ahIgZmpyjLgIX<8efvAml4=RsZmA(IuYA8=ZVoYPsBv*D9}(*A zUR%HYVtylsmY6KK%$EQrW-%w_J|O7kXv~xTt)}~Nbul5)zv3!S@RJ%$&PMuy{AsZD zFqDq7*ppd4+u=JaKy__LqEVrp$s^uTQ;1Vdm7cyg_Y zPwrt~vu5-QZp1yxY7`9dDL!QywURaTp?F4XCX{T!$P5vH89VVMnfAtoffCvs?-vqc zi+B3MtBtLF*RM`4)X#ka~^ZhMtm&OaCmQ_k0-mQ}9oN;%2TA*RFaM8B!soHjM z=0J>Y(B&%S&nfo$McSk4G8ydeE^Lk(Dy6w!6OVk3mKK*!5BUjrs&=E(%9ZU9#5!eN zzvEQ(6b0otqX%9Z1RK>nUOX`IN4`=7mdu--e$L-fEJ#0&u1@ApY3&Q_yV64{uDH(4Sz_EU zf{k)Pel|Nz6>n&EZYnn)%>_T>RUHtnF3l;p+YD~1xXpI!CkaxvZlKa7UWpCa{KLok z+q0+I-kMglLE2nR1u`a*dA<~Qk$zOU$x$9%f_WVz>$qUHX=)NO;LbD7Xk*^`Jh9$3&r493 z*Su4%mu3)HD`EarLZQgX`cht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