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; } + } +}