From b85d1773bfb6dc677cba1495bd4d8ea5327e2df4 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 16:23:20 +0400 Subject: [PATCH 1/2] fix --- .../BusinessLogic/ReportLogic.cs | 2 +- .../OfficePackage/AbstractSaveToWord.cs | 63 ++++++++++--------- .../OfficePackage/HelperModels/WordTable.cs | 15 +++++ 3 files changed, 50 insertions(+), 30 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..4532ed4 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs @@ -43,7 +43,7 @@ namespace BankBusinessLogic.BusinessLogic public void SaveRequestsToWordFile(ReportBindingModel model) { - _saveToWord.CreateDoc(new WordInfo + _saveToWord.CreateRequestsDoc(new WordInfo { FileName = model.FileName, Title = "Список заявок", diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 0cd7ba0..74c6f57 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -1,6 +1,7 @@ using BankBusinessLogic.OfficePackage.DocumentModels; using BankBusinessLogic.OfficePackage.HelperEnums; using BankBusinessLogic.OfficePackage.HelperModels; +using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; @@ -11,34 +12,32 @@ 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); - } + public void CreateRequestsDoc(WordInfo info) + { + CreateWord(info); + List> list = new List>(); + foreach (var shop in info.Shops) + { + var ls = new List + { + shop.ShopName, + shop.Address, + shop.OpeningDate.ToShortDateString() + }; + list.Add(ls); + } + var wordTable = new WordTable + { + Headers = new List { + "Название", + "Адрес", + "Дата открытия"}, + Columns = 3, + RowText = list + }; + CreateTable(wordTable); + SaveWord(info); + } /// /// Создание doc-файла /// @@ -55,5 +54,11 @@ namespace BankBusinessLogic.OfficePackage /// /// protected abstract void SaveWord(WordInfo info); - } + + /// + /// Создание doc-файла с таблицей + /// + /// + 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..dd2d23d --- /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 BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +{ + public class WordTable + { + public List Headers { get; set; } = new(); + public List> RowText { get; set; } = new(); + public int Columns { get; set; } + } +} From 8ab55a53358fa4c86767fee8fd8235d626618087 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 16:23:56 +0400 Subject: [PATCH 2/2] fix --- Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs index 4532ed4..2a90d3a 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs @@ -56,7 +56,7 @@ namespace BankBusinessLogic.BusinessLogic public void SaveRequestsComponentsToExcelFile(ReportBindingModel model) { - _saveToExcel.CreateDoc(new ExcelInfo + _saveToExcel.CreateRequestsDoc(new ExcelInfo { FileName = model.FileName, Title = "Список заявок",