This commit is contained in:
malimova 2024-04-12 01:04:02 +04:00
parent 9151fe816c
commit 7ef9f12ae7
7 changed files with 349 additions and 4 deletions

View File

@ -8,7 +8,7 @@ using ConfectioneryContracts.ViewModels;
namespace ConfectioneryBusinessLogic namespace ConfectioneryBusinessLogic
{ {
internal class ReportLogic : IReportLogic public class ReportLogic : IReportLogic
{ {
private readonly IComponentStorage _componentStorage; private readonly IComponentStorage _componentStorage;
private readonly IPastryStorage _productStorage; private readonly IPastryStorage _productStorage;

View File

@ -33,6 +33,10 @@
toolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
pastryToolStripMenuItem = new ToolStripMenuItem(); pastryToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
componentsListToolStripMenuItem = new ToolStripMenuItem();
componentPastryToolStripMenuItem = new ToolStripMenuItem();
ordersListToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button(); buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button(); buttonTakeOrderInWork = new Button();
buttonOrderReady = new Button(); buttonOrderReady = new Button();
@ -56,7 +60,7 @@
// menuStrip // menuStrip
// //
menuStrip.ImageScalingSize = new Size(24, 24); menuStrip.ImageScalingSize = new Size(24, 24);
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem }); menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0); menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip"; menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1375, 33); menuStrip.Size = new Size(1375, 33);
@ -84,6 +88,33 @@
pastryToolStripMenuItem.Text = "Кондитерские изделия"; pastryToolStripMenuItem.Text = "Кондитерские изделия";
pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click; pastryToolStripMenuItem.Click += pastryToolStripMenuItem_Click;
// //
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsListToolStripMenuItem, componentPastryToolStripMenuItem, ordersListToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(88, 29);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// componentsListToolStripMenuItem
//
componentsListToolStripMenuItem.Name = "componentsListToolStripMenuItem";
componentsListToolStripMenuItem.Size = new Size(327, 34);
componentsListToolStripMenuItem.Text = "Список компонентов";
//
// componentPastryToolStripMenuItem
//
componentPastryToolStripMenuItem.Name = "componentPastryToolStripMenuItem";
componentPastryToolStripMenuItem.Size = new Size(327, 34);
componentPastryToolStripMenuItem.Text = "Компоненты по изделиям";
componentPastryToolStripMenuItem.Click += componentPastryToolStripMenuItem_Click;
//
// ordersListToolStripMenuItem
//
ordersListToolStripMenuItem.Name = "ordersListToolStripMenuItem";
ordersListToolStripMenuItem.Size = new Size(327, 34);
ordersListToolStripMenuItem.Text = "Список заказов";
ordersListToolStripMenuItem.Click += ordersListToolStripMenuItem_Click;
//
// buttonCreateOrder // buttonCreateOrder
// //
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
@ -174,5 +205,9 @@
private Button buttonRef; private Button buttonRef;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem pastryToolStripMenuItem; private ToolStripMenuItem pastryToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem componentsListToolStripMenuItem;
private ToolStripMenuItem componentPastryToolStripMenuItem;
private ToolStripMenuItem ordersListToolStripMenuItem;
} }
} }

View File

@ -16,12 +16,15 @@ namespace ConfectioneryView
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic) private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
_reportLogic = reportLogic;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
@ -157,5 +160,19 @@ namespace ConfectioneryView
{ {
LoadData(); LoadData();
} }
private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents));
if (service is FormReportPastryComponents form)
{
form.ShowDialog();
}
}
private void ordersListToolStripMenuItem_Click(object sender, EventArgs e)
{
}
} }
} }

View File

