diff --git a/BankExecutor/AbstractBankDataModels/BankExecutorDataModels.csproj b/BankExecutor/AbstractBankDataModels/BankExecutorDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/BankExecutor/AbstractBankDataModels/BankExecutorDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/BankExecutor/AbstractBankDataModels/Enums/OrderStatus.cs b/BankExecutor/AbstractBankDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..4cdc953
--- /dev/null
+++ b/BankExecutor/AbstractBankDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankExecutorDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/BankExecutor/AbstractBankDataModels/IId.cs b/BankExecutor/AbstractBankDataModels/IId.cs
new file mode 100644
index 0000000..d98b105
--- /dev/null
+++ b/BankExecutor/AbstractBankDataModels/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankExecutorDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/BankExecutor/AbstractBankDataModels/Models/IComponentModel.cs b/BankExecutor/AbstractBankDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..e9a877c
--- /dev/null
+++ b/BankExecutor/AbstractBankDataModels/Models/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankExecutorDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/BankExecutor/AbstractBankDataModels/Models/IOrderModel.cs b/BankExecutor/AbstractBankDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..8cace82
--- /dev/null
+++ b/BankExecutor/AbstractBankDataModels/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using BankExecutorDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankExecutorDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int ProductId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/BankExecutor/AbstractBankDataModels/Models/IProductModel.cs b/BankExecutor/AbstractBankDataModels/Models/IProductModel.cs
new file mode 100644
index 0000000..25765a5
--- /dev/null
+++ b/BankExecutor/AbstractBankDataModels/Models/IProductModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankExecutorDataModels.Models
+{
+ public interface IProductModel : IId
+ {
+ string ProductName { get; }
+ double Price { get; }
+ Dictionary ProductComponents { get; }
+ }
+}
diff --git a/BankExecutor/BankExecutor.sln b/BankExecutor/BankExecutor.sln
index 1a426e8..39e3c64 100644
--- a/BankExecutor/BankExecutor.sln
+++ b/BankExecutor/BankExecutor.sln
@@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankExecutor", "BankExecutor\BankExecutor.csproj", "{88CAFAB3-C95B-4118-896A-10794A1C5FBE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorView", "BankExecutor\BankExecutorView.csproj", "{88CAFAB3-C95B-4118-896A-10794A1C5FBE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorDataModels", "AbstractBankDataModels\BankExecutorDataModels.csproj", "{03B275B6-CF13-4B65-973F-059CA2A4709D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorContracts", "BankExecutorContracts\BankExecutorContracts.csproj", "{1FBD781D-AF16-42DE-AE09-E99B898EA0AE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorBusinessLogic", "BankExecutorBusinessLogic\BankExecutorBusinessLogic.csproj", "{6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorListImplement", "BankExecutorListImplement\BankExecutorListImplement.csproj", "{17269B24-6A77-4C45-B3DD-AA444F22D9B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +23,22 @@ Global
{88CAFAB3-C95B-4118-896A-10794A1C5FBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88CAFAB3-C95B-4118-896A-10794A1C5FBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88CAFAB3-C95B-4118-896A-10794A1C5FBE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {03B275B6-CF13-4B65-973F-059CA2A4709D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {03B275B6-CF13-4B65-973F-059CA2A4709D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {03B275B6-CF13-4B65-973F-059CA2A4709D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {03B275B6-CF13-4B65-973F-059CA2A4709D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1FBD781D-AF16-42DE-AE09-E99B898EA0AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1FBD781D-AF16-42DE-AE09-E99B898EA0AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1FBD781D-AF16-42DE-AE09-E99B898EA0AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1FBD781D-AF16-42DE-AE09-E99B898EA0AE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {17269B24-6A77-4C45-B3DD-AA444F22D9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {17269B24-6A77-4C45-B3DD-AA444F22D9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {17269B24-6A77-4C45-B3DD-AA444F22D9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {17269B24-6A77-4C45-B3DD-AA444F22D9B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/BankExecutor/BankExecutor/BankExecutor.csproj b/BankExecutor/BankExecutor/BankExecutor.csproj
deleted file mode 100644
index b57c89e..0000000
--- a/BankExecutor/BankExecutor/BankExecutor.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/BankExecutorView.csproj b/BankExecutor/BankExecutor/BankExecutorView.csproj
new file mode 100644
index 0000000..9b470cc
--- /dev/null
+++ b/BankExecutor/BankExecutor/BankExecutorView.csproj
@@ -0,0 +1,23 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/Form1.Designer.cs b/BankExecutor/BankExecutor/Form1.Designer.cs
deleted file mode 100644
index c6eec8d..0000000
--- a/BankExecutor/BankExecutor/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace BankExecutor
-{
- 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/BankExecutor/BankExecutor/Form1.cs b/BankExecutor/BankExecutor/Form1.cs
deleted file mode 100644
index 91c235d..0000000
--- a/BankExecutor/BankExecutor/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace BankExecutor
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormComponent.Designer.cs b/BankExecutor/BankExecutor/FormComponent.Designer.cs
new file mode 100644
index 0000000..1abb41c
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormComponent.Designer.cs
@@ -0,0 +1,119 @@
+namespace BankExecutorView
+{
+ 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.textBoxCost = new System.Windows.Forms.TextBox();
+ this.labelCost = new System.Windows.Forms.Label();
+ 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(12, 9);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(80, 20);
+ this.labelName.TabIndex = 0;
+ this.labelName.Text = "Название:";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(98, 9);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(366, 27);
+ this.textBoxName.TabIndex = 1;
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(98, 42);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(133, 27);
+ this.textBoxCost.TabIndex = 3;
+ //
+ // labelCost
+ //
+ this.labelCost.AutoSize = true;
+ this.labelCost.Location = new System.Drawing.Point(12, 42);
+ this.labelCost.Name = "labelCost";
+ this.labelCost.Size = new System.Drawing.Size(45, 20);
+ this.labelCost.TabIndex = 2;
+ this.labelCost.Text = "Цена";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(171, 90);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(130, 40);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(328, 90);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(136, 40);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(478, 142);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.labelCost);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelName);
+ this.Name = "FormComponent";
+ this.Text = "Компонент";
+ this.Load += new System.EventHandler(this.FormComponent_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelName;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Label labelCost;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormComponent.cs b/BankExecutor/BankExecutor/FormComponent.cs
new file mode 100644
index 0000000..be0df5c
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormComponent.cs
@@ -0,0 +1,82 @@
+using Microsoft.Extensions.Logging;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.SearchModels;
+using System.Windows.Forms;
+
+namespace BankExecutorView
+{
+ 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/BankExecutor/BankExecutor/FormComponent.resx b/BankExecutor/BankExecutor/FormComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/BankExecutor/BankExecutor/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/BankExecutor/BankExecutor/FormComponents.Designer.cs b/BankExecutor/BankExecutor/FormComponents.Designer.cs
new file mode 100644
index 0000000..1cb3083
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormComponents.Designer.cs
@@ -0,0 +1,130 @@
+namespace BankExecutorView
+{
+ 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.ToolsPanel = new System.Windows.Forms.Panel();
+ 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();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.ToolsPanel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(590, 426);
+ this.dataGridView.TabIndex = 0;
+ //
+ // ToolsPanel
+ //
+ this.ToolsPanel.Controls.Add(this.buttonRef);
+ this.ToolsPanel.Controls.Add(this.buttonDel);
+ this.ToolsPanel.Controls.Add(this.buttonUpd);
+ this.ToolsPanel.Controls.Add(this.buttonAdd);
+ this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
+ this.ToolsPanel.Name = "ToolsPanel";
+ this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
+ this.ToolsPanel.TabIndex = 1;
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(31, 206);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(126, 36);
+ this.buttonRef.TabIndex = 3;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(31, 142);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(126, 36);
+ this.buttonDel.TabIndex = 2;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(31, 76);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(126, 36);
+ this.buttonUpd.TabIndex = 1;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(31, 16);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(126, 36);
+ this.buttonAdd.TabIndex = 0;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // FormComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.ToolsPanel);
+ 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.ToolsPanel.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Panel ToolsPanel;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormComponents.cs b/BankExecutor/BankExecutor/FormComponents.cs
new file mode 100644
index 0000000..a88e92c
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormComponents.cs
@@ -0,0 +1,114 @@
+using Microsoft.Extensions.Logging;
+using BankExecutor;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+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 BankExecutorView
+{
+ 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/BankExecutor/BankExecutor/FormComponents.resx b/BankExecutor/BankExecutor/FormComponents.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/BankExecutor/BankExecutor/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/BankExecutor/BankExecutor/FormCreateOrder.Designer.cs b/BankExecutor/BankExecutor/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..090fe20
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormCreateOrder.Designer.cs
@@ -0,0 +1,151 @@
+namespace BankExecutorView
+{
+ 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()
+ {
+ this.labelProduct = new System.Windows.Forms.Label();
+ this.comboBoxProduct = new System.Windows.Forms.ComboBox();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.labelSum = new System.Windows.Forms.Label();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelProduct
+ //
+ this.labelProduct.AutoSize = true;
+ this.labelProduct.Location = new System.Drawing.Point(10, 11);
+ this.labelProduct.Name = "labelProduct";
+ this.labelProduct.Size = new System.Drawing.Size(59, 15);
+ this.labelProduct.TabIndex = 0;
+ this.labelProduct.Text = "Изделие: ";
+ //
+ // comboBoxProduct
+ //
+ this.comboBoxProduct.FormattingEnabled = true;
+ this.comboBoxProduct.Location = new System.Drawing.Point(101, 9);
+ this.comboBoxProduct.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.comboBoxProduct.Name = "comboBoxProduct";
+ this.comboBoxProduct.Size = new System.Drawing.Size(314, 23);
+ this.comboBoxProduct.TabIndex = 1;
+ this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged);
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(10, 37);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(78, 15);
+ this.labelCount.TabIndex = 2;
+ this.labelCount.Text = "Количество: ";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(101, 34);
+ this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(314, 23);
+ this.textBoxCount.TabIndex = 3;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
+ //
+ // labelSum
+ //
+ this.labelSum.AutoSize = true;
+ this.labelSum.Location = new System.Drawing.Point(10, 60);
+ this.labelSum.Name = "labelSum";
+ this.labelSum.Size = new System.Drawing.Size(51, 15);
+ this.labelSum.TabIndex = 4;
+ this.labelSum.Text = "Сумма: ";
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(101, 60);
+ this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.ReadOnly = true;
+ this.textBoxSum.Size = new System.Drawing.Size(314, 23);
+ this.textBoxSum.TabIndex = 5;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(295, 85);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(96, 24);
+ this.buttonCancel.TabIndex = 6;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(193, 85);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(96, 24);
+ this.buttonSave.TabIndex = 7;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(424, 118);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.labelSum);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.comboBoxProduct);
+ this.Controls.Add(this.labelProduct);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormCreateOrder";
+ this.Text = "Заказ";
+ this.Load += new System.EventHandler(this.FormCreateOrder_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelProduct;
+ private ComboBox comboBoxProduct;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Label labelSum;
+ private TextBox textBoxSum;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormCreateOrder.cs b/BankExecutor/BankExecutor/FormCreateOrder.cs
new file mode 100644
index 0000000..5311811
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormCreateOrder.cs
@@ -0,0 +1,117 @@
+using Microsoft.Extensions.Logging;
+using Microsoft.VisualBasic.Logging;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+using BankExecutorListImplement.Models;
+using System;
+using System.Collections;
+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 BankExecutorView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IProductLogic _logicP;
+ private readonly IOrderLogic _logicO;
+ private List? _list;
+ public FormCreateOrder(ILogger logger, IProductLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _list = _logicP.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxProduct.DisplayMember = "ProductName";
+ comboBoxProduct.ValueMember = "Id";
+ comboBoxProduct.DataSource = _list;
+ comboBoxProduct.SelectedItem = null;
+ _logger.LogInformation("Загрузка изделий для заказа");
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxProduct.SelectedValue);
+ var Product = _logicP.ReadElement(new ProductSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (Product?.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 ComboBoxProduct_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxProduct.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ ProductId = Convert.ToInt32(comboBoxProduct.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 ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/BankExecutor/BankExecutor/FormCreateOrder.resx b/BankExecutor/BankExecutor/FormCreateOrder.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormCreateOrder.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/BankExecutor/BankExecutor/FormMain.Designer.cs b/BankExecutor/BankExecutor/FormMain.Designer.cs
new file mode 100644
index 0000000..60f12b8
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormMain.Designer.cs
@@ -0,0 +1,179 @@
+namespace BankExecutorView
+{
+ 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()
+ {
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.справочникToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonCreateOrder = new System.Windows.Forms.Button();
+ this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
+ this.buttonOrderReady = new System.Windows.Forms.Button();
+ this.buttonIssuedOrder = new System.Windows.Forms.Button();
+ this.buttonRef = new System.Windows.Forms.Button();
+ this.menuStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.справочникToolStripMenuItem});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Size = new System.Drawing.Size(1313, 28);
+ this.menuStrip1.TabIndex = 0;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // справочникToolStripMenuItem
+ //
+ this.справочникToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.компонентыToolStripMenuItem,
+ this.изделияToolStripMenuItem});
+ this.справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
+ this.справочникToolStripMenuItem.Size = new System.Drawing.Size(108, 24);
+ this.справочникToolStripMenuItem.Text = "Справочник";
+ //
+ // компонентыToolStripMenuItem
+ //
+ this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
+ this.компонентыToolStripMenuItem.Text = "Компоненты";
+ this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
+ //
+ // изделияToolStripMenuItem
+ //
+ this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
+ this.изделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
+ this.изделияToolStripMenuItem.Text = "Изделия";
+ this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 31);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(977, 382);
+ this.dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ this.buttonCreateOrder.Location = new System.Drawing.Point(1026, 71);
+ this.buttonCreateOrder.Name = "buttonCreateOrder";
+ this.buttonCreateOrder.Size = new System.Drawing.Size(247, 29);
+ this.buttonCreateOrder.TabIndex = 2;
+ this.buttonCreateOrder.Text = "Создать заказ";
+ this.buttonCreateOrder.UseVisualStyleBackColor = true;
+ this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
+ //
+ // buttonTakeOrderInWork
+ //
+ this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1026, 122);
+ this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ this.buttonTakeOrderInWork.Size = new System.Drawing.Size(247, 29);
+ this.buttonTakeOrderInWork.TabIndex = 3;
+ this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
+ //
+ // buttonOrderReady
+ //
+ this.buttonOrderReady.Location = new System.Drawing.Point(1026, 172);
+ this.buttonOrderReady.Name = "buttonOrderReady";
+ this.buttonOrderReady.Size = new System.Drawing.Size(247, 29);
+ this.buttonOrderReady.TabIndex = 4;
+ this.buttonOrderReady.Text = "Заказ готов";
+ this.buttonOrderReady.UseVisualStyleBackColor = true;
+ this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
+ //
+ // buttonIssuedOrder
+ //
+ this.buttonIssuedOrder.Location = new System.Drawing.Point(1026, 225);
+ this.buttonIssuedOrder.Name = "buttonIssuedOrder";
+ this.buttonIssuedOrder.Size = new System.Drawing.Size(247, 29);
+ this.buttonIssuedOrder.TabIndex = 5;
+ this.buttonIssuedOrder.Text = "Заказ выдан";
+ this.buttonIssuedOrder.UseVisualStyleBackColor = true;
+ this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(1026, 280);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(247, 29);
+ this.buttonRef.TabIndex = 6;
+ this.buttonRef.Text = "Обновить список";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1313, 425);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonIssuedOrder);
+ this.Controls.Add(this.buttonOrderReady);
+ this.Controls.Add(this.buttonTakeOrderInWork);
+ this.Controls.Add(this.buttonCreateOrder);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.menuStrip1);
+ this.MainMenuStrip = this.menuStrip1;
+ this.Name = "FormMain";
+ this.Text = "Завод железобетонных изделий";
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem изделияToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormMain.cs b/BankExecutor/BankExecutor/FormMain.cs
new file mode 100644
index 0000000..8e25977
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormMain.cs
@@ -0,0 +1,157 @@
+using Microsoft.Extensions.Logging;
+using BankExecutor;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+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 BankExecutorView
+{
+ 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 FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["ProductId"].Visible = false;
+ dataGridView.Columns["ProductName"].AutoSizeMode =
+ DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProducts));
+ if (service is FormProducts form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void ButtonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = id
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ No{id}. Меняется статус на 'Готов'",id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = id
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ No{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
+ {
+ Id = id
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ No{id} выдан", id);
+ 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/BankExecutor/BankExecutor/FormMain.resx b/BankExecutor/BankExecutor/FormMain.resx
new file mode 100644
index 0000000..938108a
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormMain.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
diff --git a/BankExecutor/BankExecutor/FormProduct.Designer.cs b/BankExecutor/BankExecutor/FormProduct.Designer.cs
new file mode 100644
index 0000000..1f2cccb
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProduct.Designer.cs
@@ -0,0 +1,237 @@
+namespace BankExecutorView
+{
+ partial class FormProduct
+ {
+ ///
+ /// 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.textBoxPrice = new System.Windows.Forms.TextBox();
+ this.groupBoxComponents = new System.Windows.Forms.GroupBox();
+ 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();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.groupBoxComponents.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(16, 15);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(84, 20);
+ this.labelName.TabIndex = 0;
+ this.labelName.Text = "Название: ";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(112, 12);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(293, 27);
+ this.textBoxName.TabIndex = 1;
+ //
+ // labelPrice
+ //
+ this.labelPrice.AutoSize = true;
+ this.labelPrice.Location = new System.Drawing.Point(16, 51);
+ this.labelPrice.Name = "labelPrice";
+ this.labelPrice.Size = new System.Drawing.Size(90, 20);
+ this.labelPrice.TabIndex = 2;
+ this.labelPrice.Text = "Стоимость: ";
+ //
+ // textBoxPrice
+ //
+ this.textBoxPrice.Location = new System.Drawing.Point(112, 51);
+ this.textBoxPrice.Name = "textBoxPrice";
+ this.textBoxPrice.Size = new System.Drawing.Size(171, 27);
+ this.textBoxPrice.TabIndex = 3;
+ //
+ // groupBoxComponents
+ //
+ this.groupBoxComponents.Controls.Add(this.buttonRef);
+ this.groupBoxComponents.Controls.Add(this.buttonDel);
+ this.groupBoxComponents.Controls.Add(this.buttonUpd);
+ this.groupBoxComponents.Controls.Add(this.buttonAdd);
+ this.groupBoxComponents.Controls.Add(this.dataGridView);
+ this.groupBoxComponents.Location = new System.Drawing.Point(12, 84);
+ this.groupBoxComponents.Name = "groupBoxComponents";
+ this.groupBoxComponents.Size = new System.Drawing.Size(661, 319);
+ this.groupBoxComponents.TabIndex = 4;
+ this.groupBoxComponents.TabStop = false;
+ this.groupBoxComponents.Text = "Компоненты";
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(502, 211);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(126, 34);
+ this.buttonRef.TabIndex = 4;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(502, 157);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(126, 34);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(502, 102);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(126, 34);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(502, 47);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(126, 34);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.id,
+ this.Component,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(6, 26);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(476, 287);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(514, 417);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(126, 34);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(368, 417);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(126, 34);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // id
+ //
+ this.id.HeaderText = "id";
+ this.id.MinimumWidth = 6;
+ this.id.Name = "id";
+ this.id.ReadOnly = true;
+ this.id.Visible = false;
+ //
+ // Component
+ //
+ this.Component.HeaderText = "Компонент";
+ this.Component.MinimumWidth = 6;
+ this.Component.Name = "Component";
+ this.Component.ReadOnly = true;
+ //
+ // Count
+ //
+ this.Count.HeaderText = "Количество";
+ this.Count.MinimumWidth = 6;
+ this.Count.Name = "Count";
+ this.Count.ReadOnly = true;
+ //
+ // FormProduct
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(685, 463);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.groupBoxComponents);
+ this.Controls.Add(this.textBoxPrice);
+ this.Controls.Add(this.labelPrice);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelName);
+ this.Name = "FormProduct";
+ this.Text = "Изделие";
+ this.Load += new System.EventHandler(this.FormProduct_Load);
+ this.groupBoxComponents.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+
+ #endregion
+
+ private Label labelName;
+ private TextBox textBoxName;
+ private Label labelPrice;
+ private TextBox textBoxPrice;
+ private GroupBox groupBoxComponents;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn Component;
+ private DataGridViewTextBoxColumn Count;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private DataGridViewTextBoxColumn id;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormProduct.cs b/BankExecutor/BankExecutor/FormProduct.cs
new file mode 100644
index 0000000..1e92c9b
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProduct.cs
@@ -0,0 +1,214 @@
+using BankExecutorDataModels.Models;
+using BankExecutor;
+using Microsoft.Extensions.Logging;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.SearchModels;
+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 BankExecutorView
+{
+ public partial class FormProduct : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IProductLogic _logic;
+ private int? _id;
+ private Dictionary _ProductComponents;
+ public int Id { set { _id = value; } }
+ public FormProduct(ILogger logger, IProductLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _ProductComponents = new Dictionary();
+ }
+ private void FormProduct_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new ProductSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.ProductName;
+ textBoxPrice.Text = view.Price.ToString();
+ _ProductComponents = view.ProductComponents ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ 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, "Ошибка загрузки компонент изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
+ if (service is FormProductComponent 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(FormProductComponent));
+ if (service is FormProductComponent 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 ProductBindingModel
+ {
+ Id = _id ?? 0,
+ ProductName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ ProductComponents = _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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/Form1.resx b/BankExecutor/BankExecutor/FormProduct.resx
similarity index 100%
rename from BankExecutor/BankExecutor/Form1.resx
rename to BankExecutor/BankExecutor/FormProduct.resx
diff --git a/BankExecutor/BankExecutor/FormProductComponent.Designer.cs b/BankExecutor/BankExecutor/FormProductComponent.Designer.cs
new file mode 100644
index 0000000..ec749ac
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProductComponent.Designer.cs
@@ -0,0 +1,119 @@
+namespace BankExecutorView
+{
+ partial class FormProductComponent
+ {
+ ///
+ /// 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.labelComponent = new System.Windows.Forms.Label();
+ this.comboBoxComponent = new System.Windows.Forms.ComboBox();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelComponent
+ //
+ this.labelComponent.AutoSize = true;
+ this.labelComponent.Location = new System.Drawing.Point(12, 9);
+ this.labelComponent.Name = "labelComponent";
+ this.labelComponent.Size = new System.Drawing.Size(91, 20);
+ this.labelComponent.TabIndex = 0;
+ this.labelComponent.Text = "Компонент:";
+ //
+ // comboBoxComponent
+ //
+ this.comboBoxComponent.FormattingEnabled = true;
+ this.comboBoxComponent.Location = new System.Drawing.Point(119, 9);
+ this.comboBoxComponent.Name = "comboBoxComponent";
+ this.comboBoxComponent.Size = new System.Drawing.Size(355, 28);
+ this.comboBoxComponent.TabIndex = 1;
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 51);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(93, 20);
+ this.labelCount.TabIndex = 2;
+ this.labelCount.Text = "Количество:";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(119, 51);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(355, 27);
+ this.textBoxCount.TabIndex = 3;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(317, 94);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(136, 41);
+ this.buttonCancel.TabIndex = 4;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(175, 94);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(136, 41);
+ this.buttonSave.TabIndex = 5;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // FormProductComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(486, 147);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.comboBoxComponent);
+ this.Controls.Add(this.labelComponent);
+ this.Name = "FormProductComponent";
+ this.Text = "Компонент изделия";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelComponent;
+ private ComboBox comboBoxComponent;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormProductComponent.cs b/BankExecutor/BankExecutor/FormProductComponent.cs
new file mode 100644
index 0000000..4006e6a
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProductComponent.cs
@@ -0,0 +1,84 @@
+using BankExecutorDataModels.Models;
+using Microsoft.VisualBasic.Logging;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.ViewModels;
+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 BankExecutorView
+{
+ public partial class FormProductComponent : 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 FormProductComponent(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/BankExecutor/BankExecutor/FormProductComponent.resx b/BankExecutor/BankExecutor/FormProductComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProductComponent.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/BankExecutor/BankExecutor/FormProducts.Designer.cs b/BankExecutor/BankExecutor/FormProducts.Designer.cs
new file mode 100644
index 0000000..8a10ba1
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProducts.Designer.cs
@@ -0,0 +1,130 @@
+namespace BankExecutorView
+{
+ partial class FormProducts
+ {
+ ///
+ /// 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.ToolsPanel = new System.Windows.Forms.Panel();
+ 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();
+ this.ToolsPanel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // ToolsPanel
+ //
+ this.ToolsPanel.Controls.Add(this.buttonRef);
+ this.ToolsPanel.Controls.Add(this.buttonDel);
+ this.ToolsPanel.Controls.Add(this.buttonUpd);
+ this.ToolsPanel.Controls.Add(this.buttonAdd);
+ this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
+ this.ToolsPanel.Name = "ToolsPanel";
+ this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
+ this.ToolsPanel.TabIndex = 3;
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(31, 206);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(126, 36);
+ this.buttonRef.TabIndex = 3;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(31, 142);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(126, 36);
+ this.buttonDel.TabIndex = 2;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(31, 76);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(126, 36);
+ this.buttonUpd.TabIndex = 1;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(31, 16);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(126, 36);
+ this.buttonAdd.TabIndex = 0;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(590, 426);
+ this.dataGridView.TabIndex = 2;
+ //
+ // FormProducts
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.ToolsPanel);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormProducts";
+ this.Text = "Изделия";
+ this.Load += new System.EventHandler(this.FormProduct_Load);
+ this.ToolsPanel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Panel ToolsPanel;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutor/FormProducts.cs b/BankExecutor/BankExecutor/FormProducts.cs
new file mode 100644
index 0000000..a79ff26
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProducts.cs
@@ -0,0 +1,110 @@
+using Microsoft.Extensions.Logging;
+using BankExecutor;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+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 BankExecutorView
+{
+ public partial class FormProducts : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IProductLogic _logic;
+ public FormProducts(ILogger logger, IProductLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormProduct_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["ProductComponents"].Visible = false;
+ dataGridView.Columns["ProductName"].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(FormProduct));
+ if (service is FormProduct 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(FormProduct));
+ if (service is FormProduct 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 ProductBindingModel
+ {
+ 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/BankExecutor/BankExecutor/FormProducts.resx b/BankExecutor/BankExecutor/FormProducts.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/BankExecutor/BankExecutor/FormProducts.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/BankExecutor/BankExecutor/Program.cs b/BankExecutor/BankExecutor/Program.cs
index b3aa233..8629703 100644
--- a/BankExecutor/BankExecutor/Program.cs
+++ b/BankExecutor/BankExecutor/Program.cs
@@ -1,9 +1,23 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using BankExecutorBusinessLogic.BusinessLogics;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.StoragesContracts;
+using BankExecutorListImplement.Implements;
+using BankExecutorView;
+using System;
+using System.Drawing;
+using BankExecutortBusinessLogic.BusinessLogics;
+
namespace BankExecutor
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
///
- /// The main entry point for the application.
+ /// The main entry point for the application.
///
[STAThread]
static void Main()
@@ -11,7 +25,32 @@ namespace BankExecutor
// 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/BankExecutor/BankExecutor/nlog.config b/BankExecutor/BankExecutor/nlog.config
new file mode 100644
index 0000000..dcd37c8
--- /dev/null
+++ b/BankExecutor/BankExecutor/nlog.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj b/BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj
new file mode 100644
index 0000000..3ed4d1a
--- /dev/null
+++ b/BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ComponentLogic.cs b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..d3b7e21
--- /dev/null
+++ b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,107 @@
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.StoragesContracts;
+using Microsoft.Extensions.Logging;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.ViewModels;
+using BankExecutorContracts.SearchModels;
+
+namespace BankExecutorBusinessLogic.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("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/OrderLogic.cs b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..387bd88
--- /dev/null
+++ b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,114 @@
+using BankExecutorDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.StoragesContracts;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutortBusinessLogic.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. OrderId:{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 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.Count <= 0)
+ {
+ throw new ArgumentException("Колличество изделий в заказе не может быть меньше 1", nameof(model.Count));
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum));
+ }
+ if(model.DateImplement.HasValue && model.DateImplement< model.DateCreate)
+ {
+ throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}");
+ }
+ _logger.LogInformation("Product. ProductId:{ProductId}.Count:{Count}.Sum:{Sum}Id:{Id}",
+ model.ProductId, model.Count,model.Sum, model.Id);
+ }
+ private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) {
+ CheckModel(model, false);
+ var element = _orderStorage.GetElement(new OrderSearchModel()
+ {
+ Id = model.Id
+ });
+ if(element == null)
+ {
+ throw new ArgumentNullException(nameof(element));
+ }
+ model.DateCreate = element.DateCreate;
+ model.ProductId = element.ProductId;
+ model.DateImplement = element.DateImplement;
+ model.Status = element.Status;
+ model.Count = element.Count;
+ model.Sum = element.Sum;
+ if(requiredStatus - model.Status == 1)
+ {
+ model.Status = requiredStatus;
+ if(model.Status == OrderStatus.Выдан)
+ model.DateImplement = DateTime.Now;
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
+ throw new ArgumentException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
+ }
+ }
+}
diff --git a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs
new file mode 100644
index 0000000..669638b
--- /dev/null
+++ b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs
@@ -0,0 +1,111 @@
+using Microsoft.Extensions.Logging;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.BusinessLogicsContracts;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.StoragesContracts;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorBusinessLogic.BusinessLogics
+{
+ public class ProductLogic : IProductLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IProductStorage _ProductStorage;
+ public ProductLogic(ILogger logger, IProductStorage ProductStorage)
+ {
+ _logger = logger;
+ _ProductStorage= ProductStorage;
+ }
+ public List? ReadList(ProductSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ProductName:{ProductName}.Id:{ Id}", model?.ProductName, model?.Id);
+ var list = model == null ? _ProductStorage.GetFullList() : _ProductStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ProductViewModel? ReadElement(ProductSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ProductName:{ProductName}.Id:{ Id}", model.ProductName, model.Id);
+ var element = _ProductStorage.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(ProductBindingModel model)
+ {
+ CheckModel(model);
+ if (_ProductStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ProductBindingModel model)
+ {
+ CheckModel(model);
+ if (_ProductStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ProductBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_ProductStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ProductBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ProductName))
+ {
+ throw new ArgumentNullException("Нет названия изделия", nameof(model.ProductName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
+ }
+ if(model.ProductComponents==null || model.ProductComponents.Count == 0)
+ {
+ throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.ProductComponents));
+ }
+ _logger.LogInformation("Product. ProductName:{ProductName}.Price:{Price}.Id: { Id}", model.ProductName, model.Price, model.Id);
+ var element = _ProductStorage.GetElement(new ProductSearchModel
+ {
+ ProductName = model.ProductName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Изделие с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj b/BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj
new file mode 100644
index 0000000..c232316
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/BankExecutor/BankExecutorContracts/BindingModels/ComponentBindingModel.cs b/BankExecutor/BankExecutorContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..b356102
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,11 @@
+using BankExecutorDataModels.Models;
+
+namespace BankExecutorContracts.BindingModels
+{
+ public class ComponentBindingModel : IComponentModel
+ {
+ public int Id { get; set; }
+ public string ComponentName { get; set; } = string.Empty;
+ public double Cost { get; set; }
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/BindingModels/OrderBindingModel.cs b/BankExecutor/BankExecutorContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..77b757f
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,16 @@
+using BankExecutorDataModels.Enums;
+using BankExecutorDataModels.Models;
+
+namespace BankExecutorContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int ProductId { 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/BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs b/BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs
new file mode 100644
index 0000000..07558ef
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs
@@ -0,0 +1,13 @@
+using BankExecutorDataModels.Models;
+
+namespace BankExecutorContracts.BindingModels
+{
+ public class ProductBindingModel : IProductModel
+ {
+ public int Id { get; set; }
+ public string ProductName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary ProductComponents { get; set; } = new();
+
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IComponentLogic.cs b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..51f214f
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,15 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorContracts.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/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IOrderLogic.cs b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..6fb9045
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,15 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorContracts.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/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs
new file mode 100644
index 0000000..042bf4c
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs
@@ -0,0 +1,15 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorContracts.BusinessLogicsContracts
+{
+ public interface IProductLogic
+ {
+ List? ReadList(ProductSearchModel? model);
+ ProductViewModel? ReadElement(ProductSearchModel model);
+ bool Create(ProductBindingModel model);
+ bool Update(ProductBindingModel model);
+ bool Delete(ProductBindingModel model);
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/SearchModels/ComponentSearchModel.cs b/BankExecutor/BankExecutorContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..43ccea4
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,8 @@
+namespace BankExecutorContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/SearchModels/OrderSearchModel.cs b/BankExecutor/BankExecutorContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..858f1be
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,7 @@
+namespace BankExecutorContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs b/BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs
new file mode 100644
index 0000000..902b09c
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs
@@ -0,0 +1,8 @@
+namespace BankExecutorContracts.SearchModels
+{
+ public class ProductSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ProductName { get; set; }
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/StoragesContracts/IComponentStorage.cs b/BankExecutor/BankExecutorContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..771fbac
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,16 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorContracts.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/BankExecutor/BankExecutorContracts/StoragesContracts/IOrderStorage.cs b/BankExecutor/BankExecutorContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..9204bc3
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,17 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+
+
+namespace BankExecutorContracts.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/BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs b/BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs
new file mode 100644
index 0000000..bfe3848
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs
@@ -0,0 +1,16 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorContracts.StoragesContracts
+{
+ public interface IProductStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ProductSearchModel model);
+ ProductViewModel? GetElement(ProductSearchModel model);
+ ProductViewModel? Insert(ProductBindingModel model);
+ ProductViewModel? Update(ProductBindingModel model);
+ ProductViewModel? Delete(ProductBindingModel model);
+ }
+}
diff --git a/BankExecutor/BankExecutorContracts/ViewModels/ComponentViewModel.cs b/BankExecutor/BankExecutorContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..b05576b
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,14 @@
+using BankExecutorDataModels.Models;
+using System.ComponentModel;
+
+namespace BankExecutorContracts.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/BankExecutor/BankExecutorContracts/ViewModels/OrderViewModel.cs b/BankExecutor/BankExecutorContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..e161c82
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,32 @@
+using BankExecutorDataModels.Enums;
+using BankExecutorDataModels.Models;
+using System.ComponentModel;
+
+namespace BankExecutorContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+
+ public int ProductId { get; set; }
+
+ [DisplayName("Изделие")]
+ public string ProductName { 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/BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs b/BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs
new file mode 100644
index 0000000..6b82665
--- /dev/null
+++ b/BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs
@@ -0,0 +1,15 @@
+using BankExecutorDataModels.Models;
+using System.ComponentModel;
+
+namespace BankExecutorContracts.ViewModels
+{
+ public class ProductViewModel : IProductModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string ProductName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary ProductComponents { get;set;} = new();
+ }
+}
diff --git a/BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj b/BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj
new file mode 100644
index 0000000..bfbea80
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/BankExecutor/BankExecutorListImplement/DataListSingleton.cs b/BankExecutor/BankExecutorListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..3f0b886
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/DataListSingleton.cs
@@ -0,0 +1,27 @@
+using BankExecutorListImplement.Models;
+
+namespace BankExecutorListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Products { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Products = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/BankExecutor/BankExecutorListImplement/Implements/ComponentStorage.cs b/BankExecutor/BankExecutorListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..da09f1e
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,101 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.StoragesContracts;
+using BankExecutorContracts.ViewModels;
+using BankExecutorListImplement.Models;
+
+namespace BankExecutorListImplement.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/BankExecutor/BankExecutorListImplement/Implements/OrderStorage.cs b/BankExecutor/BankExecutorListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..a1c4992
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,114 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.StoragesContracts;
+using BankExecutorContracts.ViewModels;
+using BankExecutorListImplement.Models;
+
+namespace BankExecutorListImplement.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(AttachProductName(order.GetViewModel));
+ }
+ return result;
+ }
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ //А, собственно, этт метод не имеет ценности, так как повторяет функционал следующего
+ var result = new List();
+ if (model == null || !model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(AttachProductName(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 AttachProductName(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 AttachProductName(newOrder.GetViewModel);
+ }
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return AttachProductName(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 AttachProductName(element.GetViewModel);
+ }
+ }
+ return null;
+ }
+ private OrderViewModel AttachProductName(OrderViewModel model)
+ {
+ foreach (var product in _source.Products)
+ {
+ if (product.Id == model.ProductId)
+ {
+ model.ProductName = product.ProductName;
+ return model;
+ }
+ }
+ return model;
+ }
+ }
+}
diff --git a/BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs b/BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs
new file mode 100644
index 0000000..8377442
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs
@@ -0,0 +1,101 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.SearchModels;
+using BankExecutorContracts.StoragesContracts;
+using BankExecutorContracts.ViewModels;
+using BankExecutorListImplement.Models;
+
+namespace BankExecutorListImplement.Implements
+{
+ public class ProductStorage : IProductStorage
+ {
+ private readonly DataListSingleton _source;
+ public ProductStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var products in _source.Products)
+ {
+ result.Add(products.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ProductSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ProductName))
+ {
+ return result;
+ }
+ foreach (var products in _source.Products)
+ {
+ if (products.ProductName.Contains(model.ProductName))
+ {
+ result.Add(products.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public ProductViewModel? GetElement(ProductSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var products in _source.Products)
+ {
+ if ((!string.IsNullOrEmpty(model.ProductName) && products.ProductName == model.ProductName) ||
+ (model.Id.HasValue && products.Id == model.Id))
+ {
+ return products.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ProductViewModel? Insert(ProductBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var products in _source.Products)
+ {
+ if (model.Id <= products.Id)
+ {
+ model.Id = products.Id + 1;
+ }
+ }
+ var newProducts = Product.Create(model);
+ if (newProducts == null)
+ {
+ return null;
+ }
+ _source.Products.Add(newProducts);
+ return newProducts.GetViewModel;
+ }
+ public ProductViewModel? Update(ProductBindingModel model)
+ {
+ foreach (var products in _source.Products)
+ {
+ if (products.Id == model.Id)
+ {
+ products.Update(model);
+ return products.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ProductViewModel? Delete(ProductBindingModel model)
+ {
+ for (int i = 0; i < _source.Products.Count; ++i)
+ {
+ if (_source.Products[i].Id == model.Id)
+ {
+ var element = _source.Products[i];
+ _source.Products.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/BankExecutor/BankExecutorListImplement/Models/Component.cs b/BankExecutor/BankExecutorListImplement/Models/Component.cs
new file mode 100644
index 0000000..b801f43
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/Models/Component.cs
@@ -0,0 +1,41 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.ViewModels;
+using BankExecutorDataModels.Models;
+
+namespace BankExecutorListImplement.Models
+{
+ public class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } = string.Empty;
+ public double Cost { get; private 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/BankExecutor/BankExecutorListImplement/Models/Order.cs b/BankExecutor/BankExecutorListImplement/Models/Order.cs
new file mode 100644
index 0000000..2f7a44c
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/Models/Order.cs
@@ -0,0 +1,58 @@
+using BankExecutorDataModels.Enums;
+using BankExecutorDataModels.Models;
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.ViewModels;
+
+namespace BankExecutorListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int ProductId { get; private set; }
+ public int Count { get; private set; }
+ public double Sum { get; private set; }
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+ public DateTime? DateImplement { get; private set; }
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ ProductId = model.ProductId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ProductId= model.ProductId;
+ Count= model.Count;
+ Sum= model.Sum;
+ Status= model.Status;
+ DateCreate= model.DateCreate;
+ DateImplement= model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ProductId = ProductId,
+ Count= Count,
+ Sum= Sum,
+ Status= Status,
+ DateCreate= DateCreate,
+ DateImplement = DateImplement,
+ };
+ }
+}
diff --git a/BankExecutor/BankExecutorListImplement/Models/Product.cs b/BankExecutor/BankExecutorListImplement/Models/Product.cs
new file mode 100644
index 0000000..fec4fda
--- /dev/null
+++ b/BankExecutor/BankExecutorListImplement/Models/Product.cs
@@ -0,0 +1,45 @@
+using BankExecutorContracts.BindingModels;
+using BankExecutorContracts.ViewModels;
+using BankExecutorDataModels.Models;
+
+namespace BankExecutorListImplement.Models
+{
+ public class Product : IProductModel
+ {
+ public int Id { get; private set; }
+ public string ProductName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary ProductComponents { get; private set;} = new Dictionary();
+ public static Product? Create(ProductBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Product()
+ {
+ Id = model.Id,
+ ProductName = model.ProductName,
+ Price = model.Price,
+ ProductComponents = model.ProductComponents,
+ };
+ }
+ public void Update(ProductBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ProductName = model.ProductName;
+ Price = model.Price;
+ ProductComponents = model.ProductComponents;
+ }
+ public ProductViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ProductName = ProductName,
+ Price = Price,
+ ProductComponents = ProductComponents
+ };
+ }
+}