From ad94885dad8bcb244363ff579ad92335f36c59d0 Mon Sep 17 00:00:00 2001 From: Artyom_Yashin Date: Sun, 26 May 2024 16:24:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/ReportLogic.cs | 2 +- .../OfficePackage/AbstractSaveToWord.cs | 69 ++++++++++--------- .../OfficePackage/HelperModels/WordTable.cs | 15 ++++ 3 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTable.cs diff --git a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs index 481dbbf..4a7a56a 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs @@ -76,7 +76,7 @@ namespace BankBusinessLogic.BusinessLogic public void SaveTransfersToWordFile(ReportBindingModel model) { - _saveToWord.CreateDoc(new WordInfo + _saveToWord.CreateTransfersDoc(new WordInfo { FileName = model.FileName, Title = "Список переводов", diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 0cd7ba0..6918f02 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -11,39 +11,37 @@ namespace BankBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { - public void CreateDoc(WordInfo info) - { - CreateWord(info); - 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 transfer in info.Transfers) - { - CreateParagraph(new WordParagraph - { - Texts = new List<(string, WordTextProperties)> { (transfer.CardNumber, new WordTextProperties { Size = "24", Bold = true}), - (" - цена " + transfer.Transfers.ToString(), new WordTextProperties { Size = "24"}) - }, - TextProperties = new WordTextProperties - { - Size = "24", - JustificationType = WordJustificationType.Both, - } - }); - } - SaveWord(info); - } - /// - /// Создание doc-файла - /// - /// - protected abstract void CreateWord(WordInfo info); + public void CreateTransfersDoc(WordInfo info) + { + CreateWord(info); + List> list = new List>(); + foreach (var shop in info.Shops) + { + var ls = new List + { + shop.ShopName, + shop.Address, + shop.DateOpen.ToShortDateString() + }; + list.Add(ls); + } + var wordTable = new WordTable + { + Headers = new List { + "Название", + "Адрес", + "Дата открытия"}, + Columns = 3, + RowText = list + }; + CreateTable(wordTable); + SaveWord(info); + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreateWord(WordInfo info); /// /// Создание абзаца с текстом /// @@ -55,5 +53,8 @@ namespace BankBusinessLogic.OfficePackage /// /// protected abstract void SaveWord(WordInfo info); - } + + protected abstract void CreateTable(WordTable table); + + } } diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTable.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTable.cs new file mode 100644 index 0000000..c257442 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTable.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + public class WordTable + { + public List Headers { get; set; } = new(); + public List> RowText { get; set; } = new(); + public int Columns { get; set; } + } +}