diff --git a/MotorPlant/MotorPlantView/FormEngine.Designer.cs b/MotorPlant/MotorPlantView/FormEngine.Designer.cs
new file mode 100644
index 0000000..1bf1c4f
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngine.Designer.cs
@@ -0,0 +1,235 @@
+namespace MotorPlantView.Forms
+{
+ partial class FormEngine
+ {
+ ///
+ /// 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()
+ {
+ label1 = new Label();
+ label2 = new Label();
+ buttonAdd = new Button();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonRef = new Button();
+ dataGridView = new DataGridView();
+ Number = new DataGridViewTextBoxColumn();
+ Component = new DataGridViewTextBoxColumn();
+ Count = new DataGridViewTextBoxColumn();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ groupBox1 = new GroupBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ groupBox1.SuspendLayout();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(16, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(62, 15);
+ label1.TabIndex = 0;
+ label1.Text = "Название:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(16, 41);
+ label2.Name = "label2";
+ label2.Size = new Size(70, 15);
+ label2.TabIndex = 1;
+ label2.Text = "Стоимость:";
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(574, 44);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(97, 28);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(574, 90);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(97, 28);
+ buttonUpd.TabIndex = 1;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(574, 134);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(97, 28);
+ buttonDel.TabIndex = 2;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(574, 173);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(97, 28);
+ buttonRef.TabIndex = 3;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { Number, Component, Count });
+ dataGridView.Location = new Point(0, 20);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 24;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.ShowEditingIcon = false;
+ dataGridView.Size = new Size(549, 332);
+ dataGridView.TabIndex = 4;
+ //
+ // Number
+ //
+ Number.HeaderText = "Номер";
+ Number.MinimumWidth = 6;
+ Number.Name = "Number";
+ Number.ReadOnly = true;
+ Number.Width = 60;
+ //
+ // Component
+ //
+ Component.HeaderText = "Компонент";
+ Component.MinimumWidth = 6;
+ Component.Name = "Component";
+ Component.ReadOnly = true;
+ Component.Width = 125;
+ //
+ // Count
+ //
+ Count.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ Count.HeaderText = "Количество";
+ Count.MinimumWidth = 6;
+ Count.Name = "Count";
+ Count.ReadOnly = true;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(94, 14);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(246, 23);
+ textBoxName.TabIndex = 3;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(94, 39);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.ReadOnly = true;
+ textBoxPrice.Size = new Size(85, 23);
+ textBoxPrice.TabIndex = 4;
+ textBoxPrice.TabStop = false;
+ //
+ // groupBox1
+ //
+ groupBox1.Controls.Add(buttonRef);
+ groupBox1.Controls.Add(buttonDel);
+ groupBox1.Controls.Add(dataGridView);
+ groupBox1.Controls.Add(buttonUpd);
+ groupBox1.Controls.Add(buttonAdd);
+ groupBox1.Location = new Point(14, 71);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new Size(689, 367);
+ groupBox1.TabIndex = 5;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Компоненты";
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(397, 454);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(114, 28);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(533, 454);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(114, 28);
+ buttonCancel.TabIndex = 0;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormEngine
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(711, 497);
+ Controls.Add(groupBox1);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(label2);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(label1);
+ Name = "FormEngine";
+ Text = "Двигатель";
+ Load += FormEngine_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ groupBox1.ResumeLayout(false);
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox groupBox1;
+ private DataGridViewTextBoxColumn Number;
+ private DataGridViewTextBoxColumn Component;
+ private DataGridViewTextBoxColumn Count;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/MotorPlant/MotorPlantView/FormEngine.cs b/MotorPlant/MotorPlantView/FormEngine.cs
new file mode 100644
index 0000000..f58811c
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngine.cs
@@ -0,0 +1,196 @@
+using Microsoft.Extensions.Logging;
+using MotorPlantDataModels.Models;
+using MotorPlantContracts.BusinessLogicsContracts;
+using MotorPlantContracts.SearchModels;
+using MotorPlantContracts.BindingModels;
+
+namespace MotorPlantView.Forms
+{
+ public partial class FormEngine : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IEngineLogic _logic;
+ private int? _id;
+ private Dictionary _productComponents;
+ public int Id { set { _id = value; } }
+ public FormEngine(ILogger logger, IEngineLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _productComponents = new Dictionary();
+ }
+ private void FormEngine_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new EngineSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.EngineName;
+ textBoxPrice.Text = view.Price.ToString();
+ _productComponents = view.EngineComponents ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_productComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _productComponents)
+ {
+ dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
+ }
+ textBoxPrice.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонент изделия");
+ }
+ }
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormEngineComponent));
+ if (service is FormEngineComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count);
+ if (_productComponents.ContainsKey(form.Id))
+ {
+ _productComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+ else
+ {
+ _productComponents.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(FormEngineComponent));
+ if (service is FormEngineComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _productComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ _productComponents[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);
+ _productComponents?.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 (_productComponents == null || _productComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new EngineBindingModel
+ {
+ Id = _id ?? 0,
+ EngineName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ EngineComponents = _productComponents
+ };
+ 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 _productComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/MotorPlant/MotorPlantView/FormEngine.resx b/MotorPlant/MotorPlantView/FormEngine.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngine.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/MotorPlant/MotorPlantView/FormEngineComponent.Designer.cs b/MotorPlant/MotorPlantView/FormEngineComponent.Designer.cs
new file mode 100644
index 0000000..a8c8d3b
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngineComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace MotorPlantView.Forms
+{
+ partial class FormEngineComponent
+ {
+ ///
+ /// 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()
+ {
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ comboBoxComponent = new ComboBox();
+ textBoxCount = new TextBox();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(174, 75);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(86, 27);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(270, 75);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(86, 27);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 14);
+ label1.Name = "label1";
+ label1.Size = new Size(72, 15);
+ label1.TabIndex = 2;
+ label1.Text = "Компонент:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(12, 44);
+ label2.Name = "label2";
+ label2.Size = new Size(75, 15);
+ label2.TabIndex = 3;
+ label2.Text = "Количество:";
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(106, 9);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(250, 23);
+ comboBoxComponent.TabIndex = 4;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(106, 44);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(250, 23);
+ textBoxCount.TabIndex = 5;
+ //
+ // FormEngineComponent
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(373, 112);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormEngineComponent";
+ Text = "Компонент двигателя";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label label1;
+ private Label label2;
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ }
+}
\ No newline at end of file
diff --git a/MotorPlant/MotorPlantView/FormEngineComponent.cs b/MotorPlant/MotorPlantView/FormEngineComponent.cs
new file mode 100644
index 0000000..71aefa2
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngineComponent.cs
@@ -0,0 +1,80 @@
+using MotorPlantContracts.BusinessLogicsContracts;
+using MotorPlantContracts.ViewModels;
+using MotorPlantDataModels.Models;
+
+namespace MotorPlantView.Forms
+{
+ public partial class FormEngineComponent : 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 FormEngineComponent(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/MotorPlant/MotorPlantView/FormEngineComponent.resx b/MotorPlant/MotorPlantView/FormEngineComponent.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngineComponent.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/MotorPlant/MotorPlantView/FormEngines.Designer.cs b/MotorPlant/MotorPlantView/FormEngines.Designer.cs
new file mode 100644
index 0000000..d31538e
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngines.Designer.cs
@@ -0,0 +1,116 @@
+namespace MotorPlantView.Forms
+{
+ partial class FormEngines
+ {
+ ///
+ /// 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()
+ {
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(648, 135);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(112, 26);
+ buttonRef.TabIndex = 9;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(648, 97);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(112, 26);
+ buttonDel.TabIndex = 8;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(648, 58);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(112, 26);
+ buttonUpd.TabIndex = 7;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(648, 20);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(112, 26);
+ buttonAdd.TabIndex = 6;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(-1, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 24;
+ dataGridView.Size = new Size(620, 426);
+ dataGridView.TabIndex = 5;
+ //
+ // FormEngines
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(783, 428);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Margin = new Padding(3, 2, 3, 2);
+ Name = "FormEngines";
+ Text = "Список двигателей";
+ Load += FormEngines_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/MotorPlant/MotorPlantView/FormEngines.cs b/MotorPlant/MotorPlantView/FormEngines.cs
new file mode 100644
index 0000000..7e129dc
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngines.cs
@@ -0,0 +1,105 @@
+using Microsoft.Extensions.Logging;
+using MotorPlantContracts.BindingModels;
+using MotorPlantContracts.BusinessLogicsContracts;
+
+namespace MotorPlantView.Forms
+{
+ public partial class FormEngines : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IEngineLogic _logic;
+ public FormEngines(ILogger logger, IEngineLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormEngines_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["EngineComponents"].Visible = false;
+ dataGridView.Columns["EngineName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка компонентов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ }
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormEngine));
+ if (service is FormEngine form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormEngine));
+ if (service is FormEngine form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDel_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 EngineBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления записи");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/MotorPlant/MotorPlantView/FormEngines.resx b/MotorPlant/MotorPlantView/FormEngines.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/MotorPlant/MotorPlantView/FormEngines.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/MotorPlant/MotorPlantView/FormMain.Designer.cs b/MotorPlant/MotorPlantView/FormMain.Designer.cs
index f2d40ff..eb3bef1 100644
--- a/MotorPlant/MotorPlantView/FormMain.Designer.cs
+++ b/MotorPlant/MotorPlantView/FormMain.Designer.cs
@@ -31,7 +31,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
toolStrip1 = new ToolStrip();
toolStripDropDownButton1 = new ToolStripDropDownButton();
- компонентыToolStripMenuItem = new ToolStripMenuItem();
+ КомпонентыToolStripMenuItem = new ToolStripMenuItem();
ДвигателиToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
@@ -56,26 +56,26 @@
// toolStripDropDownButton1
//
toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text;
- toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ДвигателиToolStripMenuItem });
+ toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, ДвигателиToolStripMenuItem });
toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image");
toolStripDropDownButton1.ImageTransparentColor = Color.Magenta;
toolStripDropDownButton1.Name = "toolStripDropDownButton1";
toolStripDropDownButton1.Size = new Size(88, 22);
toolStripDropDownButton1.Text = "Справочник";
//
- // компонентыToolStripMenuItem
+ // КомпонентыToolStripMenuItem
//
- компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- компонентыToolStripMenuItem.Size = new Size(174, 22);
- компонентыToolStripMenuItem.Text = "Компоненты";
- компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
+ КомпонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ КомпонентыToolStripMenuItem.Size = new Size(174, 22);
+ КомпонентыToolStripMenuItem.Text = "Компоненты";
+ КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
//
// ДвигателиToolStripMenuItem
//
ДвигателиToolStripMenuItem.Name = "ДвигателиToolStripMenuItem";
ДвигателиToolStripMenuItem.Size = new Size(174, 22);
- ДвигателиToolStripMenuItem.Text = "Двигатели Внутреннего Сгорания";
- ДвигателиToolStripMenuItem.Click += консервыToolStripMenuItem_Click;
+ ДвигателиToolStripMenuItem.Text = "Двигатели";
+ ДвигателиToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
//
// buttonCreateOrder
//
@@ -171,7 +171,7 @@
private Button buttonRef;
private DataGridView dataGridView;
private ToolStripDropDownButton toolStripDropDownButton1;
- private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem КомпонентыToolStripMenuItem;
private ToolStripMenuItem ДвигателиToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/MotorPlant/MotorPlantView/FormMain.cs b/MotorPlant/MotorPlantView/FormMain.cs
index 8f2d207..9b14b89 100644
--- a/MotorPlant/MotorPlantView/FormMain.cs
+++ b/MotorPlant/MotorPlantView/FormMain.cs
@@ -39,7 +39,7 @@ namespace MotorPlantView.Forms
_logger.LogError(ex, "Ошибка загрузки заказов");
}
}
- private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
@@ -47,7 +47,7 @@ namespace MotorPlantView.Forms
form.ShowDialog();
}
}
- private void консервыToolStripMenuItem_Click(object sender, EventArgs e)
+ private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEngines));
diff --git a/MotorPlant/MotorPlantView/Program.cs b/MotorPlant/MotorPlantView/Program.cs
index f15c73e..015ee8d 100644
--- a/MotorPlant/MotorPlantView/Program.cs
+++ b/MotorPlant/MotorPlantView/Program.cs
@@ -1,11 +1,11 @@
-using MotorPlant.Forms;
+using MotorPlantView.Forms;
using MotorPlantContracts.BusinessLogicsContracts;
-using MotorPlantBusinessLogic.BusinessLogic;
using MotorPlantContracts.StoragesContracts;
using MotorPlantListImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
+using MotorPlantBusinessLogic.BusinessLogics;
namespace MotorPlantView
{