diff --git a/RenovationWork.sln b/RenovationWork.sln
new file mode 100644
index 0000000..5b85026
--- /dev/null
+++ b/RenovationWork.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34024.191
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkView", "RenovationWork\RenovationWorkView.csproj", "{F7DA64D8-ACE1-4703-906A-A25CBD36F7BE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkDataModels", "RenovationWorkDataModels\RenovationWorkDataModels.csproj", "{7B3260AB-0375-4F6A-A1E1-E74228E20DAA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkContracts", "RenovationWorkContracts\RenovationWorkContracts.csproj", "{933A8F36-3513-48F4-848A-635597FDFE1C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkBusinessLogic", "RenovationWorkBusinessLogic\RenovationWorkBusinessLogic.csproj", "{F7FB3E21-1E5E-4271-A22B-53B0E40E1F95}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkListImplement", "RenovationWorkListImplement\RenovationWorkListImplement.csproj", "{5F454425-8555-4E69-A0EC-0EEC94309A06}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F7DA64D8-ACE1-4703-906A-A25CBD36F7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F7DA64D8-ACE1-4703-906A-A25CBD36F7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F7DA64D8-ACE1-4703-906A-A25CBD36F7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F7DA64D8-ACE1-4703-906A-A25CBD36F7BE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7B3260AB-0375-4F6A-A1E1-E74228E20DAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7B3260AB-0375-4F6A-A1E1-E74228E20DAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7B3260AB-0375-4F6A-A1E1-E74228E20DAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7B3260AB-0375-4F6A-A1E1-E74228E20DAA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {933A8F36-3513-48F4-848A-635597FDFE1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {933A8F36-3513-48F4-848A-635597FDFE1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {933A8F36-3513-48F4-848A-635597FDFE1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {933A8F36-3513-48F4-848A-635597FDFE1C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F7FB3E21-1E5E-4271-A22B-53B0E40E1F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F7FB3E21-1E5E-4271-A22B-53B0E40E1F95}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F7FB3E21-1E5E-4271-A22B-53B0E40E1F95}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F7FB3E21-1E5E-4271-A22B-53B0E40E1F95}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5F454425-8555-4E69-A0EC-0EEC94309A06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5F454425-8555-4E69-A0EC-0EEC94309A06}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5F454425-8555-4E69-A0EC-0EEC94309A06}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5F454425-8555-4E69-A0EC-0EEC94309A06}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {91A58B52-1154-47F4-BD3F-13132A90EEB2}
+ EndGlobalSection
+EndGlobal
diff --git a/RenovationWork/FormComponent.Designer.cs b/RenovationWork/FormComponent.Designer.cs
new file mode 100644
index 0000000..411540f
--- /dev/null
+++ b/RenovationWork/FormComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace RenovationWorkView
+{
+ 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()
+ {
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ labelName = new Label();
+ labelCost = new Label();
+ textBoxCost = new TextBox();
+ textBoxComponentName = new TextBox();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(223, 82);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(314, 83);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(11, 9);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(62, 15);
+ labelName.TabIndex = 2;
+ labelName.Text = "Название:";
+ //
+ // labelCost
+ //
+ labelCost.AutoSize = true;
+ labelCost.Location = new Point(11, 45);
+ labelCost.Name = "labelCost";
+ labelCost.Size = new Size(38, 15);
+ labelCost.TabIndex = 3;
+ labelCost.Text = "Цена:";
+ //
+ // textBoxCost
+ //
+ textBoxCost.Location = new Point(79, 45);
+ textBoxCost.Name = "textBoxCost";
+ textBoxCost.Size = new Size(170, 23);
+ textBoxCost.TabIndex = 4;
+ //
+ // textBoxComponentName
+ //
+ textBoxComponentName.Location = new Point(79, 9);
+ textBoxComponentName.Name = "textBoxComponentName";
+ textBoxComponentName.Size = new Size(310, 23);
+ textBoxComponentName.TabIndex = 5;
+ //
+ // FormComponent
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(401, 117);
+ Controls.Add(textBoxComponentName);
+ Controls.Add(textBoxCost);
+ Controls.Add(labelCost);
+ Controls.Add(labelName);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormComponent";
+ Text = "Компонент";
+ Load += FormComponent_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelName;
+ private Label labelCost;
+ private TextBox textBoxCost;
+ private TextBox textBoxComponentName;
+ }
+}
\ No newline at end of file
diff --git a/RenovationWork/FormComponent.cs b/RenovationWork/FormComponent.cs
new file mode 100644
index 0000000..e867ea7
--- /dev/null
+++ b/RenovationWork/FormComponent.cs
@@ -0,0 +1,99 @@
+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;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkView
+{
+ 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)
+ {
+ textBoxComponentName.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(textBoxComponentName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение компонента");
+ try
+ {
+ var model = new ComponentBindingModel
+ {
+ Id = _id ?? 0,
+ ComponentName = textBoxComponentName.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/RenovationWork/FormComponent.resx b/RenovationWork/FormComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/RenovationWork/FormComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RenovationWork/FormComponents.Designer.cs b/RenovationWork/FormComponents.Designer.cs
new file mode 100644
index 0000000..bcb8ac7
--- /dev/null
+++ b/RenovationWork/FormComponents.Designer.cs
@@ -0,0 +1,115 @@
+namespace RenovationWorkView
+{
+ 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()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.GridColor = SystemColors.ButtonHighlight;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(641, 277);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(659, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(126, 23);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(659, 50);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(126, 23);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(659, 88);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(126, 23);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(659, 126);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(126, 23);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(797, 301);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormComponents";
+ Text = "Компоненты";
+ Load += FormComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/RenovationWork/FormComponents.cs b/RenovationWork/FormComponents.cs
new file mode 100644
index 0000000..3d741cf
--- /dev/null
+++ b/RenovationWork/FormComponents.cs
@@ -0,0 +1,113 @@
+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;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkView
+{
+ 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/RenovationWork/FormComponents.resx b/RenovationWork/FormComponents.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/RenovationWork/FormComponents.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RenovationWork/FormCreateOrder.Designer.cs b/RenovationWork/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..5588e28
--- /dev/null
+++ b/RenovationWork/FormCreateOrder.Designer.cs
@@ -0,0 +1,143 @@
+namespace RenovationWorkView
+{
+ 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()
+ {
+ labelComponent = new Label();
+ labelCount = new Label();
+ labelSum = new Label();
+ textBoxSum = new TextBox();
+ textBoxCount = new TextBox();
+ comboBoxRepair = new ComboBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelComponent
+ //
+ labelComponent.AutoSize = true;
+ labelComponent.Location = new Point(12, 6);
+ labelComponent.Name = "labelComponent";
+ labelComponent.Size = new Size(56, 15);
+ labelComponent.TabIndex = 0;
+ labelComponent.Text = "Изделие:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(12, 37);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(75, 15);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // labelSum
+ //
+ labelSum.AutoSize = true;
+ labelSum.Location = new Point(12, 67);
+ labelSum.Name = "labelSum";
+ labelSum.Size = new Size(48, 15);
+ labelSum.TabIndex = 2;
+ labelSum.Text = "Сумма:";
+ //
+ // textBoxSum
+ //
+ textBoxSum.Location = new Point(95, 67);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.Size = new Size(298, 23);
+ textBoxSum.TabIndex = 3;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(95, 37);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(298, 23);
+ textBoxCount.TabIndex = 4;
+ textBoxCount.TextChanged += textBoxCount_TextChanged;
+ //
+ // comboBoxRepair
+ //
+ comboBoxRepair.FormattingEnabled = true;
+ comboBoxRepair.Location = new Point(95, 6);
+ comboBoxRepair.Name = "comboBoxRepair";
+ comboBoxRepair.Size = new Size(298, 23);
+ comboBoxRepair.TabIndex = 5;
+ comboBoxRepair.SelectedIndexChanged += comboBoxRepair_SelectedIndexChanged;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(220, 96);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(311, 96);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(398, 124);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(comboBoxRepair);
+ Controls.Add(textBoxCount);
+ Controls.Add(textBoxSum);
+ Controls.Add(labelSum);
+ Controls.Add(labelCount);
+ Controls.Add(labelComponent);
+ Name = "FormCreateOrder";
+ Text = "Заказ";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelComponent;
+ private Label labelCount;
+ private Label labelSum;
+ private TextBox textBoxSum;
+ private TextBox textBoxCount;
+ private ComboBox comboBoxRepair;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/RenovationWork/FormCreateOrder.cs b/RenovationWork/FormCreateOrder.cs
new file mode 100644
index 0000000..1db4606
--- /dev/null
+++ b/RenovationWork/FormCreateOrder.cs
@@ -0,0 +1,115 @@
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using RenovationWorkListImplement.Models;
+
+namespace RenovationWorkView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IRepairLogic _logicC;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, IRepairLogic logicC, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicC = logicC;
+ _logicO = logicO;
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+ var list = _logicC.ReadList(null);
+ if (list != null)
+ {
+ comboBoxRepair.DisplayMember = "RepairName";
+ comboBoxRepair.ValueMember = "Id";
+ comboBoxRepair.DataSource = list;
+ comboBoxRepair.SelectedItem = null;
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxRepair.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxRepair.SelectedValue);
+ var repair = _logicC.ReadElement(new RepairSearchModel { Id = id });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (repair?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void comboBoxRepair_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void textBoxCount_TextChanged(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 (comboBoxRepair.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ int id = Convert.ToInt32(comboBoxRepair.SelectedValue);
+ int counr = Convert.ToInt32(textBoxCount.Text);
+ double sum = Convert.ToDouble(textBoxSum.Text);
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ RepairId = Convert.ToInt32(comboBoxRepair.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/RenovationWork/FormCreateOrder.resx b/RenovationWork/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/RenovationWork/FormCreateOrder.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RenovationWork/FormMain.Designer.cs b/RenovationWork/FormMain.Designer.cs
new file mode 100644
index 0000000..7e46eda
--- /dev/null
+++ b/RenovationWork/FormMain.Designer.cs
@@ -0,0 +1,171 @@
+namespace RenovationWorkView
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ menuStrip = new MenuStrip();
+ refbooksToolStripMenuItem = new ToolStripMenuItem();
+ componentsToolStripMenuItem = new ToolStripMenuItem();
+ JobTypeToolStripMenuItem = new ToolStripMenuItem();
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonRef = new Button();
+ menuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip
+ //
+ menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(984, 24);
+ menuStrip.TabIndex = 0;
+ menuStrip.Text = "menuStrip1";
+ //
+ // refbooksToolStripMenuItem
+ //
+ refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem });
+ refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem";
+ refbooksToolStripMenuItem.Size = new Size(94, 20);
+ refbooksToolStripMenuItem.Text = "Справочники";
+ //
+ // componentsToolStripMenuItem
+ //
+ componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
+ componentsToolStripMenuItem.Size = new Size(145, 22);
+ componentsToolStripMenuItem.Text = "Компоненты";
+ componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
+ //
+ // JobTypeToolStripMenuItem
+ //
+ JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem";
+ JobTypeToolStripMenuItem.Size = new Size(145, 22);
+ JobTypeToolStripMenuItem.Text = "Вид работы";
+ JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 27);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(797, 341);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(815, 42);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(157, 23);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += buttonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(815, 71);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(157, 23);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отладить на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(815, 100);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(157, 23);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += buttonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(815, 129);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(157, 23);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += buttonIssuedOrder_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(815, 158);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(157, 23);
+ buttonRef.TabIndex = 6;
+ buttonRef.Text = "Обновить список";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(984, 370);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormMain";
+ Text = "Ремонтные работы";
+ Load += FormMain_Load;
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem refbooksToolStripMenuItem;
+ private ToolStripMenuItem componentsToolStripMenuItem;
+ private ToolStripMenuItem JobTypeToolStripMenuItem;
+ 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/RenovationWork/FormMain.cs b/RenovationWork/FormMain.cs
new file mode 100644
index 0000000..d143cbe
--- /dev/null
+++ b/RenovationWork/FormMain.cs
@@ -0,0 +1,159 @@
+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;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkView
+{
+ 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()
+ {
+ _logger.LogInformation("Загрузка заказов");
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["RepairId"].Visible = false;
+ dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void componentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void JobTypeToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormRepairs));
+ if (service is FormRepairs 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("Заказ №{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("Заказ №{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("Заказ №{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
+
diff --git a/RenovationWork/FormMain.resx b/RenovationWork/FormMain.resx
new file mode 100644
index 0000000..6c82d08
--- /dev/null
+++ b/RenovationWork/FormMain.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/RenovationWork/FormRepair.Designer.cs b/RenovationWork/FormRepair.Designer.cs
new file mode 100644
index 0000000..ec5f53a
--- /dev/null
+++ b/RenovationWork/FormRepair.Designer.cs
@@ -0,0 +1,224 @@
+namespace RenovationWorkView
+{
+ partial class FormRepair
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelName = new Label();
+ labelPrice = new Label();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ groupBox = new GroupBox();
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ID = new DataGridViewTextBoxColumn();
+ ComponentT = new DataGridViewTextBoxColumn();
+ CountT = new DataGridViewTextBoxColumn();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ groupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(4, 12);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(62, 15);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(4, 43);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(70, 15);
+ labelPrice.TabIndex = 1;
+ labelPrice.Text = "Стоимость:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(88, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(334, 23);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(88, 43);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(334, 23);
+ textBoxPrice.TabIndex = 3;
+ //
+ // groupBox
+ //
+ groupBox.Controls.Add(buttonRef);
+ groupBox.Controls.Add(buttonDel);
+ groupBox.Controls.Add(buttonUpd);
+ groupBox.Controls.Add(buttonAdd);
+ groupBox.Controls.Add(dataGridView);
+ groupBox.Location = new Point(12, 87);
+ groupBox.Name = "groupBox";
+ groupBox.Size = new Size(763, 351);
+ groupBox.TabIndex = 5;
+ groupBox.TabStop = false;
+ groupBox.Text = "Компоненты";
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(656, 121);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(99, 23);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(656, 92);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(99, 23);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(656, 63);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(99, 23);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(656, 34);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(99, 23);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ComponentT, CountT });
+ dataGridView.Location = new Point(6, 22);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(644, 323);
+ dataGridView.TabIndex = 0;
+ //
+ // ID
+ //
+ ID.HeaderText = "id";
+ ID.Name = "ID";
+ ID.Visible = false;
+ //
+ // ComponentT
+ //
+ ComponentT.HeaderText = "Компонент";
+ ComponentT.Name = "ComponentT";
+ ComponentT.Width = 300;
+ //
+ // CountT
+ //
+ CountT.HeaderText = "Количество";
+ CountT.Name = "CountT";
+ CountT.Width = 300;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(599, 451);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 5;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(692, 451);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 6;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormRepair
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(783, 486);
+ Controls.Add(buttonSave);
+ Controls.Add(buttonCancel);
+ Controls.Add(groupBox);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(labelPrice);
+ Controls.Add(labelName);
+ Name = "FormRepair";
+ Text = "Работа";
+ Load += FormRepair_Load;
+ groupBox.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelPrice;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox groupBox;
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private DataGridViewTextBoxColumn ID;
+ private DataGridViewTextBoxColumn ComponentT;
+ private DataGridViewTextBoxColumn CountT;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/RenovationWork/FormRepair.cs b/RenovationWork/FormRepair.cs
new file mode 100644
index 0000000..777b6cf
--- /dev/null
+++ b/RenovationWork/FormRepair.cs
@@ -0,0 +1,213 @@
+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;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkDataModels.Models;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkView
+{
+ public partial class FormRepair : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IRepairLogic _logic;
+ private int? _id;
+ private Dictionary _repairComponents;
+ public int Id { set { _id = value; } }
+ public FormRepair(ILogger logger, IRepairLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _repairComponents = new Dictionary();
+ }
+
+ private void FormRepair_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new RepairSearchModel { Id = _id.Value });
+ if (view != null)
+ {
+ textBoxName.Text = view.RepairName;
+ textBoxPrice.Text = view.Price.ToString();
+ _repairComponents = view.RepairComponents ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_repairComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _repairComponents)
+ {
+ 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(FormRepairComponent));
+ if (service is FormRepairComponent form)
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_repairComponents.ContainsKey(form.Id))
+ {
+ _repairComponents[form.Id] = (form.ComponentModel,
+ form.Count);
+ }
+ else
+ {
+ _repairComponents.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(FormRepairComponent));
+ if (service is FormRepairComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _repairComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count);
+ _repairComponents[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);
+ _repairComponents?.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 (_repairComponents == null || _repairComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new RepairBindingModel
+ {
+ Id = _id ?? 0,
+ RepairName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ RepairComponents = _repairComponents
+ };
+ 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 _repairComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/RenovationWork/FormRepair.resx b/RenovationWork/FormRepair.resx
new file mode 100644
index 0000000..74d6b1d
--- /dev/null
+++ b/RenovationWork/FormRepair.resx
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/RenovationWork/FormRepairComponent.Designer.cs b/RenovationWork/FormRepairComponent.Designer.cs
new file mode 100644
index 0000000..c38f826
--- /dev/null
+++ b/RenovationWork/FormRepairComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace RenovationWorkView
+{
+ partial class FormRepairComponent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelComponent = new Label();
+ labelCount = new Label();
+ comboBoxComponent = new ComboBox();
+ textBoxCount = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelComponent
+ //
+ labelComponent.AutoSize = true;
+ labelComponent.Location = new Point(9, 9);
+ labelComponent.Name = "labelComponent";
+ labelComponent.Size = new Size(72, 15);
+ labelComponent.TabIndex = 0;
+ labelComponent.Text = "Компонент:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(9, 38);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(75, 15);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(90, 9);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(354, 23);
+ comboBoxComponent.TabIndex = 2;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(90, 38);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(354, 23);
+ textBoxCount.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(288, 76);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(369, 76);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отменить";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormRepairComponent
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(456, 107);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(labelCount);
+ Controls.Add(labelComponent);
+ Name = "FormRepairComponent";
+ Text = "Компонент работы";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelComponent;
+ private Label labelCount;
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/RenovationWork/FormRepairComponent.cs b/RenovationWork/FormRepairComponent.cs
new file mode 100644
index 0000000..01d4ca8
--- /dev/null
+++ b/RenovationWork/FormRepairComponent.cs
@@ -0,0 +1,89 @@
+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;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkDataModels.Models;
+
+namespace RenovationWorkView
+{
+ public partial class FormRepairComponent : 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 FormRepairComponent(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/RenovationWork/FormRepairComponent.resx b/RenovationWork/FormRepairComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/RenovationWork/FormRepairComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RenovationWork/FormRepairs.Designer.cs b/RenovationWork/FormRepairs.Designer.cs
new file mode 100644
index 0000000..638fec6
--- /dev/null
+++ b/RenovationWork/FormRepairs.Designer.cs
@@ -0,0 +1,114 @@
+namespace RenovationWorkView
+{
+ partial class FormRepairs
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(2, 2);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(553, 444);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(561, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(98, 23);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(561, 41);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(98, 23);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(561, 70);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(98, 23);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(561, 99);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(98, 23);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormRepairs
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(671, 448);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormRepairs";
+ Text = "Список работ";
+ Load += FormRepairs_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/RenovationWork/FormRepairs.cs b/RenovationWork/FormRepairs.cs
new file mode 100644
index 0000000..dc8d7f4
--- /dev/null
+++ b/RenovationWork/FormRepairs.cs
@@ -0,0 +1,110 @@
+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;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkView
+{
+ public partial class FormRepairs : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IRepairLogic _logic;
+ public FormRepairs(ILogger logger, IRepairLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormRepairs_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["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["RepairComponents"].Visible = false;
+ }
+ _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(FormRepair));
+ if (service is FormRepair 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(FormRepair));
+ if (service is FormRepair 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 RepairBindingModel { 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/RenovationWork/FormRepairs.resx b/RenovationWork/FormRepairs.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/RenovationWork/FormRepairs.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RenovationWork/Program.cs b/RenovationWork/Program.cs
new file mode 100644
index 0000000..419c2af
--- /dev/null
+++ b/RenovationWork/Program.cs
@@ -0,0 +1,48 @@
+using RenovationWorkBusinessLogic.BusinessLogics;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkListImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
+namespace RenovationWorkView
+{
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ 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/RenovationWork/Properties/Resources.Designer.cs b/RenovationWork/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..5e21999
--- /dev/null
+++ b/RenovationWork/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace RenovationWorkView.Properties {
+ using System;
+
+
+ ///
+ /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
+ ///
+ // Этот класс создан автоматически классом StronglyTypedResourceBuilder
+ // с помощью такого средства, как ResGen или Visual Studio.
+ // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
+ // с параметром /str или перестройте свой проект VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RenovationWorkView.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Перезаписывает свойство CurrentUICulture текущего потока для всех
+ /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/RenovationWork/Properties/Resources.resx b/RenovationWork/Properties/Resources.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/RenovationWork/Properties/Resources.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RenovationWork/RenovationWorkView.csproj b/RenovationWork/RenovationWorkView.csproj
new file mode 100644
index 0000000..f6aa5a9
--- /dev/null
+++ b/RenovationWork/RenovationWorkView.csproj
@@ -0,0 +1,40 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
\ No newline at end of file
diff --git a/RenovationWork/nlog.config b/RenovationWork/nlog.config
new file mode 100644
index 0000000..77b13bf
--- /dev/null
+++ b/RenovationWork/nlog.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RenovationWorkBusinessLogic/BusinessLogics/ComponentLogic.cs b/RenovationWorkBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..6799037
--- /dev/null
+++ b/RenovationWorkBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,108 @@
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkBusinessLogic.BusinessLogics
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentStorage _componentStorage;
+ public ComponentLogic(ILogger logger, IComponentStorage
+ componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+ public List? ReadList(ComponentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
+ var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
+ var element = _componentStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ComponentBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkBusinessLogic/BusinessLogics/OrderLogic.cs b/RenovationWorkBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..b34651d
--- /dev/null
+++ b/RenovationWorkBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkDataModels.Enums;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Insert operation failed. Order status incorrect.");
+ return false;
+ }
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ model.Status = OrderStatus.Неизвестен;
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
+ {
+ var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (viewModel == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (viewModel.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Update operation failed. Order status incorrect.");
+ return false;
+ }
+ model.Status = newStatus;
+ if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
+ else
+ {
+ model.DateImplement = viewModel.DateImplement;
+ }
+ CheckModel(model, false);
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выдан);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+ 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;
+ }
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.RepairId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор документа", nameof(model.RepairId));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество работ в заказе должно быть больше 0", nameof(model.Count));
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
+ }
+ _logger.LogInformation("Order. Count: {Count}. Sum: {Sum}. Id: {Id}", model.Count, model.Sum, model.Id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkBusinessLogic/BusinessLogics/RepairLogic.cs b/RenovationWorkBusinessLogic/BusinessLogics/RepairLogic.cs
new file mode 100644
index 0000000..3301975
--- /dev/null
+++ b/RenovationWorkBusinessLogic/BusinessLogics/RepairLogic.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.BusinessLogicsContracts;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace RenovationWorkBusinessLogic.BusinessLogics
+{
+ public class RepairLogic : IRepairLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IRepairStorage _repairStorage;
+ public RepairLogic(ILogger logger, IRepairStorage repairStorage)
+ {
+ _logger = logger;
+ _repairStorage = repairStorage;
+ }
+ public List? ReadList(RepairSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. RepairName:{RepairName}.Id:{ Id}", model?.RepairName, model?.Id);
+ var list = model == null ? _repairStorage.GetFullList() : _repairStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public RepairViewModel? ReadElement(RepairSearchModel? model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. RepairName:{RepairName}.Id:{ Id}", model.RepairName, model.Id);
+ var element = _repairStorage.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(RepairBindingModel model)
+ {
+ CheckModel(model);
+ if (_repairStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(RepairBindingModel model)
+ {
+ CheckModel(model);
+ if (_repairStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(RepairBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_repairStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(RepairBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.RepairName))
+ {
+ throw new ArgumentNullException("Нет названия компьютера", nameof(model.RepairName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена компьютера должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Repair. RepairName:{RepairName}.Price:{ Price}. Id: { Id} ", model.RepairName, model.Price, model.Id);
+ var element = _repairStorage.GetElement(new RepairSearchModel
+ {
+ RepairName = model.RepairName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компьютер с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/RenovationWorkBusinessLogic/RenovationWorkBusinessLogic.csproj b/RenovationWorkBusinessLogic/RenovationWorkBusinessLogic.csproj
new file mode 100644
index 0000000..62a4b97
--- /dev/null
+++ b/RenovationWorkBusinessLogic/RenovationWorkBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RenovationWorkContracts/BindingModels/ComponentBindingModel.cs b/RenovationWorkContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..350a457
--- /dev/null
+++ b/RenovationWorkContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,12 @@
+using RenovationWorkDataModels.Models;
+
+namespace RenovationWorkContracts.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/RenovationWorkContracts/BindingModels/OrderBindingModel.cs b/RenovationWorkContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..483a273
--- /dev/null
+++ b/RenovationWorkContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkDataModels.Enums;
+using RenovationWorkDataModels.Models;
+
+
+namespace RenovationWorkContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int RepairId { 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; }
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkContracts/BindingModels/RepairBindingModel.cs b/RenovationWorkContracts/BindingModels/RepairBindingModel.cs
new file mode 100644
index 0000000..4491dd7
--- /dev/null
+++ b/RenovationWorkContracts/BindingModels/RepairBindingModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkDataModels.Models;
+
+namespace RenovationWorkContracts.BindingModels
+{
+ public class RepairBindingModel : IRepairModel
+ {
+ public int Id { get; set; }
+ public string RepairName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary RepairComponents { get; set; } = new();
+ }
+}
diff --git a/RenovationWorkContracts/BusinessLogicsContracts/IComponentLogic.cs b/RenovationWorkContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..a4726c5
--- /dev/null
+++ b/RenovationWorkContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.ViewModels;
+
+namespace RenovationWorkContracts.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/RenovationWorkContracts/BusinessLogicsContracts/IOrderLogic.cs b/RenovationWorkContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..ce60d67
--- /dev/null
+++ b/RenovationWorkContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.ViewModels;
+
+namespace RenovationWorkContracts.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/RenovationWorkContracts/BusinessLogicsContracts/IRepairLogic.cs b/RenovationWorkContracts/BusinessLogicsContracts/IRepairLogic.cs
new file mode 100644
index 0000000..46433e9
--- /dev/null
+++ b/RenovationWorkContracts/BusinessLogicsContracts/IRepairLogic.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.ViewModels;
+
+namespace RenovationWorkContracts.BusinessLogicsContracts
+{
+ public interface IRepairLogic
+ {
+ List? ReadList(RepairSearchModel? model);
+ RepairViewModel? ReadElement(RepairSearchModel model);
+ bool Create(RepairBindingModel model);
+ bool Update(RepairBindingModel model);
+ bool Delete(RepairBindingModel model);
+ }
+}
diff --git a/RenovationWorkContracts/RenovationWorkContracts.csproj b/RenovationWorkContracts/RenovationWorkContracts.csproj
new file mode 100644
index 0000000..96ab30f
--- /dev/null
+++ b/RenovationWorkContracts/RenovationWorkContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/RenovationWorkContracts/SearchModels/ComponentSearchModel.cs b/RenovationWorkContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..b2f3639
--- /dev/null
+++ b/RenovationWorkContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkContracts/SearchModels/OrderSearchModel.cs b/RenovationWorkContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..1d07126
--- /dev/null
+++ b/RenovationWorkContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
+
diff --git a/RenovationWorkContracts/SearchModels/RepairSearchModel.cs b/RenovationWorkContracts/SearchModels/RepairSearchModel.cs
new file mode 100644
index 0000000..15d1906
--- /dev/null
+++ b/RenovationWorkContracts/SearchModels/RepairSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkContracts.SearchModels
+{
+ public class RepairSearchModel
+ {
+ public int? Id { get; set; }
+ public string? RepairName { get; set; }
+ }
+}
diff --git a/RenovationWorkContracts/StoragesContracts/IComponentStorage.cs b/RenovationWorkContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..f10b3e4
--- /dev/null
+++ b/RenovationWorkContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.ViewModels;
+
+namespace RenovationWorkContracts.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/RenovationWorkContracts/StoragesContracts/IOrderStorage.cs b/RenovationWorkContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..d7e583d
--- /dev/null
+++ b/RenovationWorkContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.ViewModels;
+
+namespace RenovationWorkContracts.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/RenovationWorkContracts/StoragesContracts/IRepairStorage.cs b/RenovationWorkContracts/StoragesContracts/IRepairStorage.cs
new file mode 100644
index 0000000..b360537
--- /dev/null
+++ b/RenovationWorkContracts/StoragesContracts/IRepairStorage.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.ViewModels;
+
+namespace RenovationWorkContracts.StoragesContracts
+{
+ public interface IRepairStorage
+ {
+ List GetFullList();
+ List GetFilteredList(RepairSearchModel model);
+ RepairViewModel? GetElement(RepairSearchModel model);
+ RepairViewModel? Insert(RepairBindingModel model);
+ RepairViewModel? Update(RepairBindingModel model);
+ RepairViewModel? Delete(RepairBindingModel model);
+ }
+}
diff --git a/RenovationWorkContracts/ViewModels/ComponentViewModel.cs b/RenovationWorkContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..2ff68d6
--- /dev/null
+++ b/RenovationWorkContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkDataModels.Models;
+using System.ComponentModel;
+
+
+namespace RenovationWorkContracts.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/RenovationWorkContracts/ViewModels/OrderViewModel.cs b/RenovationWorkContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..102e7e9
--- /dev/null
+++ b/RenovationWorkContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkDataModels.Enums;
+using RenovationWorkDataModels.Models;
+using System.ComponentModel;
+
+
+namespace RenovationWorkContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int RepairId { get; set; }
+ [DisplayName("Изделие")]
+ public string RepairName { 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; }
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkContracts/ViewModels/RepairViewModel.cs b/RenovationWorkContracts/ViewModels/RepairViewModel.cs
new file mode 100644
index 0000000..9ba0548
--- /dev/null
+++ b/RenovationWorkContracts/ViewModels/RepairViewModel.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkDataModels.Models;
+using System.ComponentModel;
+
+namespace RenovationWorkContracts.ViewModels
+{
+ public class RepairViewModel : IRepairModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string RepairName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary RepairComponents { get; set; } = new();
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkDataModels/Enums/OrderStatus.cs b/RenovationWorkDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..a401b60
--- /dev/null
+++ b/RenovationWorkDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/RenovationWorkDataModels/IId.cs b/RenovationWorkDataModels/IId.cs
new file mode 100644
index 0000000..4718473
--- /dev/null
+++ b/RenovationWorkDataModels/IId.cs
@@ -0,0 +1,8 @@
+namespace RenovationWorkDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+
+ }
+}
\ No newline at end of file
diff --git a/RenovationWorkDataModels/Models/IComponentModel.cs b/RenovationWorkDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..852d354
--- /dev/null
+++ b/RenovationWorkDataModels/Models/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/RenovationWorkDataModels/Models/IOrderModel.cs b/RenovationWorkDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..7a2279d
--- /dev/null
+++ b/RenovationWorkDataModels/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using RenovationWorkDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int RepairId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/RenovationWorkDataModels/Models/IRepairModel.cs b/RenovationWorkDataModels/Models/IRepairModel.cs
new file mode 100644
index 0000000..19080ab
--- /dev/null
+++ b/RenovationWorkDataModels/Models/IRepairModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RenovationWorkDataModels.Models
+{
+ public interface IRepairModel : IId
+ {
+ string RepairName { get; }
+ double Price { get; }
+ Dictionary RepairComponents { get; }
+ }
+}
diff --git a/RenovationWorkDataModels/RenovationWorkDataModels.csproj b/RenovationWorkDataModels/RenovationWorkDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/RenovationWorkDataModels/RenovationWorkDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/RenovationWorkListImplement/DataListSingleton.cs b/RenovationWorkListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..c1e46cf
--- /dev/null
+++ b/RenovationWorkListImplement/DataListSingleton.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkListImplement.Models;
+
+namespace RenovationWorkListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Repairs { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Repairs = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/RenovationWorkListImplement/Implements/ComponentStorage.cs b/RenovationWorkListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..0f8848b
--- /dev/null
+++ b/RenovationWorkListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,105 @@
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkListImplement.Models;
+
+namespace RenovationWorkListImplement.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/RenovationWorkListImplement/Implements/OrderStorage.cs b/RenovationWorkListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..f35c26a
--- /dev/null
+++ b/RenovationWorkListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,112 @@
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkListImplement.Models;
+
+namespace RenovationWorkListImplement.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)
+ {
+ OrderViewModel thisorder = order.GetViewModel;
+ Repair? repair = _source.Repairs.Find(x => x.Id == order.RepairId);
+ string repairName = repair?.RepairName ?? string.Empty;
+ thisorder.RepairName = repairName;
+ result.Add(thisorder);
+ }
+ return result;
+ }
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ OrderViewModel thisorder = order.GetViewModel;
+ Repair? repair = _source.Repairs.Find(x => x.Id == order.RepairId);
+ string repairName = repair?.RepairName ?? string.Empty;
+ thisorder.RepairName = repairName;
+ result.Add(thisorder);
+ }
+ }
+ 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))
+ {
+ OrderViewModel thisorder = order.GetViewModel;
+ Repair? repair = _source.Repairs.Find(x => x.Id == order.RepairId);
+ string repairName = repair?.RepairName ?? string.Empty;
+ thisorder.RepairName = repairName;
+ return thisorder;
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return newOrder.GetViewModel;
+ }
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return order.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Repairs.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/RenovationWorkListImplement/Implements/RepairStorage.cs b/RenovationWorkListImplement/Implements/RepairStorage.cs
new file mode 100644
index 0000000..2c34924
--- /dev/null
+++ b/RenovationWorkListImplement/Implements/RepairStorage.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.SearchModels;
+using RenovationWorkContracts.StoragesContracts;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkListImplement.Models;
+
+namespace RenovationWorkListImplement.Implements
+{
+ public class RepairStorage : IRepairStorage
+ {
+ private readonly DataListSingleton _source;
+ public RepairStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var repair in _source.Repairs)
+ {
+ result.Add(repair.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(RepairSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.RepairName))
+ {
+ return result;
+ }
+ foreach (var repair in _source.Repairs)
+ {
+ if (repair.RepairName.Contains(model.RepairName))
+ {
+ result.Add(repair.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public RepairViewModel? GetElement(RepairSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.RepairName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var repair in _source.Repairs)
+ {
+ if ((!string.IsNullOrEmpty(model.RepairName) && repair.RepairName == model.RepairName) || (model.Id.HasValue && repair.Id == model.Id))
+ {
+ return repair.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public RepairViewModel? Insert(RepairBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var repair in _source.Repairs)
+ {
+ if (model.Id <= repair.Id)
+ {
+ model.Id = repair.Id + 1;
+ }
+ }
+ var newRepair = Repair.Create(model);
+ if (newRepair == null)
+ {
+ return null;
+ }
+ _source.Repairs.Add(newRepair);
+ return newRepair.GetViewModel;
+ }
+ public RepairViewModel? Update(RepairBindingModel model)
+ {
+ foreach (var repair in _source.Repairs)
+ {
+ if (repair.Id == model.Id)
+ {
+ repair.Update(model);
+ return repair.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public RepairViewModel? Delete(RepairBindingModel model)
+ {
+ for (int i = 0; i < _source.Repairs.Count; ++i)
+ {
+ if (_source.Repairs[i].Id == model.Id)
+ {
+ var element = _source.Repairs[i];
+ _source.Repairs.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
+
diff --git a/RenovationWorkListImplement/Models/Component.cs b/RenovationWorkListImplement/Models/Component.cs
new file mode 100644
index 0000000..e0f4f71
--- /dev/null
+++ b/RenovationWorkListImplement/Models/Component.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkDataModels.Models;
+
+namespace RenovationWorkListImplement.Models
+{
+ public class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } = string.Empty;
+ public double Cost { get; set; }
+ public static Component? Create(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost
+ };
+ }
+ public void Update(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+ }
+}
diff --git a/RenovationWorkListImplement/Models/Order.cs b/RenovationWorkListImplement/Models/Order.cs
new file mode 100644
index 0000000..b3d1069
--- /dev/null
+++ b/RenovationWorkListImplement/Models/Order.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkDataModels.Enums;
+using RenovationWorkDataModels.Models;
+
+namespace RenovationWorkListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+
+ public int RepairId { get; private set; }
+
+ public int Count { get; private set; }
+
+ public double Sum { get; private set; }
+
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+
+ public DateTime? DateImplement { get; set; }
+
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ RepairId = model.RepairId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ if (model.DateImplement != null)
+ {
+ DateImplement = model.DateImplement;
+ }
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ RepairId = RepairId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
+
diff --git a/RenovationWorkListImplement/Models/Repair.cs b/RenovationWorkListImplement/Models/Repair.cs
new file mode 100644
index 0000000..e7c8739
--- /dev/null
+++ b/RenovationWorkListImplement/Models/Repair.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RenovationWorkContracts.BindingModels;
+using RenovationWorkContracts.ViewModels;
+using RenovationWorkDataModels.Models;
+
+namespace RenovationWorkListImplement.Models
+{
+ public class Repair : IRepairModel
+ {
+ public int Id { get; private set; }
+ public string RepairName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary RepairComponents
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Repair? Create(RepairBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Repair()
+ {
+ Id = model.Id,
+ RepairName = model.RepairName,
+ Price = model.Price,
+ RepairComponents = model.RepairComponents
+ };
+ }
+ public void Update(RepairBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ RepairName = model.RepairName;
+ Price = model.Price;
+ RepairComponents = model.RepairComponents;
+ }
+ public RepairViewModel GetViewModel => new()
+ {
+ Id = Id,
+ RepairName = RepairName,
+ Price = Price,
+ RepairComponents = RepairComponents
+ };
+ }
+}
diff --git a/RenovationWorkListImplement/RenovationWorkListImplement.csproj b/RenovationWorkListImplement/RenovationWorkListImplement.csproj
new file mode 100644
index 0000000..2d896a8
--- /dev/null
+++ b/RenovationWorkListImplement/RenovationWorkListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+