Добавлен отчет списка изделий в doc-файле

This commit is contained in:
Данияр Аглиуллов 2023-03-01 20:38:56 +04:00
parent ac83f7165b
commit f1359d2657
6 changed files with 24 additions and 20 deletions

View File

@ -24,11 +24,15 @@ namespace ConfectioneryBusinessLogic.OfficePackage
} }
}); });
foreach (var component in info.Components) foreach (var pastry in info.Pastries)
{ {
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) }, Texts = new List<(string, WordTextProperties)>
{
(pastry.PastryName , new WordTextProperties { Size = "24", Bold = true}),
(" - цена: " + pastry.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",

View File

@ -11,6 +11,6 @@ namespace ConfectioneryBusinessLogic.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<PastryViewModel> Pastries { get; set; } = new();
} }
} }

View File

@ -17,7 +17,7 @@ namespace ConfectioneryBusinessLogic
{ {
private readonly IComponentStorage _componentStorage; private readonly IComponentStorage _componentStorage;
private readonly IPastryStorage _PastryStorage; private readonly IPastryStorage _pastryStorage;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
@ -30,7 +30,7 @@ namespace ConfectioneryBusinessLogic
public ReportLogic(IPastryStorage PastryStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, public ReportLogic(IPastryStorage PastryStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{ {
_PastryStorage = PastryStorage; _pastryStorage = PastryStorage;
_componentStorage = componentStorage; _componentStorage = componentStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
@ -47,7 +47,7 @@ namespace ConfectioneryBusinessLogic
{ {
var components = _componentStorage.GetFullList(); var components = _componentStorage.GetFullList();
var Pastrys = _PastryStorage.GetFullList(); var Pastrys = _pastryStorage.GetFullList();
var list = new List<ReportPastryComponentViewModel>(); var list = new List<ReportPastryComponentViewModel>();
@ -96,13 +96,13 @@ namespace ConfectioneryBusinessLogic
/// Сохранение компонент в файл-Word /// Сохранение компонент в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model) public void SavePastriesToWordFile(ReportBindingModel model)
{ {
_saveToWord.CreateDoc(new WordInfo _saveToWord.CreateDoc(new WordInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список компонент", Title = "Список изделий",
Components = _componentStorage.GetFullList() Pastries = _pastryStorage.GetFullList()
}); });
} }

View File

@ -33,7 +33,7 @@
pastryToolStripMenuItem = new ToolStripMenuItem(); pastryToolStripMenuItem = new ToolStripMenuItem();
componentToolStripMenuItem = new ToolStripMenuItem(); componentToolStripMenuItem = new ToolStripMenuItem();
reportsToolStripMenuItem = new ToolStripMenuItem(); reportsToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); pastriesToolStripMenuItem = new ToolStripMenuItem();
pastryComponentsToolStripMenuItem = new ToolStripMenuItem(); pastryComponentsToolStripMenuItem = new ToolStripMenuItem();
ordersToolStripMenuItem = new ToolStripMenuItem(); ordersToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
@ -78,17 +78,17 @@
// //
// reportsToolStripMenuItem // reportsToolStripMenuItem
// //
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastryComponentsToolStripMenuItem, ordersToolStripMenuItem }); reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastriesToolStripMenuItem, pastryComponentsToolStripMenuItem, ordersToolStripMenuItem });
reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
reportsToolStripMenuItem.Size = new Size(60, 20); reportsToolStripMenuItem.Size = new Size(60, 20);
reportsToolStripMenuItem.Text = "Отчеты"; reportsToolStripMenuItem.Text = "Отчеты";
// //
// componentsToolStripMenuItem // pastriesToolStripMenuItem
// //
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; pastriesToolStripMenuItem.Name = "pastriesToolStripMenuItem";
componentsToolStripMenuItem.Size = new Size(218, 22); pastriesToolStripMenuItem.Size = new Size(218, 22);
componentsToolStripMenuItem.Text = "Список компонентов"; pastriesToolStripMenuItem.Text = "Список изделий";
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click_1; pastriesToolStripMenuItem.Click += PastriesToolStripMenuItem_Click_1;
// //
// pastryComponentsToolStripMenuItem // pastryComponentsToolStripMenuItem
// //
@ -205,7 +205,7 @@
private ToolStripMenuItem pastryToolStripMenuItem; private ToolStripMenuItem pastryToolStripMenuItem;
private ToolStripMenuItem componentToolStripMenuItem; private ToolStripMenuItem componentToolStripMenuItem;
private ToolStripMenuItem reportsToolStripMenuItem; private ToolStripMenuItem reportsToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem pastriesToolStripMenuItem;
private ToolStripMenuItem pastryComponentsToolStripMenuItem; private ToolStripMenuItem pastryComponentsToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem; private ToolStripMenuItem ordersToolStripMenuItem;
} }

View File

@ -157,12 +157,12 @@ namespace ConfectioneryView
LoadData(); LoadData();
} }
private void ComponentsToolStripMenuItem_Click_1(object sender, EventArgs e) private void PastriesToolStripMenuItem_Click_1(object sender, EventArgs 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 { FileName = dialog.FileName }); _reportLogic.SavePastriesToWordFile(new ReportBindingModel { FileName = dialog.FileName });
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }

View File

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