diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln
index 55a2881..eb09aac 100644
--- a/PrecastConcretePlant/PrecastConcretePlant.sln
+++ b/PrecastConcretePlant/PrecastConcretePlant.sln
@@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantView", "PrecastConcretePlant\PrecastConcretePlantView.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{F97343A9-F725-4447-BB24-6B270785836A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{F97343A9-F725-4447-BB24-6B270785836A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantListImplement", "PrecastConcretePlantListImplement\PrecastConcretePlantListImplement.csproj", "{471A4697-59C0-40C0-8B5E-8BEC01BD20BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,6 +35,10 @@ Global
{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs
deleted file mode 100644
index 5704a3c..0000000
--- a/PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace PrecastConcretePlant
-{
- 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/PrecastConcretePlant/PrecastConcretePlant/Form1.cs b/PrecastConcretePlant/PrecastConcretePlant/Form1.cs
deleted file mode 100644
index 0d56e73..0000000
--- a/PrecastConcretePlant/PrecastConcretePlant/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace PrecastConcretePlant
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlant/Form1.resx b/PrecastConcretePlant/PrecastConcretePlant/Form1.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/PrecastConcretePlant/PrecastConcretePlant/Form1.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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/PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs
new file mode 100644
index 0000000..9285128
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace PrecastConcretePlantView
+{
+ 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()
+ {
+ this.labelName = new System.Windows.Forms.Label();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.labelPrice = new System.Windows.Forms.Label();
+ this.textBoxCost = new System.Windows.Forms.TextBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(37, 29);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(62, 15);
+ this.labelName.TabIndex = 0;
+ this.labelName.Text = "Название:";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(105, 26);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(258, 23);
+ this.textBoxName.TabIndex = 1;
+ //
+ // labelPrice
+ //
+ this.labelPrice.AutoSize = true;
+ this.labelPrice.Location = new System.Drawing.Point(37, 73);
+ this.labelPrice.Name = "labelPrice";
+ this.labelPrice.Size = new System.Drawing.Size(38, 15);
+ this.labelPrice.TabIndex = 2;
+ this.labelPrice.Text = "Цена:";
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(105, 73);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(136, 23);
+ this.textBoxCost.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(207, 111);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 7;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(288, 111);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 6;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(387, 149);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.labelPrice);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelName);
+ this.Name = "FormComponent";
+ this.Text = "FormComponent";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelName;
+ private TextBox textBoxName;
+ private Label labelPrice;
+ private TextBox textBoxCost;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs
new file mode 100644
index 0000000..6be5883
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs
@@ -0,0 +1,86 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ 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/PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs
new file mode 100644
index 0000000..293e0fe
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs
@@ -0,0 +1,120 @@
+namespace PrecastConcretePlantView
+{
+ 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.buttonRef = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonRef
+ //
+ this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRef.Location = new System.Drawing.Point(493, 150);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(90, 37);
+ this.buttonRef.TabIndex = 14;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDel.Location = new System.Drawing.Point(493, 111);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(90, 33);
+ this.buttonDel.TabIndex = 13;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUpd.Location = new System.Drawing.Point(493, 71);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(90, 34);
+ this.buttonUpd.TabIndex = 12;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonAdd.Location = new System.Drawing.Point(493, 35);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(90, 30);
+ this.buttonAdd.TabIndex = 11;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(475, 321);
+ this.dataGridView.TabIndex = 10;
+ //
+ // FormComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(595, 345);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormComponents";
+ this.Text = "FormComponents";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.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/PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs
new file mode 100644
index 0000000..747221f
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs
@@ -0,0 +1,108 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlant;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+
+namespace PrecastConcretePlantView
+{
+ 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 ButtonUpd_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 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 ComponentBindingModel
+ {
+ 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/PrecastConcretePlant/PrecastConcretePlant/FormComponents.resx b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj
deleted file mode 100644
index b57c89e..0000000
--- a/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj
new file mode 100644
index 0000000..9ebf5ea
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj
@@ -0,0 +1,22 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs
index aa81da8..9761986 100644
--- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs
+++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs
@@ -1,7 +1,21 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using PrecastConcretePlantBusinessLogic.BusinessLogic;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.StoragesContract;
+using PrecastConcretePlantListImplement.Implements;
+using PrecastConcretePlantListImplement;
+using PrecastConcretePlantView;
+using ConfectioneryBusinessLogic.BusinessLogic;
+
namespace PrecastConcretePlant
+
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
///
/// The main entry point for the application.
///
@@ -11,7 +25,32 @@ namespace PrecastConcretePlant
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ 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
diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs
index cc7f705..4f7e77d 100644
--- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs
@@ -5,7 +5,7 @@ using PrecastConcretePlantContracts.StoragesContract;
using PrecastConcretePlantContracts.ViewModels;
using Microsoft.Extensions.Logging;
-namespace PrecastConcretePlantBusinessLogic
+namespace PrecastConcretePlantBusinessLogic.BusinessLogic
{
public class ComponentLogic : IComponentLogic
{
diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs
index 786a1b9..ba445b6 100644
--- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs
@@ -6,9 +6,9 @@ using PrecastConcretePlantContracts.StoragesContract;
using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantDataModels.Enums;
-namespace PrecastConcretePlantBusinessLogic
+namespace PrecastConcretePlantBusinessLogic.BusinessLogic
{
- internal class OrderLogic : IOrderLogic
+ public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs
index ae1fe4a..65224b3 100644
--- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs
@@ -5,7 +5,7 @@ using PrecastConcretePlantContracts.StoragesContract;
using PrecastConcretePlantContracts.ViewModels;
using Microsoft.Extensions.Logging;
-namespace ConfectioneryBusinessLogic.BusinessLogics
+namespace ConfectioneryBusinessLogic.BusinessLogic
{
public class ReinforcedLogic : IReinforcedLogic
{
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs
new file mode 100644
index 0000000..36f2067
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs
@@ -0,0 +1,42 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Models;
+
+
+namespace PrecastConcretePlantListImplement.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
+ };
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs
new file mode 100644
index 0000000..7e813e3
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs
@@ -0,0 +1,103 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContract;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantListImplement.Models;
+
+namespace PrecastConcretePlantListImplement.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/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..64027e4
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs
@@ -0,0 +1,26 @@
+using PrecastConcretePlantListImplement.Models;
+
+namespace PrecastConcretePlantListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Reinforced { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Reinforced = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs
new file mode 100644
index 0000000..e860a80
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs
@@ -0,0 +1,67 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Enums;
+using PrecastConcretePlantDataModels.Models;
+
+
+namespace PrecastConcretePlantListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+
+ public int ReinforcedId { 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()
+ {
+ ReinforcedId = model.ReinforcedId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ Id = model.Id,
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ReinforcedId = model.ReinforcedId;
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateCreate = model.DateCreate;
+ DateImplement = model.DateImplement;
+ Id = model.Id;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ ReinforcedId = ReinforcedId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ Id = Id,
+ };
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs
new file mode 100644
index 0000000..9edba7e
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs
@@ -0,0 +1,106 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContract;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantListImplement.Models;
+
+namespace PrecastConcretePlantListImplement
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ 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? 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 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)
+ {
+ return new() { order.GetViewModel };
+ }
+ }
+ return new();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(order.GetViewModel);
+ }
+ return result;
+ }
+
+ 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;
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj
new file mode 100644
index 0000000..3b2c1a9
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs
new file mode 100644
index 0000000..e0163c5
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs
@@ -0,0 +1,49 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Models;
+
+namespace PrecastConcretePlantListImplement.Models
+{
+ public class Reinforced : IReinforcedModel
+ {
+ public int Id { get; private set; }
+ public string ReinforcedName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary ReinforcedComponents
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Reinforced? Create(ReinforcedBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Reinforced()
+ {
+ Id = model.Id,
+ ReinforcedName = model.ReinforcedName,
+ Price = model.Price,
+ ReinforcedComponents = model.ReinforcedComponents
+ };
+ }
+ public void Update(ReinforcedBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ReinforcedName = model.ReinforcedName;
+ Price = model.Price;
+ ReinforcedComponents = model.ReinforcedComponents;
+ }
+ public ReinforcedViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ReinforcedName = ReinforcedName,
+ Price = Price,
+ ReinforcedComponents = ReinforcedComponents
+ };
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs
new file mode 100644
index 0000000..e8356ce
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs
@@ -0,0 +1,108 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContract;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantListImplement.Models;
+
+namespace PrecastConcretePlantListImplement
+{
+ public class ReinforcedStorage : IReinforcedStorage
+ {
+ private readonly DataListSingleton _source;
+ public ReinforcedStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public ReinforcedViewModel? Delete(ReinforcedBindingModel model)
+ {
+ for (int i = 0; i < _source.Reinforced.Count; ++i)
+ {
+ if (_source.Reinforced[i].Id == model.Id)
+ {
+ var element = _source.Reinforced[i];
+ _source.Reinforced.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public ReinforcedViewModel? GetElement(ReinforcedSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ReinforcedName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var reinforced in _source.Reinforced)
+ {
+ if ((!string.IsNullOrEmpty(model.ReinforcedName) &&
+ reinforced.ReinforcedName == model.ReinforcedName) ||
+ (model.Id.HasValue && reinforced.Id == model.Id))
+ {
+ return reinforced.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public List GetFilteredList(ReinforcedSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ReinforcedName))
+ {
+ return result;
+ }
+ foreach (var reinforced in _source.Reinforced)
+ {
+ if (reinforced.ReinforcedName.Contains(model.ReinforcedName ?? string.Empty))
+ {
+ result.Add(reinforced.GetViewModel);
+ }
+ }
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var reinforced in _source.Reinforced)
+ {
+ result.Add(reinforced.GetViewModel);
+ }
+ return result;
+ }
+
+ public ReinforcedViewModel? Insert(ReinforcedBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var reinforced in _source.Reinforced)
+ {
+ if (model.Id <= reinforced.Id)
+ {
+ model.Id = reinforced.Id + 1;
+ }
+ }
+ var newReinforced = Reinforced.Create(model);
+ if (newReinforced == null)
+ {
+ return null;
+ }
+ _source.Reinforced.Add(newReinforced);
+ return newReinforced.GetViewModel;
+ }
+
+ public ReinforcedViewModel? Update(ReinforcedBindingModel model)
+ {
+ foreach (var reinforced in _source.Reinforced)
+ {
+ if (reinforced.Id == model.Id)
+ {
+ reinforced.Update(model);
+ return reinforced.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}