diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index fb9eeed..7084612 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -45,6 +45,7 @@ this.buttonRef = new System.Windows.Forms.Button(); this.buttonFillStore = new System.Windows.Forms.Button(); this.buttonSellManufacture = new System.Windows.Forms.Button(); + this.reportStoresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -96,7 +97,8 @@ this.reportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.reportComponentsToolStripMenuItem, this.reportManufactureComponentsToolStripMenuItem, - this.reportOrdersToolStripMenuItem}); + this.reportOrdersToolStripMenuItem, + this.reportStoresToolStripMenuItem}); this.reportToolStripMenuItem.Name = "reportToolStripMenuItem"; this.reportToolStripMenuItem.Size = new System.Drawing.Size(51, 20); this.reportToolStripMenuItem.Text = "Отчет"; @@ -208,6 +210,13 @@ this.buttonSellManufacture.UseVisualStyleBackColor = true; this.buttonSellManufacture.Click += new System.EventHandler(this.ButtonSellManufacture_Click); // + // reportStoresToolStripMenuItem + // + this.reportStoresToolStripMenuItem.Name = "reportStoresToolStripMenuItem"; + this.reportStoresToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.reportStoresToolStripMenuItem.Text = "Список магазинов"; + this.reportStoresToolStripMenuItem.Click += new System.EventHandler(this.ReportStoresToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -253,5 +262,6 @@ private ToolStripMenuItem reportComponentsToolStripMenuItem; private ToolStripMenuItem reportManufactureComponentsToolStripMenuItem; private ToolStripMenuItem reportOrdersToolStripMenuItem; + private ToolStripMenuItem reportStoresToolStripMenuItem; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 9da2eb9..7beff79 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -200,5 +200,15 @@ namespace BlacksmithWorkshopView LoadData(); } } + + private void ReportStoresToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveStoresToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs index 65ad99d..a793215 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -15,16 +15,18 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics { private readonly IComponentStorage _componentStorage; private readonly IManufactureStorage _manufactureStorage; + private readonly IStoreStorage _storeStorage; private readonly IOrderStorage _orderStorage; private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToPdf _saveToPdf; - public ReportLogic(IManufactureStorage manufactureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, + public ReportLogic(IManufactureStorage manufactureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IStoreStorage storeStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _manufactureStorage = manufactureStorage; _componentStorage = componentStorage; _orderStorage = orderStorage; + _storeStorage = storeStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; @@ -92,11 +94,24 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics Manufactures = _manufactureStorage.GetFullList() }); } - /// - /// Сохранение изделий с указаеним продуктов в файл-Excel - /// - /// - public void SaveManufactureComponentToExcelFile(ReportBindingModel model) + /// + /// Сохранение магазинов в файл-Word + /// + /// + public void SaveStoresToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDocStores(new WordInfo + { + FileName = model.FileName, + Title = "Список магазинов", + Stores = _storeStorage.GetFullList() + }); + } + /// + /// Сохранение изделий с указаеним продуктов в файл-Excel + /// + /// + public void SaveManufactureComponentToExcelFile(ReportBindingModel model) { _saveToExcel.CreateReport(new ExcelInfo { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 1e4e6eb..a48f537 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -39,6 +39,42 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage } SaveWord(info); } + public void CreateDocStores(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 store in info.Stores) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { + (store.StoreName, new WordTextProperties { Bold = true, Size = "24", }), + (" ", new WordTextProperties { Size = "24"}), + (store.Address, new WordTextProperties { Size = "24" }), + (" ", new WordTextProperties { Size = "24"}), + (store.OpeningDate.ToShortDateString(), new WordTextProperties { Size = "24" }) + }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + SaveWord(info); + } /// /// Создание doc-файла /// diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index 4eee400..364f2fc 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -7,5 +7,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; public List Manufactures { get; set; } = new(); + public List Stores { get; set; } = new(); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs index 00696bb..7a965d6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs @@ -31,5 +31,10 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts /// /// void SaveOrdersToPdfFile(ReportBindingModel model); - } + /// + /// Сохранение магазинов в файл-Word + /// + /// + void SaveStoresToWordFile(ReportBindingModel model); + } }