From 50797a9c5d134477cfac00400d67d1def019bf79 Mon Sep 17 00:00:00 2001 From: abazov73 <92822431+abazov73@users.noreply.github.com> Date: Mon, 20 Mar 2023 11:10:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A7=D0=B5=D1=82=D0=B2=D1=91=D1=80=D1=82?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Confectionery/Confectionery.csproj | 7 + .../Confectionery/FormMain.Designer.cs | 42 +- Confectionery/Confectionery/FormMain.cs | 35 +- .../FormReportOrders.Designer.cs | 136 +++++ .../Confectionery/FormReportOrders.cs | 100 +++ .../Confectionery/FormReportOrders.resx | 60 ++ .../FormReportPastryIngredients.Designer.cs | 113 ++++ .../FormReportPastryIngredients.cs | 78 +++ .../FormReportPastryIngredients.resx | 69 +++ Confectionery/Confectionery/Program.cs | 8 + Confectionery/Confectionery/ReportOrders.rdlc | 572 ++++++++++++++++++ .../BusinessLogics/ReportLogic.cs | 140 +++++ .../ConfectioneryBusinessLogic.csproj | 2 + .../OfficePackage/AbstractSaveToExcel.cs | 112 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 74 +++ .../OfficePackage/AbstractSaveToWord.cs | 56 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 16 + .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 22 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 16 + .../OfficePackage/HelperModels/WordInfo.cs | 16 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 297 +++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 119 ++++ .../OfficePackage/Implements/SaveToWord.cs | 140 +++++ .../BindingModels/ReportBindingModel.cs | 15 + .../BusinessLogicsContracts/IReportLogic.cs | 40 ++ .../SearchModels/OrderSearchModel.cs | 3 +- .../ViewModels/ReportOrdersViewModel.cs | 18 + .../ReportPastryIngredientViewModel.cs | 15 + .../Implements/OrderStorage.cs | 23 +- .../Implements/OrderStorage.cs | 20 +- .../Implements/OrderStorage.cs | 21 +- 39 files changed, 2489 insertions(+), 19 deletions(-) create mode 100644 Confectionery/Confectionery/FormReportOrders.Designer.cs create mode 100644 Confectionery/Confectionery/FormReportOrders.cs create mode 100644 Confectionery/Confectionery/FormReportOrders.resx create mode 100644 Confectionery/Confectionery/FormReportPastryIngredients.Designer.cs create mode 100644 Confectionery/Confectionery/FormReportPastryIngredients.cs create mode 100644 Confectionery/Confectionery/FormReportPastryIngredients.resx create mode 100644 Confectionery/Confectionery/ReportOrders.rdlc create mode 100644 Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 Confectionery/ConfectioneryContracts/BindingModels/ReportBindingModel.cs create mode 100644 Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 Confectionery/ConfectioneryContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 Confectionery/ConfectioneryContracts/ViewModels/ReportPastryIngredientViewModel.cs diff --git a/Confectionery/Confectionery/Confectionery.csproj b/Confectionery/Confectionery/Confectionery.csproj index b60ee41..8ced976 100644 --- a/Confectionery/Confectionery/Confectionery.csproj +++ b/Confectionery/Confectionery/Confectionery.csproj @@ -29,6 +29,7 @@ + @@ -55,4 +56,10 @@ + + + Always + + + \ No newline at end of file diff --git a/Confectionery/Confectionery/FormMain.Designer.cs b/Confectionery/Confectionery/FormMain.Designer.cs index 1b586a0..1d2ecce 100644 --- a/Confectionery/Confectionery/FormMain.Designer.cs +++ b/Confectionery/Confectionery/FormMain.Designer.cs @@ -32,6 +32,10 @@ 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.IngredientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.IngredientPastriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.OrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); @@ -46,7 +50,8 @@ // this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); + this.справочникиToolStripMenuItem, + this.отчётыToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1238, 28); @@ -76,6 +81,37 @@ this.изделияToolStripMenuItem.Text = "Кондитерские изделия"; this.изделияToolStripMenuItem.Click += new System.EventHandler(this.изделияToolStripMenuItem_Click); // + // отчётыToolStripMenuItem + // + this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.IngredientsToolStripMenuItem, + this.IngredientPastriesToolStripMenuItem, + this.OrdersToolStripMenuItem}); + this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); + this.отчётыToolStripMenuItem.Text = "Отчёты"; + // + // IngredientsToolStripMenuItem + // + this.IngredientsToolStripMenuItem.Name = "IngredientsToolStripMenuItem"; + this.IngredientsToolStripMenuItem.Size = new System.Drawing.Size(280, 26); + this.IngredientsToolStripMenuItem.Text = "Список изделий"; + this.IngredientsToolStripMenuItem.Click += new System.EventHandler(this.IngredientsToolStripMenuItem_Click); + // + // IngredientPastriesToolStripMenuItem + // + this.IngredientPastriesToolStripMenuItem.Name = "IngredientPastriesToolStripMenuItem"; + this.IngredientPastriesToolStripMenuItem.Size = new System.Drawing.Size(280, 26); + this.IngredientPastriesToolStripMenuItem.Text = "Ингрединеты по изделиям"; + this.IngredientPastriesToolStripMenuItem.Click += new System.EventHandler(this.IngredientPastriesToolStripMenuItem_Click); + // + // OrdersToolStripMenuItem + // + this.OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + this.OrdersToolStripMenuItem.Size = new System.Drawing.Size(280, 26); + this.OrdersToolStripMenuItem.Text = "Список заказов"; + this.OrdersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.BackgroundColor = System.Drawing.Color.White; @@ -175,5 +211,9 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem IngredientsToolStripMenuItem; + private ToolStripMenuItem IngredientPastriesToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/Confectionery/Confectionery/FormMain.cs b/Confectionery/Confectionery/FormMain.cs index 5a41079..b361b36 100644 --- a/Confectionery/Confectionery/FormMain.cs +++ b/Confectionery/Confectionery/FormMain.cs @@ -1,4 +1,5 @@ -using ConfectioneryContracts.BindingModels; +using ConfectioneryBusinessLogic.BusinessLogics; +using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; using System; @@ -17,12 +18,14 @@ namespace Confectionery { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) @@ -152,5 +155,33 @@ namespace Confectionery { LoadData(); } + + private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SavePastrysToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void IngredientPastriesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryIngredients)); + if (service is FormReportPastryIngredients form) + { + form.ShowDialog(); + } + } + + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/Confectionery/Confectionery/FormReportOrders.Designer.cs b/Confectionery/Confectionery/FormReportOrders.Designer.cs new file mode 100644 index 0000000..e8bbdef --- /dev/null +++ b/Confectionery/Confectionery/FormReportOrders.Designer.cs @@ -0,0 +1,136 @@ +namespace Confectionery +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.buttonToPdf = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.labelTo = new System.Windows.Forms.Label(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.labelTo); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(1181, 48); + this.panel.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(18, 20); + this.label1.TabIndex = 0; + this.label1.Text = "С"; + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(36, 9); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(187, 27); + this.dateTimePickerFrom.TabIndex = 1; + // + // buttonToPdf + // + this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToPdf.Location = new System.Drawing.Point(1008, 7); + this.buttonToPdf.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(159, 36); + this.buttonToPdf.TabIndex = 9; + this.buttonToPdf.Text = "В Pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.buttonToPdf_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(512, 6); + this.buttonMake.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(159, 36); + this.buttonMake.TabIndex = 8; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.buttonMake_Click); + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(265, 10); + this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(186, 27); + this.dateTimePickerTo.TabIndex = 7; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(232, 14); + this.labelTo.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(27, 20); + this.labelTo.TabIndex = 6; + this.labelTo.Text = "по"; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1181, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "FormReportOrders"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private DateTimePicker dateTimePickerFrom; + private Label label1; + private Button buttonToPdf; + private Button buttonMake; + private DateTimePicker dateTimePickerTo; + private Label labelTo; + } +} \ No newline at end of file diff --git a/Confectionery/Confectionery/FormReportOrders.cs b/Confectionery/Confectionery/FormReportOrders.cs new file mode 100644 index 0000000..3683155 --- /dev/null +++ b/Confectionery/Confectionery/FormReportOrders.cs @@ -0,0 +1,100 @@ +using ConfectioneryContracts.BusinessLogicsContracts; +using Microsoft.Reporting.WinForms; +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; +using Microsoft.Extensions.Logging; +using ConfectioneryContracts.BindingModels; + +namespace Confectionery +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void buttonMake_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", + $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; + reportViewer.LocalReport.SetParameters(parameters); + + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/Confectionery/Confectionery/FormReportOrders.resx b/Confectionery/Confectionery/FormReportOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Confectionery/Confectionery/FormReportOrders.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Confectionery/Confectionery/FormReportPastryIngredients.Designer.cs b/Confectionery/Confectionery/FormReportPastryIngredients.Designer.cs new file mode 100644 index 0000000..3109d7b --- /dev/null +++ b/Confectionery/Confectionery/FormReportPastryIngredients.Designer.cs @@ -0,0 +1,113 @@ +namespace Confectionery +{ + partial class FormReportPastryIngredients + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonSaveToExcel = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ColumnPastry = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnIngredient = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 12); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(164, 29); + this.buttonSaveToExcel.TabIndex = 0; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnPastry, + this.ColumnIngredient, + this.ColumnCount}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 52); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.Size = new System.Drawing.Size(800, 398); + this.dataGridView.TabIndex = 1; + // + // ColumnPastry + // + this.ColumnPastry.HeaderText = "Кондитерское изделие"; + this.ColumnPastry.MinimumWidth = 6; + this.ColumnPastry.Name = "ColumnPastry"; + this.ColumnPastry.Width = 125; + // + // ColumnIngredient + // + this.ColumnIngredient.HeaderText = "Ингредиент"; + this.ColumnIngredient.MinimumWidth = 6; + this.ColumnIngredient.Name = "ColumnIngredient"; + this.ColumnIngredient.Width = 125; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.MinimumWidth = 6; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.Width = 125; + // + // FormReportPastryIngredients + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonSaveToExcel); + this.Name = "FormReportPastryIngredients"; + this.Text = "FormReportPastryIngredients"; + this.Load += new System.EventHandler(this.FormReportPastryIngredients_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnPastry; + private DataGridViewTextBoxColumn ColumnIngredient; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/Confectionery/Confectionery/FormReportPastryIngredients.cs b/Confectionery/Confectionery/FormReportPastryIngredients.cs new file mode 100644 index 0000000..dd55679 --- /dev/null +++ b/Confectionery/Confectionery/FormReportPastryIngredients.cs @@ -0,0 +1,78 @@ +using ConfectioneryContracts.BusinessLogicsContracts; +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; +using Microsoft.Extensions.Logging; +using ConfectioneryContracts.BindingModels; + +namespace Confectionery +{ + public partial class FormReportPastryIngredients : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportPastryIngredients(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportPastryIngredients_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetPastryIngredient(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" }); + foreach (var listElem in elem.Ingredients) + { + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _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.SavePastryIngredientToExcelFile(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); + } + } + } + } +} diff --git a/Confectionery/Confectionery/FormReportPastryIngredients.resx b/Confectionery/Confectionery/FormReportPastryIngredients.resx new file mode 100644 index 0000000..ef873df --- /dev/null +++ b/Confectionery/Confectionery/FormReportPastryIngredients.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Confectionery/Confectionery/Program.cs b/Confectionery/Confectionery/Program.cs index 590412a..19d5880 100644 --- a/Confectionery/Confectionery/Program.cs +++ b/Confectionery/Confectionery/Program.cs @@ -1,4 +1,6 @@ using ConfectioneryBusinessLogic.BusinessLogics; +using ConfectioneryBusinessLogic.OfficePackage.Implements; +using ConfectioneryBusinessLogic.OfficePackage; using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.StoragesContracts; using ConfectioneryDataBaseImplement.Implements; @@ -41,6 +43,10 @@ namespace Confectionery services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +54,8 @@ namespace Confectionery services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/Confectionery/Confectionery/ReportOrders.rdlc b/Confectionery/Confectionery/ReportOrders.rdlc new file mode 100644 index 0000000..6b3375b --- /dev/null +++ b/Confectionery/Confectionery/ReportOrders.rdlc @@ -0,0 +1,572 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + ConfectioneryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + PastryName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + ConfectioneryContracts.ViewModels + ReportOrdersViewModel + ConfectioneryContracts.ViewModels.ReportOrdersViewModel, ConfectioneryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + Заказы + + + + 0.6cm + 16.51cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + ReportParameterPeriod + 0.6cm + 0.6cm + 16.51cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.60583cm + + + 3.262cm + + + 4.8495cm + + + 2.5cm + + + 2.5cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Изделие + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PastryName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 1.9177cm + 0.79267cm + 1.2cm + 15.71733cm + 2 + + + + + + true + true + + + + + Итого: + + + + 3.46287cm + 11.51cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +