diff --git a/FishFactory/FishFactory.csproj b/FishFactory/FishFactory.csproj index 07508e2..d544413 100644 --- a/FishFactory/FishFactory.csproj +++ b/FishFactory/FishFactory.csproj @@ -14,6 +14,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -25,4 +26,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/FishFactory/FormCanned.Designer.cs b/FishFactory/Forms/FormCanned.Designer.cs similarity index 100% rename from FishFactory/FormCanned.Designer.cs rename to FishFactory/Forms/FormCanned.Designer.cs diff --git a/FishFactory/FormCanned.cs b/FishFactory/Forms/FormCanned.cs similarity index 86% rename from FishFactory/FormCanned.cs rename to FishFactory/Forms/FormCanned.cs index 8b515ea..c6dd870 100644 --- a/FishFactory/FormCanned.cs +++ b/FishFactory/Forms/FormCanned.cs @@ -11,14 +11,14 @@ namespace FishFactory.Forms private readonly ILogger _logger; private readonly ICannedLogic _logic; private int? _id; - private Dictionary _productComponents; + private Dictionary _CannedComponents; public int Id { set { _id = value; } } public FormCanned(ILogger logger, ICannedLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _productComponents = new Dictionary(); + _CannedComponents = new Dictionary(); } private void FormCanned_Load(object sender, EventArgs e) { @@ -35,7 +35,7 @@ namespace FishFactory.Forms { textBoxName.Text = view.CannedName; textBoxPrice.Text = view.Price.ToString(); - _productComponents = view.CannedComponents ?? new Dictionary(); + _CannedComponents = view.CannedComponents ?? new Dictionary(); LoadData(); } } @@ -50,10 +50,10 @@ namespace FishFactory.Forms _logger.LogInformation("Загрузка компонент изделия"); try { - if (_productComponents != null) + if (_CannedComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _productComponents) + foreach (var pc in _CannedComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -77,13 +77,13 @@ namespace FishFactory.Forms return; } _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); - if (_productComponents.ContainsKey(form.Id)) + if (_CannedComponents.ContainsKey(form.Id)) { - _productComponents[form.Id] = (form.ComponentModel, form.Count); + _CannedComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _productComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _CannedComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); } @@ -98,7 +98,7 @@ namespace FishFactory.Forms { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _productComponents[id].Item2; + form.Count = _CannedComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -106,7 +106,7 @@ namespace FishFactory.Forms return; } _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - _productComponents[form.Id] = (form.ComponentModel, form.Count); + _CannedComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -121,7 +121,7 @@ namespace FishFactory.Forms try { _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _CannedComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -147,7 +147,7 @@ namespace FishFactory.Forms MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_productComponents == null || _productComponents.Count == 0) + if (_CannedComponents == null || _CannedComponents.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -160,7 +160,7 @@ namespace FishFactory.Forms Id = _id ?? 0, CannedName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - CannedComponents = _productComponents + CannedComponents = _CannedComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -186,7 +186,7 @@ namespace FishFactory.Forms private double CalcPrice() { double price = 0; - foreach (var elem in _productComponents) + foreach (var elem in _CannedComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/FishFactory/FormCanned.resx b/FishFactory/Forms/FormCanned.resx similarity index 100% rename from FishFactory/FormCanned.resx rename to FishFactory/Forms/FormCanned.resx diff --git a/FishFactory/FormCannedComponent.Designer.cs b/FishFactory/Forms/FormCannedComponent.Designer.cs similarity index 100% rename from FishFactory/FormCannedComponent.Designer.cs rename to FishFactory/Forms/FormCannedComponent.Designer.cs diff --git a/FishFactory/FormCannedComponent.cs b/FishFactory/Forms/FormCannedComponent.cs similarity index 100% rename from FishFactory/FormCannedComponent.cs rename to FishFactory/Forms/FormCannedComponent.cs diff --git a/FishFactory/FormCannedComponent.resx b/FishFactory/Forms/FormCannedComponent.resx similarity index 100% rename from FishFactory/FormCannedComponent.resx rename to FishFactory/Forms/FormCannedComponent.resx diff --git a/FishFactory/FormCanneds.Designer.cs b/FishFactory/Forms/FormCanneds.Designer.cs similarity index 100% rename from FishFactory/FormCanneds.Designer.cs rename to FishFactory/Forms/FormCanneds.Designer.cs diff --git a/FishFactory/FormCanneds.cs b/FishFactory/Forms/FormCanneds.cs similarity index 100% rename from FishFactory/FormCanneds.cs rename to FishFactory/Forms/FormCanneds.cs diff --git a/FishFactory/FormCanneds.resx b/FishFactory/Forms/FormCanneds.resx similarity index 100% rename from FishFactory/FormCanneds.resx rename to FishFactory/Forms/FormCanneds.resx diff --git a/FishFactory/FormComponent.Designer.cs b/FishFactory/Forms/FormComponent.Designer.cs similarity index 100% rename from FishFactory/FormComponent.Designer.cs rename to FishFactory/Forms/FormComponent.Designer.cs diff --git a/FishFactory/FormComponent.cs b/FishFactory/Forms/FormComponent.cs similarity index 100% rename from FishFactory/FormComponent.cs rename to FishFactory/Forms/FormComponent.cs diff --git a/FishFactory/FormComponent.resx b/FishFactory/Forms/FormComponent.resx similarity index 100% rename from FishFactory/FormComponent.resx rename to FishFactory/Forms/FormComponent.resx diff --git a/FishFactory/FormComponents.Designer.cs b/FishFactory/Forms/FormComponents.Designer.cs similarity index 100% rename from FishFactory/FormComponents.Designer.cs rename to FishFactory/Forms/FormComponents.Designer.cs diff --git a/FishFactory/FormComponents.cs b/FishFactory/Forms/FormComponents.cs similarity index 100% rename from FishFactory/FormComponents.cs rename to FishFactory/Forms/FormComponents.cs diff --git a/FishFactory/FormComponents.resx b/FishFactory/Forms/FormComponents.resx similarity index 100% rename from FishFactory/FormComponents.resx rename to FishFactory/Forms/FormComponents.resx diff --git a/FishFactory/FormCreateOrder.Designer.cs b/FishFactory/Forms/FormCreateOrder.Designer.cs similarity index 100% rename from FishFactory/FormCreateOrder.Designer.cs rename to FishFactory/Forms/FormCreateOrder.Designer.cs diff --git a/FishFactory/FormCreateOrder.cs b/FishFactory/Forms/FormCreateOrder.cs similarity index 100% rename from FishFactory/FormCreateOrder.cs rename to FishFactory/Forms/FormCreateOrder.cs diff --git a/FishFactory/FormCreateOrder.resx b/FishFactory/Forms/FormCreateOrder.resx similarity index 100% rename from FishFactory/FormCreateOrder.resx rename to FishFactory/Forms/FormCreateOrder.resx diff --git a/FishFactory/FormMain.Designer.cs b/FishFactory/Forms/FormMain.Designer.cs similarity index 63% rename from FishFactory/FormMain.Designer.cs rename to FishFactory/Forms/FormMain.Designer.cs index 73fef74..4b7e0e5 100644 --- a/FishFactory/FormMain.Designer.cs +++ b/FishFactory/Forms/FormMain.Designer.cs @@ -39,6 +39,10 @@ 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(); @@ -46,10 +50,10 @@ // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1 }); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripDropDownButton2 }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new Size(1107, 27); + toolStrip1.Size = new Size(969, 25); toolStrip1.TabIndex = 0; toolStrip1.Text = "toolStrip1"; // @@ -60,29 +64,28 @@ toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(108, 24); + toolStripDropDownButton1.Size = new Size(88, 22); toolStripDropDownButton1.Text = "Справочник"; // // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(182, 26); + компонентыToolStripMenuItem.Size = new Size(145, 22); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; // // консервыToolStripMenuItem // консервыToolStripMenuItem.Name = "консервыToolStripMenuItem"; - консервыToolStripMenuItem.Size = new Size(182, 26); + консервыToolStripMenuItem.Size = new Size(145, 22); консервыToolStripMenuItem.Text = "Консервы"; консервыToolStripMenuItem.Click += консервыToolStripMenuItem_Click; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(914, 75); - buttonCreateOrder.Margin = new Padding(3, 4, 3, 4); + buttonCreateOrder.Location = new Point(800, 56); buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(161, 32); + buttonCreateOrder.Size = new Size(141, 24); buttonCreateOrder.TabIndex = 1; buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.UseVisualStyleBackColor = true; @@ -90,10 +93,9 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(914, 133); - buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4); + buttonTakeOrderInWork.Location = new Point(800, 100); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(161, 32); + buttonTakeOrderInWork.Size = new Size(141, 24); buttonTakeOrderInWork.TabIndex = 2; buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.UseVisualStyleBackColor = true; @@ -101,10 +103,9 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(914, 190); - buttonOrderReady.Margin = new Padding(3, 4, 3, 4); + buttonOrderReady.Location = new Point(800, 142); buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(161, 32); + buttonOrderReady.Size = new Size(141, 24); buttonOrderReady.TabIndex = 3; buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.UseVisualStyleBackColor = true; @@ -112,10 +113,9 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(914, 241); - buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4); + buttonIssuedOrder.Location = new Point(800, 181); buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(161, 32); + buttonIssuedOrder.Size = new Size(141, 24); buttonIssuedOrder.TabIndex = 4; buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.UseVisualStyleBackColor = true; @@ -123,10 +123,9 @@ // // buttonRef // - buttonRef.Location = new Point(914, 296); - buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Location = new Point(800, 222); buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(161, 32); + buttonRef.Size = new Size(141, 24); buttonRef.TabIndex = 5; buttonRef.Text = "Обновить список"; buttonRef.UseVisualStyleBackColor = true; @@ -135,21 +134,51 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 35); - dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Location = new Point(0, 26); dataGridView.Name = "dataGridView"; dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 24; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(872, 580); + dataGridView.Size = new Size(763, 435); 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(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1107, 615); + ClientSize = new Size(969, 461); Controls.Add(dataGridView); Controls.Add(buttonRef); Controls.Add(buttonIssuedOrder); @@ -157,7 +186,6 @@ Controls.Add(buttonTakeOrderInWork); Controls.Add(buttonCreateOrder); Controls.Add(toolStrip1); - Margin = new Padding(3, 4, 3, 4); Name = "FormMain"; Text = "Рыбный завод"; Load += FormMain_Load; @@ -180,5 +208,9 @@ private ToolStripDropDownButton toolStripDropDownButton1; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem консервыToolStripMenuItem; + private ToolStripDropDownButton toolStripDropDownButton2; + private ToolStripMenuItem списокКомпонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/FishFactory/FormMain.cs b/FishFactory/Forms/FormMain.cs similarity index 80% rename from FishFactory/FormMain.cs rename to FishFactory/Forms/FormMain.cs index b8c0b8f..149ea78 100644 --- a/FishFactory/FormMain.cs +++ b/FishFactory/Forms/FormMain.cs @@ -1,15 +1,7 @@ -using FishFactoryContracts.BindingModels; +using FishFactoryBusinessLogic.BusinessLogic; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.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 FishFactory.Forms { @@ -17,6 +9,7 @@ namespace FishFactory.Forms { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; public FormMain(ILogger logger, IOrderLogic orderLogic) { InitializeComponent(); @@ -151,5 +144,38 @@ namespace FishFactory.Forms { LoadData(); } + + private void списокКомпонентовToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + } + + private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportCannedComponents)); + if (service is FormReportCannedComponents form) + { + form.ShowDialog(); + } + + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/FishFactory/FormMain.resx b/FishFactory/Forms/FormMain.resx similarity index 89% rename from FishFactory/FormMain.resx rename to FishFactory/Forms/FormMain.resx index 672dbc1..a50214e 100644 --- a/FishFactory/FormMain.resx +++ b/FishFactory/Forms/FormMain.resx @@ -124,7 +124,7 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc @@ -134,6 +134,17 @@ mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEISURBVEhL3ZErDsJAGIR7DlA47oArV8CDR9RiSDAQPBcA + Qx1BgUMQBEk1ooJAKE0I4Wlqf5gmu1n6oqW7hiZfthkx33aqeZ5HKvEFpmmSYRhSQScXINB1XSroDAke + 96cUpAmupyPZsx7Z8x4drAnPpQmsgU7LdoHDJNIEYjnAlyBXJ3jPhVyaYLca8nLMhX+CPJXAOT+ouTj5 + p5in4asApdWpS8XRwT+zShIFG/fOyxlZJbGC9f5G5bHzUf6LJFJQqTViyxlxEmRiHhLUW10qDbeRpUGC + ErwjE/OQoG9dIsviYGWsXMwxc24BYLcO5pgZc+cWJIG5MbsyAUDnHwlUAkFHJZraR9NeMVq3zi+WF/0A + AAAASUVORK5CYII= diff --git a/FishFactory/Forms/FormReportCannedComponents.Designer.cs b/FishFactory/Forms/FormReportCannedComponents.Designer.cs new file mode 100644 index 0000000..497ff67 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.Designer.cs @@ -0,0 +1,99 @@ +namespace FishFactory.Forms +{ + partial class FormReportCannedComponents + { + /// + /// 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() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + Component = new DataGridViewTextBoxColumn(); + Canned = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(27, 15); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(160, 23); + buttonSaveToExcel.TabIndex = 0; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += buttonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Component, Canned, Count }); + dataGridView.Location = new Point(0, 47); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(799, 438); + dataGridView.TabIndex = 1; + // + // Component + // + Component.HeaderText = "Компонент"; + Component.Name = "Component"; + Component.ReadOnly = true; + // + // Canned + // + Canned.HeaderText = "Консервы"; + Canned.Name = "Canned"; + // + // Count + // + Count.HeaderText = "Количество"; + Count.Name = "Count"; + Count.ReadOnly = true; + // + // FormReportCannedComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(801, 484); + Controls.Add(dataGridView); + Controls.Add(buttonSaveToExcel); + Name = "FormReportCannedComponents"; + Text = "Компоненты по консервам"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Canned; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/FishFactory/Forms/FormReportCannedComponents.cs b/FishFactory/Forms/FormReportCannedComponents.cs new file mode 100644 index 0000000..83129d3 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.cs @@ -0,0 +1,73 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace FishFactory.Forms +{ + public partial class FormReportCannedComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportCannedComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportCannedComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetCannedComponent(); + 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[] { "", 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.SaveCannedComponentToExcelFile(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/FishFactory/Forms/FormReportCannedComponents.resx b/FishFactory/Forms/FormReportCannedComponents.resx new file mode 100644 index 0000000..cc8c5d0 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/FishFactory/Forms/FormReportOrders.Designer.cs b/FishFactory/Forms/FormReportOrders.Designer.cs new file mode 100644 index 0000000..19810bd --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.Designer.cs @@ -0,0 +1,114 @@ +namespace FishFactory.Forms +{ + 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() + { + dateTimePickerFrom = new DateTimePicker(); + dateTimePickerTo = new DateTimePicker(); + buttonMake = new Button(); + label1 = new Label(); + label2 = new Label(); + panel = new Panel(); + SuspendLayout(); + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(33, 7); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(149, 23); + dateTimePickerFrom.TabIndex = 0; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(215, 7); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(149, 23); + dateTimePickerTo.TabIndex = 1; + // + // buttonMake + // + buttonMake.Location = new Point(570, 7); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(120, 23); + buttonMake.TabIndex = 2; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += buttonMake_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(14, 12); + label1.Name = "label1"; + label1.Size = new Size(15, 15); + label1.TabIndex = 3; + label1.Text = "С"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(192, 11); + label2.Name = "label2"; + label2.Size = new Size(21, 15); + label2.TabIndex = 4; + label2.Text = "по"; + // + // panel + // + panel.Location = new Point(0, 36); + panel.Name = "panel"; + panel.Size = new Size(802, 418); + panel.TabIndex = 5; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(buttonMake); + Controls.Add(dateTimePickerTo); + Controls.Add(dateTimePickerFrom); + Name = "FormReportOrders"; + Text = "Заказы"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DateTimePicker dateTimePickerFrom; + private DateTimePicker dateTimePickerTo; + private Button buttonMake; + private Label label1; + private Label label2; + private Panel panel; + } +} \ No newline at end of file diff --git a/FishFactory/Forms/FormReportOrders.cs b/FishFactory/Forms/FormReportOrders.cs new file mode 100644 index 0000000..aa45614 --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.cs @@ -0,0 +1,92 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace FishFactory.Forms +{ + 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/FishFactory/Forms/FormReportOrders.resx b/FishFactory/Forms/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/FishFactory/Program.cs b/FishFactory/Program.cs index ba4bc0a..9d315dc 100644 --- a/FishFactory/Program.cs +++ b/FishFactory/Program.cs @@ -41,6 +41,7 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +49,8 @@ namespace FishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FishFactory/Properties/Resources.Designer.cs b/FishFactory/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c7c7065 --- /dev/null +++ b/FishFactory/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace FishFactory.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FishFactory.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/FishFactory/Properties/Resources.resx b/FishFactory/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/FishFactory/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/FishFactory/ReportOrders.rdlc b/FishFactory/ReportOrders.rdlc new file mode 100644 index 0000000..5317f35 --- /dev/null +++ b/FishFactory/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + FishFactoryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + CannedName + System.String + + + Sum + System.Decimal + + + OrderStatus + FishFactoryDataModels.OrderStatus + + + + FishFactoryContracts.ViewModels + ReportOrderViewModel + FishFactoryContracts.ViewModels.ReportOrderViewModel, FishFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.59525cm + + + 3.30963cm + + + 8.32842cm + + + 2.59525cm + + + 2.59525cm + + + + + 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!CannedName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 19.4238cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4.21167cm + 14.97625cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4.21167cm + 17.47625cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +