From af0eff1288ec13cd2b26658dcb45d66e1e2486b3 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 9 Feb 2024 21:30:06 +0400 Subject: [PATCH 01/18] =?UTF-8?q?=D0=BF=D0=BE=D0=BA=D0=B0=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlacksmithWorkshop/BlacksmithWorkshop.sln | 26 +++- .../BlacksmithWorkshop.csproj | 5 + .../BlacksmithWorkshop/Form1.Designer.cs | 39 ------ .../BlacksmithWorkshop/Form1.cs | 10 -- .../FormComponent.Designer.cs | 116 +++++++++++++++++ .../BlacksmithWorkshop/FormComponent.cs | 90 +++++++++++++ .../{Form1.resx => FormComponent.resx} | 50 ++++---- .../FormComponents.Designer.cs | 108 ++++++++++++++++ .../BlacksmithWorkshop/FormComponents.cs | 117 +++++++++++++++++ .../BlacksmithWorkshop/FormComponents.resx | 120 ++++++++++++++++++ .../BlacksmithWorkshop/Program.cs | 2 +- .../BlacksmithWorkshopBusinessLogic.csproj | 17 +++ .../BusinessLogics/ComponentLogic.cs | 112 ++++++++++++++++ .../BusinessLogics/ManufactureLogic.cs | 114 +++++++++++++++++ .../BusinessLogics/OrderLogic.cs | 112 ++++++++++++++++ .../BindingModels/ComponentBindingModel.cs | 12 ++ .../BindingModels/ManufactureBindingModel.cs | 21 +++ .../BindingModels/OrderBindingModel .cs | 27 ++++ .../BlacksmithWorkshopContracts.csproj | 13 ++ .../IComponentLogic.cs | 20 +++ .../IManufactureLogic.cs | 20 +++ .../BusinessLogicsContracts/IOrderLogic.cs | 20 +++ .../SearchModels/ComponentSearchModel.cs | 14 ++ .../SearchModels/ManufactureSearchModel.cs | 14 ++ .../SearchModels/OrderSearchModel.cs | 13 ++ .../StoragesContracts/IComponentStorage.cs | 21 +++ .../StoragesContracts/IManufactureStorage.cs | 21 +++ .../StoragesContracts/IOrderStorage.cs | 21 +++ .../ViewModels/ComponentViewModel.cs | 19 +++ .../ViewModels/ManufactureViewModel.cs | 24 ++++ .../ViewModels/OrderViewModel.cs | 31 +++++ .../BlacksmithWorkshopDataModels.csproj | 9 ++ .../Enums/OrderStatus.cs | 15 +++ .../BlacksmithWorkshopDataModels/IId.cs | 13 ++ .../Models/IComponentModel.cs | 15 +++ .../Models/IManufactureModel.cs | 15 +++ .../Models/IOrderModel.cs | 19 +++ .../BlacksmithWorkshopListImplement.csproj | 14 ++ .../DataListSingleton.cs | 31 +++++ .../Implements/ComponentStorage.cs | 108 ++++++++++++++++ .../Implements/ManufactureStorage.cs | 108 ++++++++++++++++ .../Implements/OrderStorage.cs | 118 +++++++++++++++++ .../Models/Component.cs | 41 ++++++ .../Models/Manufacture.cs | 54 ++++++++ .../Models/Order .cs | 65 ++++++++++ 45 files changed, 1898 insertions(+), 76 deletions(-) delete mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Form1.Designer.cs delete mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Form1.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs rename BlacksmithWorkshop/BlacksmithWorkshop/{Form1.resx => FormComponent.resx} (93%) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.resx create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BlacksmithWorkshopBusinessLogic.csproj create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ComponentLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ComponentBindingModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ManufactureBindingModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel .cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BlacksmithWorkshopContracts.csproj create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IManufactureLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ComponentSearchModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ManufactureSearchModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IComponentStorage.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IManufactureStorage.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IOrderStorage.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDataModels/BlacksmithWorkshopDataModels.csproj create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDataModels/IId.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IComponentModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IManufactureModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Component.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Manufacture.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs diff --git a/BlacksmithWorkshop/BlacksmithWorkshop.sln b/BlacksmithWorkshop/BlacksmithWorkshop.sln index d33b098..408f263 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop.sln +++ b/BlacksmithWorkshop/BlacksmithWorkshop.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34031.279 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshop", "BlacksmithWorkshop\BlacksmithWorkshop.csproj", "{54575961-6705-47D3-8063-416A45518BED}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshop", "BlacksmithWorkshop\BlacksmithWorkshop.csproj", "{54575961-6705-47D3-8063-416A45518BED}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopDataModels", "BlacksmithWorkshopDataModels\BlacksmithWorkshopDataModels.csproj", "{96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopContracts", "BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj", "{40A50297-20F6-4F73-834D-0902F6F7965B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopBusinessLogic", "BlacksmithWorkshopBusinessLogic\BlacksmithWorkshopBusinessLogic.csproj", "{81DD48F2-F58D-4C86-AC0C-74E447366DFA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopListImplement", "BlacksmithWorkshopListImplement\BlacksmithWorkshopListImplement.csproj", "{F6B2AA66-2A89-4DEA-AE90-84991C1EE424}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +23,22 @@ Global {54575961-6705-47D3-8063-416A45518BED}.Debug|Any CPU.Build.0 = Debug|Any CPU {54575961-6705-47D3-8063-416A45518BED}.Release|Any CPU.ActiveCfg = Release|Any CPU {54575961-6705-47D3-8063-416A45518BED}.Release|Any CPU.Build.0 = Release|Any CPU + {96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96E8CFC7-A9D8-438B-AE8C-184ED25D5AAC}.Release|Any CPU.Build.0 = Release|Any CPU + {40A50297-20F6-4F73-834D-0902F6F7965B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40A50297-20F6-4F73-834D-0902F6F7965B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40A50297-20F6-4F73-834D-0902F6F7965B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40A50297-20F6-4F73-834D-0902F6F7965B}.Release|Any CPU.Build.0 = Release|Any CPU + {81DD48F2-F58D-4C86-AC0C-74E447366DFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81DD48F2-F58D-4C86-AC0C-74E447366DFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81DD48F2-F58D-4C86-AC0C-74E447366DFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81DD48F2-F58D-4C86-AC0C-74E447366DFA}.Release|Any CPU.Build.0 = Release|Any CPU + {F6B2AA66-2A89-4DEA-AE90-84991C1EE424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6B2AA66-2A89-4DEA-AE90-84991C1EE424}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6B2AA66-2A89-4DEA-AE90-84991C1EE424}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6B2AA66-2A89-4DEA-AE90-84991C1EE424}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj index b57c89e..28bb67b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj @@ -8,4 +8,9 @@ enable + + + + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Form1.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Form1.Designer.cs deleted file mode 100644 index 6d3391d..0000000 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace BlacksmithWorkshop -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Form1.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Form1.cs deleted file mode 100644 index 6c3de35..0000000 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace BlacksmithWorkshop -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs new file mode 100644 index 0000000..46816f7 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs @@ -0,0 +1,116 @@ +namespace BlacksmithWorkshop +{ + partial class FormComponent + { + /// + /// 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() + { + labelName = new Label(); + labelCost = new Label(); + textBoxName = new TextBox(); + textBoxCost = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(18, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(62, 15); + labelName.TabIndex = 0; + labelName.Text = "Название:"; + // + // labelCost + // + labelCost.AutoSize = true; + labelCost.Location = new Point(18, 39); + labelCost.Name = "labelCost"; + labelCost.Size = new Size(38, 15); + labelCost.TabIndex = 1; + labelCost.Text = "Цена:"; + // + // textBoxName + // + textBoxName.Location = new Point(86, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(393, 23); + textBoxName.TabIndex = 2; + // + // textBoxCost + // + textBoxCost.Location = new Point(86, 36); + textBoxCost.Name = "textBoxCost"; + textBoxCost.Size = new Size(393, 23); + textBoxCost.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(108, 65); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(76, 24); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + // + // buttonCancel + // + buttonCancel.Location = new Point(314, 65); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(76, 24); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // FormComponent + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(503, 103); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxCost); + Controls.Add(textBoxName); + Controls.Add(labelCost); + Controls.Add(labelName); + Name = "FormComponent"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компонент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelCost; + private TextBox textBoxName; + private TextBox textBoxCost; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs new file mode 100644 index 0000000..05fa8db --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs @@ -0,0 +1,90 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using Microsoft.Extensions.Logging; + +namespace BlacksmithWorkshop +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormComponent(ILogger logger, IComponentLogic + logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation(" "); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = + _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation(" "); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception(" . ."); + + } + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Form1.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.resx similarity index 93% rename from BlacksmithWorkshop/BlacksmithWorkshop/Form1.resx rename to BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.resx index 1af7de1..af32865 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Form1.resx +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.resx @@ -1,17 +1,17 @@  - diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs new file mode 100644 index 0000000..60570e1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs @@ -0,0 +1,108 @@ +namespace BlacksmithWorkshop +{ + partial class FormComponents + { + /// + /// 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() + { + dataGridViewComponents = new DataGridView(); + buttonAdd = new Button(); + buttonChange = new Button(); + buttonDelete = new Button(); + buttonRefresh = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit(); + SuspendLayout(); + // + // dataGridViewComponents + // + dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewComponents.Location = new Point(0, 0); + dataGridViewComponents.Name = "dataGridViewComponents"; + dataGridViewComponents.RowTemplate.Height = 25; + dataGridViewComponents.Size = new Size(472, 450); + dataGridViewComponents.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(487, 16); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(118, 29); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + // + // buttonChange + // + buttonChange.Location = new Point(487, 51); + buttonChange.Name = "buttonChange"; + buttonChange.Size = new Size(118, 29); + buttonChange.TabIndex = 2; + buttonChange.Text = "Изменить"; + buttonChange.UseVisualStyleBackColor = true; + // + // buttonDelete + // + buttonDelete.Location = new Point(487, 86); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(118, 29); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(487, 121); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(118, 29); + buttonRefresh.TabIndex = 4; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + // + // FormComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(619, 450); + Controls.Add(buttonRefresh); + Controls.Add(buttonDelete); + Controls.Add(buttonChange); + Controls.Add(buttonAdd); + Controls.Add(dataGridViewComponents); + Name = "FormComponents"; + Text = "Компоненты"; + ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewComponents; + private Button buttonAdd; + private Button buttonChange; + private Button buttonDelete; + private Button buttonRefresh; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs new file mode 100644 index 0000000..a89840c --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs @@ -0,0 +1,117 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.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 BlacksmithWorkshop +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic + logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void ComponentsForm_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + DataGridView.DataSource = list; + DataGridView.Columns["Id"].Visible = false; + DataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void AddButton_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ChangeButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + } + private void DeleteButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + } + private void RefreshButton_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.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/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 1d7fc1e..99fb8ce 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -11,7 +11,7 @@ namespace BlacksmithWorkshop // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormComponent()); } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BlacksmithWorkshopBusinessLogic.csproj b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BlacksmithWorkshopBusinessLogic.csproj new file mode 100644 index 0000000..e0e8cbd --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BlacksmithWorkshopBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ComponentLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ComponentLogic.cs new file mode 100644 index 0000000..57f5ce5 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -0,0 +1,112 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BlacksmithWorkshopBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage + componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : + _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id}", model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs new file mode 100644 index 0000000..5c4e861 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs @@ -0,0 +1,114 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BlacksmithWorkshopBusinessLogic.BusinessLogics +{ + public class ManufactureLogic : IManufactureLogic + { + private readonly ILogger _logger; + private readonly IManufactureStorage _ManufactureStorage; + public ManufactureLogic(ILogger logger, IManufactureStorage ManufactureStorage) + { + _logger = logger; + _ManufactureStorage = ManufactureStorage; + } + + public List? ReadList(ManufactureSearchModel? model) + { + _logger.LogInformation("ReadList. ManufactureName:{ManufactureName}. Id:{ Id}", model?.ManufactureName, model?.Id); + var list = model == null ? _ManufactureStorage.GetFullList() : + _ManufactureStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ManufactureViewModel? ReadElement(ManufactureSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}.Id:{ Id}", model.ManufactureName, model.Id); + var element = _ManufactureStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + public bool Create(ManufactureBindingModel model) + { + CheckModel(model); + if (_ManufactureStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(ManufactureBindingModel model) + { + CheckModel(model); + if (_ManufactureStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ManufactureBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_ManufactureStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + private void CheckModel(ManufactureBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ManufactureName)) + { + throw new ArgumentNullException("Нет названия мороженного", + nameof(model.ManufactureName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена мороженного должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Manufacture. Manufacture:{Manufacture}. Price:{ Price }. Id: { Id}", model.ManufactureName, model.Price, model.Id); + var element = _ManufactureStorage.GetElement(new ManufactureSearchModel + { + ManufactureName = model.ManufactureName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..a77a22a --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,112 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : + _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) return false; + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool ChangeStatus(OrderBindingModel model, OrderStatus status) + { + CheckModel(model); + var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (element == null) + { + _logger.LogWarning("Read operation failed"); + return false; + } + if (element.Status != status - 1) + { + _logger.LogWarning("Status change operation failed"); + throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный"); + } + model.Status = status; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + _orderStorage.Update(model); + return true; + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Готов); + } + + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выдан); + } + + private void CheckModel(OrderBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count)); + } + _logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ComponentBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..f864b46 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,12 @@ +using BlacksmithWorkshopDataModels.Models; + +namespace BlacksmithWorkshopContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } + +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ManufactureBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ManufactureBindingModel.cs new file mode 100644 index 0000000..f50f381 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ManufactureBindingModel.cs @@ -0,0 +1,21 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BindingModels +{ + public class ManufactureBindingModel : IManufactureModel + { + public int Id { get; set; } + public string ManufactureName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary ManufactureComponents + { + get; + set; + } = new(); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel .cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel .cs new file mode 100644 index 0000000..473bd7d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel .cs @@ -0,0 +1,27 @@ +using BlacksmithWorkshopDataModels.Enums; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + + public int ManufactureId { get; set; } + + public int Count { get; set; } + + public double Sum { get; set; } + + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + public DateTime DateCreate { get; set; } = DateTime.Now; + + public DateTime? DateImplement { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BlacksmithWorkshopContracts.csproj b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BlacksmithWorkshopContracts.csproj new file mode 100644 index 0000000..f685e06 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BlacksmithWorkshopContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IComponentLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..6cdef07 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,20 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IManufactureLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IManufactureLogic.cs new file mode 100644 index 0000000..25a2de5 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IManufactureLogic.cs @@ -0,0 +1,20 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BusinessLogicsContracts +{ + public interface IManufactureLogic + { + List? ReadList(ManufactureSearchModel? model); + ManufactureViewModel? ReadElement(ManufactureSearchModel model); + bool Create(ManufactureBindingModel model); + bool Update(ManufactureBindingModel model); + bool Delete(ManufactureBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..bdd54b4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,20 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ComponentSearchModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..1a75d04 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ManufactureSearchModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ManufactureSearchModel.cs new file mode 100644 index 0000000..5048a87 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ManufactureSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.SearchModels +{ + public class ManufactureSearchModel + { + public int? Id { get; set; } + public string? ManufactureName { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..254be46 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IComponentStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..da33674 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IManufactureStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IManufactureStorage.cs new file mode 100644 index 0000000..3a45bd4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IManufactureStorage.cs @@ -0,0 +1,21 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.StoragesContracts +{ + public interface IManufactureStorage + { + List GetFullList(); + List GetFilteredList(ManufactureSearchModel model); + ManufactureViewModel? GetElement(ManufactureSearchModel model); + ManufactureViewModel? Insert(ManufactureBindingModel model); + ManufactureViewModel? Update(ManufactureBindingModel model); + ManufactureViewModel? Delete(ManufactureBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IOrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..f772c1e --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,21 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..616ef51 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs new file mode 100644 index 0000000..8fad94d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs @@ -0,0 +1,24 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.ViewModels +{ + public class ManufactureViewModel : IManufactureModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string ManufactureName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary ManufactureComponents + { + get; + set; + } = new(); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..f02826f --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,31 @@ +using BlacksmithWorkshopDataModels.Enums; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + + public int ManufactureId { get; set; } + [DisplayName("Изделие")] + public string ManufactureName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/BlacksmithWorkshopDataModels.csproj b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/BlacksmithWorkshopDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/BlacksmithWorkshopDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..4777cd9 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs @@ -0,0 +1,15 @@ +namespace BlacksmithWorkshopDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + + Принят = 0, + + Выполняется = 1, + + Готов = 2, + + Выдан = 3 + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/IId.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/IId.cs new file mode 100644 index 0000000..e0a71f4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IComponentModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..a3ec2c7 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IComponentModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } + +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IManufactureModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IManufactureModel.cs new file mode 100644 index 0000000..90bf9a1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IManufactureModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDataModels.Models +{ + public interface IManufactureModel : IId + { + string ManufactureName { get; } + double Price { get; } + Dictionary ManufactureComponents { get; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..f815a16 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using BlacksmithWorkshopDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDataModels.Models +{ + public interface IOrderModel : IId + { + int ManufactureId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj new file mode 100644 index 0000000..b65badc --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs new file mode 100644 index 0000000..71c00d4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using BlacksmithWorkshopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Manufactures { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Manufactures = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..d1512a1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,108 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs new file mode 100644 index 0000000..bd338f6 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs @@ -0,0 +1,108 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Implements +{ + public class ManufactureStorage : IManufactureStorage + { + private readonly DataListSingleton _source; + public ManufactureStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var Manufacture in _source.Manufactures) + { + result.Add(Manufacture.GetViewModel); + } + return result; + } + public List GetFilteredList(ManufactureSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ManufactureName)) + { + return result; + } + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.ManufactureName.Contains(model.ManufactureName)) + { + result.Add(Manufacture.GetViewModel); + } + } + return result; + } + public ManufactureViewModel? GetElement(ManufactureSearchModel model) + { + if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) + { + return null; + } + foreach (var Manufacture in _source.Manufactures) + { + if ((!string.IsNullOrEmpty(model.ManufactureName) && + Manufacture.ManufactureName == model.ManufactureName) || + (model.Id.HasValue && Manufacture.Id == model.Id)) + { + return Manufacture.GetViewModel; + } + } + return null; + } + public ManufactureViewModel? Insert(ManufactureBindingModel model) + { + model.Id = 1; + foreach (var Manufacture in _source.Manufactures) + { + if (model.Id <= Manufacture.Id) + { + model.Id = Manufacture.Id + 1; + } + } + var newManufacture = Manufacture.Create(model); + if (newManufacture == null) + { + return null; + } + _source.Manufactures.Add(newManufacture); + return newManufacture.GetViewModel; + } + public ManufactureViewModel? Update(ManufactureBindingModel model) + { + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.Id == model.Id) + { + Manufacture.Update(model); + return Manufacture.GetViewModel; + } + } + return null; + } + public ManufactureViewModel? Delete(ManufactureBindingModel model) + { + for (int i = 0; i < _source.Manufactures.Count; ++i) + { + if (_source.Manufactures[i].Id == model.Id) + { + var element = _source.Manufactures[i]; + _source.Manufactures.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..409331b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs @@ -0,0 +1,118 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(AccessManufactureStorage(order.GetViewModel)); + } + return result; + } + public List GetFilteredList(OrderSearchModel + model) + { + var result = new List(); + if (!model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(AccessManufactureStorage(order.GetViewModel)); + } + } + return result; + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var order in _source.Orders) + { + if (model.Id <= order.Id) + { + model.Id = order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return newOrder.GetViewModel; + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + public OrderViewModel AccessManufactureStorage(OrderViewModel model) + { + foreach (var Manufacture in _source.Manufactures) + { + if (Manufacture.Id == model.ManufactureId) + { + model.ManufactureName = Manufacture.ManufactureName; + break; + } + } + return model; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Component.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Component.cs new file mode 100644 index 0000000..d3e9adf --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Component.cs @@ -0,0 +1,41 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; + +namespace BlacksmithWorkshopListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Manufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Manufacture.cs new file mode 100644 index 0000000..d4a658f --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Manufacture.cs @@ -0,0 +1,54 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Models +{ + public class Manufacture : IManufactureModel + { + public int Id { get; private set; } + public string ManufactureName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary ManufactureComponents + { + get; + private set; + } = new Dictionary(); + public static Manufacture? Create(ManufactureBindingModel? model) + { + if (model == null) + { + return null; + } + return new Manufacture() + { + Id = model.Id, + ManufactureName = model.ManufactureName, + Price = model.Price, + ManufactureComponents = model.ManufactureComponents + }; + } + public void Update(ManufactureBindingModel? model) + { + if (model == null) + { + return; + } + ManufactureName = model.ManufactureName; + Price = model.Price; + ManufactureComponents = model.ManufactureComponents; + } + public ManufactureViewModel GetViewModel => new() + { + Id = Id, + ManufactureName = ManufactureName, + Price = Price, + ManufactureComponents = ManufactureComponents + }; + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs new file mode 100644 index 0000000..c49044e --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs @@ -0,0 +1,65 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Enums; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int ManufactureId { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } + public DateTime DateCreate { get; private set; } + public DateTime? DateImplement { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + ManufactureId = model.ManufactureId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Id = model.Id; + ManufactureId = model.ManufactureId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + ManufactureId = ManufactureId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + }; + } +} -- 2.25.1 From 48cf6658c28b6462e750a7b2f5da64de4916a554 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 9 Feb 2024 22:00:53 +0400 Subject: [PATCH 02/18] =?UTF-8?q?=D0=B2=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5?= =?UTF-8?q?=D1=81=D1=81=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshop.csproj | 4 + .../FormComponent.Designer.cs | 3 + .../FormComponents.Designer.cs | 34 ++--- .../BlacksmithWorkshop/FormComponents.cs | 22 ++-- .../FormManufactureComponent.Designer.cs | 118 +++++++++++++++++ .../FormManufactureComponent.cs | 90 +++++++++++++ .../FormManufactureComponent.resx | 120 ++++++++++++++++++ .../BlacksmithWorkshop/Program.cs | 35 ++++- 8 files changed, 399 insertions(+), 27 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.resx diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj index 28bb67b..0d261a7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj @@ -8,6 +8,10 @@ enable + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs index 46816f7..3f8123d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.Designer.cs @@ -76,6 +76,7 @@ buttonSave.TabIndex = 4; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; // // buttonCancel // @@ -85,6 +86,7 @@ buttonCancel.TabIndex = 5; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; // // FormComponent // @@ -100,6 +102,7 @@ Name = "FormComponent"; StartPosition = FormStartPosition.CenterParent; Text = "Компонент"; + Load += FormComponent_Load; ResumeLayout(false); PerformLayout(); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs index 60570e1..50c50a4 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs @@ -28,23 +28,14 @@ /// private void InitializeComponent() { - dataGridViewComponents = new DataGridView(); buttonAdd = new Button(); buttonChange = new Button(); buttonDelete = new Button(); buttonRefresh = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit(); + dataGridView = new DataGridView(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // - // dataGridViewComponents - // - dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewComponents.Location = new Point(0, 0); - dataGridViewComponents.Name = "dataGridViewComponents"; - dataGridViewComponents.RowTemplate.Height = 25; - dataGridViewComponents.Size = new Size(472, 450); - dataGridViewComponents.TabIndex = 0; - // // buttonAdd // buttonAdd.Location = new Point(487, 16); @@ -53,6 +44,7 @@ buttonAdd.TabIndex = 1; buttonAdd.Text = "Добавить"; buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += AddButton_Click; // // buttonChange // @@ -62,6 +54,7 @@ buttonChange.TabIndex = 2; buttonChange.Text = "Изменить"; buttonChange.UseVisualStyleBackColor = true; + buttonChange.Click += ChangeButton_Click; // // buttonDelete // @@ -71,6 +64,7 @@ buttonDelete.TabIndex = 3; buttonDelete.Text = "Удалить"; buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += DeleteButton_Click; // // buttonRefresh // @@ -80,29 +74,39 @@ buttonRefresh.TabIndex = 4; buttonRefresh.Text = "Обновить"; buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += RefreshButton_Click; + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 0); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(468, 450); + dataGridView.TabIndex = 5; // // FormComponents // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(619, 450); + Controls.Add(dataGridView); Controls.Add(buttonRefresh); Controls.Add(buttonDelete); Controls.Add(buttonChange); Controls.Add(buttonAdd); - Controls.Add(dataGridViewComponents); Name = "FormComponents"; Text = "Компоненты"; - ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit(); + Load += ComponentsForm_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } #endregion - - private DataGridView dataGridViewComponents; private Button buttonAdd; private Button buttonChange; private Button buttonDelete; private Button buttonRefresh; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs index a89840c..6cb054c 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs @@ -35,9 +35,9 @@ namespace BlacksmithWorkshop var list = _logic.ReadList(null); if (list != null) { - DataGridView.DataSource = list; - DataGridView.Columns["Id"].Visible = false; - DataGridView.Columns["ComponentName"].AutoSizeMode = + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка компонентов"); @@ -46,7 +46,7 @@ namespace BlacksmithWorkshop { _logger.LogError(ex, "Ошибка загрузки компонентов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBoxIcon.Error); } } private void AddButton_Click(object sender, EventArgs e) @@ -62,14 +62,14 @@ namespace BlacksmithWorkshop } private void ChangeButton_Click(object sender, EventArgs e) { - if (DataGridView.SelectedRows.Count == 1) + if (dataGridView.SelectedRows.Count == 1) { var service = - Program.ServiceProvider?.GetService(typeof(FormComponent)); + Program.ServiceProvider?.GetService(typeof(FormComponent)); if (service is FormComponent form) { form.Id = - Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) { LoadData(); @@ -80,13 +80,13 @@ namespace BlacksmithWorkshop } private void DeleteButton_Click(object sender, EventArgs e) { - if (DataGridView.SelectedRows.Count == 1) + if (dataGridView.SelectedRows.Count == 1) { if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = - Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление компонента"); try { @@ -103,7 +103,7 @@ namespace BlacksmithWorkshop { _logger.LogError(ex, "Ошибка удаления компонента"); MessageBox.Show(ex.Message, "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs new file mode 100644 index 0000000..6c76c54 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs @@ -0,0 +1,118 @@ +namespace BlacksmithWorkshop +{ + partial class FormManufactureComponent + { + /// + /// 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() + { + labelComponent = new Label(); + comboBoxComponent = new ComboBox(); + labelCount = new Label(); + textBoxCount = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelComponent + // + labelComponent.AutoSize = true; + labelComponent.Location = new Point(12, 9); + labelComponent.Name = "labelComponent"; + labelComponent.Size = new Size(72, 15); + labelComponent.TabIndex = 0; + labelComponent.Text = "Компонент:"; + // + // comboBoxComponent + // + comboBoxComponent.FormattingEnabled = true; + comboBoxComponent.Location = new Point(93, 6); + comboBoxComponent.Name = "comboBoxComponent"; + comboBoxComponent.Size = new Size(285, 23); + comboBoxComponent.TabIndex = 1; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(12, 34); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(75, 15); + labelCount.TabIndex = 2; + labelCount.Text = "Количество:"; + // + // textBoxCount + // + textBoxCount.Location = new Point(93, 31); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(285, 23); + textBoxCount.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(64, 60); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(107, 29); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(228, 60); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(107, 29); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormManufactureComponent + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(394, 98); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxCount); + Controls.Add(labelCount); + Controls.Add(comboBoxComponent); + Controls.Add(labelComponent); + Name = "FormManufactureComponent"; + Text = "Компонент изделия"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelComponent; + private ComboBox comboBoxComponent; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.cs new file mode 100644 index 0000000..8ab5728 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.cs @@ -0,0 +1,90 @@ +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +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 BlacksmithWorkshop +{ + public partial class FormManufactureComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return + Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set + { textBoxCount.Text = value.ToString(); } + } + public FormManufactureComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.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/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 99fb8ce..bd22a4b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -1,7 +1,16 @@ +using BlacksmithWorkshopBusinessLogic.BusinessLogics; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using System; + namespace BlacksmithWorkshop { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +20,31 @@ namespace BlacksmithWorkshop // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormComponent()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file -- 2.25.1 From 3688251e2ee7b63f360241ce4313a39cf5e35f9c Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 18:40:40 +0400 Subject: [PATCH 03/18] FormManufacture --- .../FormManufacture.Designer.cs | 223 ++++++++++++++++++ .../BlacksmithWorkshop/FormManufacture.cs | 215 +++++++++++++++++ .../BlacksmithWorkshop/FormManufacture.resx | 129 ++++++++++ 3 files changed, 567 insertions(+) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs new file mode 100644 index 0000000..ab60114 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs @@ -0,0 +1,223 @@ +namespace BlacksmithWorkshop +{ + partial class FormManufacture + { + /// + /// 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() + { + labelName = new Label(); + labelCost = new Label(); + textBoxName = new TextBox(); + textBoxPrice = new TextBox(); + groupBoxComponents = new GroupBox(); + dataGridView = new DataGridView(); + ColumnId = new DataGridViewTextBoxColumn(); + ColumnName = new DataGridViewTextBoxColumn(); + ColumnPrice = new DataGridViewTextBoxColumn(); + buttonRefresh = new Button(); + buttonDelete = new Button(); + buttonChange = new Button(); + buttonAdd = new Button(); + buttonSave = new Button(); + buttonCancel = new Button(); + groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(15, 10); + labelName.Name = "labelName"; + labelName.Size = new Size(62, 15); + labelName.TabIndex = 0; + labelName.Text = "Название:"; + // + // labelCost + // + labelCost.AutoSize = true; + labelCost.Location = new Point(15, 41); + labelCost.Name = "labelCost"; + labelCost.Size = new Size(70, 15); + labelCost.TabIndex = 1; + labelCost.Text = "Стоимость:"; + // + // textBoxName + // + textBoxName.Location = new Point(106, 7); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(289, 23); + textBoxName.TabIndex = 2; + // + // textBoxPrice + // + textBoxPrice.Location = new Point(106, 38); + textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.Size = new Size(289, 23); + textBoxPrice.TabIndex = 3; + // + // groupBoxComponents + // + groupBoxComponents.Controls.Add(dataGridView); + groupBoxComponents.Controls.Add(buttonRefresh); + groupBoxComponents.Controls.Add(buttonDelete); + groupBoxComponents.Controls.Add(buttonChange); + groupBoxComponents.Controls.Add(buttonAdd); + groupBoxComponents.Location = new Point(15, 67); + groupBoxComponents.Name = "groupBoxComponents"; + groupBoxComponents.Size = new Size(596, 285); + groupBoxComponents.TabIndex = 4; + groupBoxComponents.TabStop = false; + groupBoxComponents.Text = "Компоненты"; + // + // dataGridView + // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnPrice }); + dataGridView.Location = new Point(11, 23); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(439, 256); + dataGridView.TabIndex = 5; + // + // ColumnId + // + ColumnId.HeaderText = "Идентификатор"; + ColumnId.Name = "ColumnId"; + ColumnId.Visible = false; + // + // ColumnName + // + ColumnName.FillWeight = 200F; + ColumnName.HeaderText = "Компонент"; + ColumnName.Name = "ColumnName"; + // + // ColumnPrice + // + ColumnPrice.HeaderText = "Стоимость"; + ColumnPrice.Name = "ColumnPrice"; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(470, 137); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(106, 29); + buttonRefresh.TabIndex = 4; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRef_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(470, 102); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(106, 29); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDel_Click; + // + // buttonChange + // + buttonChange.Location = new Point(470, 67); + buttonChange.Name = "buttonChange"; + buttonChange.Size = new Size(106, 29); + buttonChange.TabIndex = 2; + buttonChange.Text = "Изменить"; + buttonChange.UseVisualStyleBackColor = true; + buttonChange.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(470, 32); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(106, 29); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonSave + // + buttonSave.Location = new Point(373, 358); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(106, 29); + buttonSave.TabIndex = 5; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(485, 358); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(106, 29); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormManufacture + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(626, 401); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBoxComponents); + Controls.Add(textBoxPrice); + Controls.Add(textBoxName); + Controls.Add(labelCost); + Controls.Add(labelName); + Name = "FormManufacture"; + Text = "Изделие"; + Load += FormManufacture_Load; + groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelCost; + private TextBox textBoxName; + private TextBox textBoxPrice; + private GroupBox groupBoxComponents; + private Button buttonRefresh; + private Button buttonDelete; + private Button buttonChange; + private Button buttonAdd; + private Button buttonSave; + private Button buttonCancel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnId; + private DataGridViewTextBoxColumn ColumnName; + private DataGridViewTextBoxColumn ColumnPrice; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs new file mode 100644 index 0000000..80b8f7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs @@ -0,0 +1,215 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopDataModels.Models; +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 BlacksmithWorkshop +{ + public partial class FormManufacture : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logic; + private int? _id; + private Dictionary _manufactureComponents; + public int Id { set { _id = value; } } + public FormManufacture(ILogger logger, IManufactureLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _manufactureComponents = new Dictionary(); + } + private void FormManufacture_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); + if (view != null) + { + textBoxName.Text = view.ManufactureName; + textBoxPrice.Text = view.Price.ToString(); + _manufactureComponents = view.ManufactureComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_manufactureComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _manufactureComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, + pc.Value.Item1.ComponentName, pc.Value.Item2 }); + + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); + if (service is FormManufactureComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + if (_manufactureComponents.ContainsKey(form.Id)) + { + _manufactureComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _manufactureComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); + if (service is FormManufactureComponent form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _manufactureComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count); + _manufactureComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента:{ ComponentName}- { Count} ", dataGridView.SelectedRows[0].Cells[1].Value); + _manufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_manufactureComponents == null || _manufactureComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new ManufactureBindingModel + { + Id = _id ?? 0, + ManufactureName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + ManufactureComponents = _manufactureComponents + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _manufactureComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx new file mode 100644 index 0000000..4178078 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.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 -- 2.25.1 From 8f7cfd85e3b23fde82f37df2df51bc877c248674 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 19:22:42 +0400 Subject: [PATCH 04/18] FormCreateOrder --- .../BlacksmithWorkshop.csproj | 6 + .../FormCreateOrder.Designer.cs | 145 ++++++++++++++++++ .../BlacksmithWorkshop/FormCreateOrder.cs | 135 ++++++++++++++++ .../BlacksmithWorkshop/FormCreateOrder.resx | 120 +++++++++++++++ 4 files changed, 406 insertions(+) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.resx diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj index 0d261a7..0d78b48 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj @@ -17,4 +17,10 @@ + + + + + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..e3eb734 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs @@ -0,0 +1,145 @@ +namespace BlacksmithWorkshop +{ + partial class FormCreateOrder + { + /// + /// 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() + { + labelName = new Label(); + labelCount = new Label(); + labelSum = new Label(); + TextBoxCount = new TextBox(); + ComboBoxManufacture = new ComboBox(); + TextBoxSum = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(22, 17); + labelName.Name = "labelName"; + labelName.Size = new Size(56, 15); + labelName.TabIndex = 0; + labelName.Text = "Изделие:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(22, 46); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(75, 15); + labelCount.TabIndex = 1; + labelCount.Text = "Количество:"; + // + // labelSum + // + labelSum.AutoSize = true; + labelSum.Location = new Point(22, 75); + labelSum.Name = "labelSum"; + labelSum.Size = new Size(48, 15); + labelSum.TabIndex = 2; + labelSum.Text = "Сумма:"; + // + // TextBoxCount + // + TextBoxCount.Location = new Point(125, 43); + TextBoxCount.Name = "TextBoxCount"; + TextBoxCount.Size = new Size(214, 23); + TextBoxCount.TabIndex = 3; + TextBoxCount.TextChanged += TextBoxCount_TextChanged; + // + // ComboBoxManufacture + // + ComboBoxManufacture.FormattingEnabled = true; + ComboBoxManufacture.Location = new Point(125, 14); + ComboBoxManufacture.Name = "ComboBoxManufacture"; + ComboBoxManufacture.Size = new Size(214, 23); + ComboBoxManufacture.TabIndex = 4; + ComboBoxManufacture.SelectedIndexChanged += ComboBoxManufacture_SelectedIndexChanged; + // + // TextBoxSum + // + TextBoxSum.Location = new Point(125, 72); + TextBoxSum.Name = "TextBoxSum"; + TextBoxSum.ReadOnly = true; + TextBoxSum.Size = new Size(214, 23); + TextBoxSum.TabIndex = 5; + TextBoxSum.TextChanged += TextBoxSum_TextChanged; + // + // buttonCancel + // + buttonCancel.Location = new Point(247, 104); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(77, 24); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += CancelButton_Click; + // + // buttonSave + // + buttonSave.Location = new Point(164, 104); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(77, 24); + buttonSave.TabIndex = 7; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += SaveButton_Click; + // + // FormCreateOrder + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(349, 139); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Controls.Add(TextBoxSum); + Controls.Add(ComboBoxManufacture); + Controls.Add(TextBoxCount); + Controls.Add(labelSum); + Controls.Add(labelCount); + Controls.Add(labelName); + Name = "FormCreateOrder"; + Text = "FormCreateOrder"; + Load += FormCreateOrder_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelCount; + private Label labelSum; + private TextBox TextBoxCount; + private ComboBox ComboBoxManufacture; + private TextBox TextBoxSum; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs new file mode 100644 index 0000000..bbeb795 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs @@ -0,0 +1,135 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +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 BlacksmithWorkshop +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logicI; + private readonly IOrderLogic _logicO; + public FormCreateOrder(ILogger logger, IManufactureLogic + logicI, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicI = logicI; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка мороженного для заказа"); + try + { + var list = _logicI.ReadList(null); + if (list != null) + { + ComboBoxManufacture.DisplayMember = "ManufactureName"; + ComboBoxManufacture.ValueMember = "Id"; + ComboBoxManufacture.DataSource = list; + ComboBoxManufacture.SelectedItem = null; + } + _logger.LogInformation("Мороженное загружено"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки мороженного"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + + } + private void CalcSum() + { + if (ComboBoxManufacture.SelectedValue != null && + !string.IsNullOrEmpty(TextBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(ComboBoxManufacture.SelectedValue); + var Manufacture = _logicI.ReadElement(new ManufactureSearchModel + { + Id = id + }); + int count = Convert.ToInt32(TextBoxCount.Text); + TextBoxSum.Text = Math.Round(count * (Manufacture?.Price ?? 0), + 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void TextBoxSum_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void SaveButton_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(TextBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (ComboBoxManufacture.SelectedValue == null) + { + MessageBox.Show("Выберите мороженное", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + ManufactureId = Convert.ToInt32(ComboBoxManufacture.SelectedValue), + Count = Convert.ToInt32(TextBoxCount.Text), + Sum = Convert.ToDouble(TextBoxSum.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void CancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.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 -- 2.25.1 From 1c5b348723a5ec10d51aafa15f177bcff9f764cc Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 19:52:14 +0400 Subject: [PATCH 05/18] FormMain --- .../FormCreateOrder.Designer.cs | 2 +- .../BlacksmithWorkshop/FormCreateOrder.cs | 1 - .../BlacksmithWorkshop/FormMain.Designer.cs | 170 ++++++++++++++++++ .../BlacksmithWorkshop/FormMain.cs | 167 +++++++++++++++++ .../BlacksmithWorkshop/FormMain.resx | 123 +++++++++++++ 5 files changed, 461 insertions(+), 2 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormMain.resx diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs index e3eb734..c5d615d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs @@ -125,7 +125,7 @@ Controls.Add(labelCount); Controls.Add(labelName); Name = "FormCreateOrder"; - Text = "FormCreateOrder"; + Text = "Заказ"; Load += FormCreateOrder_Load; ResumeLayout(false); PerformLayout(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs index bbeb795..956c47d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs @@ -48,7 +48,6 @@ namespace BlacksmithWorkshop MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } private void CalcSum() { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs new file mode 100644 index 0000000..57f26e2 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -0,0 +1,170 @@ +namespace BlacksmithWorkshop +{ + partial class FormMain + { + /// + /// 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() + { + menuStrip = new MenuStrip(); + GuidesToolStripMenuItem = new ToolStripMenuItem(); + ComponentsToolStripMenuItem = new ToolStripMenuItem(); + ManufactureToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonRefresh = new Button(); + buttonIssued = new Button(); + buttonReady = new Button(); + buttonTakeInWork = new Button(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(800, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // GuidesToolStripMenuItem + // + GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufactureToolStripMenuItem }); + GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem"; + GuidesToolStripMenuItem.Size = new Size(94, 20); + GuidesToolStripMenuItem.Text = "Справочники"; + // + // ComponentsToolStripMenuItem + // + ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; + ComponentsToolStripMenuItem.Size = new Size(180, 22); + ComponentsToolStripMenuItem.Text = "Компоненты"; + ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; + // + // ManufactureToolStripMenuItem + // + ManufactureToolStripMenuItem.Name = "ManufactureToolStripMenuItem"; + ManufactureToolStripMenuItem.Size = new Size(180, 22); + ManufactureToolStripMenuItem.Text = "Изделия"; + ManufactureToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 23); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(627, 427); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(640, 44); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(148, 31); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += CreateOrderButton_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(640, 192); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(148, 31); + buttonRefresh.TabIndex = 3; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += RefreshButton_Click; + // + // buttonIssued + // + buttonIssued.Location = new Point(640, 155); + buttonIssued.Name = "buttonIssued"; + buttonIssued.Size = new Size(148, 31); + buttonIssued.TabIndex = 4; + buttonIssued.Text = "Заказ выдан"; + buttonIssued.UseVisualStyleBackColor = true; + buttonIssued.Click += IssuedButton_Click; + // + // buttonReady + // + buttonReady.Location = new Point(640, 118); + buttonReady.Name = "buttonReady"; + buttonReady.Size = new Size(148, 31); + buttonReady.TabIndex = 5; + buttonReady.Text = "Заказ готов"; + buttonReady.UseVisualStyleBackColor = true; + buttonReady.Click += ReadyButton_Click; + // + // buttonTakeInWork + // + buttonTakeInWork.Location = new Point(640, 81); + buttonTakeInWork.Name = "buttonTakeInWork"; + buttonTakeInWork.Size = new Size(148, 31); + buttonTakeInWork.TabIndex = 6; + buttonTakeInWork.Text = "Отдать на выполнение"; + buttonTakeInWork.UseVisualStyleBackColor = true; + buttonTakeInWork.Click += TakeInWorkButton_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(buttonTakeInWork); + Controls.Add(buttonReady); + Controls.Add(buttonIssued); + Controls.Add(buttonRefresh); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Кузница"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem GuidesToolStripMenuItem; + private ToolStripMenuItem ComponentsToolStripMenuItem; + private ToolStripMenuItem ManufactureToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonRefresh; + private Button buttonIssued; + private Button buttonReady; + private Button buttonTakeInWork; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs new file mode 100644 index 0000000..89406f5 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -0,0 +1,167 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopDataModels.Enums; +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 BlacksmithWorkshop +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void ComponentsStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["IceCreamId"].Visible = false; + dataGridView.Columns["IceCreamName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ManufacturesStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); + if (service is FormManufacture form) + { + form.ShowDialog(); + } + } + private void CreateOrderButton_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) + { + return new OrderBindingModel + { + Id = id, + ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }; + } + private void TakeInWorkButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ReadyButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); + try + { + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void IssuedButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); + try + { + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void RefreshButton_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.resx new file mode 100644 index 0000000..6c82d08 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file -- 2.25.1 From ef50028365826373d24bd723e6fb841ad680e9f5 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 20:07:41 +0400 Subject: [PATCH 06/18] FormManufactures --- .../BlacksmithWorkshop/FormComponent.cs | 3 +- .../FormManufactures.Designer.cs | 113 +++++++++++++++++ .../BlacksmithWorkshop/FormManufactures.cs | 106 ++++++++++++++++ .../BlacksmithWorkshop/FormManufactures.resx | 120 ++++++++++++++++++ .../BlacksmithWorkshop/Program.cs | 4 +- 5 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.resx diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs index 05fa8db..1cca08c 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs @@ -11,8 +11,7 @@ namespace BlacksmithWorkshop private readonly IComponentLogic _logic; private int? _id; public int Id { set { _id = value; } } - public FormComponent(ILogger logger, IComponentLogic - logic) + public FormComponent(ILogger logger, IComponentLogic logic) { InitializeComponent(); _logger = logger; diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs new file mode 100644 index 0000000..c211b94 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs @@ -0,0 +1,113 @@ +namespace BlacksmithWorkshop +{ + partial class FormManufactures + { + /// + /// 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() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonChange = new Button(); + buttonDelete = new Button(); + buttonRefresh = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(1, 0); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(468, 450); + dataGridView.TabIndex = 6; + // + // buttonAdd + // + buttonAdd.Location = new Point(489, 21); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(118, 29); + buttonAdd.TabIndex = 7; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += AddButton_Click; + // + // buttonChange + // + buttonChange.Location = new Point(489, 56); + buttonChange.Name = "buttonChange"; + buttonChange.Size = new Size(118, 29); + buttonChange.TabIndex = 8; + buttonChange.Text = "Изменить"; + buttonChange.UseVisualStyleBackColor = true; + buttonChange.Click += UpdateButton_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(489, 91); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(118, 29); + buttonDelete.TabIndex = 9; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += DeleteButton_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(489, 126); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(118, 29); + buttonRefresh.TabIndex = 10; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += RefreshButton_Click; + // + // FormManufactures + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(619, 450); + Controls.Add(buttonRefresh); + Controls.Add(buttonDelete); + Controls.Add(buttonChange); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormManufactures"; + Text = "Изделия"; + Load += FormManufactures_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonChange; + private Button buttonDelete; + private Button buttonRefresh; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs new file mode 100644 index 0000000..fd1fd92 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs @@ -0,0 +1,106 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.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 BlacksmithWorkshop +{ + public partial class FormManufactures : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logic; + public FormManufactures(ILogger logger, IManufactureLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormManufactures_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ManufactureComponents"].Visible = false; + } + _logger.LogInformation("Загрузка мороженого"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки мороженого"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void AddButton_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); + if (service is FormManufacture form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void UpdateButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); + if (service is FormManufacture form) + { + var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void DeleteButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление мороженого"); + try + { + if (!_logic.Delete(new ManufactureBindingModel { Id = id })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления мороженого"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void RefreshButton_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.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/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index bd22a4b..72ed2a7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -41,10 +41,10 @@ namespace BlacksmithWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file -- 2.25.1 From dfd99f386e7d3fc355001410c2eed84baae615e5 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 20:21:10 +0400 Subject: [PATCH 07/18] some minor fixes --- .../BlacksmithWorkshop/FormMain.Designer.cs | 20 +++++++++---------- .../BlacksmithWorkshop/FormMain.cs | 4 ++-- .../BlacksmithWorkshop/Program.cs | 2 ++ .../ViewModels/OrderViewModel.cs | 1 - 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 57f26e2..34ec0da 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -47,7 +47,7 @@ menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(800, 24); + menuStrip.Size = new Size(1011, 24); menuStrip.TabIndex = 0; menuStrip.Text = "menuStrip1"; // @@ -61,14 +61,14 @@ // ComponentsToolStripMenuItem // ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; - ComponentsToolStripMenuItem.Size = new Size(180, 22); + ComponentsToolStripMenuItem.Size = new Size(145, 22); ComponentsToolStripMenuItem.Text = "Компоненты"; ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; // // ManufactureToolStripMenuItem // ManufactureToolStripMenuItem.Name = "ManufactureToolStripMenuItem"; - ManufactureToolStripMenuItem.Size = new Size(180, 22); + ManufactureToolStripMenuItem.Size = new Size(145, 22); ManufactureToolStripMenuItem.Text = "Изделия"; ManufactureToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; // @@ -78,12 +78,12 @@ dataGridView.Location = new Point(0, 23); dataGridView.Name = "dataGridView"; dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(627, 427); + dataGridView.Size = new Size(847, 427); dataGridView.TabIndex = 1; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(640, 44); + buttonCreateOrder.Location = new Point(853, 38); buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Size = new Size(148, 31); buttonCreateOrder.TabIndex = 2; @@ -93,7 +93,7 @@ // // buttonRefresh // - buttonRefresh.Location = new Point(640, 192); + buttonRefresh.Location = new Point(853, 186); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(148, 31); buttonRefresh.TabIndex = 3; @@ -103,7 +103,7 @@ // // buttonIssued // - buttonIssued.Location = new Point(640, 155); + buttonIssued.Location = new Point(853, 149); buttonIssued.Name = "buttonIssued"; buttonIssued.Size = new Size(148, 31); buttonIssued.TabIndex = 4; @@ -113,7 +113,7 @@ // // buttonReady // - buttonReady.Location = new Point(640, 118); + buttonReady.Location = new Point(853, 112); buttonReady.Name = "buttonReady"; buttonReady.Size = new Size(148, 31); buttonReady.TabIndex = 5; @@ -123,7 +123,7 @@ // // buttonTakeInWork // - buttonTakeInWork.Location = new Point(640, 81); + buttonTakeInWork.Location = new Point(853, 75); buttonTakeInWork.Name = "buttonTakeInWork"; buttonTakeInWork.Size = new Size(148, 31); buttonTakeInWork.TabIndex = 6; @@ -135,7 +135,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(1011, 450); Controls.Add(buttonTakeInWork); Controls.Add(buttonReady); Controls.Add(buttonIssued); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 89406f5..9148d1f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -45,8 +45,8 @@ namespace BlacksmithWorkshop if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["IceCreamId"].Visible = false; - dataGridView.Columns["IceCreamName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ManufactureId"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 72ed2a7..65045db 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -3,6 +3,8 @@ using BlacksmithWorkshopContracts.BusinessLogicsContracts; using BlacksmithWorkshopContracts.StoragesContracts; using BlacksmithWorkshopListImplement.Implements; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; using System; namespace BlacksmithWorkshop diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs index f02826f..4bb1c48 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs @@ -13,7 +13,6 @@ namespace BlacksmithWorkshopContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - public int ManufactureId { get; set; } [DisplayName("Изделие")] public string ManufactureName { get; set; } = string.Empty; -- 2.25.1 From c935268db6f83ad9ca731cdea3007648c7cf3990 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 20:34:40 +0400 Subject: [PATCH 08/18] some minor fixes --- BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs | 8 ++++---- BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs | 4 ++-- BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs | 8 ++++---- .../BusinessLogics/ManufactureLogic.cs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs index 956c47d..36ff2dd 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs @@ -29,7 +29,7 @@ namespace BlacksmithWorkshop } private void FormCreateOrder_Load(object sender, EventArgs e) { - _logger.LogInformation("Загрузка мороженного для заказа"); + _logger.LogInformation("Загрузка кузнечных изделий для заказа"); try { var list = _logicI.ReadList(null); @@ -40,11 +40,11 @@ namespace BlacksmithWorkshop ComboBoxManufacture.DataSource = list; ComboBoxManufacture.SelectedItem = null; } - _logger.LogInformation("Мороженное загружено"); + _logger.LogInformation("Кузнечные изделий загружено"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки мороженного"); + _logger.LogError(ex, "Ошибка загрузки кузнечных изделий"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -92,7 +92,7 @@ namespace BlacksmithWorkshop } if (ComboBoxManufacture.SelectedValue == null) { - MessageBox.Show("Выберите мороженное", "Ошибка", + MessageBox.Show("Выберите кузнечных изделий", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 9148d1f..7174015 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -58,8 +58,8 @@ namespace BlacksmithWorkshop } private void ManufacturesStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); + if (service is FormManufactures form) { form.ShowDialog(); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs index fd1fd92..0752cfc 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs @@ -39,11 +39,11 @@ namespace BlacksmithWorkshop dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ManufactureComponents"].Visible = false; } - _logger.LogInformation("Загрузка мороженого"); + _logger.LogInformation("Загрузка кузнечных изделий"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки мороженого"); + _logger.LogError(ex, "Ошибка загрузки кузнечных изделий"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -81,7 +81,7 @@ namespace BlacksmithWorkshop if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление мороженого"); + _logger.LogInformation("Удаление кузнечных изделий"); try { if (!_logic.Delete(new ManufactureBindingModel { Id = id })) @@ -92,7 +92,7 @@ namespace BlacksmithWorkshop } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления мороженого"); + _logger.LogError(ex, "Ошибка удаления кузнечных изделий"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs index 5c4e861..f7c82e8 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ManufactureLogic.cs @@ -93,12 +93,12 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics } if (string.IsNullOrEmpty(model.ManufactureName)) { - throw new ArgumentNullException("Нет названия мороженного", + throw new ArgumentNullException("Нет названия кузнечного изделия", nameof(model.ManufactureName)); } if (model.Price <= 0) { - throw new ArgumentNullException("Цена мороженного должна быть больше 0", nameof(model.Price)); + throw new ArgumentNullException("Цена кузнечных изделий должна быть больше 0", nameof(model.Price)); } _logger.LogInformation("Manufacture. Manufacture:{Manufacture}. Price:{ Price }. Id: { Id}", model.ManufactureName, model.Price, model.Id); var element = _ManufactureStorage.GetElement(new ManufactureSearchModel -- 2.25.1 From 90935ab1645a1470d94ec605c307b4ff77a968b1 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 20:41:00 +0400 Subject: [PATCH 09/18] some minor fixes --- .../BlacksmithWorkshop/FormCreateOrder.cs | 2 +- .../BlacksmithWorkshop/FormMain.Designer.cs | 6 +++--- .../BlacksmithWorkshop/FormManufacture.cs | 10 +++++----- .../BlacksmithWorkshop/FormManufactures.cs | 4 ++-- .../ViewModels/ManufactureViewModel.cs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs index 36ff2dd..e610485 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs @@ -40,7 +40,7 @@ namespace BlacksmithWorkshop ComboBoxManufacture.DataSource = list; ComboBoxManufacture.SelectedItem = null; } - _logger.LogInformation("Кузнечные изделий загружено"); + _logger.LogInformation("Кузнечные изделия загружены"); } catch (Exception ex) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 34ec0da..4dabbf6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -61,15 +61,15 @@ // ComponentsToolStripMenuItem // ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; - ComponentsToolStripMenuItem.Size = new Size(145, 22); + ComponentsToolStripMenuItem.Size = new Size(181, 22); ComponentsToolStripMenuItem.Text = "Компоненты"; ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; // // ManufactureToolStripMenuItem // ManufactureToolStripMenuItem.Name = "ManufactureToolStripMenuItem"; - ManufactureToolStripMenuItem.Size = new Size(145, 22); - ManufactureToolStripMenuItem.Text = "Изделия"; + ManufactureToolStripMenuItem.Size = new Size(181, 22); + ManufactureToolStripMenuItem.Text = "Кузнечные изделия"; ManufactureToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; // // dataGridView diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs index 80b8f7b..92a6d68 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs @@ -33,7 +33,7 @@ namespace BlacksmithWorkshop { if (_id.HasValue) { - _logger.LogInformation("Загрузка изделия"); + _logger.LogInformation("Загрузка кузнечного изделия"); try { var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); @@ -48,7 +48,7 @@ namespace BlacksmithWorkshop } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки изделия"); + _logger.LogError(ex, "Ошибка загрузки кузнечного изделия"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -56,7 +56,7 @@ namespace BlacksmithWorkshop } private void LoadData() { - _logger.LogInformation("Загрузка компонент изделия"); + _logger.LogInformation("Загрузка компонентов кузнечного изделия"); try { if (_manufactureComponents != null) @@ -73,7 +73,7 @@ namespace BlacksmithWorkshop } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + _logger.LogError(ex, "Ошибка загрузки компонентов кузнечного изделия"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -170,7 +170,7 @@ namespace BlacksmithWorkshop MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение изделия"); + _logger.LogInformation("Сохранение кузнечного изделия"); try { var model = new ManufactureBindingModel diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs index 0752cfc..98c512c 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs @@ -81,7 +81,7 @@ namespace BlacksmithWorkshop if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление кузнечных изделий"); + _logger.LogInformation("Удаление кузнечного изделия"); try { if (!_logic.Delete(new ManufactureBindingModel { Id = id })) @@ -92,7 +92,7 @@ namespace BlacksmithWorkshop } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления кузнечных изделий"); + _logger.LogError(ex, "Ошибка удаления кузнечного изделия"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs index 8fad94d..64ac3a9 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs @@ -11,7 +11,7 @@ namespace BlacksmithWorkshopContracts.ViewModels public class ManufactureViewModel : IManufactureModel { public int Id { get; set; } - [DisplayName("Название изделия")] + [DisplayName("Название кузнечного изделия")] public string ManufactureName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } -- 2.25.1 From c24016026901a2f3dd4a5af5731c80e7e3f935fe Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sat, 10 Feb 2024 20:45:14 +0400 Subject: [PATCH 10/18] some minor fixes --- BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs | 2 +- BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs | 2 +- .../BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs index e610485..6f5f157 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs @@ -92,7 +92,7 @@ namespace BlacksmithWorkshop } if (ComboBoxManufacture.SelectedValue == null) { - MessageBox.Show("Выберите кузнечных изделий", "Ошибка", + MessageBox.Show("Выберите кузнечное изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs index 92a6d68..3fa92b1 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs @@ -193,7 +193,7 @@ namespace BlacksmithWorkshop } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения изделия"); + _logger.LogError(ex, "Ошибка сохранения кузнечного изделия"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs index 4bb1c48..654cade 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs @@ -14,7 +14,7 @@ namespace BlacksmithWorkshopContracts.ViewModels [DisplayName("Номер")] public int Id { get; set; } public int ManufactureId { get; set; } - [DisplayName("Изделие")] + [DisplayName("Кузнечное изделие")] public string ManufactureName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } -- 2.25.1 From 506eeedab041f29530a29ccf936fcb5f71cd7477 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 11 Feb 2024 16:59:47 +0400 Subject: [PATCH 11/18] some minor fixes in forms --- .../FormComponents.Designer.cs | 10 ++--- .../FormCreateOrder.Designer.cs | 1 + .../BlacksmithWorkshop/FormMain.Designer.cs | 16 +++---- .../FormManufacture.Designer.cs | 45 ++++++++++--------- .../BlacksmithWorkshop/FormManufacture.resx | 2 +- .../FormManufactureComponent.Designer.cs | 1 + .../FormManufactures.Designer.cs | 12 ++--- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs index 50c50a4..88ae3f3 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs @@ -38,7 +38,7 @@ // // buttonAdd // - buttonAdd.Location = new Point(487, 16); + buttonAdd.Location = new Point(474, 12); buttonAdd.Name = "buttonAdd"; buttonAdd.Size = new Size(118, 29); buttonAdd.TabIndex = 1; @@ -48,7 +48,7 @@ // // buttonChange // - buttonChange.Location = new Point(487, 51); + buttonChange.Location = new Point(474, 47); buttonChange.Name = "buttonChange"; buttonChange.Size = new Size(118, 29); buttonChange.TabIndex = 2; @@ -58,7 +58,7 @@ // // buttonDelete // - buttonDelete.Location = new Point(487, 86); + buttonDelete.Location = new Point(474, 82); buttonDelete.Name = "buttonDelete"; buttonDelete.Size = new Size(118, 29); buttonDelete.TabIndex = 3; @@ -68,7 +68,7 @@ // // buttonRefresh // - buttonRefresh.Location = new Point(487, 121); + buttonRefresh.Location = new Point(474, 117); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(118, 29); buttonRefresh.TabIndex = 4; @@ -89,7 +89,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(619, 450); + ClientSize = new Size(600, 450); Controls.Add(dataGridView); Controls.Add(buttonRefresh); Controls.Add(buttonDelete); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs index c5d615d..cbe89a7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs @@ -75,6 +75,7 @@ // // ComboBoxManufacture // + ComboBoxManufacture.DropDownStyle = ComboBoxStyle.DropDownList; ComboBoxManufacture.FormattingEnabled = true; ComboBoxManufacture.Location = new Point(125, 14); ComboBoxManufacture.Name = "ComboBoxManufacture"; diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 4dabbf6..eb45662 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -31,7 +31,7 @@ menuStrip = new MenuStrip(); GuidesToolStripMenuItem = new ToolStripMenuItem(); ComponentsToolStripMenuItem = new ToolStripMenuItem(); - ManufactureToolStripMenuItem = new ToolStripMenuItem(); + ManufacturesToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); buttonRefresh = new Button(); @@ -53,7 +53,7 @@ // // GuidesToolStripMenuItem // - GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufactureToolStripMenuItem }); + GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem }); GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem"; GuidesToolStripMenuItem.Size = new Size(94, 20); GuidesToolStripMenuItem.Text = "Справочники"; @@ -65,12 +65,12 @@ ComponentsToolStripMenuItem.Text = "Компоненты"; ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; // - // ManufactureToolStripMenuItem + // ManufacturesToolStripMenuItem // - ManufactureToolStripMenuItem.Name = "ManufactureToolStripMenuItem"; - ManufactureToolStripMenuItem.Size = new Size(181, 22); - ManufactureToolStripMenuItem.Text = "Кузнечные изделия"; - ManufactureToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; + ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem"; + ManufacturesToolStripMenuItem.Size = new Size(181, 22); + ManufacturesToolStripMenuItem.Text = "Кузнечные изделия"; + ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; // // dataGridView // @@ -159,7 +159,7 @@ private MenuStrip menuStrip; private ToolStripMenuItem GuidesToolStripMenuItem; private ToolStripMenuItem ComponentsToolStripMenuItem; - private ToolStripMenuItem ManufactureToolStripMenuItem; + private ToolStripMenuItem ManufacturesToolStripMenuItem; private DataGridView dataGridView; private Button buttonCreateOrder; private Button buttonRefresh; diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs index ab60114..6867046 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs @@ -34,15 +34,15 @@ textBoxPrice = new TextBox(); groupBoxComponents = new GroupBox(); dataGridView = new DataGridView(); - ColumnId = new DataGridViewTextBoxColumn(); - ColumnName = new DataGridViewTextBoxColumn(); - ColumnPrice = new DataGridViewTextBoxColumn(); buttonRefresh = new Button(); buttonDelete = new Button(); buttonChange = new Button(); buttonAdd = new Button(); buttonSave = new Button(); buttonCancel = new Button(); + ColumnId = new DataGridViewTextBoxColumn(); + ColumnName = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -76,6 +76,7 @@ // textBoxPrice.Location = new Point(106, 38); textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.ReadOnly = true; textBoxPrice.Size = new Size(289, 23); textBoxPrice.TabIndex = 3; // @@ -97,30 +98,13 @@ // dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnPrice }); + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnCount }); dataGridView.Location = new Point(11, 23); dataGridView.Name = "dataGridView"; dataGridView.RowTemplate.Height = 25; dataGridView.Size = new Size(439, 256); dataGridView.TabIndex = 5; // - // ColumnId - // - ColumnId.HeaderText = "Идентификатор"; - ColumnId.Name = "ColumnId"; - ColumnId.Visible = false; - // - // ColumnName - // - ColumnName.FillWeight = 200F; - ColumnName.HeaderText = "Компонент"; - ColumnName.Name = "ColumnName"; - // - // ColumnPrice - // - ColumnPrice.HeaderText = "Стоимость"; - ColumnPrice.Name = "ColumnPrice"; - // // buttonRefresh // buttonRefresh.Location = new Point(470, 137); @@ -181,6 +165,23 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; // + // ColumnId + // + ColumnId.HeaderText = "Идентификатор"; + ColumnId.Name = "ColumnId"; + ColumnId.Visible = false; + // + // ColumnName + // + ColumnName.FillWeight = 200F; + ColumnName.HeaderText = "Компонент"; + ColumnName.Name = "ColumnName"; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.Name = "ColumnCount"; + // // FormManufacture // AutoScaleDimensions = new SizeF(7F, 15F); @@ -218,6 +219,6 @@ private DataGridView dataGridView; private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ColumnName; - private DataGridViewTextBoxColumn ColumnPrice; + private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx index 4178078..fcacbcb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.resx @@ -123,7 +123,7 @@ True - + True \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs index 6c76c54..250fe8b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs @@ -47,6 +47,7 @@ // // comboBoxComponent // + comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxComponent.FormattingEnabled = true; comboBoxComponent.Location = new Point(93, 6); comboBoxComponent.Name = "comboBoxComponent"; diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs index c211b94..5b26d58 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs @@ -39,7 +39,7 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(1, 0); + dataGridView.Location = new Point(0, 0); dataGridView.Name = "dataGridView"; dataGridView.RowTemplate.Height = 25; dataGridView.Size = new Size(468, 450); @@ -47,7 +47,7 @@ // // buttonAdd // - buttonAdd.Location = new Point(489, 21); + buttonAdd.Location = new Point(474, 12); buttonAdd.Name = "buttonAdd"; buttonAdd.Size = new Size(118, 29); buttonAdd.TabIndex = 7; @@ -57,7 +57,7 @@ // // buttonChange // - buttonChange.Location = new Point(489, 56); + buttonChange.Location = new Point(474, 47); buttonChange.Name = "buttonChange"; buttonChange.Size = new Size(118, 29); buttonChange.TabIndex = 8; @@ -67,7 +67,7 @@ // // buttonDelete // - buttonDelete.Location = new Point(489, 91); + buttonDelete.Location = new Point(474, 82); buttonDelete.Name = "buttonDelete"; buttonDelete.Size = new Size(118, 29); buttonDelete.TabIndex = 9; @@ -77,7 +77,7 @@ // // buttonRefresh // - buttonRefresh.Location = new Point(489, 126); + buttonRefresh.Location = new Point(474, 117); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(118, 29); buttonRefresh.TabIndex = 10; @@ -89,7 +89,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(619, 450); + ClientSize = new Size(600, 450); Controls.Add(buttonRefresh); Controls.Add(buttonDelete); Controls.Add(buttonChange); -- 2.25.1 From 100820bcdb7db39bf6a8a18223be3ca1f678bf93 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 11 Feb 2024 17:06:51 +0400 Subject: [PATCH 12/18] some minor fixes in forms --- .../FormComponents.Designer.cs | 1 + .../FormCreateOrder.Designer.cs | 1 + .../BlacksmithWorkshop/FormMain.Designer.cs | 1 + .../FormManufacture.Designer.cs | 41 ++++++++++--------- .../FormManufactureComponent.Designer.cs | 1 + .../FormManufactures.Designer.cs | 1 + 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs index 88ae3f3..7ed35e2 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.Designer.cs @@ -96,6 +96,7 @@ Controls.Add(buttonChange); Controls.Add(buttonAdd); Name = "FormComponents"; + StartPosition = FormStartPosition.CenterParent; Text = "Компоненты"; Load += ComponentsForm_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs index cbe89a7..666f1bf 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs @@ -126,6 +126,7 @@ Controls.Add(labelCount); Controls.Add(labelName); Name = "FormCreateOrder"; + StartPosition = FormStartPosition.CenterParent; Text = "Заказ"; Load += FormCreateOrder_Load; ResumeLayout(false); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index eb45662..e8e1949 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -145,6 +145,7 @@ Controls.Add(menuStrip); MainMenuStrip = menuStrip; Name = "FormMain"; + StartPosition = FormStartPosition.CenterParent; Text = "Кузница"; Load += FormMain_Load; menuStrip.ResumeLayout(false); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs index 6867046..878c8ba 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.Designer.cs @@ -34,15 +34,15 @@ textBoxPrice = new TextBox(); groupBoxComponents = new GroupBox(); dataGridView = new DataGridView(); + ColumnId = new DataGridViewTextBoxColumn(); + ColumnName = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); buttonRefresh = new Button(); buttonDelete = new Button(); buttonChange = new Button(); buttonAdd = new Button(); buttonSave = new Button(); buttonCancel = new Button(); - ColumnId = new DataGridViewTextBoxColumn(); - ColumnName = new DataGridViewTextBoxColumn(); - ColumnCount = new DataGridViewTextBoxColumn(); groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -105,6 +105,23 @@ dataGridView.Size = new Size(439, 256); dataGridView.TabIndex = 5; // + // ColumnId + // + ColumnId.HeaderText = "Идентификатор"; + ColumnId.Name = "ColumnId"; + ColumnId.Visible = false; + // + // ColumnName + // + ColumnName.FillWeight = 200F; + ColumnName.HeaderText = "Компонент"; + ColumnName.Name = "ColumnName"; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.Name = "ColumnCount"; + // // buttonRefresh // buttonRefresh.Location = new Point(470, 137); @@ -165,23 +182,6 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; // - // ColumnId - // - ColumnId.HeaderText = "Идентификатор"; - ColumnId.Name = "ColumnId"; - ColumnId.Visible = false; - // - // ColumnName - // - ColumnName.FillWeight = 200F; - ColumnName.HeaderText = "Компонент"; - ColumnName.Name = "ColumnName"; - // - // ColumnCount - // - ColumnCount.HeaderText = "Количество"; - ColumnCount.Name = "ColumnCount"; - // // FormManufacture // AutoScaleDimensions = new SizeF(7F, 15F); @@ -195,6 +195,7 @@ Controls.Add(labelCost); Controls.Add(labelName); Name = "FormManufacture"; + StartPosition = FormStartPosition.CenterParent; Text = "Изделие"; Load += FormManufacture_Load; groupBoxComponents.ResumeLayout(false); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs index 250fe8b..64d4a64 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactureComponent.Designer.cs @@ -102,6 +102,7 @@ Controls.Add(comboBoxComponent); Controls.Add(labelComponent); Name = "FormManufactureComponent"; + StartPosition = FormStartPosition.CenterParent; Text = "Компонент изделия"; ResumeLayout(false); PerformLayout(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs index 5b26d58..b7dc438 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.Designer.cs @@ -96,6 +96,7 @@ Controls.Add(buttonAdd); Controls.Add(dataGridView); Name = "FormManufactures"; + StartPosition = FormStartPosition.CenterParent; Text = "Изделия"; Load += FormManufactures_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); -- 2.25.1 From 60a4ab19d5ed72866d16d2661ce8b03c5e071ebf Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 11 Feb 2024 18:19:28 +0400 Subject: [PATCH 13/18] some minor fixes --- BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs index 3fa92b1..44f15f2 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufacture.cs @@ -66,7 +66,6 @@ namespace BlacksmithWorkshop { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); - } textBoxPrice.Text = CalcPrice().ToString(); } -- 2.25.1 From 99cbd53f714317b47b5ed5788c2e5a77464d9956 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Tue, 13 Feb 2024 20:15:47 +0400 Subject: [PATCH 14/18] some minor fixes --- .../Implements/ComponentStorage.cs | 2 +- .../Implements/ManufactureStorage.cs | 2 +- .../BlacksmithWorkshopListImplement/Implements/OrderStorage.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs index d1512a1..ce2bba6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ComponentStorage.cs @@ -28,7 +28,7 @@ namespace BlacksmithWorkshopListImplement.Implements return result; } public List GetFilteredList(ComponentSearchModel - model) + model) { var result = new List(); if (string.IsNullOrEmpty(model.ComponentName)) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs index bd338f6..a414c39 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ManufactureStorage.cs @@ -28,7 +28,7 @@ namespace BlacksmithWorkshopListImplement.Implements return result; } public List GetFilteredList(ManufactureSearchModel - model) + model) { var result = new List(); if (string.IsNullOrEmpty(model.ManufactureName)) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs index 409331b..9a73159 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs @@ -28,7 +28,7 @@ namespace BlacksmithWorkshopListImplement.Implements return result; } public List GetFilteredList(OrderSearchModel - model) + model) { var result = new List(); if (!model.Id.HasValue) -- 2.25.1 From ae55218c52f762f27fa4e5eac04a2a898b0df946 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 19 Feb 2024 21:29:12 +0400 Subject: [PATCH 15/18] =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BA=20=D0=BF=D1=83=D0=BB=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshopListImplement/Models/Order .cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs index c49044e..ee69919 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order .cs @@ -43,12 +43,7 @@ namespace BlacksmithWorkshopListImplement.Models { return; } - Id = model.Id; - ManufactureId = model.ManufactureId; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() -- 2.25.1 From 01fbb5cd8338287af9a943c25487984f5a60b1fe Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 19 Feb 2024 21:45:55 +0400 Subject: [PATCH 16/18] =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BA=20=D0=BF=D1=83=D0=BB=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshop/FormMain.Designer.cs | 326 +++++++++--------- .../BlacksmithWorkshop/FormMain.cs | 300 ++++++++-------- 2 files changed, 313 insertions(+), 313 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index e8e1949..d50c30b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -1,171 +1,171 @@ namespace BlacksmithWorkshop { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// 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); - } + /// + /// 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 + #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() - { - menuStrip = new MenuStrip(); - GuidesToolStripMenuItem = new ToolStripMenuItem(); - ComponentsToolStripMenuItem = new ToolStripMenuItem(); - ManufacturesToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonRefresh = new Button(); - buttonIssued = new Button(); - buttonReady = new Button(); - buttonTakeInWork = new Button(); - menuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // menuStrip - // - menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1011, 24); - menuStrip.TabIndex = 0; - menuStrip.Text = "menuStrip1"; - // - // GuidesToolStripMenuItem - // - GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem }); - GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem"; - GuidesToolStripMenuItem.Size = new Size(94, 20); - GuidesToolStripMenuItem.Text = "Справочники"; - // - // ComponentsToolStripMenuItem - // - ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; - ComponentsToolStripMenuItem.Size = new Size(181, 22); - ComponentsToolStripMenuItem.Text = "Компоненты"; - ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; - // - // ManufacturesToolStripMenuItem - // - ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem"; - ManufacturesToolStripMenuItem.Size = new Size(181, 22); - ManufacturesToolStripMenuItem.Text = "Кузнечные изделия"; - ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; - // - // dataGridView - // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 23); - dataGridView.Name = "dataGridView"; - dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(847, 427); - dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(853, 38); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(148, 31); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += CreateOrderButton_Click; - // - // buttonRefresh - // - buttonRefresh.Location = new Point(853, 186); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(148, 31); - buttonRefresh.TabIndex = 3; - buttonRefresh.Text = "Обновить список"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += RefreshButton_Click; - // - // buttonIssued - // - buttonIssued.Location = new Point(853, 149); - buttonIssued.Name = "buttonIssued"; - buttonIssued.Size = new Size(148, 31); - buttonIssued.TabIndex = 4; - buttonIssued.Text = "Заказ выдан"; - buttonIssued.UseVisualStyleBackColor = true; - buttonIssued.Click += IssuedButton_Click; - // - // buttonReady - // - buttonReady.Location = new Point(853, 112); - buttonReady.Name = "buttonReady"; - buttonReady.Size = new Size(148, 31); - buttonReady.TabIndex = 5; - buttonReady.Text = "Заказ готов"; - buttonReady.UseVisualStyleBackColor = true; - buttonReady.Click += ReadyButton_Click; - // - // buttonTakeInWork - // - buttonTakeInWork.Location = new Point(853, 75); - buttonTakeInWork.Name = "buttonTakeInWork"; - buttonTakeInWork.Size = new Size(148, 31); - buttonTakeInWork.TabIndex = 6; - buttonTakeInWork.Text = "Отдать на выполнение"; - buttonTakeInWork.UseVisualStyleBackColor = true; - buttonTakeInWork.Click += TakeInWorkButton_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1011, 450); - Controls.Add(buttonTakeInWork); - Controls.Add(buttonReady); - Controls.Add(buttonIssued); - Controls.Add(buttonRefresh); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip); - MainMenuStrip = menuStrip; - Name = "FormMain"; - StartPosition = FormStartPosition.CenterParent; - Text = "Кузница"; - Load += FormMain_Load; - menuStrip.ResumeLayout(false); - menuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip = new MenuStrip(); + GuidesToolStripMenuItem = new ToolStripMenuItem(); + ComponentsToolStripMenuItem = new ToolStripMenuItem(); + ManufacturesToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonRefresh = new Button(); + buttonIssued = new Button(); + buttonReady = new Button(); + buttonTakeInWork = new Button(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1011, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "Меню"; + // + // GuidesToolStripMenuItem + // + GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem }); + GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem"; + GuidesToolStripMenuItem.Size = new Size(94, 20); + GuidesToolStripMenuItem.Text = "Справочники"; + // + // ComponentsToolStripMenuItem + // + ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; + ComponentsToolStripMenuItem.Size = new Size(181, 22); + ComponentsToolStripMenuItem.Text = "Компоненты"; + ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; + // + // ManufacturesToolStripMenuItem + // + ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem"; + ManufacturesToolStripMenuItem.Size = new Size(181, 22); + ManufacturesToolStripMenuItem.Text = "Кузнечные изделия"; + ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 23); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(847, 427); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(853, 38); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(148, 31); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += CreateOrderButton_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(853, 186); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(148, 31); + buttonRefresh.TabIndex = 3; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += RefreshButton_Click; + // + // buttonIssued + // + buttonIssued.Location = new Point(853, 149); + buttonIssued.Name = "buttonIssued"; + buttonIssued.Size = new Size(148, 31); + buttonIssued.TabIndex = 4; + buttonIssued.Text = "Заказ выдан"; + buttonIssued.UseVisualStyleBackColor = true; + buttonIssued.Click += IssuedButton_Click; + // + // buttonReady + // + buttonReady.Location = new Point(853, 112); + buttonReady.Name = "buttonReady"; + buttonReady.Size = new Size(148, 31); + buttonReady.TabIndex = 5; + buttonReady.Text = "Заказ готов"; + buttonReady.UseVisualStyleBackColor = true; + buttonReady.Click += ReadyButton_Click; + // + // buttonTakeInWork + // + buttonTakeInWork.Location = new Point(853, 75); + buttonTakeInWork.Name = "buttonTakeInWork"; + buttonTakeInWork.Size = new Size(148, 31); + buttonTakeInWork.TabIndex = 6; + buttonTakeInWork.Text = "Отдать на выполнение"; + buttonTakeInWork.UseVisualStyleBackColor = true; + buttonTakeInWork.Click += TakeInWorkButton_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1011, 450); + Controls.Add(buttonTakeInWork); + Controls.Add(buttonReady); + Controls.Add(buttonIssued); + Controls.Add(buttonRefresh); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + StartPosition = FormStartPosition.CenterParent; + Text = "Кузница"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip; - private ToolStripMenuItem GuidesToolStripMenuItem; - private ToolStripMenuItem ComponentsToolStripMenuItem; - private ToolStripMenuItem ManufacturesToolStripMenuItem; - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonRefresh; - private Button buttonIssued; - private Button buttonReady; - private Button buttonTakeInWork; - } + private MenuStrip menuStrip; + private ToolStripMenuItem GuidesToolStripMenuItem; + private ToolStripMenuItem ComponentsToolStripMenuItem; + private ToolStripMenuItem ManufacturesToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonRefresh; + private Button buttonIssued; + private Button buttonReady; + private Button buttonTakeInWork; + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 7174015..1037ae2 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -14,154 +14,154 @@ using System.Windows.Forms; namespace BlacksmithWorkshop { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - } - private void ComponentsStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } - private void LoadData() - { - _logger.LogInformation("Загрузка заказов"); - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void ManufacturesStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); - if (service is FormManufactures form) - { - form.ShowDialog(); - } - } - private void CreateOrderButton_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } - private OrderBindingModel CreateBindingModel(int id, bool isDone = false) - { - return new OrderBindingModel - { - Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), - }; - } - private void TakeInWorkButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void ReadyButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", - id); - try - { - var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void IssuedButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", - id); - try - { - var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void RefreshButton_Click(object sender, EventArgs e) - { - LoadData(); - } - } + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void ComponentsStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ManufactureId"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ManufacturesStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); + if (service is FormManufactures form) + { + form.ShowDialog(); + } + } + private void CreateOrderButton_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) + { + return new OrderBindingModel + { + Id = id, + ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }; + } + private void TakeInWorkButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ReadyButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); + try + { + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void IssuedButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); + try + { + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void RefreshButton_Click(object sender, EventArgs e) + { + LoadData(); + } + } } -- 2.25.1 From b6738ce1a4f942baa45beefb738f3a4d7a94a9fc Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 19 Feb 2024 22:12:06 +0400 Subject: [PATCH 17/18] =?UTF-8?q?Revert=20"=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BA=20=D0=BF=D1=83=D0=BB?= =?UTF-8?q?=D1=83"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 01fbb5cd8338287af9a943c25487984f5a60b1fe. --- .../BlacksmithWorkshop/FormMain.Designer.cs | 326 +++++++++--------- .../BlacksmithWorkshop/FormMain.cs | 300 ++++++++-------- 2 files changed, 313 insertions(+), 313 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index d50c30b..e8e1949 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -1,171 +1,171 @@ namespace BlacksmithWorkshop { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// 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); - } + /// + /// 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 + #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() - { - menuStrip = new MenuStrip(); - GuidesToolStripMenuItem = new ToolStripMenuItem(); - ComponentsToolStripMenuItem = new ToolStripMenuItem(); - ManufacturesToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonRefresh = new Button(); - buttonIssued = new Button(); - buttonReady = new Button(); - buttonTakeInWork = new Button(); - menuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // menuStrip - // - menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1011, 24); - menuStrip.TabIndex = 0; - menuStrip.Text = "Меню"; - // - // GuidesToolStripMenuItem - // - GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem }); - GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem"; - GuidesToolStripMenuItem.Size = new Size(94, 20); - GuidesToolStripMenuItem.Text = "Справочники"; - // - // ComponentsToolStripMenuItem - // - ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; - ComponentsToolStripMenuItem.Size = new Size(181, 22); - ComponentsToolStripMenuItem.Text = "Компоненты"; - ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; - // - // ManufacturesToolStripMenuItem - // - ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem"; - ManufacturesToolStripMenuItem.Size = new Size(181, 22); - ManufacturesToolStripMenuItem.Text = "Кузнечные изделия"; - ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; - // - // dataGridView - // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 23); - dataGridView.Name = "dataGridView"; - dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(847, 427); - dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(853, 38); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(148, 31); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += CreateOrderButton_Click; - // - // buttonRefresh - // - buttonRefresh.Location = new Point(853, 186); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(148, 31); - buttonRefresh.TabIndex = 3; - buttonRefresh.Text = "Обновить список"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += RefreshButton_Click; - // - // buttonIssued - // - buttonIssued.Location = new Point(853, 149); - buttonIssued.Name = "buttonIssued"; - buttonIssued.Size = new Size(148, 31); - buttonIssued.TabIndex = 4; - buttonIssued.Text = "Заказ выдан"; - buttonIssued.UseVisualStyleBackColor = true; - buttonIssued.Click += IssuedButton_Click; - // - // buttonReady - // - buttonReady.Location = new Point(853, 112); - buttonReady.Name = "buttonReady"; - buttonReady.Size = new Size(148, 31); - buttonReady.TabIndex = 5; - buttonReady.Text = "Заказ готов"; - buttonReady.UseVisualStyleBackColor = true; - buttonReady.Click += ReadyButton_Click; - // - // buttonTakeInWork - // - buttonTakeInWork.Location = new Point(853, 75); - buttonTakeInWork.Name = "buttonTakeInWork"; - buttonTakeInWork.Size = new Size(148, 31); - buttonTakeInWork.TabIndex = 6; - buttonTakeInWork.Text = "Отдать на выполнение"; - buttonTakeInWork.UseVisualStyleBackColor = true; - buttonTakeInWork.Click += TakeInWorkButton_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1011, 450); - Controls.Add(buttonTakeInWork); - Controls.Add(buttonReady); - Controls.Add(buttonIssued); - Controls.Add(buttonRefresh); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip); - MainMenuStrip = menuStrip; - Name = "FormMain"; - StartPosition = FormStartPosition.CenterParent; - Text = "Кузница"; - Load += FormMain_Load; - menuStrip.ResumeLayout(false); - menuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip = new MenuStrip(); + GuidesToolStripMenuItem = new ToolStripMenuItem(); + ComponentsToolStripMenuItem = new ToolStripMenuItem(); + ManufacturesToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonRefresh = new Button(); + buttonIssued = new Button(); + buttonReady = new Button(); + buttonTakeInWork = new Button(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1011, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // GuidesToolStripMenuItem + // + GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem }); + GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem"; + GuidesToolStripMenuItem.Size = new Size(94, 20); + GuidesToolStripMenuItem.Text = "Справочники"; + // + // ComponentsToolStripMenuItem + // + ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; + ComponentsToolStripMenuItem.Size = new Size(181, 22); + ComponentsToolStripMenuItem.Text = "Компоненты"; + ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click; + // + // ManufacturesToolStripMenuItem + // + ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem"; + ManufacturesToolStripMenuItem.Size = new Size(181, 22); + ManufacturesToolStripMenuItem.Text = "Кузнечные изделия"; + ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click; + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 23); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(847, 427); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(853, 38); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(148, 31); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += CreateOrderButton_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(853, 186); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(148, 31); + buttonRefresh.TabIndex = 3; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += RefreshButton_Click; + // + // buttonIssued + // + buttonIssued.Location = new Point(853, 149); + buttonIssued.Name = "buttonIssued"; + buttonIssued.Size = new Size(148, 31); + buttonIssued.TabIndex = 4; + buttonIssued.Text = "Заказ выдан"; + buttonIssued.UseVisualStyleBackColor = true; + buttonIssued.Click += IssuedButton_Click; + // + // buttonReady + // + buttonReady.Location = new Point(853, 112); + buttonReady.Name = "buttonReady"; + buttonReady.Size = new Size(148, 31); + buttonReady.TabIndex = 5; + buttonReady.Text = "Заказ готов"; + buttonReady.UseVisualStyleBackColor = true; + buttonReady.Click += ReadyButton_Click; + // + // buttonTakeInWork + // + buttonTakeInWork.Location = new Point(853, 75); + buttonTakeInWork.Name = "buttonTakeInWork"; + buttonTakeInWork.Size = new Size(148, 31); + buttonTakeInWork.TabIndex = 6; + buttonTakeInWork.Text = "Отдать на выполнение"; + buttonTakeInWork.UseVisualStyleBackColor = true; + buttonTakeInWork.Click += TakeInWorkButton_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1011, 450); + Controls.Add(buttonTakeInWork); + Controls.Add(buttonReady); + Controls.Add(buttonIssued); + Controls.Add(buttonRefresh); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + StartPosition = FormStartPosition.CenterParent; + Text = "Кузница"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip; - private ToolStripMenuItem GuidesToolStripMenuItem; - private ToolStripMenuItem ComponentsToolStripMenuItem; - private ToolStripMenuItem ManufacturesToolStripMenuItem; - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonRefresh; - private Button buttonIssued; - private Button buttonReady; - private Button buttonTakeInWork; - } + private MenuStrip menuStrip; + private ToolStripMenuItem GuidesToolStripMenuItem; + private ToolStripMenuItem ComponentsToolStripMenuItem; + private ToolStripMenuItem ManufacturesToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonRefresh; + private Button buttonIssued; + private Button buttonReady; + private Button buttonTakeInWork; + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 1037ae2..7174015 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -14,154 +14,154 @@ using System.Windows.Forms; namespace BlacksmithWorkshop { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - } - private void ComponentsStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } - private void LoadData() - { - _logger.LogInformation("Загрузка заказов"); - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void ManufacturesStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); - if (service is FormManufactures form) - { - form.ShowDialog(); - } - } - private void CreateOrderButton_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } - private OrderBindingModel CreateBindingModel(int id, bool isDone = false) - { - return new OrderBindingModel - { - Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), - }; - } - private void TakeInWorkButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void ReadyButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", - id); - try - { - var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void IssuedButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", - id); - try - { - var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void RefreshButton_Click(object sender, EventArgs e) - { - LoadData(); - } - } + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void ComponentsStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ManufactureId"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ManufacturesStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); + if (service is FormManufactures form) + { + form.ShowDialog(); + } + } + private void CreateOrderButton_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) + { + return new OrderBindingModel + { + Id = id, + ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }; + } + private void TakeInWorkButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ReadyButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); + try + { + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void IssuedButton_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); + try + { + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void RefreshButton_Click(object sender, EventArgs e) + { + LoadData(); + } + } } -- 2.25.1 From 2748bd4934a1db9655f2404c500d7e746d9fc0e6 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 19 Feb 2024 22:13:56 +0400 Subject: [PATCH 18/18] =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BA=20=D0=BF=D1=83=D0=BB=D1=83=20?= =?UTF-8?q?=D1=873?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index e8e1949..0e7c108 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -49,7 +49,7 @@ menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(1011, 24); menuStrip.TabIndex = 0; - menuStrip.Text = "menuStrip1"; + menuStrip.Text = "Меню"; // // GuidesToolStripMenuItem // -- 2.25.1