@ -0,0 +1,130 @@
namespace ConfectioneryView
{
partial class FormReportPastryComponents
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
dataGridView = new DataGridView();
ColumnComponent = new DataGridViewTextBoxColumn();
ColumnPastry = new DataGridViewTextBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
buttonSaveToExcel = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.BackgroundColor = Color.AliceBlue;
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = SystemColors.Control;
dataGridViewCellStyle1.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
dataGridViewCellStyle1.ForeColor = SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = DataGridViewTriState.True;
dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnPastry, ColumnCount });
dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = SystemColors.Window;
dataGridViewCellStyle2.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
dataGridViewCellStyle2.ForeColor = SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = DataGridViewTriState.False;
dataGridView.DefaultCellStyle = dataGridViewCellStyle2;
dataGridView.Location = new Point(12, 141);
dataGridView.Name = "dataGridView";
dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = SystemColors.Control;
dataGridViewCellStyle3.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
dataGridViewCellStyle3.ForeColor = SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True;
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
dataGridView.RowHeadersWidth = 62;
dataGridView.RowTemplate.Height = 33;
dataGridView.Size = new Size(875, 498);
dataGridView.TabIndex = 0;
//
// ColumnComponent
//
ColumnComponent.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnComponent.HeaderText = "Компонент";
ColumnComponent.MinimumWidth = 8;
ColumnComponent.Name = "ColumnComponent";
//
// ColumnPastry
//
ColumnPastry.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnPastry.HeaderText = "Изделие";
ColumnPastry.MinimumWidth = 8;
ColumnPastry.Name = "ColumnPastry";
//
// ColumnCount
//
ColumnCount.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 8;
ColumnCount.Name = "ColumnCount";
//
// buttonSaveToExcel
//
buttonSaveToExcel.Location = new Point(66, 45);
buttonSaveToExcel.Name = "buttonSaveToExcel";
buttonSaveToExcel.Size = new Size(187, 52);
buttonSaveToExcel.TabIndex = 1;
buttonSaveToExcel.Text = "Сохранить в Excel";
buttonSaveToExcel.UseVisualStyleBackColor = true;
buttonSaveToExcel.Click += buttonSaveToExcel_Click;
//
// FormReportPastryComponents
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(899, 651);
Controls.Add(buttonSaveToExcel);
Controls.Add(dataGridView);
Name = "FormReportPastryComponents";
Text = "Компоненты по изделиям";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnComponent;
private DataGridViewTextBoxColumn ColumnPastry;
private DataGridViewTextBoxColumn ColumnCount;
private Button buttonSaveToExcel;
}
}

View File

@ -0,0 +1,86 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConfectioneryView
{
public partial class FormReportPastryComponents : Form
{
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportPastryComponents(ILogger<FormReportPastryComponents> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormReportPastryComponents_Load(object sender, EventArgs e)
{
try
{
var dict = _logic.GetPastryComponent();
if (dict != null)
{
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Pastrys)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка кондитерских изделий по компонентам");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка кондитерских изделий по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SavePastryComponentToExcelFile(new
ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка изделий по компонентам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,69 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnComponent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnPastry.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -1,4 +1,6 @@
using ConfectioneryBusinessLogic; using ConfectioneryBusinessLogic;
using ConfectioneryBusinessLogic.OfficePackage.Implements;
using ConfectioneryBusinessLogic.OfficePackage;
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.StoragesContracts; using ConfectioneryContracts.StoragesContracts;
using ConfectioneryDatabaseImplement.Implements; using ConfectioneryDatabaseImplement.Implements;
@ -38,6 +40,10 @@ namespace ConfectioneryView
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPastryLogic, PastryLogic>(); services.AddTransient<IPastryLogic, PastryLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
@ -45,6 +51,8 @@ namespace ConfectioneryView
services.AddTransient<FormPastry>(); services.AddTransient<FormPastry>();
services.AddTransient<FormPastryComponent>(); services.AddTransient<FormPastryComponent>();
services.AddTransient<FormPastrys>(); services.AddTransient<FormPastrys>();
services.AddTransient<FormReportPastryComponents>();
//services.AddTransient<FormReportOrders>();
} }
} }
} }