diff --git a/PlumbingRepair/PlumbingRepair.sln b/PlumbingRepair/PlumbingRepair.sln
index c59fa66..0b09086 100644
--- a/PlumbingRepair/PlumbingRepair.sln
+++ b/PlumbingRepair/PlumbingRepair.sln
@@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32319.34
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepair", "PlumbingRepair\PlumbingRepair.csproj", "{62D060C1-79C7-4CA4-A12F-0FE631EAD84F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairDataModels", "PlumbingRepairDataModels\PlumbingRepairDataModels.csproj", "{47C2C02B-0090-41D2-B228-AC2FBD8BC8FB}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairContracts", "PlumbingRepairContracts\PlumbingRepairContracts.csproj", "{12075D5B-8EB1-4777-AB0A-5A8A46080C92}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairBusinessLogic", "PlumbingRepairBusinesLogic\PlumbingRepairBusinessLogic.csproj", "{7BD66726-84BE-4A37-9E31-95E3802A74F0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairListImplement", "PlumbingRepairListImplement\PlumbingRepairListImplement.csproj", "{111DF058-BDAC-479D-AB5F-1AC10A75FEA1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairView", "PlumbingRepairView\PlumbingRepairView.csproj", "{A67F7409-283B-47B5-A6ED-E9550F9C7185}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,10 +19,26 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {62D060C1-79C7-4CA4-A12F-0FE631EAD84F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {62D060C1-79C7-4CA4-A12F-0FE631EAD84F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {62D060C1-79C7-4CA4-A12F-0FE631EAD84F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {62D060C1-79C7-4CA4-A12F-0FE631EAD84F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {47C2C02B-0090-41D2-B228-AC2FBD8BC8FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {47C2C02B-0090-41D2-B228-AC2FBD8BC8FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {47C2C02B-0090-41D2-B228-AC2FBD8BC8FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {47C2C02B-0090-41D2-B228-AC2FBD8BC8FB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {12075D5B-8EB1-4777-AB0A-5A8A46080C92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {12075D5B-8EB1-4777-AB0A-5A8A46080C92}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {12075D5B-8EB1-4777-AB0A-5A8A46080C92}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {12075D5B-8EB1-4777-AB0A-5A8A46080C92}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7BD66726-84BE-4A37-9E31-95E3802A74F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7BD66726-84BE-4A37-9E31-95E3802A74F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7BD66726-84BE-4A37-9E31-95E3802A74F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7BD66726-84BE-4A37-9E31-95E3802A74F0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {111DF058-BDAC-479D-AB5F-1AC10A75FEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {111DF058-BDAC-479D-AB5F-1AC10A75FEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {111DF058-BDAC-479D-AB5F-1AC10A75FEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {111DF058-BDAC-479D-AB5F-1AC10A75FEA1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A67F7409-283B-47B5-A6ED-E9550F9C7185}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A67F7409-283B-47B5-A6ED-E9550F9C7185}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A67F7409-283B-47B5-A6ED-E9550F9C7185}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A67F7409-283B-47B5-A6ED-E9550F9C7185}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/PlumbingRepair/PlumbingRepair/Form1.Designer.cs b/PlumbingRepair/PlumbingRepair/Form1.Designer.cs
deleted file mode 100644
index 0bf1336..0000000
--- a/PlumbingRepair/PlumbingRepair/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace PlumbingRepair
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepair/Form1.cs b/PlumbingRepair/PlumbingRepair/Form1.cs
deleted file mode 100644
index 24cdd22..0000000
--- a/PlumbingRepair/PlumbingRepair/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace PlumbingRepair
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepair/Form1.resx b/PlumbingRepair/PlumbingRepair/Form1.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/PlumbingRepair/PlumbingRepair/Form1.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj b/PlumbingRepair/PlumbingRepair/PlumbingRepairView.csproj
similarity index 100%
rename from PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj
rename to PlumbingRepair/PlumbingRepair/PlumbingRepairView.csproj
diff --git a/PlumbingRepair/PlumbingRepair/Program.cs b/PlumbingRepair/PlumbingRepair/Program.cs
index 9bc4817..1d4535b 100644
--- a/PlumbingRepair/PlumbingRepair/Program.cs
+++ b/PlumbingRepair/PlumbingRepair/Program.cs
@@ -11,7 +11,7 @@ namespace PlumbingRepair
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new FormComponent());
}
}
}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairBusinesLogic/ComponentLogic.cs b/PlumbingRepair/PlumbingRepairBusinesLogic/ComponentLogic.cs
new file mode 100644
index 0000000..f08bce1
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairBusinesLogic/ComponentLogic.cs
@@ -0,0 +1,108 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace PlumbingRepairBusinessLogic.BusinesLogics
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentStorage _componentStorage;
+ public ComponentLogic(ILogger logger, IComponentStorage componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+ public List? ReadList(ComponentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.ComponentName, model?.Id);
+ var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
+ if(list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}",list.Count);
+ return list;
+ }
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if(model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{Id}", model.ComponentName, model.Id);
+ var element = _componentStorage.GetElement(model);
+ if(element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}",element.Id);
+ return element;
+ }
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ComponentBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента",
+ nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairBusinesLogic/OrderLogic.cs b/PlumbingRepair/PlumbingRepairBusinesLogic/OrderLogic.cs
new file mode 100644
index 0000000..ad67007
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairBusinesLogic/OrderLogic.cs
@@ -0,0 +1,130 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Enums;
+using Microsoft.Extensions.Logging;
+
+namespace PlumbingRepairBusinessLogic.BusinesLogics
+{
+ public class OrderLogic: IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Insert operation failed. Order status incorrect.");
+ return false;
+ }
+
+ model.Status = OrderStatus.Принят;
+
+ if (_orderStorage.Insert(model) == null)
+ {
+ model.Status = OrderStatus.Неизвестен;
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
+ {
+ CheckModel(model);
+
+ if (model.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
+ return false;
+ }
+
+ model.Status = newStatus;
+
+ if (model.Status == OrderStatus.Выдан)
+ model.DateImplement = DateTime.Now;
+
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выдан);
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("Order. OrderId:{Id}", model?.Id);
+
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (model.WorkId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.WorkId));
+ }
+
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
+ }
+
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
+ }
+
+ _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. WorkId: { WorkId}", model.Id, model.Sum, model.WorkId);
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairBusinesLogic/PlumbingRepairBusinessLogic.csproj b/PlumbingRepair/PlumbingRepairBusinesLogic/PlumbingRepairBusinessLogic.csproj
new file mode 100644
index 0000000..e958b30
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairBusinesLogic/PlumbingRepairBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PlumbingRepair/PlumbingRepairBusinesLogic/WorkLogic.cs b/PlumbingRepair/PlumbingRepairBusinesLogic/WorkLogic.cs
new file mode 100644
index 0000000..2c08e4e
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairBusinesLogic/WorkLogic.cs
@@ -0,0 +1,107 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace PlumbingRepairBusinessLogic.BusinesLogics
+{
+ public class WorkLogic: IWorkLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IWorkStorage _workStorage;
+ public WorkLogic(ILogger logger, IWorkStorage workStorage)
+ {
+ _logger = logger;
+ _workStorage= workStorage;
+ }
+ public List? ReadList(WorkSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. WorkName:{WorkName}. Id:{Id}", model?.WorkName, model?.Id);
+ var list = model == null ? _workStorage.GetFullList() : _workStorage.GetFilteredList(model);
+ if(list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public WorkViewModel? ReadElement(WorkSearchModel model)
+ {
+ if(model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. WorkName:{WorkName}. Id:{Id}", model.WorkName, model.Id);
+ var element=_workStorage.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(WorkBindingModel model)
+ {
+ CheckModel(model);
+ if (_workStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(WorkBindingModel model)
+ {
+ CheckModel(model);
+ if (_workStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(WorkBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_workStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(WorkBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.WorkName))
+ {
+ throw new ArgumentNullException("Нет названия работы", nameof(model.WorkName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Стоимость работы должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Work. WorkName:{WorkName}. Price:{Price}. Id:{Id}", model.WorkName, model.Price, model.Id);
+ var element = _workStorage.GetElement(new WorkSearchModel
+ {
+ WorkName = model.WorkName
+ });
+ if(element!=null && element.Id!= model.Id)
+ {
+ throw new InvalidOperationException("Работа с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/ComponentBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..8ad50c2
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,11 @@
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairContracts.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/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..7a35005
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,17 @@
+using PlumbingRepairDataModels.Models;
+using PlumbingRepairDataModels.Enums;
+
+namespace PlumbingRepairContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int WorkId { get; set; }
+ public int Count { get; set; }
+ public double Sum { get; set; }
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; set; }= DateTime.Now;
+ public DateTime? DateImplement { get; set; }
+ public string WorkName { get; set; }= string.Empty;
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/WorkBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/WorkBindingModel.cs
new file mode 100644
index 0000000..455ff18
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/WorkBindingModel.cs
@@ -0,0 +1,12 @@
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairContracts.BindingModels
+{
+ public class WorkBindingModel : IWorkModel
+ {
+ public int Id { get; set; }
+ public string WorkName { get; set; } = String.Empty;
+ public double Price { get; set; }
+ public Dictionary WorkComponents { get; set; } = new();
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IComponentLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..5a23daa
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,15 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+
+namespace PlumbingRepairContracts.BusinesLogicsContracts
+{
+ 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/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IOrderLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..8699440
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,15 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+
+namespace PlumbingRepairContracts.BusinesLogicsContracts
+{
+ 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/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IWorkLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IWorkLogic.cs
new file mode 100644
index 0000000..79517d7
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/BusinesLogicsContracts/IWorkLogic.cs
@@ -0,0 +1,15 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+
+namespace PlumbingRepairContracts.BusinesLogicsContracts
+{
+ public interface IWorkLogic
+ {
+ List? ReadList(WorkSearchModel? model);
+ WorkViewModel? ReadElement(WorkSearchModel model);
+ bool Create(WorkBindingModel model);
+ bool Update(WorkBindingModel model);
+ bool Delete(WorkBindingModel model);
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj b/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj
new file mode 100644
index 0000000..5c96a30
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/PlumbingRepair/PlumbingRepairContracts/SearchModels/ComponentSearchModel.cs b/PlumbingRepair/PlumbingRepairContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..011b3c6
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,8 @@
+namespace PlumbingRepairContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs b/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..77ad642
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,7 @@
+namespace PlumbingRepairContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/SearchModels/WorkSearchModel.cs b/PlumbingRepair/PlumbingRepairContracts/SearchModels/WorkSearchModel.cs
new file mode 100644
index 0000000..34c40d5
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/SearchModels/WorkSearchModel.cs
@@ -0,0 +1,8 @@
+namespace PlumbingRepairContracts.SearchModels
+{
+ public class WorkSearchModel
+ {
+ public int? Id { get; set; }
+ public string? WorkName { get; set; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IComponentStorage.cs b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..aabbc71
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,16 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+
+namespace PlumbingRepairContracts.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/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IOrderStorage.cs b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..17a7c96
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,16 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+
+namespace PlumbingRepairContracts.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/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IWorkStorage.cs b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IWorkStorage.cs
new file mode 100644
index 0000000..11eeef2
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IWorkStorage.cs
@@ -0,0 +1,18 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+
+namespace PlumbingRepairContracts.StoragesContracts
+{
+ public interface IWorkStorage
+ {
+ List GetFullList();
+ List GetFilteredList(WorkSearchModel model);
+
+ WorkViewModel? GetElement(WorkSearchModel model);
+ WorkViewModel? Insert(WorkBindingModel model);
+ WorkViewModel? Update(WorkBindingModel model);
+ WorkViewModel? Delete(WorkBindingModel model);
+
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..2318746
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,16 @@
+using PlumbingRepairDataModels.Models;
+using System.ComponentModel;
+
+namespace PlumbingRepairContracts.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/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..9f619ea
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,32 @@
+using System.ComponentModel;
+using PlumbingRepairDataModels.Models;
+using PlumbingRepairDataModels.Enums;
+
+namespace PlumbingRepairContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+
+ public int WorkId { get; set; }
+
+ [DisplayName("Работа")]
+ public string WorkName { 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/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs
new file mode 100644
index 0000000..0a11184
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs
@@ -0,0 +1,18 @@
+using System.ComponentModel;
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairContracts.ViewModels
+{
+ public class WorkViewModel : IWorkModel
+ {
+ public int Id { get; set; }
+
+ [DisplayName("Название работы")]
+ public string WorkName { get; set; } =String.Empty;
+
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+
+ public Dictionary WorkComponents { get; set; } = new();
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairDataModels/IComponentModel.cs b/PlumbingRepair/PlumbingRepairDataModels/IComponentModel.cs
new file mode 100644
index 0000000..183a6fc
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairDataModels/IComponentModel.cs
@@ -0,0 +1,8 @@
+namespace PlumbingRepairDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairDataModels/IId.cs b/PlumbingRepair/PlumbingRepairDataModels/IId.cs
new file mode 100644
index 0000000..2cf8ec5
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairDataModels/IId.cs
@@ -0,0 +1,7 @@
+namespace PlumbingRepairDataModels.Models
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairDataModels/IOrderModel.cs b/PlumbingRepair/PlumbingRepairDataModels/IOrderModel.cs
new file mode 100644
index 0000000..a57c935
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairDataModels/IOrderModel.cs
@@ -0,0 +1,14 @@
+using PlumbingRepairDataModels.Enums;
+
+namespace PlumbingRepairDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int WorkId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairDataModels/IWorkModel.cs b/PlumbingRepair/PlumbingRepairDataModels/IWorkModel.cs
new file mode 100644
index 0000000..f2d10d0
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairDataModels/IWorkModel.cs
@@ -0,0 +1,9 @@
+namespace PlumbingRepairDataModels.Models
+{
+ public interface IWorkModel : IId
+ {
+ string WorkName { get; }
+ double Price { get; }
+ Dictionary WorkComponents { get; }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairDataModels/OrderStatus.cs b/PlumbingRepair/PlumbingRepairDataModels/OrderStatus.cs
new file mode 100644
index 0000000..46e19f4
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairDataModels/OrderStatus.cs
@@ -0,0 +1,11 @@
+namespace PlumbingRepairDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairDataModels/PlumbingRepairDataModels.csproj b/PlumbingRepair/PlumbingRepairDataModels/PlumbingRepairDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairDataModels/PlumbingRepairDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs b/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..e2f421c
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs
@@ -0,0 +1,26 @@
+using PlumbingRepairListImplement.Models;
+
+namespace PlumbingRepairListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Works { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Works = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/ComponentStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..98a8e14
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,102 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairListImplement.Models;
+
+namespace PlumbingRepairListImplement.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/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..cca8837
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,119 @@
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairListImplement.Models;
+
+namespace PlumbingRepairListImplement.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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs
new file mode 100644
index 0000000..2493826
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs
@@ -0,0 +1,121 @@
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairListImplement.Models;
+
+namespace PlumbingRepairListImplement.Implements
+{
+ public class WorkStorage : IWorkStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public WorkStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+
+ foreach (var work in _source.Works)
+ {
+ result.Add(work.GetViewModel);
+ }
+
+ return result;
+ }
+
+ public List GetFilteredList(WorkSearchModel model)
+ {
+ var result = new List();
+
+ if (string.IsNullOrEmpty(model.WorkName))
+ {
+ return result;
+ }
+
+ foreach (var work in _source.Works)
+ {
+ if (work.WorkName.Contains(model.WorkName))
+ {
+ result.Add(work.GetViewModel);
+ }
+ }
+
+ return result;
+ }
+
+ public WorkViewModel? GetElement(WorkSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.WorkName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+
+ foreach (var work in _source.Works)
+ {
+ if ((!string.IsNullOrEmpty(model.WorkName) && work.WorkName == model.WorkName) || (model.Id.HasValue && work.Id == model.Id))
+ {
+ return work.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public WorkViewModel? Insert(WorkBindingModel model)
+ {
+ model.Id = 1;
+
+ foreach (var work in _source.Works)
+ {
+ if (model.Id <= work.Id)
+ {
+ model.Id = work.Id + 1;
+ }
+ }
+
+ var newWork = Work.Create(model);
+
+ if (newWork == null)
+ {
+ return null;
+ }
+
+ _source.Works.Add(newWork);
+
+ return newWork.GetViewModel;
+ }
+
+ public WorkViewModel? Update(WorkBindingModel model)
+ {
+ foreach (var work in _source.Works)
+ {
+ if (work.Id == model.Id)
+ {
+ work.Update(model);
+ return work.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public WorkViewModel? Delete(WorkBindingModel model)
+ {
+ for (int i = 0; i < _source.Works.Count; ++i)
+ {
+ if (_source.Works[i].Id == model.Id)
+ {
+ var element = _source.Works[i];
+ _source.Works.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs
new file mode 100644
index 0000000..2e17780
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs
@@ -0,0 +1,42 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairListImplement.Models
+{
+ public class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } =String.Empty;
+ public double Cost { get; set; }
+ public static Component? Create(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost,
+ };
+ }
+ public void Update(ComponentBindingModel? model)
+ {
+ if(model == null)
+ {
+ return;
+ }
+ ComponentName= model.ComponentName;
+ Cost= model.Cost;
+ }
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs
new file mode 100644
index 0000000..6acffb7
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs
@@ -0,0 +1,65 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Enums;
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int WorkId { get; private set; }
+ public string WorkName { 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,
+ WorkId = model.WorkId,
+ WorkName = model.WorkName,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement
+ };
+ }
+
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ WorkId = model.WorkId;
+ WorkName = model.WorkName;
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateCreate = model.DateCreate;
+ DateImplement = model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ WorkId = WorkId,
+ WorkName = WorkName,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs
new file mode 100644
index 0000000..b220bbc
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs
@@ -0,0 +1,48 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairListImplement.Models
+{
+ public class Work : IWorkModel
+ {
+ public int Id { get; private set; }
+ public string WorkName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary WorkComponents { get; private set; } = new Dictionary();
+
+ public static Work? Create(WorkBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Work()
+ {
+ Id = model.Id,
+ WorkName = model.WorkName,
+ Price = model.Price,
+ WorkComponents = model.WorkComponents
+ };
+ }
+
+ public void Update(WorkBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ WorkName = model.WorkName;
+ Price = model.Price;
+ WorkComponents = model.WorkComponents;
+ }
+
+ public WorkViewModel GetViewModel => new()
+ {
+ Id = Id,
+ WorkName = WorkName,
+ Price = Price,
+ WorkComponents = WorkComponents
+ };
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj b/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj
new file mode 100644
index 0000000..05f8377
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponent.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormComponent.Designer.cs
new file mode 100644
index 0000000..44a7f2e
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponent.Designer.cs
@@ -0,0 +1,119 @@
+namespace PlumbingRepairView
+{
+ partial class FormComponent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.textBoxCost = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 14);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(80, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Название:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 57);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(48, 20);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Цена:";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(107, 14);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(314, 27);
+ this.textBoxName.TabIndex = 2;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(335, 113);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 29);
+ this.buttonCancel.TabIndex = 3;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(235, 113);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(94, 29);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(107, 57);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(140, 27);
+ this.textBoxCost.TabIndex = 5;
+ //
+ // FormComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(441, 154);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Name = "FormComponent";
+ this.Text = "Компонент";
+ this.Load += new System.EventHandler(this.FormComponent_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private TextBox textBoxName;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxCost;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponent.cs b/PlumbingRepair/PlumbingRepairView/FormComponent.cs
new file mode 100644
index 0000000..35a8b17
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponent.cs
@@ -0,0 +1,80 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace PlumbingRepairView
+{
+ 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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponent.resx b/PlumbingRepair/PlumbingRepairView/FormComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs
new file mode 100644
index 0000000..702a1a8
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs
@@ -0,0 +1,115 @@
+namespace PlumbingRepairView
+{
+ partial class FormComponents
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonRef = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(0, 1);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(626, 449);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(669, 29);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(94, 29);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(669, 96);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(94, 29);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(669, 162);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(94, 29);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(669, 239);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(94, 29);
+ this.buttonRef.TabIndex = 4;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
+ //
+ // FormComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormComponents";
+ this.Text = "Компоненты";
+ this.Load += new System.EventHandler(this.FormComponents_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponents.cs b/PlumbingRepair/PlumbingRepairView/FormComponents.cs
new file mode 100644
index 0000000..5d647d3
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponents.cs
@@ -0,0 +1,101 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace PlumbingRepairView
+{
+ 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/PlumbingRepair/PlumbingRepairView/FormComponents.resx b/PlumbingRepair/PlumbingRepairView/FormComponents.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponents.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormCreateOrder.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..4a7df40
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.Designer.cs
@@ -0,0 +1,144 @@
+namespace PlumbingRepairView
+{
+ 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.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.comboBoxWork = new System.Windows.Forms.ComboBox();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(23, 18);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(60, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Работа:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(23, 55);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(93, 20);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Количество:";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(23, 92);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(58, 20);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "Сумма:";
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(389, 139);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 29);
+ this.buttonCancel.TabIndex = 3;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(289, 139);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(94, 29);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(142, 55);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(341, 27);
+ this.textBoxCount.TabIndex = 5;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCount_TextChanged);
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(142, 92);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.Size = new System.Drawing.Size(341, 27);
+ this.textBoxSum.TabIndex = 6;
+ //
+ // comboBoxWork
+ //
+ this.comboBoxWork.FormattingEnabled = true;
+ this.comboBoxWork.Location = new System.Drawing.Point(142, 18);
+ this.comboBoxWork.Name = "comboBoxWork";
+ this.comboBoxWork.Size = new System.Drawing.Size(341, 28);
+ this.comboBoxWork.TabIndex = 7;
+ this.comboBoxWork.SelectedIndexChanged += new System.EventHandler(this.comboBoxWork_SelectedIndexChanged);
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(495, 180);
+ this.Controls.Add(this.comboBoxWork);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Name = "FormCreateOrder";
+ this.Text = "Заказ";
+ this.Load += new System.EventHandler(this.FormCreateOrder_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private ComboBox comboBoxWork;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormCreateOrder.cs b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.cs
new file mode 100644
index 0000000..42c173e
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.cs
@@ -0,0 +1,132 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace PlumbingRepairView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IWorkLogic _logicW;
+ private readonly IOrderLogic _logicO;
+
+ public FormCreateOrder(ILogger logger, IWorkLogic logicW, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicW = logicW;
+ _logicO = logicO;
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+
+ try
+ {
+ var list = _logicW.ReadList(null);
+ if (list != null)
+ {
+ comboBoxWork.DisplayMember = "WorkName";
+ comboBoxWork.ValueMember = "Id";
+ comboBoxWork.DataSource = list;
+ comboBoxWork.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void CalcSum()
+ {
+ if (comboBoxWork.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxWork.SelectedValue);
+
+ var product = _logicW.ReadElement(new WorkSearchModel
+ {
+ Id = id
+ });
+
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ }
+ private void textBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void comboBoxWork_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 (comboBoxWork.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Создание заказа");
+
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ WorkId = Convert.ToInt32(comboBoxWork.SelectedValue),
+ WorkName = comboBoxWork.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/PlumbingRepair/PlumbingRepairView/FormCreateOrder.resx b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
new file mode 100644
index 0000000..0c18e41
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
@@ -0,0 +1,176 @@
+namespace PlumbingRepairView
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonCreateOrder = new System.Windows.Forms.Button();
+ this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
+ this.buttonOrderReady = new System.Windows.Forms.Button();
+ this.buttonIssuedOrder = new System.Windows.Forms.Button();
+ this.buttonUpdateList = new System.Windows.Forms.Button();
+ this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.работыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.menuStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.справочникиToolStripMenuItem});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Size = new System.Drawing.Size(896, 28);
+ this.menuStrip1.TabIndex = 0;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.компонентыToolStripMenuItem,
+ this.работыToolStripMenuItem});
+ this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
+ this.справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(0, 31);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(586, 420);
+ this.dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ this.buttonCreateOrder.Location = new System.Drawing.Point(608, 44);
+ this.buttonCreateOrder.Name = "buttonCreateOrder";
+ this.buttonCreateOrder.Size = new System.Drawing.Size(276, 29);
+ this.buttonCreateOrder.TabIndex = 2;
+ this.buttonCreateOrder.Text = "Создать заказ";
+ this.buttonCreateOrder.UseVisualStyleBackColor = true;
+ this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
+ //
+ // buttonTakeOrderInWork
+ //
+ this.buttonTakeOrderInWork.Location = new System.Drawing.Point(608, 132);
+ this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ this.buttonTakeOrderInWork.Size = new System.Drawing.Size(276, 29);
+ this.buttonTakeOrderInWork.TabIndex = 3;
+ this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click);
+ //
+ // buttonOrderReady
+ //
+ this.buttonOrderReady.Location = new System.Drawing.Point(608, 223);
+ this.buttonOrderReady.Name = "buttonOrderReady";
+ this.buttonOrderReady.Size = new System.Drawing.Size(276, 29);
+ this.buttonOrderReady.TabIndex = 4;
+ this.buttonOrderReady.Text = "Заказ готов";
+ this.buttonOrderReady.UseVisualStyleBackColor = true;
+ this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click);
+ //
+ // buttonIssuedOrder
+ //
+ this.buttonIssuedOrder.Location = new System.Drawing.Point(608, 313);
+ this.buttonIssuedOrder.Name = "buttonIssuedOrder";
+ this.buttonIssuedOrder.Size = new System.Drawing.Size(276, 29);
+ this.buttonIssuedOrder.TabIndex = 5;
+ this.buttonIssuedOrder.Text = "Заказ выдан";
+ this.buttonIssuedOrder.UseVisualStyleBackColor = true;
+ this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click);
+ //
+ // buttonUpdateList
+ //
+ this.buttonUpdateList.Location = new System.Drawing.Point(608, 384);
+ this.buttonUpdateList.Name = "buttonUpdateList";
+ this.buttonUpdateList.Size = new System.Drawing.Size(276, 29);
+ this.buttonUpdateList.TabIndex = 6;
+ this.buttonUpdateList.Text = "Обновить список";
+ this.buttonUpdateList.UseVisualStyleBackColor = true;
+ this.buttonUpdateList.Click += new System.EventHandler(this.buttonUpdateList_Click);
+ //
+ // компонентыToolStripMenuItem
+ //
+ this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.компонентыToolStripMenuItem.Text = "Компоненты";
+ this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
+ //
+ // работыToolStripMenuItem
+ //
+ this.работыToolStripMenuItem.Name = "работыToolStripMenuItem";
+ this.работыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.работыToolStripMenuItem.Text = "Работы";
+ this.работыToolStripMenuItem.Click += new System.EventHandler(this.работыToolStripMenuItem_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(896, 450);
+ this.Controls.Add(this.buttonUpdateList);
+ this.Controls.Add(this.buttonIssuedOrder);
+ this.Controls.Add(this.buttonOrderReady);
+ this.Controls.Add(this.buttonTakeOrderInWork);
+ this.Controls.Add(this.buttonCreateOrder);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.menuStrip1);
+ this.MainMenuStrip = this.menuStrip1;
+ this.Name = "FormMain";
+ this.Text = "Ремонт сантехники";
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonUpdateList;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem работыToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.cs b/PlumbingRepair/PlumbingRepairView/FormMain.cs
new file mode 100644
index 0000000..cdb5c27
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormMain.cs
@@ -0,0 +1,190 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairDataModels.Enums;
+
+namespace PlumbingRepairView
+{
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["WorkId"].Visible = false;
+ }
+
+ _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(FormWorks));
+
+ if (service is FormWorks form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void buttonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = id,
+ WorkId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["WorkId"].Value),
+ WorkName = dataGridView.SelectedRows[0].Cells["WorkName"].Value.ToString(),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
+
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
+ {
+ Id = id,
+ WorkId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["WorkId"].Value),
+ WorkName = dataGridView.SelectedRows[0].Cells["WorkName"].Value.ToString(),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+
+ try
+ {
+
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = id,
+ WorkId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["WorkId"].Value),
+ WorkName = dataGridView.SelectedRows[0].Cells["WorkName"].Value.ToString(),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonUpdateList_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.resx b/PlumbingRepair/PlumbingRepairView/FormMain.resx
new file mode 100644
index 0000000..938108a
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormMain.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
new file mode 100644
index 0000000..c1b1399
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
@@ -0,0 +1,231 @@
+namespace PlumbingRepairView
+{
+ partial class FormWork
+ {
+ ///
+ /// 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.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.buttonRef = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.textBoxCost = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.ComponentId = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(32, 10);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(80, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Название:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(32, 49);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(86, 20);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Стоимость:";
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.buttonRef);
+ this.groupBox1.Controls.Add(this.buttonDel);
+ this.groupBox1.Controls.Add(this.buttonUpd);
+ this.groupBox1.Controls.Add(this.buttonAdd);
+ this.groupBox1.Controls.Add(this.dataGridView);
+ this.groupBox1.Location = new System.Drawing.Point(32, 86);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(756, 307);
+ this.groupBox1.TabIndex = 2;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Компоненты";
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(602, 206);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(94, 29);
+ this.buttonRef.TabIndex = 4;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.UpdateButton_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(602, 152);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(94, 29);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.DeleteButton_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(602, 98);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(94, 29);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ChangeButton_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(602, 44);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(94, 29);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.AddButton_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ComponentId,
+ this.ComponentName,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(0, 26);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(534, 275);
+ this.dataGridView.TabIndex = 0;
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(150, 10);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(299, 27);
+ this.textBoxName.TabIndex = 3;
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(150, 49);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(206, 27);
+ this.textBoxCost.TabIndex = 4;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(634, 409);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 29);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отменить";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(534, 409);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(94, 29);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.SaveButton_Click);
+ //
+ // ComponentId
+ //
+ this.ComponentId.HeaderText = "Id";
+ this.ComponentId.MinimumWidth = 6;
+ this.ComponentId.Name = "ComponentId";
+ this.ComponentId.Visible = false;
+ this.ComponentId.Width = 125;
+ //
+ // ComponentName
+ //
+ this.ComponentName.HeaderText = "Компонент";
+ this.ComponentName.MinimumWidth = 6;
+ this.ComponentName.Name = "ComponentName";
+ this.ComponentName.Width = 355;
+ //
+ // Count
+ //
+ this.Count.HeaderText = "Количество";
+ this.Count.MinimumWidth = 6;
+ this.Count.Name = "Count";
+ this.Count.Width = 125;
+ //
+ // FormWork
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Name = "FormWork";
+ this.Text = "Работа";
+ this.groupBox1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private GroupBox groupBox1;
+ private DataGridView dataGridView;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private DataGridViewTextBoxColumn ComponentId;
+ private DataGridViewTextBoxColumn ComponentName;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWork.cs b/PlumbingRepair/PlumbingRepairView/FormWork.cs
new file mode 100644
index 0000000..698528a
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWork.cs
@@ -0,0 +1,229 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairDataModels.Models;
+using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
+
+namespace PlumbingRepairView
+{
+ public partial class FormWork : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IWorkLogic _logic;
+
+ private int? _id;
+
+ private Dictionary _workComponents;
+
+ public int Id { set { _id = value; } }
+ public FormWork(ILogger logger, IWorkLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _workComponents = new Dictionary();
+ }
+ private void FormWork_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+
+ try
+ {
+ var view = _logic.ReadElement(new WorkSearchModel
+ {
+ Id = _id.Value
+ });
+
+ if (view != null)
+ {
+ textBoxName.Text = view.WorkName;
+ textBoxCost.Text = view.Price.ToString();
+ _workComponents = view.WorkComponents ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+
+ try
+ {
+ if (_workComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _workComponents)
+ {
+ dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
+ }
+ textBoxCost.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонент изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent));
+
+ if (service is FormWorkComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+
+ if (_workComponents.ContainsKey(form.Id))
+ {
+ _workComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+
+ else
+ {
+ _workComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent));
+
+ if (service is FormWorkComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _workComponents[id].Item2;
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ _workComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void DeleteButton_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);
+ _workComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxCost.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (_workComponents == null || _workComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Сохранение изделия");
+
+ try
+ {
+ var model = new WorkBindingModel
+ {
+ Id = _id ?? 0,
+ WorkName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxCost.Text),
+ WorkComponents = _workComponents
+ };
+
+ 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 _workComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairView/FormWork.resx b/PlumbingRepair/PlumbingRepairView/FormWork.resx
new file mode 100644
index 0000000..9fb07e6
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWork.resx
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs
new file mode 100644
index 0000000..2dc4cc4
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs
@@ -0,0 +1,119 @@
+namespace PlumbingRepairView
+{
+ partial class FormWorkComponent
+ {
+ ///
+ /// 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.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.comboBoxComponent = new System.Windows.Forms.ComboBox();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(20, 22);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(91, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Компонент:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(20, 71);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(93, 20);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Количество:";
+ //
+ // comboBoxComponent
+ //
+ this.comboBoxComponent.FormattingEnabled = true;
+ this.comboBoxComponent.Location = new System.Drawing.Point(149, 19);
+ this.comboBoxComponent.Name = "comboBoxComponent";
+ this.comboBoxComponent.Size = new System.Drawing.Size(288, 28);
+ this.comboBoxComponent.TabIndex = 2;
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(149, 71);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(288, 27);
+ this.textBoxCount.TabIndex = 3;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(330, 117);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 29);
+ this.buttonCancel.TabIndex = 4;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(230, 117);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(94, 29);
+ this.buttonSave.TabIndex = 5;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // FormWorkComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(460, 161);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.comboBoxComponent);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Name = "FormWorkComponent";
+ this.Text = "Компонент работы";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs
new file mode 100644
index 0000000..f40195f
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs
@@ -0,0 +1,82 @@
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Models;
+
+namespace PlumbingRepairView
+{
+ public partial class FormWorkComponent : 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 FormWorkComponent(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/PlumbingRepair/PlumbingRepairView/FormWorkComponent.resx b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorks.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormWorks.Designer.cs
new file mode 100644
index 0000000..5231cdb
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorks.Designer.cs
@@ -0,0 +1,114 @@
+namespace PlumbingRepairView
+{
+ partial class FormWorks
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonRef = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(1, 0);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(611, 449);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(670, 23);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(94, 29);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.AddButton_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(670, 75);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(94, 29);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ChangeButton_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(670, 132);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(94, 29);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.DeleteButton_Click);
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(670, 188);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(94, 29);
+ this.buttonRef.TabIndex = 4;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.UpdateButton_Click);
+ //
+ // FormWorks
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormWorks";
+ this.Text = "Работы";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorks.cs b/PlumbingRepair/PlumbingRepairView/FormWorks.cs
new file mode 100644
index 0000000..a65b532
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorks.cs
@@ -0,0 +1,111 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinesLogicsContracts;
+
+namespace PlumbingRepairView
+{
+ public partial class FormWorks : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IWorkLogic _logic;
+
+ public FormWorks(ILogger logger, IWorkLogic 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["WorkName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["WorkComponents"].Visible = false;
+ }
+
+ _logger.LogInformation("Загрузка изделий");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormWork));
+
+ if (service is FormWork form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormWork));
+
+ if (service is FormWork form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void DeleteButton_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 WorkBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorks.resx b/PlumbingRepair/PlumbingRepairView/FormWorks.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorks.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/PlumbingRepairView.csproj b/PlumbingRepair/PlumbingRepairView/PlumbingRepairView.csproj
new file mode 100644
index 0000000..5e182e3
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/PlumbingRepairView.csproj
@@ -0,0 +1,22 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/Program.cs b/PlumbingRepair/PlumbingRepairView/Program.cs
new file mode 100644
index 0000000..14d3f5a
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/Program.cs
@@ -0,0 +1,54 @@
+using PlumbingRepairContracts.BusinesLogicsContracts;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairListImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using PlumbingRepairBusinessLogic.BusinesLogics;
+
+
+namespace PlumbingRepairView
+{
+ 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