diff --git a/FishFactory/FishFactory.csproj b/FishFactory/FishFactory.csproj index 07508e2..41f596a 100644 --- a/FishFactory/FishFactory.csproj +++ b/FishFactory/FishFactory.csproj @@ -15,6 +15,7 @@ + @@ -25,4 +26,25 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + Always + + + \ 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 60% rename from FishFactory/FormMain.Designer.cs rename to FishFactory/Forms/FormMain.Designer.cs index 73fef74..a3599ad 100644 --- a/FishFactory/FormMain.Designer.cs +++ b/FishFactory/Forms/FormMain.Designer.cs @@ -33,6 +33,10 @@ 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(); @@ -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,60 @@ 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; // + // 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; + // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(914, 75); - buttonCreateOrder.Margin = new Padding(3, 4, 3, 4); + buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + 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 +125,10 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(914, 133); - buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4); + buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; + 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 +136,10 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(914, 190); - buttonOrderReady.Margin = new Padding(3, 4, 3, 4); + buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; + 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 +147,10 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(914, 241); - buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4); + buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + 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 +158,10 @@ // // buttonRef // - buttonRef.Location = new Point(914, 296); - buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; + 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 +170,20 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 35); - dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Location = new Point(0, 20); 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, 441); dataGridView.TabIndex = 6; // // 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 +191,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 +213,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 79% rename from FishFactory/FormMain.cs rename to FishFactory/Forms/FormMain.cs index b8c0b8f..9104c44 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,11 +9,13 @@ namespace FishFactory.Forms { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -151,5 +145,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.SaveCannedsToWordFile(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..7fd682f 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 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEKSURBVEhL3ZG9DsFQHMXvczDZvIOtXsHObuhqkViI3Quw + 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 new file mode 100644 index 0000000..dd6bce1 --- /dev/null +++ b/FishFactory/Forms/FormReportCannedComponents.Designer.cs @@ -0,0 +1,106 @@ +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(); + Count = new DataGridViewTextBoxColumn(); + Canned = new DataGridViewTextBoxColumn(); + Component = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(31, 19); + buttonSaveToExcel.Margin = new Padding(3, 4, 3, 4); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(183, 29); + 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, 60); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(913, 555); + dataGridView.TabIndex = 1; + // + // 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(8F, 19F); + AutoScaleMode = AutoScaleMode.Font; + 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); + } + + #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..a734c97 --- /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.CannedName, "", "" }); + foreach (var listElem in elem.Components) + { + 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..b3cb1b7 --- /dev/null +++ b/FishFactory/Forms/FormReportOrders.Designer.cs @@ -0,0 +1,135 @@ +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(); + buttonSaveToPdf = new Button(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(38, 12); + dateTimePickerFrom.Margin = new Padding(3, 4, 3, 4); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(170, 27); + dateTimePickerFrom.TabIndex = 0; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(246, 12); + dateTimePickerTo.Margin = new Padding(3, 4, 3, 4); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(170, 27); + dateTimePickerTo.TabIndex = 1; + // + // buttonMake + // + buttonMake.Location = new Point(597, 13); + buttonMake.Margin = new Padding(3, 4, 3, 4); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(137, 31); + buttonMake.TabIndex = 2; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += buttonMake_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(15, 16); + label1.Name = "label1"; + label1.Size = new Size(18, 20); + label1.TabIndex = 3; + label1.Text = "С"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(218, 15); + label2.Name = "label2"; + label2.Size = new Size(27, 20); + label2.TabIndex = 4; + label2.Text = "по"; + // + // panel + // + 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(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(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(941, 723); + Controls.Add(panel); + Margin = new Padding(3, 4, 3, 4); + Name = "FormReportOrders"; + Text = "Заказы"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private DateTimePicker dateTimePickerFrom; + private DateTimePicker dateTimePickerTo; + private Button buttonMake; + 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 new file mode 100644 index 0000000..2e12759 --- /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 buttonSaveToPdf_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 + { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + _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..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 { @@ -41,6 +43,10 @@ namespace FishFactory 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 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..47f80cc --- /dev/null +++ b/FishFactory/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + FishFactoryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + CannedName + System.String + + + Status + FishFactoryDataModels.Status + + + Sum + System.Decimal + + + + FishFactoryContracts.ViewModels + ReportOrdersViewModel + FishFactoryContracts.ViewModels.ReportOrdersViewModel, 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.5cm + + + 3.21438cm + + + 8.23317cm + + + 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!CannedName.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 + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +