From c3d9757ad1c5da9713339af594d8051b02b3478b Mon Sep 17 00:00:00 2001 From: dex_moth Date: Wed, 10 Apr 2024 19:04:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=87=D0=B8=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=B4=D1=84=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FishFactory.csproj | 8 +- FishFactory/Forms/FormMain.Designer.cs | 120 ++++++++++-------- FishFactory/Forms/FormMain.cs | 5 +- FishFactory/Forms/FormMain.resx | 14 +- .../FormReportCannedComponents.Designer.cs | 45 ++++--- .../Forms/FormReportCannedComponents.cs | 14 +- .../Forms/FormReportOrders.Designer.cs | 61 ++++++--- FishFactory/Forms/FormReportOrders.cs | 17 ++- FishFactory/Program.cs | 7 +- .../BusinessLogic/ReportLogic.cs | 76 +++-------- .../OfficePackage/AbstractSaveToExcel.cs | 48 +++---- .../OfficePackage/Implements/SaveToWord.cs | 7 +- .../BusinessLogicsContracts/IReportLogic.cs | 4 +- .../ReportCannedComponentViewModel.cs | 4 +- .../ViewModels/ReportOrdersViewModel.cs | 2 +- .../FishFactoryDatabase.cs | 2 +- .../Implements/OrderStorage.cs | 12 +- .../Implements/OrderStorage.cs | 28 ++-- .../Implements/OrderStorage.cs | 4 +- 19 files changed, 244 insertions(+), 234 deletions(-) diff --git a/FishFactory/FishFactory.csproj b/FishFactory/FishFactory.csproj index d544413..41f596a 100644 --- a/FishFactory/FishFactory.csproj +++ b/FishFactory/FishFactory.csproj @@ -14,8 +14,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -41,4 +41,10 @@ + + + Always + + + \ No newline at end of file diff --git a/FishFactory/Forms/FormMain.Designer.cs b/FishFactory/Forms/FormMain.Designer.cs index 4b7e0e5..85453da 100644 --- a/FishFactory/Forms/FormMain.Designer.cs +++ b/FishFactory/Forms/FormMain.Designer.cs @@ -33,16 +33,16 @@ toolStripDropDownButton1 = new ToolStripDropDownButton(); компонентыToolStripMenuItem = new ToolStripMenuItem(); консервыToolStripMenuItem = new ToolStripMenuItem(); + toolStripDropDownButton2 = new ToolStripDropDownButton(); + списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоКонсервамToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); - toolStripDropDownButton2 = new ToolStripDropDownButton(); - списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); - компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); - списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -53,7 +53,7 @@ toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripDropDownButton2 }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new Size(969, 25); + toolStrip1.Size = new Size(1107, 27); toolStrip1.TabIndex = 0; toolStrip1.Text = "toolStrip1"; // @@ -64,28 +64,61 @@ toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(88, 22); + toolStripDropDownButton1.Size = new Size(108, 24); toolStripDropDownButton1.Text = "Справочник"; // // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(145, 22); + компонентыToolStripMenuItem.Size = new Size(182, 26); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; // // консервыToolStripMenuItem // консервыToolStripMenuItem.Name = "консервыToolStripMenuItem"; - консервыToolStripMenuItem.Size = new Size(145, 22); + консервыToolStripMenuItem.Size = new Size(182, 26); консервыToolStripMenuItem.Text = "Консервы"; консервыToolStripMenuItem.Click += консервыToolStripMenuItem_Click; // + // toolStripDropDownButton2 + // + toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text; + toolStripDropDownButton2.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоКонсервамToolStripMenuItem, списокЗаказовToolStripMenuItem }); + toolStripDropDownButton2.Image = (Image)resources.GetObject("toolStripDropDownButton2.Image"); + toolStripDropDownButton2.ImageTransparentColor = Color.Magenta; + toolStripDropDownButton2.Name = "toolStripDropDownButton2"; + toolStripDropDownButton2.Size = new Size(73, 24); + toolStripDropDownButton2.Text = "Отчёты"; + // + // списокКомпонентовToolStripMenuItem + // + списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + списокКомпонентовToolStripMenuItem.Size = new Size(284, 26); + списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click; + // + // компонентыПоКонсервамToolStripMenuItem + // + компонентыПоКонсервамToolStripMenuItem.Name = "компонентыПоКонсервамToolStripMenuItem"; + компонентыПоКонсервамToolStripMenuItem.Size = new Size(284, 26); + компонентыПоКонсервамToolStripMenuItem.Text = "Компоненты по консервам"; + компонентыПоКонсервамToolStripMenuItem.Click += компонентыПоИзделиямToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(284, 26); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(800, 56); + buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonCreateOrder.Location = new Point(914, 75); + buttonCreateOrder.Margin = new Padding(3, 4, 3, 4); buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(141, 24); + buttonCreateOrder.Size = new Size(161, 32); buttonCreateOrder.TabIndex = 1; buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.UseVisualStyleBackColor = true; @@ -93,9 +126,11 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(800, 100); + buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonTakeOrderInWork.Location = new Point(914, 133); + buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(141, 24); + buttonTakeOrderInWork.Size = new Size(161, 32); buttonTakeOrderInWork.TabIndex = 2; buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.UseVisualStyleBackColor = true; @@ -103,9 +138,11 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(800, 142); + buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonOrderReady.Location = new Point(914, 189); + buttonOrderReady.Margin = new Padding(3, 4, 3, 4); buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(141, 24); + buttonOrderReady.Size = new Size(161, 32); buttonOrderReady.TabIndex = 3; buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.UseVisualStyleBackColor = true; @@ -113,9 +150,11 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(800, 181); + buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonIssuedOrder.Location = new Point(914, 241); + buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4); buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(141, 24); + buttonIssuedOrder.Size = new Size(161, 32); buttonIssuedOrder.TabIndex = 4; buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.UseVisualStyleBackColor = true; @@ -123,9 +162,11 @@ // // buttonRef // - buttonRef.Location = new Point(800, 222); + buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonRef.Location = new Point(914, 296); + buttonRef.Margin = new Padding(3, 4, 3, 4); buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(141, 24); + buttonRef.Size = new Size(161, 32); buttonRef.TabIndex = 5; buttonRef.Text = "Обновить список"; buttonRef.UseVisualStyleBackColor = true; @@ -134,51 +175,21 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 26); + dataGridView.Location = new Point(0, 27); + dataGridView.Margin = new Padding(3, 4, 3, 4); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 24; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(763, 435); + dataGridView.Size = new Size(872, 588); dataGridView.TabIndex = 6; // - // toolStripDropDownButton2 - // - toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton2.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem }); - toolStripDropDownButton2.Image = (Image)resources.GetObject("toolStripDropDownButton2.Image"); - toolStripDropDownButton2.ImageTransparentColor = Color.Magenta; - toolStripDropDownButton2.Name = "toolStripDropDownButton2"; - toolStripDropDownButton2.Size = new Size(61, 22); - toolStripDropDownButton2.Text = "Отчёты"; - // - // списокКомпонентовToolStripMenuItem - // - списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - списокКомпонентовToolStripMenuItem.Size = new Size(225, 22); - списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; - списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click; - // - // компонентыПоИзделиямToolStripMenuItem - // - компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; - компонентыПоИзделиямToolStripMenuItem.Size = new Size(225, 22); - компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по консервам"; - компонентыПоИзделиямToolStripMenuItem.Click += компонентыПоИзделиямToolStripMenuItem_Click; - // - // списокЗаказовToolStripMenuItem - // - списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - списокЗаказовToolStripMenuItem.Size = new Size(225, 22); - списокЗаказовToolStripMenuItem.Text = "Список заказов"; - списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; - // // FormMain // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(969, 461); + ClientSize = new Size(1107, 615); Controls.Add(dataGridView); Controls.Add(buttonRef); Controls.Add(buttonIssuedOrder); @@ -186,6 +197,7 @@ Controls.Add(buttonTakeOrderInWork); Controls.Add(buttonCreateOrder); Controls.Add(toolStrip1); + Margin = new Padding(3, 4, 3, 4); Name = "FormMain"; Text = "Рыбный завод"; Load += FormMain_Load; @@ -210,7 +222,7 @@ private ToolStripMenuItem консервыToolStripMenuItem; private ToolStripDropDownButton toolStripDropDownButton2; private ToolStripMenuItem списокКомпонентовToolStripMenuItem; - private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem компонентыПоКонсервамToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/FishFactory/Forms/FormMain.cs b/FishFactory/Forms/FormMain.cs index 149ea78..9104c44 100644 --- a/FishFactory/Forms/FormMain.cs +++ b/FishFactory/Forms/FormMain.cs @@ -10,11 +10,12 @@ namespace FishFactory.Forms 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) { @@ -150,7 +151,7 @@ namespace FishFactory.Forms using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { - _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + _reportLogic.SaveCannedsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); diff --git a/FishFactory/Forms/FormMain.resx b/FishFactory/Forms/FormMain.resx index a50214e..cb299dc 100644 --- a/FishFactory/Forms/FormMain.resx +++ b/FishFactory/Forms/FormMain.resx @@ -124,7 +124,7 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc @@ -139,12 +139,12 @@ iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEISURBVEhL3ZErDsJAGIR7DlA47oArV8CDR9RiSDAQPBcA - Qx1BgUMQBEk1ooJAKE0I4Wlqf5gmu1n6oqW7hiZfthkx33aqeZ5HKvEFpmmSYRhSQScXINB1XSroDAke - 96cUpAmupyPZsx7Z8x4drAnPpQmsgU7LdoHDJNIEYjnAlyBXJ3jPhVyaYLca8nLMhX+CPJXAOT+ouTj5 - p5in4asApdWpS8XRwT+zShIFG/fOyxlZJbGC9f5G5bHzUf6LJFJQqTViyxlxEmRiHhLUW10qDbeRpUGC - ErwjE/OQoG9dIsviYGWsXMwxc24BYLcO5pgZc+cWJIG5MbsyAUDnHwlUAkFHJZraR9NeMVq3zi+WF/0A - AAAASUVORK5CYII= + YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEKSURBVEhL3ZG9DsFQHMXvczDZvIOtXsHObuhqkViI3Quw + 6CYmNoMYJJ0NBiFFIoIytOuf0+TeXP3yde+iyS+3OcP53Z4y3/dJJ4HAsiwyTVMp6BQCBIZhKAWdEcHV + vSlBmeB82NFy1KLluEWOPRC5MoHdMWhazwi4RJlALgf4EuT6BI+5kCsTrGddUY658E+QvyXYHq9UnRyC + U87f4aUApcXhnrI9Jzg/laQKFntXlHM+lSQK5psL5fvbp/JvJLGCQqmSWM5JkiCT84igXGtSrruKLQ0T + luAdmZxHBG37FFuWBC/j5XKOmX8WAH7rcI6ZMffPgjQwN2bXJgDo/COBTpjneQ2dML0PY3cISreGe8HM + qgAAAABJRU5ErkJggg== diff --git a/FishFactory/Forms/FormReportCannedComponents.Designer.cs b/FishFactory/Forms/FormReportCannedComponents.Designer.cs index 497ff67..dd6bce1 100644 --- a/FishFactory/Forms/FormReportCannedComponents.Designer.cs +++ b/FishFactory/Forms/FormReportCannedComponents.Designer.cs @@ -30,17 +30,18 @@ { buttonSaveToExcel = new Button(); dataGridView = new DataGridView(); - Component = new DataGridViewTextBoxColumn(); - Canned = new DataGridViewTextBoxColumn(); Count = new DataGridViewTextBoxColumn(); + Canned = new DataGridViewTextBoxColumn(); + Component = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // // buttonSaveToExcel // - buttonSaveToExcel.Location = new Point(27, 15); + buttonSaveToExcel.Location = new Point(31, 19); + buttonSaveToExcel.Margin = new Padding(3, 4, 3, 4); buttonSaveToExcel.Name = "buttonSaveToExcel"; - buttonSaveToExcel.Size = new Size(160, 23); + buttonSaveToExcel.Size = new Size(183, 29); buttonSaveToExcel.TabIndex = 0; buttonSaveToExcel.Text = "Сохранить в Excel"; buttonSaveToExcel.UseVisualStyleBackColor = true; @@ -51,39 +52,45 @@ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Columns.AddRange(new DataGridViewColumn[] { Component, Canned, Count }); - dataGridView.Location = new Point(0, 47); + dataGridView.Location = new Point(0, 60); + dataGridView.Margin = new Padding(3, 4, 3, 4); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(799, 438); + dataGridView.Size = new Size(913, 555); dataGridView.TabIndex = 1; // - // Component - // - Component.HeaderText = "Компонент"; - Component.Name = "Component"; - Component.ReadOnly = true; - // - // Canned - // - Canned.HeaderText = "Консервы"; - Canned.Name = "Canned"; - // // Count // Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; Count.Name = "Count"; Count.ReadOnly = true; // + // Canned + // + Canned.HeaderText = "Консервы"; + Canned.MinimumWidth = 6; + Canned.Name = "Canned"; + // + // Component + // + Component.HeaderText = "Компонент"; + Component.MinimumWidth = 6; + Component.Name = "Component"; + Component.ReadOnly = true; + // // FormReportCannedComponents // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 19F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(801, 484); + ClientSize = new Size(915, 613); Controls.Add(dataGridView); Controls.Add(buttonSaveToExcel); + Margin = new Padding(3, 4, 3, 4); Name = "FormReportCannedComponents"; Text = "Компоненты по консервам"; + Load += FormReportCannedComponents_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } diff --git a/FishFactory/Forms/FormReportCannedComponents.cs b/FishFactory/Forms/FormReportCannedComponents.cs index 83129d3..27c01be 100644 --- a/FishFactory/Forms/FormReportCannedComponents.cs +++ b/FishFactory/Forms/FormReportCannedComponents.cs @@ -18,14 +18,14 @@ namespace FishFactory.Forms { try { - var dict = _logic.GetCannedComponent(); + var dict = _logic.GetCannedComponents(); if (dict != null) { dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); - foreach (var listElem in elem.Canneds) + dataGridView.Rows.Add(new object[] { elem.CannedName, "", "" }); + foreach (var listElem in elem.Components) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } @@ -33,11 +33,11 @@ namespace FishFactory.Forms dataGridView.Rows.Add(Array.Empty()); } } - _logger.LogInformation("Загрузка списка изделий по компонентам"); + _logger.LogInformation("Загрузка списка консерв по компонентам"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам"); + _logger.LogError(ex, "Ошибка загрузки списка консерв по компонентам"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -57,13 +57,13 @@ namespace FishFactory.Forms { FileName = dialog.FileName }); - _logger.LogInformation("Сохранение списка изделий по компонентам"); + _logger.LogInformation("Сохранение списка консерв по компонентам"); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам"); + _logger.LogError(ex, "Ошибка сохранения списка консерв по компонентам"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } diff --git a/FishFactory/Forms/FormReportOrders.Designer.cs b/FishFactory/Forms/FormReportOrders.Designer.cs index 19810bd..b3cb1b7 100644 --- a/FishFactory/Forms/FormReportOrders.Designer.cs +++ b/FishFactory/Forms/FormReportOrders.Designer.cs @@ -34,27 +34,32 @@ label1 = new Label(); label2 = new Label(); panel = new Panel(); + buttonSaveToPdf = new Button(); + panel.SuspendLayout(); SuspendLayout(); // // dateTimePickerFrom // - dateTimePickerFrom.Location = new Point(33, 7); + dateTimePickerFrom.Location = new Point(38, 12); + dateTimePickerFrom.Margin = new Padding(3, 4, 3, 4); dateTimePickerFrom.Name = "dateTimePickerFrom"; - dateTimePickerFrom.Size = new Size(149, 23); + dateTimePickerFrom.Size = new Size(170, 27); dateTimePickerFrom.TabIndex = 0; // // dateTimePickerTo // - dateTimePickerTo.Location = new Point(215, 7); + dateTimePickerTo.Location = new Point(246, 12); + dateTimePickerTo.Margin = new Padding(3, 4, 3, 4); dateTimePickerTo.Name = "dateTimePickerTo"; - dateTimePickerTo.Size = new Size(149, 23); + dateTimePickerTo.Size = new Size(170, 27); dateTimePickerTo.TabIndex = 1; // // buttonMake // - buttonMake.Location = new Point(570, 7); + buttonMake.Location = new Point(597, 13); + buttonMake.Margin = new Padding(3, 4, 3, 4); buttonMake.Name = "buttonMake"; - buttonMake.Size = new Size(120, 23); + buttonMake.Size = new Size(137, 31); buttonMake.TabIndex = 2; buttonMake.Text = "Сформировать"; buttonMake.UseVisualStyleBackColor = true; @@ -63,43 +68,58 @@ // label1 // label1.AutoSize = true; - label1.Location = new Point(14, 12); + label1.Location = new Point(15, 16); label1.Name = "label1"; - label1.Size = new Size(15, 15); + label1.Size = new Size(18, 20); label1.TabIndex = 3; label1.Text = "С"; // // label2 // label2.AutoSize = true; - label2.Location = new Point(192, 11); + label2.Location = new Point(218, 15); label2.Name = "label2"; - label2.Size = new Size(21, 15); + label2.Size = new Size(27, 20); label2.TabIndex = 4; label2.Text = "по"; // // panel // - panel.Location = new Point(0, 36); + panel.Controls.Add(buttonSaveToPdf); + panel.Controls.Add(dateTimePickerFrom); + panel.Controls.Add(label2); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(label1); + panel.Controls.Add(buttonMake); + panel.Dock = DockStyle.Top; + panel.Location = new Point(0, 0); + panel.Margin = new Padding(3, 3, 3, 4); panel.Name = "panel"; - panel.Size = new Size(802, 418); + panel.Size = new Size(941, 51); panel.TabIndex = 5; // + // buttonSaveToPdf + // + buttonSaveToPdf.Location = new Point(749, 13); + buttonSaveToPdf.Name = "buttonSaveToPdf"; + buttonSaveToPdf.Size = new Size(140, 31); + buttonSaveToPdf.TabIndex = 6; + buttonSaveToPdf.Text = "Сохранить в pdf"; + buttonSaveToPdf.UseVisualStyleBackColor = true; + buttonSaveToPdf.Click += buttonSaveToPdf_Click; + // // FormReportOrders // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(941, 723); Controls.Add(panel); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(buttonMake); - Controls.Add(dateTimePickerTo); - Controls.Add(dateTimePickerFrom); + Margin = new Padding(3, 4, 3, 4); Name = "FormReportOrders"; Text = "Заказы"; + panel.ResumeLayout(false); + panel.PerformLayout(); ResumeLayout(false); - PerformLayout(); } #endregion @@ -110,5 +130,6 @@ private Label label1; private Label label2; private Panel panel; + private Button buttonSaveToPdf; } } \ No newline at end of file diff --git a/FishFactory/Forms/FormReportOrders.cs b/FishFactory/Forms/FormReportOrders.cs index aa45614..3d50e99 100644 --- a/FishFactory/Forms/FormReportOrders.cs +++ b/FishFactory/Forms/FormReportOrders.cs @@ -10,8 +10,8 @@ namespace FishFactory.Forms private readonly ReportViewer reportViewer; private readonly ILogger _logger; private readonly IReportLogic _logic; - public FormReportOrders(ILogger logger, IReportLogic - logic) + + public FormReportOrders(ILogger logger, IReportLogic logic) { InitializeComponent(); _logger = logger; @@ -20,8 +20,7 @@ namespace FishFactory.Forms { Dock = DockStyle.Fill }; - reportViewer.LocalReport.LoadReportDefinition(new - FileStream("ReportOrders.rdlc", FileMode.Open)); + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); Controls.Clear(); Controls.Add(reportViewer); Controls.Add(panel); @@ -43,10 +42,10 @@ namespace FishFactory.Forms 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()}") }; + 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()); } @@ -56,7 +55,7 @@ namespace FishFactory.Forms MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void ButtonToPdf_Click(object sender, EventArgs e) + private void buttonSaveToPdf_Click(object sender, EventArgs e) { if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { @@ -83,7 +82,7 @@ namespace FishFactory.Forms catch (Exception ex) { _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); - + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/FishFactory/Program.cs b/FishFactory/Program.cs index 9d315dc..0a2e32a 100644 --- a/FishFactory/Program.cs +++ b/FishFactory/Program.cs @@ -2,10 +2,12 @@ using FishFactory.Forms; using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryBusinessLogic.BusinessLogic; using FishFactoryContracts.StoragesContracts; -using FishFactoryDatabaseImplement.Implements; +using FishFactoryFileImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using FishFactoryBusinessLogic.OfficePackage; +using FishFactoryBusinessLogic.OfficePackage.Implements; namespace FishFactory { @@ -42,6 +44,9 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs index 4851227..c3e7e0d 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs @@ -11,59 +11,31 @@ namespace FishFactoryBusinessLogic.BusinessLogic public class ReportLogic : IReportLogic { private readonly IComponentStorage _componentStorage; - private readonly ICannedStorage _CannedStorage; + private readonly ICannedStorage _cannedStorage; private readonly IOrderStorage _orderStorage; private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToPdf _saveToPdf; - public ReportLogic(ICannedStorage CannedStorage, IComponentStorage - componentStorage, IOrderStorage orderStorage, - AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, - AbstractSaveToPdf saveToPdf) + public ReportLogic(ICannedStorage CannedStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, + AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { - _CannedStorage = CannedStorage; + _cannedStorage = CannedStorage; _componentStorage = componentStorage; _orderStorage = orderStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; } - /// - /// Получение списка компонент с указанием, в каких изделиях используются - /// - /// - public List GetCannedComponent() + public List GetCannedComponents() { - var components = _componentStorage.GetFullList(); - var Canneds = _CannedStorage.GetFullList(); - var list = new List(); - foreach (var component in components) + return _cannedStorage.GetFullList().Select( x => new ReportCannedComponentViewModel { - var record = new ReportCannedComponentViewModel - { - ComponentName = component.ComponentName, - Canneds = new List>(), - TotalCount = 0 - }; - foreach (var Canned in Canneds) - { - if (Canned.CannedComponents.ContainsKey(component.Id)) - { - record.Canneds.Add(new Tuple(Canned.CannedName, Canned.CannedComponents[component.Id].Item2)); - record.TotalCount += - Canned.CannedComponents[component.Id].Item2; - } - } - list.Add(record); - } - return list; + CannedName = x.CannedName, + Components = x.CannedComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(), + TotalCount = x.CannedComponents.Select(x => x.Value.Item2).Sum() + }).ToList(); } - /// - /// Получение списка заказов за определенный период - /// - /// - /// + public List GetOrders(ReportBindingModel model) { return _orderStorage.GetFilteredList(new OrderSearchModel @@ -76,40 +48,32 @@ namespace FishFactoryBusinessLogic.BusinessLogic Id = x.Id, DateCreate = x.DateCreate, CannedName = x.CannedName, - Sum = x.Sum + Sum = x.Sum, + Status = x.Status.ToString() }) .ToList(); } - /// - /// Сохранение компонент в файл-Word - /// - /// - public void SaveComponentsToWordFile(ReportBindingModel model) + + public void SaveCannedsToWordFile(ReportBindingModel model) { _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список компонент", + Title = "Список консерв", Components = _componentStorage.GetFullList() }); } - /// - /// Сохранение компонент с указаеним продуктов в файл-Excel - /// - /// + public void SaveCannedComponentToExcelFile(ReportBindingModel model) { _saveToExcel.CreateReport(new ExcelInfo { FileName = model.FileName, - Title = "Список компонент", - CannedComponents = GetCannedComponent() + Title = "Список консерв", + CannedComponents = GetCannedComponents() }); } - /// - /// Сохранение заказов в файл-Pdf - /// - /// + public void SaveOrdersToPdfFile(ReportBindingModel model) { _saveToPdf.CreateDoc(new PdfInfo diff --git a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 38948f5..1157def 100644 --- a/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -5,13 +5,10 @@ namespace FishFactoryBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcel { - /// - /// Создание отчета - /// - /// public void CreateReport(ExcelInfo info) { CreateExcel(info); + InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "A", @@ -31,28 +28,27 @@ namespace FishFactoryBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.CannedName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var Canned in pc.Canneds) + foreach (var Component in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = Canned.Item1, - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = Component.Item1, + StyleInfo = ExcelStyleInfoType.TextWithBroder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = Canned.Item2.ToString(), - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = Component.Item2.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder }); + rowIndex++; } InsertCellInWorksheet(new ExcelCellParameters @@ -73,27 +69,13 @@ namespace FishFactoryBusinessLogic.OfficePackage } SaveExcel(info); } - /// - /// Создание excel-файла - /// - /// - protected abstract void CreateExcel(ExcelInfo info); - /// - /// Добавляем новую ячейку в лист - /// - /// - protected abstract void InsertCellInWorksheet(ExcelCellParameters - excelParams); - /// - /// Объединение ячеек - /// - /// - protected abstract void MergeCells(ExcelMergeParameters excelParams); - /// - /// Сохранение файла - /// - /// - protected abstract void SaveExcel(ExcelInfo info); + protected abstract void CreateExcel(ExcelInfo info); + + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + + protected abstract void MergeCells(ExcelMergeParameters excelParams); + + protected abstract void SaveExcel(ExcelInfo info); } } diff --git a/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs index a591a04..8b5e8fd 100644 --- a/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -16,8 +16,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements /// /// /// - private static JustificationValues - GetJustificationValues(WordJustificationType type) + private static JustificationValues GetJustificationValues(WordJustificationType type) { return type switch { @@ -45,8 +44,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements /// /// /// - private static ParagraphProperties? - CreateParagraphProperties(WordTextProperties? paragraphProperties) + private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties) { if (paragraphProperties == null) { @@ -62,6 +60,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements LineRule = LineSpacingRuleValues.Auto }); properties.AppendChild(new Indentation()); + var paragraphMarkRunProperties = new ParagraphMarkRunProperties(); if (!string.IsNullOrEmpty(paragraphProperties.Size)) { diff --git a/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs b/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs index b7948ac..0dc2806 100644 --- a/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs @@ -9,7 +9,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts /// Получение списка компонент с указанием, в каких изделиях используются /// /// - List GetCannedComponent(); + List GetCannedComponents(); /// /// Получение списка заказов за определенный период /// @@ -20,7 +20,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts /// Сохранение компонент в файл-Word /// /// - void SaveComponentsToWordFile(ReportBindingModel model); + void SaveCannedsToWordFile(ReportBindingModel model); /// /// Сохранение компонент с указаеним продуктов в файл-Excel /// diff --git a/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs b/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs index f0e6170..bc83e3e 100644 --- a/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs +++ b/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs @@ -2,8 +2,8 @@ { public class ReportCannedComponentViewModel { - public string ComponentName { get; set; } = string.Empty; + public string CannedName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List> Canneds { get; set; } = new(); + public List<(string Component, int Count)> Components { get; set; } = new(); } } diff --git a/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs b/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs index b0fbdb2..63cd422 100644 --- a/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs +++ b/FishFactoryContracts/ViewModels/ReportOrdersViewModel.cs @@ -7,6 +7,6 @@ namespace FishFactoryContracts.ViewModels public DateTime DateCreate { get; set; } public string CannedName { get; set; } = string.Empty; public double Sum { get; set; } - + public string Status { get; set; } = string.Empty; } } diff --git a/FishFactoryDatabaseImplement/FishFactoryDatabase.cs b/FishFactoryDatabaseImplement/FishFactoryDatabase.cs index 16b5a6e..d93d11d 100644 --- a/FishFactoryDatabaseImplement/FishFactoryDatabase.cs +++ b/FishFactoryDatabaseImplement/FishFactoryDatabase.cs @@ -9,7 +9,7 @@ namespace FishFactoryDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql(@"Host=localhost;Database=FishFactory2;Username=postgres;Password=postgres"); + optionsBuilder.UseNpgsql(@"Host=localhost;Database=FishFactory;Username=postgres;Password=postgres"); } base.OnConfiguring(optionsBuilder); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); diff --git a/FishFactoryDatabaseImplement/Implements/OrderStorage.cs b/FishFactoryDatabaseImplement/Implements/OrderStorage.cs index 3c38dca..d2e9090 100644 --- a/FishFactoryDatabaseImplement/Implements/OrderStorage.cs +++ b/FishFactoryDatabaseImplement/Implements/OrderStorage.cs @@ -19,11 +19,21 @@ namespace FishFactoryDatabaseImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue) { return new(); } using var context = new FishFactoryDatabase(); + + if (model.DateFrom.HasValue) + { + return context.Orders + .Include(x => x.Canned) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.Orders .Include(x => x.Canned) .Where(x => x.Id == model.Id) diff --git a/FishFactoryFileImplement/Implements/OrderStorage.cs b/FishFactoryFileImplement/Implements/OrderStorage.cs index e4281d1..af38185 100644 --- a/FishFactoryFileImplement/Implements/OrderStorage.cs +++ b/FishFactoryFileImplement/Implements/OrderStorage.cs @@ -3,6 +3,7 @@ using FishFactoryContracts.SearchModels; using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.ViewModels; using FishFactoryFileImplement.Models; +using System.Reflection; using System.Xml.Linq; namespace FishFactoryFileImplement.Implements @@ -18,15 +19,15 @@ namespace FishFactoryFileImplement.Implements public List GetFullList() { - return _source.Orders.Select(x => AttachCannedName(x)).ToList(); + return _source.Orders.Select(x => AttachCannedName(x.GetViewModel)).ToList(); } public List GetFilteredList(OrderSearchModel model) { - if (model == null || !model.Id.HasValue) + if (!model.Id.HasValue || !model.DateFrom.HasValue || !model.DateTo.HasValue) { return new(); } - return _source.Orders.Where(x => x.Id == model.Id).Select(x => AttachCannedName(x)).ToList(); + return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => AttachCannedName(x.GetViewModel)).ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { @@ -34,7 +35,7 @@ namespace FishFactoryFileImplement.Implements { return null; } - return AttachCannedName(_source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)); + return AttachCannedName(_source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel); } public OrderViewModel? Insert(OrderBindingModel model) { @@ -46,7 +47,7 @@ namespace FishFactoryFileImplement.Implements } _source.Orders.Add(newOrder); _source.SaveOrders(); - return AttachCannedName(newOrder); + return AttachCannedName(newOrder.GetViewModel); } public OrderViewModel? Update(OrderBindingModel model) { @@ -57,7 +58,7 @@ namespace FishFactoryFileImplement.Implements } order.Update(model); _source.SaveOrders(); - return AttachCannedName(order); + return AttachCannedName(order.GetViewModel); } public OrderViewModel? Delete(OrderBindingModel model) { @@ -68,17 +69,20 @@ namespace FishFactoryFileImplement.Implements } _source.Orders.Remove(order); _source.SaveOrders(); - return AttachCannedName(order); + return AttachCannedName(order.GetViewModel); } - private OrderViewModel AttachCannedName(Order order) + private OrderViewModel? AttachCannedName(OrderViewModel? model) { - var viewModel = order.GetViewModel; - var canned = _source.Canneds.FirstOrDefault(x => x.Id == order.CannedId); + if (model == null) + { + return null; + } + var canned = _source.Canneds.FirstOrDefault(x => x.Id == model.CannedId); if (canned != null) { - viewModel.CannedName = canned.CannedName; + model.CannedName = canned.CannedName; } - return viewModel; + return model; } } } diff --git a/FishFactoryListImplement/Implements/OrderStorage.cs b/FishFactoryListImplement/Implements/OrderStorage.cs index 75896f3..3562783 100644 --- a/FishFactoryListImplement/Implements/OrderStorage.cs +++ b/FishFactoryListImplement/Implements/OrderStorage.cs @@ -33,13 +33,13 @@ namespace FishFactoryListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); - if (model == null || !model.Id.HasValue) + if (model == null || !model.Id.HasValue || !model.DateFrom.HasValue || !model.DateFrom.HasValue) { return result; } foreach (var order in _source.Orders) { - if (order.Id == model.Id) + if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) { result.Add(AttachCannedName(order.GetViewModel)); }