Вывод списка изделий в doc-файл

This commit is contained in:
prodigygirl 2023-03-11 08:24:40 +04:00
parent 3bba334dbb
commit e856ffa262
6 changed files with 31 additions and 31 deletions

View File

@ -39,8 +39,8 @@
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокКомонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.FurnituresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.компонентыПоИзделиямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.FurnituresComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
@ -142,26 +142,26 @@
// отчетыToolStripMenuItem // отчетыToolStripMenuItem
// //
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокКомонентовToolStripMenuItem, this.FurnituresToolStripMenuItem,
this.компонентыПоИзделиямToolStripMenuItem, this.FurnituresComponentsToolStripMenuItem,
this.списокЗаказовToolStripMenuItem}); this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчетыToolStripMenuItem.Text = "Отчеты"; this.отчетыToolStripMenuItem.Text = "Отчеты";
// //
// списокКомонентовToolStripMenuItem // FurnituresToolStripMenuItem
// //
this.списокКомонентовToolStripMenuItem.Name = "списокКомонентовToolStripMenuItem"; this.FurnituresToolStripMenuItem.Name = "FurnituresToolStripMenuItem";
this.списокКомонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); this.FurnituresToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.списокКомонентовToolStripMenuItem.Text = "Список комонентов"; this.FurnituresToolStripMenuItem.Text = "Список изделий";
this.списокКомонентовToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); this.FurnituresToolStripMenuItem.Click += new System.EventHandler(this.FurnituresToolStripMenuItem_Click);
// //
// компонентыПоИзделиямToolStripMenuItem // FurnituresComponentsToolStripMenuItem
// //
this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; this.FurnituresComponentsToolStripMenuItem.Name = "FurnituresComponentsToolStripMenuItem";
this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); this.FurnituresComponentsToolStripMenuItem.Size = new System.Drawing.Size(216, 22);
this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; this.FurnituresComponentsToolStripMenuItem.Text = "Изделия по компонентам";
this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.ComponentProductsToolStripMenuItem_Click); this.FurnituresComponentsToolStripMenuItem.Click += new System.EventHandler(this.FurnitureComponentsToolStripMenuItem_Click);
// //
// списокЗаказовToolStripMenuItem // списокЗаказовToolStripMenuItem
// //
@ -207,8 +207,8 @@
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem списокКомонентовToolStripMenuItem; private ToolStripMenuItem FurnituresToolStripMenuItem;
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; private ToolStripMenuItem FurnituresComponentsToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem;
} }
} }

View File

@ -1,7 +1,6 @@
using FurnitureAssemblyBusinessLogic; using FurnitureAssemblyBusinessLogic;
using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContarcts; using FurnitureAssemblyContracts.BusinessLogicsContarcts;
using FurnitureAssemblyDataModels.Enums;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -158,13 +157,13 @@ namespace FurnitureAssembly
LoadData(); LoadData();
} }
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs private void FurnituresToolStripMenuItem_Click(object sender, EventArgs
e) e)
{ {
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel _reportLogic.SaveFurnituresToWordFile(new ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });
@ -172,7 +171,7 @@ namespace FurnitureAssembly
MessageBoxIcon.Information); MessageBoxIcon.Information);
} }
} }
private void ComponentProductsToolStripMenuItem_Click(object sender, private void FurnitureComponentsToolStripMenuItem_Click(object sender,
EventArgs e) EventArgs e)
{ {
var service = var service =

View File

@ -18,17 +18,18 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
JustificationType = WordJustificationType.Center JustificationType = WordJustificationType.Center
} }
}); });
foreach (var component in info.Components) foreach (var furniture in info.Furnitures)
{ {
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) }, Texts = new List<(string, WordTextProperties)> { (furniture.FurnitureName, new WordTextProperties { Size = "24", Bold=true}), (" - " + furniture.Price.ToString(), new WordTextProperties { Size = "24", }) },
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",
JustificationType = WordJustificationType.Both JustificationType = WordJustificationType.Both
} }
}); });
} }
SaveWord(info); SaveWord(info);
} }

View File

@ -6,6 +6,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{ {
public string FileName { get; set; } = string.Empty; public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new(); public List<FurnitureViewModel> Furnitures { get; set; } = new();
} }
} }

View File

@ -16,15 +16,15 @@ namespace FurnitureAssemblyBusinessLogic
public class ReportLogic : IReportLogic public class ReportLogic : IReportLogic
{ {
private readonly IComponentStorage _componentStorage; private readonly IComponentStorage _componentStorage;
private readonly IFurnitureStorage _productStorage; private readonly IFurnitureStorage _furnitureStorage;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf; private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IFurnitureStorage productStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, public ReportLogic(IFurnitureStorage furnitureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{ {
_productStorage = productStorage; _furnitureStorage = furnitureStorage;
_componentStorage = componentStorage; _componentStorage = componentStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_saveToExcel = saveToExcel; _saveToExcel = saveToExcel;
@ -38,7 +38,7 @@ namespace FurnitureAssemblyBusinessLogic
public List<ReportFurnitureComponentViewModel> GetFurnitureComponent() public List<ReportFurnitureComponentViewModel> GetFurnitureComponent()
{ {
var components = _componentStorage.GetFullList(); var components = _componentStorage.GetFullList();
var products = _productStorage.GetFullList(); var products = _furnitureStorage.GetFullList();
var list = new List<ReportFurnitureComponentViewModel>(); var list = new List<ReportFurnitureComponentViewModel>();
foreach (var component in components) foreach (var component in components)
{ {
@ -86,13 +86,13 @@ namespace FurnitureAssemblyBusinessLogic
/// Сохранение компонент в файл-Word /// Сохранение компонент в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model) public void SaveFurnituresToWordFile(ReportBindingModel model)
{ {
_saveToWord.CreateDoc(new WordInfo _saveToWord.CreateDoc(new WordInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список компонент", Title = "Список изделий",
Components = _componentStorage.GetFullList() Furnitures = _furnitureStorage.GetFullList()
}); });
} }
/// <summary> /// <summary>

View File

@ -20,7 +20,7 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContarcts
/// Сохранение компонент в файл-Word /// Сохранение компонент в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveComponentsToWordFile(ReportBindingModel model); void SaveFurnituresToWordFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel /// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary> /// </summary>