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 0000000..aa9fadc Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам differ diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам.xls b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам.xls new file mode 100644 index 0000000..75fad10 Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_переводам.xls differ