diff --git a/JewelryStore/FormComponents.Designer.cs b/JewelryStore/FormComponents.Designer.cs
new file mode 100644
index 0000000..5a76842
--- /dev/null
+++ b/JewelryStore/FormComponents.Designer.cs
@@ -0,0 +1,116 @@
+namespace FurnitureAssemblyView
+{
+ 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()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonChange = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 62;
+ this.dataGridView.RowTemplate.Height = 33;
+ this.dataGridView.Size = new System.Drawing.Size(459, 488);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(480, 25);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(112, 34);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonChange
+ //
+ this.buttonChange.Location = new System.Drawing.Point(481, 67);
+ this.buttonChange.Name = "buttonChange";
+ this.buttonChange.Size = new System.Drawing.Size(112, 34);
+ this.buttonChange.TabIndex = 2;
+ this.buttonChange.Text = "Изменить";
+ this.buttonChange.UseVisualStyleBackColor = true;
+ this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(481, 107);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(112, 34);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(481, 147);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(112, 34);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // FormComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(614, 488);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonChange);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormComponents";
+ this.Text = "Компоненты";
+ this.Load += new System.EventHandler(this.FormComponents_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonChange;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/JewelryStore/FormComponents.cs b/JewelryStore/FormComponents.cs
new file mode 100644
index 0000000..0df5b91
--- /dev/null
+++ b/JewelryStore/FormComponents.cs
@@ -0,0 +1,121 @@
+
+using JewelryStore;
+using JewelryStoreContracts.BindingModels;
+using JewelryStoreContracts.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 FurnitureAssemblyView
+{
+ 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 FormComponents_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 buttonAdd_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 buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonDelete_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 buttonChange_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();
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/JewelryStore/FormComponents.resx b/JewelryStore/FormComponents.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/JewelryStore/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