diff --git a/PrecastConcretePlant/Form1.Designer.cs b/PrecastConcretePlant/Form1.Designer.cs
deleted file mode 100644
index e047708..0000000
--- a/PrecastConcretePlant/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace PrecastConcretePlant
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
diff --git a/PrecastConcretePlant/Form1.cs b/PrecastConcretePlant/Form1.cs
deleted file mode 100644
index 401d4d9..0000000
--- a/PrecastConcretePlant/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace PrecastConcretePlant
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/PrecastConcretePlant/PrecastConcretePlant.csproj b/PrecastConcretePlant/PrecastConcretePlant.csproj
deleted file mode 100644
index 663fdb8..0000000
--- a/PrecastConcretePlant/PrecastConcretePlant.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net8.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln
new file mode 100644
index 0000000..513b733
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlant.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34525.116
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantView", "PrecastConcretePlantView\PrecastConcretePlantView.csproj", "{027351D4-8910-4C96-8991-3D13B26429FE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{34D9A707-3256-40F7-9748-9B9D4828C526}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{7BBA6D17-DDEE-4971-A350-2C4677A28B3D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{6C45F2BD-77AE-4324-B567-3B1FFAE52DA1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantListImplement", "PrecastConcretePlantListImplement\PrecastConcretePlantListImplement.csproj", "{432CDD30-04CE-4505-999C-1FC85C2220B1}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {027351D4-8910-4C96-8991-3D13B26429FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {027351D4-8910-4C96-8991-3D13B26429FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {027351D4-8910-4C96-8991-3D13B26429FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {027351D4-8910-4C96-8991-3D13B26429FE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {34D9A707-3256-40F7-9748-9B9D4828C526}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {34D9A707-3256-40F7-9748-9B9D4828C526}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {34D9A707-3256-40F7-9748-9B9D4828C526}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {34D9A707-3256-40F7-9748-9B9D4828C526}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7BBA6D17-DDEE-4971-A350-2C4677A28B3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7BBA6D17-DDEE-4971-A350-2C4677A28B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7BBA6D17-DDEE-4971-A350-2C4677A28B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7BBA6D17-DDEE-4971-A350-2C4677A28B3D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6C45F2BD-77AE-4324-B567-3B1FFAE52DA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6C45F2BD-77AE-4324-B567-3B1FFAE52DA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6C45F2BD-77AE-4324-B567-3B1FFAE52DA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6C45F2BD-77AE-4324-B567-3B1FFAE52DA1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {432CDD30-04CE-4505-999C-1FC85C2220B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {432CDD30-04CE-4505-999C-1FC85C2220B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {432CDD30-04CE-4505-999C-1FC85C2220B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {432CDD30-04CE-4505-999C-1FC85C2220B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {22FE170D-1862-458C-A4FF-1E8F20D9EE51}
+ EndGlobalSection
+EndGlobal
diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ComponentLogic.cs
new file mode 100644
index 0000000..b21e709
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ComponentLogic.cs
@@ -0,0 +1,112 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantBusinessLogic.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/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs
new file mode 100644
index 0000000..29765fb
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -0,0 +1,123 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id: {Id}", model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count: {Count}", list.Count);
+ return list;
+ }
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Invalid order status");
+ return false;
+ }
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_orderStorage.GetElement(new OrderSearchModel { Id = model.Id })?.Status != OrderStatus.Принят)
+ {
+ _logger.LogWarning("Invalid order status");
+ return false;
+ }
+ model.Status = OrderStatus.Выполняется;
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ }
+ return true;
+ }
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_orderStorage.GetElement(new OrderSearchModel { Id = model.Id })?.Status != OrderStatus.Выполняется)
+ {
+ _logger.LogWarning("Invalid order status");
+ return false;
+ }
+ model.Status = OrderStatus.Готов;
+ model.DateImplement = DateTime.Now;
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ }
+ return true;
+ }
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ CheckModel(model, false);
+ var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (order?.Status != OrderStatus.Готов)
+ {
+ _logger.LogWarning("Invalid order status");
+ return false;
+ }
+ model.Status = OrderStatus.Выдан;
+ model.DateImplement = order.DateImplement;
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ }
+ return true;
+ }
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Стоимость должна быть больше 0", nameof(model.Sum));
+ }
+ _logger.LogInformation("Order. Id: {Id}. Sum: {Sum}. ReinforcedId: {ReinforcedId}", model.Id, model.Sum, model.ReinforcedId);
+ var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (element != null && element.Id == model.Id)
+ {
+ throw new InvalidOperationException("Заказ с таким номером уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ReinforcedLogic.cs
new file mode 100644
index 0000000..d4684b2
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ReinforcedLogic.cs
@@ -0,0 +1,112 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantBusinessLogic.BusinessLogics
+{
+ public class ReinforcedLogic : IReinforcedLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IReinforcedStorage _reinforcedStorage;
+ public ReinforcedLogic(ILogger logger, IReinforcedStorage reinforcedStorage)
+ {
+ _logger = logger;
+ _reinforcedStorage = reinforcedStorage;
+ }
+ public List? ReadList(ReinforcedSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ReinforcedName:{ReinforcedName}.Id:{ Id}", model?.ReinforcedName, model?.Id);
+ var list = model == null ? _reinforcedStorage.GetFullList() : _reinforcedStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ReinforcedViewModel? ReadElement(ReinforcedSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ReinforcedName:{ReinforcedName}.Id:{ Id}", model.ReinforcedName, model.Id);
+ var element = _reinforcedStorage.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(ReinforcedBindingModel model)
+ {
+ CheckModel(model);
+ if (_reinforcedStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ReinforcedBindingModel model)
+ {
+ CheckModel(model);
+ if (_reinforcedStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ReinforcedBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_reinforcedStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ReinforcedBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ReinforcedName))
+ {
+ throw new ArgumentNullException("Нет названия изделия", nameof(model.ReinforcedName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Reinforced. ReinforcedName:{ReinforcedName}.Price:{Price}.Id: { Id}", model.ReinforcedName, model.Price, model.Id);
+ var element = _reinforcedStorage.GetElement(new ReinforcedSearchModel
+ {
+ ReinforcedName = model.ReinforcedName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Изделие с таким названием уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj
new file mode 100644
index 0000000..d47aac7
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..fad4e83
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,16 @@
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..e535312
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,22 @@
+using PrecastConcretePlantDataModels.Enums;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int ReinforcedId { get; set; }
+ public string ReinforcedName { get; set; } = string.Empty;
+ public int Count { get; set; }
+ public double Sum { get; set; }
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+ public DateTime? DateImplement { get; set; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs
new file mode 100644
index 0000000..f77f5a4
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs
@@ -0,0 +1,17 @@
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.BindingModels
+{
+ public class ReinforcedBindingModel : IReinforcedModel
+ {
+ public int Id { get; set; }
+ public string ReinforcedName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary ReinforcedComponents { get; set; } = new();
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..6d2750f
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,20 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..bdc97c8
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,20 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs
new file mode 100644
index 0000000..4618843
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs
@@ -0,0 +1,20 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.BusinessLogicsContracts
+{
+ public interface IReinforcedLogic
+ {
+ List? ReadList(ReinforcedSearchModel? model);
+ ReinforcedViewModel? ReadElement(ReinforcedSearchModel model);
+ bool Create(ReinforcedBindingModel model);
+ bool Update(ReinforcedBindingModel model);
+ bool Delete(ReinforcedBindingModel model);
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj
new file mode 100644
index 0000000..80977c8
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..c5f5348
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..14a8d3f
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs
new file mode 100644
index 0000000..9c41732
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.SearchModels
+{
+ public class ReinforcedSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ReinforcedName { get; set; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..3f4b869
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..4847e6a
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,22 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs
new file mode 100644
index 0000000..3921b68
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs
@@ -0,0 +1,21 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.StoragesContracts
+{
+ public interface IReinforcedStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ReinforcedSearchModel model);
+ ReinforcedViewModel? GetElement(ReinforcedSearchModel model);
+ ReinforcedViewModel? Insert(ReinforcedBindingModel model);
+ ReinforcedViewModel? Update(ReinforcedBindingModel model);
+ ReinforcedViewModel? Delete(ReinforcedBindingModel model);
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..037d8c7
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,21 @@
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.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/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..512bec2
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,47 @@
+using PrecastConcretePlantDataModels.Enums;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+
+
+ public int ReinforcedId { get; set; }
+
+
+ [DisplayName("Изделие")]
+ public string ReinforcedName { get; set; } = string.Empty;
+
+
+ [DisplayName("Количество")]
+ public int Count { get; set; }
+
+
+ [DisplayName("Сумма")]
+ public double Sum { get; set; }
+
+
+ [DisplayName("Статус")]
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+
+
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+
+
+ [DisplayName("Дата выполнения")]
+ public DateTime? DateImplement { get; set; }
+
+
+
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs
new file mode 100644
index 0000000..5903fac
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs
@@ -0,0 +1,23 @@
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantContracts.ViewModels
+{
+ public class ReinforcedViewModel : IReinforcedModel
+ {
+ public int Id { get; set; }
+
+ [DisplayName("Название изделия")]
+ public string ReinforcedName { get; set; } = string.Empty;
+
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+
+ public Dictionary ReinforcedComponents { get; set; } = new();
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/Enums/OrderStatus.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..9e463c1
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+
+ Принят = 0,
+
+ Выполняется = 1,
+
+ Готов = 2,
+
+ Выдан = 3
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs
new file mode 100644
index 0000000..3ce5663
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs
@@ -0,0 +1,7 @@
+namespace PrecastConcretePlantDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IComponentModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..41fab82
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IOrderModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..50d8b16
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IOrderModel.cs
@@ -0,0 +1,20 @@
+using PrecastConcretePlantDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int ReinforcedId { get; }
+ string ReinforcedName { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IReinforcedModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IReinforcedModel.cs
new file mode 100644
index 0000000..6a42c6f
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/Models/IReinforcedModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantDataModels.Models
+{
+ public interface IReinforcedModel : IId
+ {
+ string ReinforcedName { get; }
+ double Price { get; }
+ Dictionary ReinforcedComponents { get; }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj
new file mode 100644
index 0000000..7b8c1c6
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..04a9ff5
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs
@@ -0,0 +1,32 @@
+using PrecastConcretePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Reinforceds { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Reinforceds = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..2c3cf59
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,106 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement.Implements
+{
+ public class ComponentStorage : IComponentStorage
+ {
+ private readonly DataListSingleton _source;
+ public ComponentStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var component in _source.Components)
+ {
+ result.Add(component.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ComponentSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Components)
+ {
+ if (component.ComponentName.Contains(model.ComponentName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public ComponentViewModel? GetElement(ComponentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var component in _source.Components)
+ {
+ if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) ||
+ (model.Id.HasValue && component.Id == model.Id))
+ {
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ComponentViewModel? Insert(ComponentBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var component in _source.Components)
+ {
+ if (model.Id <= component.Id)
+ {
+ model.Id = component.Id + 1;
+ }
+ }
+ var newComponent = Component.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ _source.Components.Add(newComponent);
+ return newComponent.GetViewModel;
+ }
+ public ComponentViewModel? Update(ComponentBindingModel model)
+ {
+ foreach (var component in _source.Components)
+ {
+ if (component.Id == model.Id)
+ {
+ component.Update(model);
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ComponentViewModel? Delete(ComponentBindingModel model)
+ {
+ for (int i = 0; i < _source.Components.Count; ++i)
+ {
+ if (_source.Components[i].Id == model.Id)
+ {
+ var element = _source.Components[i];
+ _source.Components.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..ce71720
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,105 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(order.GetViewModel);
+ }
+ 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)
+ {
+ result.Add(order.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ return order.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return 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.Orders.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs
new file mode 100644
index 0000000..bf2b300
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs
@@ -0,0 +1,106 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement.Implements
+{
+ public class ReinforcedStorage : IReinforcedStorage
+ {
+ private readonly DataListSingleton _source;
+ public ReinforcedStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var reinforced in _source.Reinforceds)
+ {
+ result.Add(reinforced.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ReinforcedSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ReinforcedName))
+ {
+ return result;
+ }
+ foreach (var reinforced in _source.Reinforceds)
+ {
+ if (reinforced.ReinforcedName.Contains(model.ReinforcedName))
+ {
+ result.Add(reinforced.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public ReinforcedViewModel? GetElement(ReinforcedSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ReinforcedName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var reinforced in _source.Reinforceds)
+ {
+ if ((!string.IsNullOrEmpty(model.ReinforcedName) && reinforced.ReinforcedName == model.ReinforcedName) ||
+ (model.Id.HasValue && reinforced.Id == model.Id))
+ {
+ return reinforced.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ReinforcedViewModel? Insert(ReinforcedBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var reinforced in _source.Reinforceds)
+ {
+ if (model.Id <= reinforced.Id)
+ {
+ model.Id = reinforced.Id + 1;
+ }
+ }
+ var newReinforced = Reinforced.Create(model);
+ if (newReinforced == null)
+ {
+ return null;
+ }
+ _source.Reinforceds.Add(newReinforced);
+ return newReinforced.GetViewModel;
+ }
+ public ReinforcedViewModel? Update(ReinforcedBindingModel model)
+ {
+ foreach (var reinforced in _source.Reinforceds)
+ {
+ if (reinforced.Id == model.Id)
+ {
+ reinforced.Update(model);
+ return reinforced.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ReinforcedViewModel? Delete(ReinforcedBindingModel model)
+ {
+ for (int i = 0; i < _source.Reinforceds.Count; ++i)
+ {
+ if (_source.Reinforceds[i].Id == model.Id)
+ {
+ var element = _source.Reinforceds[i];
+ _source.Reinforceds.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs
new file mode 100644
index 0000000..aa6cf6d
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs
@@ -0,0 +1,46 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement.Models
+{
+ public class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } = string.Empty;
+ public double Cost { get; private set; }
+ public static Component? Create(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost
+ };
+ }
+ public void Update(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs
new file mode 100644
index 0000000..5b08bd4
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs
@@ -0,0 +1,62 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Enums;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int ReinforcedId { get; private set; }
+ public string ReinforcedName { get; private set; } = String.Empty;
+ public int Count { get; private set; }
+ public double Sum { get; private set; }
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+ public DateTime? DateImplement { get; private set; }
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ ReinforcedId = model.ReinforcedId,
+ ReinforcedName = model.ReinforcedName,
+ 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;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ReinforcedId = ReinforcedId,
+ ReinforcedName = ReinforcedName,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ };
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs
new file mode 100644
index 0000000..c54e2f2
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs
@@ -0,0 +1,50 @@
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrecastConcretePlantListImplement.Models
+{
+ public class Reinforced : IReinforcedModel
+ {
+ public int Id { get; private set; }
+ public string ReinforcedName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary ReinforcedComponents { get; private set; } = new Dictionary();
+ public static Reinforced? Create(ReinforcedBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Reinforced()
+ {
+ Id = model.Id,
+ ReinforcedName = model.ReinforcedName,
+ Price = model.Price,
+ ReinforcedComponents = model.ReinforcedComponents
+ };
+ }
+ public void Update(ReinforcedBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ReinforcedName = model.ReinforcedName;
+ Price = model.Price;
+ ReinforcedComponents = model.ReinforcedComponents;
+ }
+ public ReinforcedViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ReinforcedName = ReinforcedName,
+ Price = Price,
+ ReinforcedComponents = ReinforcedComponents
+ };
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj
new file mode 100644
index 0000000..91e38df
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs
new file mode 100644
index 0000000..906ec9d
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs
@@ -0,0 +1,118 @@
+namespace PrecastConcretePlantView
+{
+ partial class FormComponent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelName = new Label();
+ labelCost = new Label();
+ textBoxName = new TextBox();
+ textBoxCost = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(12, 15);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(77, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название";
+ //
+ // labelCost
+ //
+ labelCost.AutoSize = true;
+ labelCost.Location = new Point(44, 46);
+ labelCost.Name = "labelCost";
+ labelCost.Size = new Size(45, 20);
+ labelCost.TabIndex = 1;
+ labelCost.Text = "Цена";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(95, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(298, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxCost
+ //
+ textBoxCost.Location = new Point(95, 43);
+ textBoxCost.Name = "textBoxCost";
+ textBoxCost.Size = new Size(298, 27);
+ textBoxCost.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(95, 76);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(140, 29);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(241, 76);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(152, 29);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(405, 121);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCost);
+ Controls.Add(textBoxName);
+ Controls.Add(labelCost);
+ Controls.Add(labelName);
+ Name = "FormComponent";
+ Text = "Компонент";
+ Load += FormComponent_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelCost;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs
new file mode 100644
index 0000000..aa5888b
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs
@@ -0,0 +1,96 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormComponent : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormComponent(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormComponent_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение компонента");
+ var view = _logic.ReadElement(new ComponentSearchModel
+ {
+ Id = _id.Value
+ });
+
+ if (view != null)
+ {
+ textBoxName.Text = view.ComponentName;
+ textBoxCost.Text = view.Cost.ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Сохранение компонента");
+
+ try
+ {
+ var model = new ComponentBindingModel
+ {
+ Id = _id ?? 0,
+ ComponentName = textBoxName.Text,
+ Cost = Convert.ToDouble(textBoxCost.Text)
+ };
+
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/PrecastConcretePlant/Form1.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.resx
similarity index 93%
rename from PrecastConcretePlant/Form1.resx
rename to PrecastConcretePlant/PrecastConcretePlantView/FormComponent.resx
index 1af7de1..af32865 100644
--- a/PrecastConcretePlant/Form1.resx
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.resx
@@ -1,17 +1,17 @@
-
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.Designer.cs
new file mode 100644
index 0000000..0b33c0d
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.Designer.cs
@@ -0,0 +1,117 @@
+namespace PrecastConcretePlantView
+{
+ partial class FormComponentS
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ ButtonDel = new Button();
+ ButtonRef = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(616, 12);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(172, 62);
+ ButtonAdd.TabIndex = 1;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(616, 80);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(172, 62);
+ ButtonUpd.TabIndex = 2;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(616, 148);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(172, 62);
+ ButtonDel.TabIndex = 3;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDel_Click;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(616, 216);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(172, 62);
+ ButtonRef.TabIndex = 4;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.Size = new Size(610, 450);
+ dataGridView.TabIndex = 5;
+ //
+ // FormComponentS
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridView);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonDel);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Name = "FormComponentS";
+ Text = "Компоненты";
+ Load += FormComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+ private Button ButtonAdd;
+ private Button ButtonUpd;
+ private Button ButtonDel;
+ private Button ButtonRef;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.cs
new file mode 100644
index 0000000..29ed646
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.cs
@@ -0,0 +1,116 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormComponentS : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _logic;
+
+ public FormComponentS(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormComponents_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["ComponentName"].AutoSizeMode =
+ DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка компонентов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
+ if (service is FormComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormComponent));
+ if (service is FormComponent form)
+ {
+ form.Id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление компонента");
+ try
+ {
+ if (!_logic.Delete(new ComponentBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении.Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormComponentS.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/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/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..1194728
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs
@@ -0,0 +1,153 @@
+namespace PrecastConcretePlantView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.labelReinforced = new System.Windows.Forms.Label();
+ this.comboBoxReinforced = new System.Windows.Forms.ComboBox();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.labelSumm = new System.Windows.Forms.Label();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelReinforced
+ //
+ this.labelReinforced.AutoSize = true;
+ this.labelReinforced.Location = new System.Drawing.Point(10, 11);
+ this.labelReinforced.Name = "labelReinforced";
+ this.labelReinforced.Size = new System.Drawing.Size(59, 15);
+ this.labelReinforced.TabIndex = 0;
+ this.labelReinforced.Text = "Изделие: ";
+ //
+ // comboBoxReinforced
+ //
+ this.comboBoxReinforced.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxReinforced.FormattingEnabled = true;
+ this.comboBoxReinforced.Location = new System.Drawing.Point(101, 9);
+ this.comboBoxReinforced.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.comboBoxReinforced.Name = "comboBoxReinforced";
+ this.comboBoxReinforced.Size = new System.Drawing.Size(200, 23);
+ this.comboBoxReinforced.TabIndex = 1;
+ this.comboBoxReinforced.SelectedIndexChanged += new System.EventHandler(this.ComboBoxReinforced_SelectedIndexChanged);
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(10, 37);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(78, 15);
+ this.labelCount.TabIndex = 2;
+ this.labelCount.Text = "Количество: ";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(101, 34);
+ this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(200, 23);
+ this.textBoxCount.TabIndex = 3;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
+ //
+ // labelSumm
+ //
+ this.labelSumm.AutoSize = true;
+ this.labelSumm.Location = new System.Drawing.Point(10, 60);
+ this.labelSumm.Name = "labelSumm";
+ this.labelSumm.Size = new System.Drawing.Size(51, 15);
+ this.labelSumm.TabIndex = 4;
+ this.labelSumm.Text = "Сумма: ";
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(101, 60);
+ this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.ReadOnly = true;
+ this.textBoxSum.Size = new System.Drawing.Size(200, 23);
+ this.textBoxSum.TabIndex = 5;
+ this.textBoxSum.Click += new System.EventHandler(this.TextBoxCount_TextChanged);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(203, 87);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(96, 24);
+ this.buttonCancel.TabIndex = 6;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(101, 87);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(96, 24);
+ this.buttonSave.TabIndex = 7;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(315, 118);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.labelSumm);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.comboBoxReinforced);
+ this.Controls.Add(this.labelReinforced);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormCreateOrder";
+ this.Text = "Заказ";
+ this.Load += new System.EventHandler(this.FormCreateOrder_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelReinforced;
+ private ComboBox comboBoxReinforced;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Label labelSumm;
+ private TextBox textBoxSum;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs
new file mode 100644
index 0000000..8162bed
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs
@@ -0,0 +1,127 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReinforcedLogic _logicR;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, IReinforcedLogic logicR, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicR = logicR;
+ _logicO = logicO;
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logicR.ReadList(null);
+ if (list != null)
+ {
+ comboBoxReinforced.DisplayMember = "ReinforcedName";
+ comboBoxReinforced.ValueMember = "Id";
+ comboBoxReinforced.DataSource = list;
+ comboBoxReinforced.SelectedItem = null;
+ }
+ _logger.LogInformation("Загрузка изделий для заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделий для заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxReinforced.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxReinforced.SelectedValue);
+ var Reinforced = _logicR.ReadElement(new ReinforcedSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (Reinforced?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void TextBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void ComboBoxReinforced_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxReinforced.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ ReinforcedId = Convert.ToInt32(comboBoxReinforced.SelectedValue),
+ ReinforcedName = comboBoxReinforced.Text,
+ 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/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/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/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs
new file mode 100644
index 0000000..760d5b2
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs
@@ -0,0 +1,173 @@
+namespace PrecastConcretePlantView
+{
+ 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()
+ {
+ menuStrip1 = new MenuStrip();
+ справочникToolStripMenuItem = new ToolStripMenuItem();
+ компонентыToolStripMenuItem = new ToolStripMenuItem();
+ изделияToolStripMenuItem = new ToolStripMenuItem();
+ buttonRef = new Button();
+ buttonIssuedOrder = new Button();
+ buttonOrderReady = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonCreateOrder = new Button();
+ dataGridView = new DataGridView();
+ menuStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip1
+ //
+ menuStrip1.ImageScalingSize = new Size(20, 20);
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Padding = new Padding(6, 3, 0, 3);
+ menuStrip1.Size = new Size(1100, 30);
+ menuStrip1.TabIndex = 0;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // справочникToolStripMenuItem
+ //
+ справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem });
+ справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
+ справочникToolStripMenuItem.Size = new Size(117, 24);
+ справочникToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ компонентыToolStripMenuItem.Size = new Size(182, 26);
+ компонентыToolStripMenuItem.Text = "Компоненты";
+ компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
+ //
+ // изделияToolStripMenuItem
+ //
+ изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
+ изделияToolStripMenuItem.Size = new Size(182, 26);
+ изделияToolStripMenuItem.Text = "Изделия";
+ изделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(931, 273);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(157, 54);
+ buttonRef.TabIndex = 23;
+ buttonRef.Text = "Обновить список";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += ButtonRef_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(931, 213);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(157, 54);
+ buttonIssuedOrder.TabIndex = 22;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(931, 153);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(157, 54);
+ buttonOrderReady.TabIndex = 21;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += ButtonOrderReady_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(931, 93);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(157, 54);
+ buttonTakeOrderInWork.TabIndex = 20;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(931, 33);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(157, 54);
+ buttonCreateOrder.TabIndex = 19;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += ButtonCreateOrder_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 30);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.Size = new Size(925, 374);
+ dataGridView.TabIndex = 18;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1100, 404);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
+ Name = "FormMain";
+ Text = "Завод ЖБИ";
+ Load += FormMain_Load;
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem изделияToolStripMenuItem;
+ private Button buttonRef;
+ private Button buttonIssuedOrder;
+ private Button buttonOrderReady;
+ private Button buttonTakeOrderInWork;
+ private Button buttonCreateOrder;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs
new file mode 100644
index 0000000..6c6534f
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs
@@ -0,0 +1,156 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["ReinforcedId"].Visible = false;
+ dataGridView.Columns["ReinforcedName"].AutoSizeMode =
+ DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation(" ");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponentS));
+ if (service is FormComponentS form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void ToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedS));
+ if (service is FormReinforcedS form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void ButtonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation(" No{id}. ' '", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = id
+ });
+ if (!operationResult)
+ {
+ throw new Exception(" . .");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation(" No{id}. ''", id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = id
+ });
+ if (!operationResult)
+ {
+ throw new Exception(" . .");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation(" No{id}. ''", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
+ {
+ Id = id
+ });
+ if (!operationResult)
+ {
+ throw new Exception(" . .");
+ }
+ _logger.LogInformation(" No{id} ", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx
new file mode 100644
index 0000000..a0623c8
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs
new file mode 100644
index 0000000..6810e09
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs
@@ -0,0 +1,232 @@
+namespace PrecastConcretePlantView
+{
+ partial class FormReinforced
+ {
+ ///
+ /// 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();
+ textBoxName = new TextBox();
+ labelPrice = new Label();
+ textBoxPrice = new TextBox();
+ groupBoxComponents = new GroupBox();
+ ButtonRef = new Button();
+ dataGridView = new DataGridView();
+ id = new DataGridViewTextBoxColumn();
+ Component = new DataGridViewTextBoxColumn();
+ Count = new DataGridViewTextBoxColumn();
+ ButtonDel = new Button();
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ groupBoxComponents.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(16, 15);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(84, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название: ";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(112, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(281, 27);
+ textBoxName.TabIndex = 1;
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(16, 51);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(90, 20);
+ labelPrice.TabIndex = 2;
+ labelPrice.Text = "Стоимость: ";
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(112, 51);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.ReadOnly = true;
+ textBoxPrice.Size = new Size(154, 27);
+ textBoxPrice.TabIndex = 3;
+ //
+ // groupBoxComponents
+ //
+ groupBoxComponents.Controls.Add(ButtonRef);
+ groupBoxComponents.Controls.Add(dataGridView);
+ groupBoxComponents.Controls.Add(ButtonDel);
+ groupBoxComponents.Controls.Add(ButtonAdd);
+ groupBoxComponents.Controls.Add(ButtonUpd);
+ groupBoxComponents.Location = new Point(11, 84);
+ groupBoxComponents.Name = "groupBoxComponents";
+ groupBoxComponents.Size = new Size(669, 319);
+ groupBoxComponents.TabIndex = 4;
+ groupBoxComponents.TabStop = false;
+ groupBoxComponents.Text = "Компоненты";
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(487, 231);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(172, 62);
+ ButtonRef.TabIndex = 10;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { id, Component, Count });
+ dataGridView.Location = new Point(6, 27);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.Size = new Size(475, 287);
+ dataGridView.TabIndex = 0;
+ //
+ // id
+ //
+ id.HeaderText = "id";
+ id.MinimumWidth = 6;
+ id.Name = "id";
+ id.ReadOnly = true;
+ id.Visible = false;
+ //
+ // Component
+ //
+ Component.HeaderText = "Компонент";
+ Component.MinimumWidth = 6;
+ Component.Name = "Component";
+ Component.ReadOnly = true;
+ //
+ // Count
+ //
+ Count.HeaderText = "Количество";
+ Count.MinimumWidth = 6;
+ Count.Name = "Count";
+ Count.ReadOnly = true;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(487, 163);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(172, 62);
+ ButtonDel.TabIndex = 9;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDel_Click;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(487, 27);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(172, 62);
+ ButtonAdd.TabIndex = 7;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(487, 95);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(172, 62);
+ ButtonUpd.TabIndex = 8;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(544, 416);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(126, 35);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(17, 416);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(126, 35);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // FormReinforced
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(690, 463);
+ Controls.Add(buttonSave);
+ Controls.Add(buttonCancel);
+ Controls.Add(groupBoxComponents);
+ Controls.Add(textBoxPrice);
+ Controls.Add(labelPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(labelName);
+ Name = "FormReinforced";
+ Text = "Изделие";
+ Load += FormReinforced_Load;
+ groupBoxComponents.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private TextBox textBoxName;
+ private Label labelPrice;
+ private TextBox textBoxPrice;
+ private GroupBox groupBoxComponents;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn Component;
+ private DataGridViewTextBoxColumn Count;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private DataGridViewTextBoxColumn id;
+ private Button ButtonRef;
+ private Button ButtonDel;
+ private Button ButtonAdd;
+ private Button ButtonUpd;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs
new file mode 100644
index 0000000..79b707c
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs
@@ -0,0 +1,213 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.SearchModels;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormReinforced : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReinforcedLogic _logic;
+ private int? _id;
+ private Dictionary _ReinforcedComponents;
+ public int Id { set { _id = value; } }
+ public FormReinforced(ILogger logger, IReinforcedLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _ReinforcedComponents = new Dictionary();
+ }
+ private void FormReinforced_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new ReinforcedSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.ReinforcedName;
+ textBoxPrice.Text = view.Price.ToString();
+ _ReinforcedComponents = view.ReinforcedComponents ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_ReinforcedComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _ReinforcedComponents)
+ {
+ 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(FormReinforcedComponent));
+ if (service is FormReinforcedComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_ReinforcedComponents.ContainsKey(form.Id))
+ {
+ _ReinforcedComponents[form.Id] = (form.ComponentModel,
+ form.Count);
+ }
+ else
+ {
+ _ReinforcedComponents.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(FormReinforcedComponent));
+ if (service is FormReinforcedComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _ReinforcedComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
+ _ReinforcedComponents[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);
+ _ReinforcedComponents?.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 (_ReinforcedComponents == null || _ReinforcedComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new ReinforcedBindingModel
+ {
+ Id = _id ?? 0,
+ ReinforcedName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ ReinforcedComponents = _ReinforcedComponents
+ };
+ 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 _ReinforcedComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs
new file mode 100644
index 0000000..d479907
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs
@@ -0,0 +1,119 @@
+namespace PrecastConcretePlantView
+{
+ partial class FormReinforcedComponent
+ {
+ ///
+ /// 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()
+ {
+ labelComp = new Label();
+ labelCount = new Label();
+ textBoxCount = new TextBox();
+ ButtonSave = new Button();
+ ButtonCancel = new Button();
+ comboBoxComponent = new ComboBox();
+ SuspendLayout();
+ //
+ // labelComp
+ //
+ labelComp.AutoSize = true;
+ labelComp.Location = new Point(10, 9);
+ labelComp.Name = "labelComp";
+ labelComp.Size = new Size(88, 20);
+ labelComp.TabIndex = 0;
+ labelComp.Text = "Компонент";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(12, 43);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(90, 20);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(108, 40);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(286, 27);
+ textBoxCount.TabIndex = 3;
+ //
+ // ButtonSave
+ //
+ ButtonSave.Location = new Point(108, 73);
+ ButtonSave.Name = "ButtonSave";
+ ButtonSave.Size = new Size(143, 31);
+ ButtonSave.TabIndex = 4;
+ ButtonSave.Text = "Сохранить";
+ ButtonSave.UseVisualStyleBackColor = true;
+ ButtonSave.Click += ButtonSave_Click;
+ //
+ // ButtonCancel
+ //
+ ButtonCancel.Location = new Point(257, 73);
+ ButtonCancel.Name = "ButtonCancel";
+ ButtonCancel.Size = new Size(137, 31);
+ ButtonCancel.TabIndex = 5;
+ ButtonCancel.Text = "Отмена";
+ ButtonCancel.UseVisualStyleBackColor = true;
+ ButtonCancel.Click += ButtonCancel_Click;
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(108, 6);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(281, 28);
+ comboBoxComponent.TabIndex = 6;
+ //
+ // FormReinforcedComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(401, 124);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(ButtonCancel);
+ Controls.Add(ButtonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(labelCount);
+ Controls.Add(labelComp);
+ Name = "FormReinforcedComponent";
+ Text = "Компонент изделия";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelComp;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Button ButtonSave;
+ private Button ButtonCancel;
+ private ComboBox comboBoxComponent;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs
new file mode 100644
index 0000000..82f3fb0
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs
@@ -0,0 +1,89 @@
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.ViewModels;
+using PrecastConcretePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormReinforcedComponent : 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 FormReinforcedComponent(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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.Designer.cs
new file mode 100644
index 0000000..d45af2a
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.Designer.cs
@@ -0,0 +1,124 @@
+namespace PrecastConcretePlantView
+{
+ partial class FormReinforcedS
+ {
+ ///
+ /// 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()
+ {
+ ToolsPanel = new Panel();
+ ButtonRef = new Button();
+ ButtonDel = new Button();
+ ButtonUpd = new Button();
+ ButtonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // ToolsPanel
+ //
+ ToolsPanel.Location = new Point(-1, -1);
+ ToolsPanel.Name = "ToolsPanel";
+ ToolsPanel.Size = new Size(819, 481);
+ ToolsPanel.TabIndex = 3;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(626, 216);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(172, 62);
+ ButtonRef.TabIndex = 9;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(626, 148);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(172, 62);
+ ButtonDel.TabIndex = 8;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDel_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(626, 80);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(172, 62);
+ ButtonUpd.TabIndex = 7;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(626, 12);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(172, 62);
+ ButtonAdd.TabIndex = 6;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.Size = new Size(610, 479);
+ dataGridView.TabIndex = 5;
+ //
+ // FormReinforcedS
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(808, 479);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonDel);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Controls.Add(dataGridView);
+ Controls.Add(ToolsPanel);
+ Name = "FormReinforcedS";
+ Text = "Изделия";
+ Load += FormReinforcedes_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel ToolsPanel;
+ private Button ButtonRef;
+ private Button ButtonDel;
+ private Button ButtonUpd;
+ private Button ButtonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.cs
new file mode 100644
index 0000000..bfb69db
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.cs
@@ -0,0 +1,110 @@
+using Microsoft.Extensions.Logging;
+using PrecastConcretePlantContracts.BindingModels;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PrecastConcretePlantView
+{
+ public partial class FormReinforcedS : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReinforcedLogic _logic;
+ public FormReinforcedS(ILogger logger, IReinforcedLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormReinforcedes_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["ReinforcedComponents"].Visible = false;
+ dataGridView.Columns["ReinforcedName"].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(FormReinforced));
+ if (service is FormReinforced 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(FormReinforced));
+ if (service is FormReinforced 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 ReinforcedBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
+
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedS.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/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj b/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj
new file mode 100644
index 0000000..cb3c1f6
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj
@@ -0,0 +1,23 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PrecastConcretePlant/PrecastConcretePlantView/Program.cs b/PrecastConcretePlant/PrecastConcretePlantView/Program.cs
new file mode 100644
index 0000000..5fbed1a
--- /dev/null
+++ b/PrecastConcretePlant/PrecastConcretePlantView/Program.cs
@@ -0,0 +1,55 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using PrecastConcretePlantBusinessLogic.BusinessLogics;
+using PrecastConcretePlantContracts.BusinessLogicsContracts;
+using PrecastConcretePlantContracts.StoragesContracts;
+using PrecastConcretePlantListImplement.Implements;
+using System;
+
+namespace PrecastConcretePlantView
+{
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ ///
+ /// The main entry point for the application.
+ ///
+ [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/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/Program.cs
deleted file mode 100644
index aa81da8..0000000
--- a/PrecastConcretePlant/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace PrecastConcretePlant
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
- }
- }
-}
\ No newline at end of file