From a0fd0c6864d6689a137207fdb0181602a67d46d5 Mon Sep 17 00:00:00 2001
From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com>
Date: Tue, 27 Feb 2024 22:51:12 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B11?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
PlumbingRepair/PlumbingRepair.sln | 18 +-
.../PlumbingRepair/PlumbingRepair.csproj | 4 +
PlumbingRepair/PlumbingRepair/Program.cs | 2 +-
.../BusinessLogics/OrderLogic.cs | 22 +-
.../BindingModels/OrderBindingModel.cs | 1 +
.../ViewModels/OrderViewModel.cs | 1 +
.../DataListSingleton.cs | 31 +++
.../Implements/ComponentStorage.cs | 107 ++++++++
.../Implements/OrderStorage.cs | 105 ++++++++
.../Implements/WorkStorage.cs | 126 +++++++++
.../Models/Component.cs | 41 +++
.../Models/Order.cs | 62 +++++
.../Models/Work.cs | 55 ++++
.../PlumbingRepairListImplement.csproj | 14 +
.../FormComponent.Designer.cs | 117 +++++++++
.../PlumbingRepairView/FormComponent.cs | 87 +++++++
.../PlumbingRepairView/FormComponent.resx | 120 +++++++++
.../FormComponents.Designer.cs | 109 ++++++++
.../PlumbingRepairView/FormComponents.cs | 104 ++++++++
.../PlumbingRepairView/FormComponents.resx | 120 +++++++++
.../FormCreateOrder.Designer.cs | 144 +++++++++++
.../PlumbingRepairView/FormCreateOrder.cs | 141 ++++++++++
.../PlumbingRepairView/FormCreateOrder.resx | 120 +++++++++
.../PlumbingRepairView/FormMain.Designer.cs | 180 +++++++++++++
PlumbingRepair/PlumbingRepairView/FormMain.cs | 199 +++++++++++++++
.../PlumbingRepairView/FormMain.resx | 123 +++++++++
.../PlumbingRepairView/FormWork.Designer.cs | 241 ++++++++++++++++++
PlumbingRepair/PlumbingRepairView/FormWork.cs | 237 +++++++++++++++++
.../PlumbingRepairView/FormWork.resx | 120 +++++++++
.../FormWorkComponent.Designer.cs | 116 +++++++++
.../PlumbingRepairView/FormWorkComponent.cs | 90 +++++++
.../PlumbingRepairView/FormWorkComponent.resx | 120 +++++++++
.../PlumbingRepairView/FormWorks.Designer.cs | 114 +++++++++
.../PlumbingRepairView/FormWorks.cs | 120 +++++++++
.../PlumbingRepairView/FormWorks.resx | 120 +++++++++
.../PlumbingRepairView.csproj | 22 ++
PlumbingRepair/PlumbingRepairView/Program.cs | 53 ++++
37 files changed, 3492 insertions(+), 14 deletions(-)
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Implements/ComponentStorage.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs
create mode 100644 PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj
create mode 100644 PlumbingRepair/PlumbingRepairView/FormComponent.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormComponent.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormComponent.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormComponents.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormComponents.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/FormCreateOrder.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormCreateOrder.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormCreateOrder.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormMain.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormMain.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWork.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWork.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWorkComponent.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWorks.Designer.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWorks.cs
create mode 100644 PlumbingRepair/PlumbingRepairView/FormWorks.resx
create mode 100644 PlumbingRepair/PlumbingRepairView/PlumbingRepairView.csproj
create mode 100644 PlumbingRepair/PlumbingRepairView/Program.cs
diff --git a/PlumbingRepair/PlumbingRepair.sln b/PlumbingRepair/PlumbingRepair.sln
index 4088c1d..f5fba87 100644
--- a/PlumbingRepair/PlumbingRepair.sln
+++ b/PlumbingRepair/PlumbingRepair.sln
@@ -5,11 +5,15 @@ VisualStudioVersion = 17.6.33801.468
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepair", "PlumbingRepair\PlumbingRepair.csproj", "{16CDF38C-189C-4BED-AB66-DB3C212C4047}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairDataModels", "PlumbingRepairDataModels\PlumbingRepairDataModels.csproj", "{F62B3ADF-0FE7-4066-BEF7-5DB0AE1A53A9}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairDataModels", "PlumbingRepairDataModels\PlumbingRepairDataModels.csproj", "{F62B3ADF-0FE7-4066-BEF7-5DB0AE1A53A9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairContracts", "PlumbingRepairContracts\PlumbingRepairContracts.csproj", "{FD429137-A114-4447-B51A-FCC11FEF7E2C}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairContracts", "PlumbingRepairContracts\PlumbingRepairContracts.csproj", "{FD429137-A114-4447-B51A-FCC11FEF7E2C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairBusinessLogic", "PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj", "{B960E476-E516-4BAA-B5D7-55F29B376993}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairBusinessLogic", "PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj", "{B960E476-E516-4BAA-B5D7-55F29B376993}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairListImplement", "PlumbingRepairListImplement\PlumbingRepairListImplement.csproj", "{E89CA82F-2FEA-4235-93A2-E5A412D0116F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairView", "PlumbingRepairView\PlumbingRepairView.csproj", "{4FB885A2-56C9-4267-84B0-A2161EB314C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,6 +37,14 @@ Global
{B960E476-E516-4BAA-B5D7-55F29B376993}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B960E476-E516-4BAA-B5D7-55F29B376993}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B960E476-E516-4BAA-B5D7-55F29B376993}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E89CA82F-2FEA-4235-93A2-E5A412D0116F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4FB885A2-56C9-4267-84B0-A2161EB314C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4FB885A2-56C9-4267-84B0-A2161EB314C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4FB885A2-56C9-4267-84B0-A2161EB314C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4FB885A2-56C9-4267-84B0-A2161EB314C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj b/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj
index b57c89e..e60bd40 100644
--- a/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj
+++ b/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj
@@ -8,4 +8,8 @@
enable
+
+
+
+
\ No newline at end of file
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/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs
index 28467f3..5fc5c55 100644
--- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -72,40 +72,42 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
return true;
}
- public bool StatusUpdate(OrderBindingModel model)
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
{
CheckModel(model);
- if(model.Status + 1 > OrderStatus.Выдан)
+ if (model.Status + 1 != newStatus)
{
- _logger.LogWarning("Status update: operation failed. Order status incorrect.");
+ _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
return false;
}
- model.Status += 1;
- if(model.Status == OrderStatus.Выдан)
- {
+
+ 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);
+ return StatusUpdate(model, OrderStatus.Выполняется);
}
public bool DeliveryOrder(OrderBindingModel model)
{
- return StatusUpdate(model);
+ return StatusUpdate(model, OrderStatus.Готов);
}
public bool FinishOrder(OrderBindingModel model)
{
- return StatusUpdate(model);
+ return StatusUpdate(model, OrderStatus.Выдан);
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs
index 80b2ea5..780a29e 100644
--- a/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs
+++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs
@@ -17,5 +17,6 @@ namespace PlumbingRepairContracts.BindingModels
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;
}
}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs
index 4aab652..5b54828 100644
--- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs
+++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs
@@ -1,4 +1,5 @@
using PlumbingRepairDataModels.Enums;
+using PlumbingRepairDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
diff --git a/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs b/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..93d388a
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs
@@ -0,0 +1,31 @@
+using PlumbingRepairListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+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..8c350cb
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,107 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+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..ab24931
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,105 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+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;
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs
new file mode 100644
index 0000000..7e3846d
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/WorkStorage.cs
@@ -0,0 +1,126 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+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;
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs
new file mode 100644
index 0000000..a84a43e
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Component.cs
@@ -0,0 +1,41 @@
+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
+ };
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs
new file mode 100644
index 0000000..a350881
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs
@@ -0,0 +1,62 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Enums;
+using PlumbingRepairDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PlumbingRepairListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int WorkId { get; private set; }
+ public int Count { get; private set; }
+ public double Sum { get; private set; }
+ public OrderStatus Status { get; private set; }
+ public DateTime DateCreate { get; private set; }
+ public DateTime? DateImplement { get; private set; }
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if(model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ WorkId = model.WorkId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateCreate = model.DateCreate;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ WorkId = WorkId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ };
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs
new file mode 100644
index 0000000..2971326
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Work.cs
@@ -0,0 +1,55 @@
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+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
+ };
+ }
+}
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..d5db281
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponent.Designer.cs
@@ -0,0 +1,117 @@
+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()
+ {
+ textBoxName = new TextBox();
+ textBoxCost = new TextBox();
+ labelName = new Label();
+ labelCost = new Label();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(140, 13);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(168, 31);
+ textBoxName.TabIndex = 0;
+ //
+ // textBoxCost
+ //
+ textBoxCost.Location = new Point(140, 58);
+ textBoxCost.Name = "textBoxCost";
+ textBoxCost.Size = new Size(168, 31);
+ textBoxCost.TabIndex = 1;
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(10, 19);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(94, 25);
+ labelName.TabIndex = 2;
+ labelName.Text = "Название:";
+ //
+ // labelCost
+ //
+ labelCost.AutoSize = true;
+ labelCost.Location = new Point(12, 64);
+ labelCost.Name = "labelCost";
+ labelCost.Size = new Size(57, 25);
+ labelCost.TabIndex = 3;
+ labelCost.Text = "Цена:";
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(163, 95);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(112, 34);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(281, 95);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(86, 34);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormComponent
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(374, 141);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(labelCost);
+ Controls.Add(labelName);
+ Controls.Add(textBoxCost);
+ Controls.Add(textBoxName);
+ Name = "FormComponent";
+ Text = "Компонент";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Label labelName;
+ private Label labelCost;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponent.cs b/PlumbingRepair/PlumbingRepairView/FormComponent.cs
new file mode 100644
index 0000000..c080e07
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponent.cs
@@ -0,0 +1,87 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.SearchModels;
+using System.Windows.Forms;
+
+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..a395bff
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs
new file mode 100644
index 0000000..583fc0f
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponents.Designer.cs
@@ -0,0 +1,109 @@
+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()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonDel = new Button();
+ buttonChange = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 10);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 62;
+ dataGridView.RowTemplate.Height = 33;
+ dataGridView.Size = new Size(640, 505);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(684, 41);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(135, 34);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(684, 106);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(135, 34);
+ buttonDel.TabIndex = 2;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(684, 184);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(135, 34);
+ buttonChange.TabIndex = 3;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(684, 261);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(135, 34);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(848, 527);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormComponents";
+ Text = "Компоненты";
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonDel;
+ private Button buttonChange;
+ 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..4cc2bcc
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponents.cs
@@ -0,0 +1,104 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+
+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..a395bff
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormComponents.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/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..b12da69
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.cs
@@ -0,0 +1,141 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace 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..1af7de1
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormCreateOrder.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
new file mode 100644
index 0000000..c3cf2cb
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
@@ -0,0 +1,180 @@
+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()
+ {
+ menuStrip1 = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ компонентыToolStripMenuItem = new ToolStripMenuItem();
+ работыToolStripMenuItem = new ToolStripMenuItem();
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonUpdateList = new Button();
+ menuStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip1
+ //
+ menuStrip1.ImageScalingSize = new Size(20, 20);
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Padding = new Padding(8, 2, 0, 2);
+ menuStrip1.Size = new Size(992, 33);
+ menuStrip1.TabIndex = 0;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, работыToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(139, 29);
+ справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ компонентыToolStripMenuItem.Size = new Size(218, 34);
+ компонентыToolStripMenuItem.Text = "Компоненты";
+ компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
+ //
+ // работыToolStripMenuItem
+ //
+ работыToolStripMenuItem.Name = "работыToolStripMenuItem";
+ работыToolStripMenuItem.Size = new Size(218, 34);
+ работыToolStripMenuItem.Text = "Работы";
+ работыToolStripMenuItem.Click += работыToolStripMenuItem_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 39);
+ dataGridView.Margin = new Padding(4, 4, 4, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(732, 525);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(760, 55);
+ buttonCreateOrder.Margin = new Padding(4, 4, 4, 4);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(212, 36);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += buttonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(760, 165);
+ buttonTakeOrderInWork.Margin = new Padding(4, 4, 4, 4);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(212, 36);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(760, 279);
+ buttonOrderReady.Margin = new Padding(4, 4, 4, 4);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(212, 36);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += buttonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(760, 391);
+ buttonIssuedOrder.Margin = new Padding(4, 4, 4, 4);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(212, 36);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += buttonIssuedOrder_Click;
+ //
+ // buttonUpdateList
+ //
+ buttonUpdateList.Location = new Point(760, 480);
+ buttonUpdateList.Margin = new Padding(4, 4, 4, 4);
+ buttonUpdateList.Name = "buttonUpdateList";
+ buttonUpdateList.Size = new Size(212, 36);
+ buttonUpdateList.TabIndex = 6;
+ buttonUpdateList.Text = "Обновить список";
+ buttonUpdateList.UseVisualStyleBackColor = true;
+ buttonUpdateList.Click += buttonUpdateList_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(992, 562);
+ Controls.Add(buttonUpdateList);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
+ Margin = new Padding(4, 4, 4, 4);
+ Name = "FormMain";
+ Text = "Ремонт сантехники";
+ Load += FormMain_Load;
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private 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..3ba4a05
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormMain.cs
@@ -0,0 +1,199 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace 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..5203d24
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormMain.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
new file mode 100644
index 0000000..7efd0de
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
@@ -0,0 +1,241 @@
+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()
+ {
+ label1 = new Label();
+ label2 = new Label();
+ groupBox1 = new GroupBox();
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ComponentId = new DataGridViewTextBoxColumn();
+ ComponentName = new DataGridViewTextBoxColumn();
+ Count = new DataGridViewTextBoxColumn();
+ textBoxName = new TextBox();
+ textBoxCost = new TextBox();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(40, 12);
+ label1.Margin = new Padding(4, 0, 4, 0);
+ label1.Name = "label1";
+ label1.Size = new Size(94, 25);
+ label1.TabIndex = 0;
+ label1.Text = "Название:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(40, 61);
+ label2.Margin = new Padding(4, 0, 4, 0);
+ label2.Name = "label2";
+ label2.Size = new Size(103, 25);
+ label2.TabIndex = 1;
+ label2.Text = "Стоимость:";
+ //
+ // groupBox1
+ //
+ groupBox1.Controls.Add(buttonRef);
+ groupBox1.Controls.Add(buttonDel);
+ groupBox1.Controls.Add(buttonUpd);
+ groupBox1.Controls.Add(buttonAdd);
+ groupBox1.Controls.Add(dataGridView);
+ groupBox1.Location = new Point(40, 108);
+ groupBox1.Margin = new Padding(4, 4, 4, 4);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Padding = new Padding(4, 4, 4, 4);
+ groupBox1.Size = new Size(945, 384);
+ groupBox1.TabIndex = 2;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Компоненты";
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(752, 258);
+ buttonRef.Margin = new Padding(4, 4, 4, 4);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(118, 36);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += UpdateButton_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(752, 190);
+ buttonDel.Margin = new Padding(4, 4, 4, 4);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(118, 36);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += DeleteButton_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(752, 122);
+ buttonUpd.Margin = new Padding(4, 4, 4, 4);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(118, 36);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ChangeButton_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(752, 55);
+ buttonAdd.Margin = new Padding(4, 4, 4, 4);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(118, 36);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += AddButton_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentId, ComponentName, Count });
+ dataGridView.Location = new Point(0, 32);
+ dataGridView.Margin = new Padding(4, 4, 4, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(668, 344);
+ dataGridView.TabIndex = 0;
+ //
+ // ComponentId
+ //
+ ComponentId.HeaderText = "Id";
+ ComponentId.MinimumWidth = 6;
+ ComponentId.Name = "ComponentId";
+ ComponentId.Visible = false;
+ ComponentId.Width = 125;
+ //
+ // ComponentName
+ //
+ ComponentName.HeaderText = "Компонент";
+ ComponentName.MinimumWidth = 6;
+ ComponentName.Name = "ComponentName";
+ ComponentName.Width = 355;
+ //
+ // Count
+ //
+ Count.HeaderText = "Количество";
+ Count.MinimumWidth = 6;
+ Count.Name = "Count";
+ Count.Width = 125;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(188, 12);
+ textBoxName.Margin = new Padding(4, 4, 4, 4);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(373, 31);
+ textBoxName.TabIndex = 3;
+ //
+ // textBoxCost
+ //
+ textBoxCost.Location = new Point(188, 61);
+ textBoxCost.Margin = new Padding(4, 4, 4, 4);
+ textBoxCost.Name = "textBoxCost";
+ textBoxCost.Size = new Size(256, 31);
+ textBoxCost.TabIndex = 4;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(857, 511);
+ buttonCancel.Margin = new Padding(4, 4, 4, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(118, 36);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отменить";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(731, 511);
+ buttonSave.Margin = new Padding(4, 4, 4, 4);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(118, 36);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += SaveButton_Click;
+ //
+ // FormWork
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1000, 562);
+ Controls.Add(buttonSave);
+ Controls.Add(buttonCancel);
+ Controls.Add(textBoxCost);
+ Controls.Add(textBoxName);
+ Controls.Add(groupBox1);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Margin = new Padding(4, 4, 4, 4);
+ Name = "FormWork";
+ Text = "Работа";
+ groupBox1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ 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..d79d70e
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWork.cs
@@ -0,0 +1,237 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairContracts.SearchModels;
+using PlumbingRepairDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace 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..a395bff
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWork.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs
new file mode 100644
index 0000000..000d6e3
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.Designer.cs
@@ -0,0 +1,116 @@
+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()
+ {
+ comboBoxComponent = new ComboBox();
+ labelComponent = new Label();
+ labelCount = new Label();
+ textBoxCount = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(138, 12);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(295, 33);
+ comboBoxComponent.TabIndex = 0;
+ //
+ // labelComponent
+ //
+ labelComponent.AutoSize = true;
+ labelComponent.Location = new Point(12, 15);
+ labelComponent.Name = "labelComponent";
+ labelComponent.Size = new Size(107, 25);
+ labelComponent.TabIndex = 1;
+ labelComponent.Text = "Компонент:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(12, 69);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(111, 25);
+ labelCount.TabIndex = 2;
+ labelCount.Text = "Количество:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(140, 69);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(293, 31);
+ textBoxCount.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(177, 106);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(112, 34);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(295, 106);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(82, 34);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormWorkComponent
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(445, 146);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(labelCount);
+ Controls.Add(labelComponent);
+ Controls.Add(comboBoxComponent);
+ Name = "FormWorkComponent";
+ Text = "Компонент Изделия";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private ComboBox comboBoxComponent;
+ private Label labelComponent;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs
new file mode 100644
index 0000000..9e2a11f
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.cs
@@ -0,0 +1,90 @@
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairContracts.ViewModels;
+using PlumbingRepairDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace 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..a395bff
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorkComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/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..b09fdda
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorks.cs
@@ -0,0 +1,120 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace 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..1af7de1
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/FormWorks.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepairView/PlumbingRepairView.csproj b/PlumbingRepair/PlumbingRepairView/PlumbingRepairView.csproj
new file mode 100644
index 0000000..4194bad
--- /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..9aa4ced
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepairView/Program.cs
@@ -0,0 +1,53 @@
+using PlumbingRepairContracts.BusinessLogicsContracts;
+using PlumbingRepairContracts.StoragesContracts;
+using PlumbingRepairListImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using PlumbingRepairBusinessLogic.BusinessLogics;
+
+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