From 697db40b943974c4eacb8a4d21a1c6870b27bcab Mon Sep 17 00:00:00 2001 From: sofiaivv Date: Thu, 8 Feb 2024 00:52:37 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=BC=D1=8F=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrecastConcretePlant/PrecastConcretePlant.sln | 34 ++++++++++++++++--- .../PrecastConcretePlantBusinessLogic.csproj | 9 +++++ .../PrecastConcretePlantContracts.csproj | 9 +++++ .../IComponentModel.cs | 12 +++++++ .../PrecastConcretePlantDataModels/IId.cs | 12 +++++++ .../IOrderModel.cs | 12 +++++++ .../IReinforcedModel.cs | 12 +++++++ .../OrderStatus.cs | 12 +++++++ .../PrecastConcretePlantDataModels.csproj | 9 +++++ .../PrecastConcretePlantListImplement.csproj | 9 +++++ .../PrecastConcretePlantView.csproj | 9 +++++ 11 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln index 3e53635..405f74d 100644 --- a/PrecastConcretePlant/PrecastConcretePlant.sln +++ b/PrecastConcretePlant/PrecastConcretePlant.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33627.172 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{6CAD7B33-E843-406E-B355-D6DFA1B9C3C3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{EAF69D0D-880A-4C49-9453-C75DB36819DD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{CE7F1778-2FB7-4BB4-B0E0-321782775DC8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantView", "PrecastConcretePlantView\PrecastConcretePlantView.csproj", "{ADE81417-6048-4551-A0D0-38F3EA2D19A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{13580262-9584-4C45-AB47-31901F3FBCC8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantListImplement", "PrecastConcretePlantListImplement\PrecastConcretePlantListImplement.csproj", "{CF73527C-9003-4A88-AFBB-58272DFB6859}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,10 +19,26 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6CAD7B33-E843-406E-B355-D6DFA1B9C3C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6CAD7B33-E843-406E-B355-D6DFA1B9C3C3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6CAD7B33-E843-406E-B355-D6DFA1B9C3C3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6CAD7B33-E843-406E-B355-D6DFA1B9C3C3}.Release|Any CPU.Build.0 = Release|Any CPU + {EAF69D0D-880A-4C49-9453-C75DB36819DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAF69D0D-880A-4C49-9453-C75DB36819DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAF69D0D-880A-4C49-9453-C75DB36819DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAF69D0D-880A-4C49-9453-C75DB36819DD}.Release|Any CPU.Build.0 = Release|Any CPU + {CE7F1778-2FB7-4BB4-B0E0-321782775DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE7F1778-2FB7-4BB4-B0E0-321782775DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE7F1778-2FB7-4BB4-B0E0-321782775DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE7F1778-2FB7-4BB4-B0E0-321782775DC8}.Release|Any CPU.Build.0 = Release|Any CPU + {ADE81417-6048-4551-A0D0-38F3EA2D19A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ADE81417-6048-4551-A0D0-38F3EA2D19A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ADE81417-6048-4551-A0D0-38F3EA2D19A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ADE81417-6048-4551-A0D0-38F3EA2D19A8}.Release|Any CPU.Build.0 = Release|Any CPU + {13580262-9584-4C45-AB47-31901F3FBCC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13580262-9584-4C45-AB47-31901F3FBCC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13580262-9584-4C45-AB47-31901F3FBCC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13580262-9584-4C45-AB47-31901F3FBCC8}.Release|Any CPU.Build.0 = Release|Any CPU + {CF73527C-9003-4A88-AFBB-58272DFB6859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF73527C-9003-4A88-AFBB-58272DFB6859}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF73527C-9003-4A88-AFBB-58272DFB6859}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF73527C-9003-4A88-AFBB-58272DFB6859}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs new file mode 100644 index 0000000..22eb861 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantDataModels +{ + internal class IComponentModel + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs new file mode 100644 index 0000000..1b8cc8c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantDataModels +{ + internal class IId + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs new file mode 100644 index 0000000..af2b072 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantDataModels +{ + internal class IOrderModel + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs new file mode 100644 index 0000000..c21df8b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantDataModels +{ + internal class IReinforcedModel + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs new file mode 100644 index 0000000..3ffceef --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantDataModels +{ + internal class OrderStatus + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj b/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + -- 2.25.1 From 2d53ba936b0abeedd1145cd55883f816ca7a9022 Mon Sep 17 00:00:00 2001 From: sofiaivv Date: Thu, 8 Feb 2024 20:30:24 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=BC=D1=8F=D1=832?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/ComponentBindingModel.cs | 12 ++++++++++++ .../IComponentModel.cs | 11 +++++++---- .../PrecastConcretePlantDataModels/IId.cs | 5 +++-- .../PrecastConcretePlantDataModels/IOrderModel.cs | 13 ++++++++++--- .../IReinforcedModel.cs | 10 +++++++--- .../PrecastConcretePlantDataModels/OrderStatus.cs | 11 ++++++++--- 6 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..6a630d6 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantContracts.BindingModels +{ + internal class ComponentBindingModel + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs index 22eb861..dee2b92 100644 --- a/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs @@ -1,12 +1,15 @@ -using System; +using PrecastConcretePlantDataModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PrecastConcretePlantDataModels +namespace PrecastConcretePlantDataModels.Models { - internal class IComponentModel + public interface IComponentModel : IId { + string ComponentName { get; } + double Cost { get; } } -} +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs index 1b8cc8c..d7c9ee9 100644 --- a/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace PrecastConcretePlantDataModels { - internal class IId + public interface IId { + int Id { get; } } -} +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs index af2b072..db89e4e 100644 --- a/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs @@ -1,12 +1,19 @@ -using System; +using PrecastConcretePlantDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PrecastConcretePlantDataModels +namespace PrecastConcretePlantDataModels.Models { - internal class IOrderModel + public interface IOrderModel : IId { + int ReinforcedId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } } } diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs index c21df8b..a0df31c 100644 --- a/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs @@ -1,12 +1,16 @@ -using System; +using PrecastConcretePlantDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PrecastConcretePlantDataModels +namespace PrecastConcretePlantDataModels.Models { - internal class IReinforcedModel + public interface IReinforcedModel : IId { + string ReinforcedName { get; } + double Price { get; } + Dictionary ReinforcedComponents { get; } } } diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs index 3ffceef..e90a627 100644 --- a/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs @@ -4,9 +4,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PrecastConcretePlantDataModels +namespace PrecastConcretePlantDataModels.Enums { - internal class OrderStatus + public enum OrderStatus { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 } -} +} \ No newline at end of file -- 2.25.1 From 1b9dfa12377414f98529485c2a721ad324cda939 Mon Sep 17 00:00:00 2001 From: sofiaivv Date: Fri, 9 Feb 2024 20:42:20 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B5=20=D0=BC=D1=8F=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/ComponentBindingModel.cs | 7 +++++- .../BindingModels/OrderBindingModel.cs | 22 +++++++++++++++++++ .../BindingModels/ProductBindingModel.cs | 12 ++++++++++ .../PrecastConcretePlantContracts.csproj | 6 ++++- 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs index 6a630d6..f0b8942 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs @@ -3,10 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using PrecastConcretePlantDataModels.Models; namespace PrecastConcretePlantContracts.BindingModels { - internal class ComponentBindingModel + public class ComponentBindingModel : IComponentModel { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } } + } diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..82d3b9d --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int ProductId { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs new file mode 100644 index 0000000..e280246 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantContracts.BindingModels +{ + internal class ProductBindingModel + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj index 132c02c..dae7eac 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,4 +6,8 @@ enable + + + + -- 2.25.1 From 4a217bb01f2806fc6b39783f9067203c4ace9c0f Mon Sep 17 00:00:00 2001 From: sofiaivv Date: Tue, 5 Mar 2024 07:44:51 +0400 Subject: [PATCH 4/5] done --- PrecastConcretePlant/PrecastConcretePlant.sln | 10 +- .../ComponentLogic.cs | 112 +++++++++ .../OrderLogic.cs | 120 +++++++++ .../PrecastConcretePlantBusinessLogic.csproj | 8 + .../ReinforcedLogic.cs | 122 ++++++++++ .../BindingModels/ComponentBindingModel.cs | 7 +- .../BindingModels/OrderBindingModel.cs | 2 +- .../BindingModels/ReinforcedBindingModel.cs | 18 ++ .../IComponentLogic.cs | 20 ++ .../BusinessLogicsContracts/IOrderLogic.cs | 20 ++ .../IReinforcedLogic.cs | 20 ++ .../PrecastConcretePlantContracts.csproj | 4 + .../SearchModels/ComponentSearchModel.cs | 14 ++ .../OrderSearchModel.cs} | 7 +- .../SearchModels/ReinforcedSearchModel.cs | 14 ++ .../StoragesContracts/IComponentStorage.cs | 21 ++ .../StoragesContracts/IOrderStorage.cs | 21 ++ .../StoragesContracts/IReinforcedStorage.cs | 21 ++ .../ViewModels/ComponentViewModel.cs | 19 ++ .../ViewModels/OrderViewModel.cs | 30 +++ .../ViewModels/ReinforcedViewModel.cs | 20 ++ .../DataListSingleton.cs | 32 +++ .../Implements/ComponentStorage.cs | 106 ++++++++ .../Implements/OrderStorage.cs | 122 ++++++++++ .../Implements/ReinforcedStorage.cs | 106 ++++++++ .../Models/Component.cs | 46 ++++ .../Models/Order.cs | 63 +++++ .../Models/Reinforced.cs | 50 ++++ .../PrecastConcretePlantListImplement.csproj | 7 +- .../FormComponent.Designer.cs | 120 +++++++++ .../PrecastConcretePlantView/FormComponent.cs | 93 +++++++ .../FormComponent.resx | 60 +++++ .../FormComponents.Designer.cs | 150 ++++++++++++ .../FormComponents.cs | 118 +++++++++ .../FormComponents.resx | 69 ++++++ .../FormCreateOrder.Designer.cs | 143 +++++++++++ .../FormCreateOrder.cs | 118 +++++++++ .../FormCreateOrder.resx | 60 +++++ .../FormMain.Designer.cs | 230 ++++++++++++++++++ .../PrecastConcretePlantView/FormMain.cs | 165 +++++++++++++ .../PrecastConcretePlantView/FormMain.resx | 84 +++++++ .../FormReinforced.Designer.cs | 221 +++++++++++++++++ .../FormReinforced.cs | 20 ++ .../FormReinforced.resx | 69 ++++++ .../FormReinforcedComponent.Designer.cs | 119 +++++++++ .../FormReinforcedComponent.cs | 85 +++++++ .../FormReinforcedComponent.resx | 60 +++++ .../FormReinforcedes.Designer.cs | 39 +++ .../FormReinforcedes.cs | 20 ++ .../FormReinforcedes.resx | 120 +++++++++ .../PrecastConcretePlantView.csproj | 20 +- .../PrecastConcretePlantView/Program.cs | 55 +++++ 52 files changed, 3382 insertions(+), 18 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs rename PrecastConcretePlant/PrecastConcretePlantContracts/{BindingModels/ProductBindingModel.cs => SearchModels/OrderSearchModel.cs} (51%) create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormComponent.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlantView/Program.cs diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln index 405f74d..8791798 100644 --- a/PrecastConcretePlant/PrecastConcretePlant.sln +++ b/PrecastConcretePlant/PrecastConcretePlant.sln @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33627.172 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{EAF69D0D-880A-4C49-9453-C75DB36819DD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{EAF69D0D-880A-4C49-9453-C75DB36819DD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{CE7F1778-2FB7-4BB4-B0E0-321782775DC8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{CE7F1778-2FB7-4BB4-B0E0-321782775DC8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantView", "PrecastConcretePlantView\PrecastConcretePlantView.csproj", "{ADE81417-6048-4551-A0D0-38F3EA2D19A8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantView", "PrecastConcretePlantView\PrecastConcretePlantView.csproj", "{ADE81417-6048-4551-A0D0-38F3EA2D19A8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{13580262-9584-4C45-AB47-31901F3FBCC8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{13580262-9584-4C45-AB47-31901F3FBCC8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantListImplement", "PrecastConcretePlantListImplement\PrecastConcretePlantListImplement.csproj", "{CF73527C-9003-4A88-AFBB-58272DFB6859}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantListImplement", "PrecastConcretePlantListImplement\PrecastConcretePlantListImplement.csproj", "{CF73527C-9003-4A88-AFBB-58272DFB6859}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..a3168dc --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.StoragesContracts; +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantContracts.SearchModels; + +namespace PrecastConcretePlantBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}.Id: { Id}", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..1626f0a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Enums; + +namespace PrecastConcretePlantBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + return false; + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Готов); + } + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выдан); + } + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий в заказе не может быть меньше 1", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum)); + } + if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate) + { + throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}"); + } + _logger.LogInformation("Reinforced. ReinforcedId:{ReinforcedId}.Count:{Count}.Sum:{Sum}Id:{Id}", + model.ReinforcedId, model.Count, model.Sum, model.Id); + } + private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) + { + CheckModel(model, false); + var element = _orderStorage.GetElement(new OrderSearchModel() + { + Id = model.Id + }); + if (element == null) + { + throw new ArgumentNullException(nameof(element)); + } + model.DateCreate = element.DateCreate; + model.ReinforcedId = element.ReinforcedId; + model.DateImplement = element.DateImplement; + model.Status = element.Status; + model.Count = element.Count; + model.Sum = element.Sum; + if (requiredStatus - model.Status == 1) + { + model.Status = requiredStatus; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); + throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj index 132c02c..87c12b3 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj @@ -6,4 +6,12 @@ enable + + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs new file mode 100644 index 0000000..4ebc6df --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantBusinessLogic.BusinessLogics +{ + public class ReinforcedLogic : IReinforcedLogic + { + private readonly ILogger _logger; + private readonly IReinforcedStorage _reinforcedStorage; + public ReinforcedLogic(ILogger logger, IReinforcedStorage reinforcedStorage) + { + _logger = logger; + _reinforcedStorage = reinforcedStorage; + } + public List? ReadList(ReinforcedSearchModel? model) + { + _logger.LogInformation("ReadList. ReinforcedName:{ReinforcedName}.Id:{ Id}", model?.ReinforcedName, model?.Id); + var list = model == null ? _reinforcedStorage.GetFullList() : _reinforcedStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ReinforcedViewModel? ReadElement(ReinforcedSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ReinforcedName:{ReinforcedName}.Id:{ Id}", model.ReinforcedName, model.Id); + var element = _reinforcedStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ReinforcedBindingModel model) + { + CheckModel(model); + if (_reinforcedStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ReinforcedBindingModel model) + { + CheckModel(model); + if (_reinforcedStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ReinforcedBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_reinforcedStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ReinforcedBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ReinforcedName)) + { + throw new ArgumentNullException("Нет названия изделия", nameof(model.ReinforcedName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); + } + if (model.ReinforcedComponents == null || model.ReinforcedComponents.Count == 0) + { + throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.ReinforcedComponents)); + } + _logger.LogInformation("Reinforced. ReinforcedName:{ReinforcedName}.Price:{Price}.Id: { Id}", model.ReinforcedName, model.Price, model.Id); + var element = _reinforcedStorage.GetElement(new ReinforcedSearchModel + { + ReinforcedName = model.ReinforcedName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Изделие с таким названием уже есть"); + } + } + } +} +namespace PrecastConcretePlantBusinessLogic +{ + internal class ReinforcedLogic + { + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs index f0b8942..19079bd 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs @@ -1,9 +1,9 @@ -using System; +using PrecastConcretePlantDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using PrecastConcretePlantDataModels.Models; namespace PrecastConcretePlantContracts.BindingModels { @@ -13,5 +13,4 @@ namespace PrecastConcretePlantContracts.BindingModels public string ComponentName { get; set; } = string.Empty; public double Cost { get; set; } } - -} +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs index 82d3b9d..c1e4264 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs @@ -11,7 +11,7 @@ namespace PrecastConcretePlantContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int ProductId { get; set; } + public int ReinforcedId { get; set; } public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs new file mode 100644 index 0000000..36983bc --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class ReinforcedBindingModel : IReinforcedModel + { + public int Id { get; set; } + public string ReinforcedName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary ReinforcedComponents { get; set; } = new(); + + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..b08f5ad --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..0026ffd --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs new file mode 100644 index 0000000..a0ad7b4 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLogic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IReinforcedLogic + { + List? ReadList(ReinforcedSearchModel? model); + ReinforcedViewModel? ReadElement(ReinforcedSearchModel model); + bool Create(ReinforcedBindingModel model); + bool Update(ReinforcedBindingModel model); + bool Delete(ReinforcedBindingModel model); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj index dae7eac..5d631be 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj @@ -6,6 +6,10 @@ enable + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..fe4f55f --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs similarity index 51% rename from PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs rename to PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs index e280246..17521b8 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ProductBindingModel.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs @@ -4,9 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PrecastConcretePlantContracts.BindingModels +namespace PrecastConcretePlantContracts.SearchModels { - internal class ProductBindingModel + public class OrderSearchModel { + public int? Id { get; set; } } -} +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs new file mode 100644 index 0000000..45b15f3 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PrecastConcretePlantContracts.SearchModels +{ + public class ReinforcedSearchModel + { + public int? Id { get; set; } + public string? ReinforcedName { get; set; } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..13d81ea --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..9f4b333 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs new file mode 100644 index 0000000..509f7c8 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContracts/IReinforcedStorage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContracts +{ + public interface IReinforcedStorage + { + List GetFullList(); + List GetFilteredList(ReinforcedSearchModel model); + ReinforcedViewModel? GetElement(ReinforcedSearchModel model); + ReinforcedViewModel? Insert(ReinforcedBindingModel model); + ReinforcedViewModel? Update(ReinforcedBindingModel model); + ReinforcedViewModel? Delete(ReinforcedBindingModel model); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..5536d8c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..6f78c69 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int ReinforcedId { get; set; } + [DisplayName("Изделие")] + public string ReinforcedName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs new file mode 100644 index 0000000..2a3660e --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class ReinforcedViewModel : IReinforcedModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string ReinforcedName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary ReinforcedComponents { get; set; } = new(); + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs new file mode 100644 index 0000000..1800757 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Reinforceds { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Reinforceds = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..3fb2166 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..54f8022 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/OrderStorage.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(AttachReinforcedName(order.GetViewModel)); + } + return result; + } + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (model == null || !model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(AttachReinforcedName(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 AttachReinforcedName(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 AttachReinforcedName(newOrder.GetViewModel); + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return AttachReinforcedName(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 AttachReinforcedName(element.GetViewModel); + } + } + return null; + } + private OrderViewModel AttachReinforcedName(OrderViewModel model) + { + //Из всех мест, это выглядит наиболее подходящим, для данной манипуляции. + //При расположении ниже нарушится целостность данных + //При расположении выше будет нарушен принцип разделения уровней + foreach (var reinforced in _source.Reinforceds) + { + if (reinforced.Id == model.ReinforcedId) + { + model.ReinforcedName = reinforced.ReinforcedName; + return model; + } + } + return model; + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs new file mode 100644 index 0000000..a7da41e --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Implements/ReinforcedStorage.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement.Implements +{ + public class ReinforcedStorage : IReinforcedStorage + { + private readonly DataListSingleton _source; + public ReinforcedStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var reinforced in _source.Reinforceds) + { + result.Add(reinforced.GetViewModel); + } + return result; + } + public List GetFilteredList(ReinforcedSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ReinforcedName)) + { + return result; + } + foreach (var reinforced in _source.Reinforceds) + { + if (reinforced.ReinforcedName.Contains(model.ReinforcedName)) + { + result.Add(reinforced.GetViewModel); + } + } + return result; + } + public ReinforcedViewModel? GetElement(ReinforcedSearchModel model) + { + if (string.IsNullOrEmpty(model.ReinforcedName) && !model.Id.HasValue) + { + return null; + } + foreach (var reinforced in _source.Reinforceds) + { + if ((!string.IsNullOrEmpty(model.ReinforcedName) && reinforced.ReinforcedName == model.ReinforcedName) || + (model.Id.HasValue && reinforced.Id == model.Id)) + { + return reinforced.GetViewModel; + } + } + return null; + } + public ReinforcedViewModel? Insert(ReinforcedBindingModel model) + { + model.Id = 1; + foreach (var reinforced in _source.Reinforceds) + { + if (model.Id <= reinforced.Id) + { + model.Id = reinforced.Id + 1; + } + } + var newReinforced = Reinforced.Create(model); + if (newReinforced == null) + { + return null; + } + _source.Reinforceds.Add(newReinforced); + return newReinforced.GetViewModel; + } + public ReinforcedViewModel? Update(ReinforcedBindingModel model) + { + foreach (var reinforced in _source.Reinforceds) + { + if (reinforced.Id == model.Id) + { + reinforced.Update(model); + return reinforced.GetViewModel; + } + } + return null; + } + public ReinforcedViewModel? Delete(ReinforcedBindingModel model) + { + for (int i = 0; i < _source.Reinforceds.Count; ++i) + { + if (_source.Reinforceds[i].Id == model.Id) + { + var element = _source.Reinforceds[i]; + _source.Reinforceds.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs new file mode 100644 index 0000000..f99a8c6 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Component.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; private set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs new file mode 100644 index 0000000..4e5ba73 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Order.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int ReinforcedId { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; private set; } = DateTime.Now; + public DateTime? DateImplement { get; private set; } + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + ReinforcedId = model.ReinforcedId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + + Status = model.Status; + + if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement; + + } + public OrderViewModel GetViewModel => new() + { + //ReinforcedName будет определено далее, в классе хранилища, так как это более рационально + Id = Id, + ReinforcedId = ReinforcedId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + }; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs new file mode 100644 index 0000000..b086d64 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Models/Reinforced.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantListImplement.Models +{ + public class Reinforced : IReinforcedModel + { + public int Id { get; private set; } + public string ReinforcedName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary ReinforcedComponents { get; private set; } = new Dictionary(); + public static Reinforced? Create(ReinforcedBindingModel? model) + { + if (model == null) + { + return null; + } + return new Reinforced() + { + Id = model.Id, + ReinforcedName = model.ReinforcedName, + Price = model.Price, + ReinforcedComponents = model.ReinforcedComponents + }; + } + public void Update(ReinforcedBindingModel? model) + { + if (model == null) + { + return; + } + ReinforcedName = model.ReinforcedName; + Price = model.Price; + ReinforcedComponents = model.ReinforcedComponents; + } + public ReinforcedViewModel GetViewModel => new() + { + Id = Id, + ReinforcedName = ReinforcedName, + Price = Price, + ReinforcedComponents = ReinforcedComponents + }; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj index 132c02c..d3bab3e 100644 --- a/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,4 +6,9 @@ enable + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs new file mode 100644 index 0000000..524ffe9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.Designer.cs @@ -0,0 +1,120 @@ +namespace PrecastConcretePlantView +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + textBoxCost = new TextBox(); + textBoxName = new TextBox(); + labelName = new Label(); + labelCost = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(350, 71); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(100, 28); + buttonCancel.TabIndex = 0; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(239, 71); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(100, 28); + buttonSave.TabIndex = 1; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // textBoxCost + // + textBoxCost.Location = new Point(84, 39); + textBoxCost.Multiline = true; + textBoxCost.Name = "textBoxCost"; + textBoxCost.Size = new Size(133, 27); + textBoxCost.TabIndex = 2; + // + // textBoxName + // + textBoxName.Location = new Point(84, 6); + textBoxName.Multiline = true; + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(366, 27); + textBoxName.TabIndex = 3; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(12, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(59, 15); + labelName.TabIndex = 4; + labelName.Text = "Название"; + // + // labelCost + // + labelCost.AutoSize = true; + labelCost.Location = new Point(36, 42); + labelCost.Name = "labelCost"; + labelCost.Size = new Size(35, 15); + labelCost.TabIndex = 5; + labelCost.Text = "Цена"; + // + // FormComponent + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(462, 103); + Controls.Add(labelCost); + Controls.Add(labelName); + Controls.Add(textBoxName); + Controls.Add(textBoxCost); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Name = "FormComponent"; + Text = "Компонент"; + Load += FormComponent_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxCost; + private TextBox textBoxName; + private Label labelName; + private Label labelCost; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs new file mode 100644 index 0000000..66638d9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.cs @@ -0,0 +1,93 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение компонента"); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение компонента"); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");//При обновлении, может быть, тоже ошибка появиться.. + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/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/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs new file mode 100644 index 0000000..9f964ea --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs @@ -0,0 +1,150 @@ +namespace PrecastConcretePlantView +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + panel1 = new Panel(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ID = new DataGridViewTextBoxColumn(); + ComponentName = new DataGridViewTextBoxColumn(); + ColumnCost = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ComponentName, ColumnCost }); + dataGridView.Location = new Point(12, 12); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(590, 387); + dataGridView.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonRef); + panel1.Location = new Point(608, 12); + panel1.Name = "panel1"; + panel1.Size = new Size(164, 387); + panel1.TabIndex = 1; + // + // buttonAdd + // + buttonAdd.Location = new Point(17, 148); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(126, 36); + buttonAdd.TabIndex = 3; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(17, 106); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(126, 36); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonDel + // + buttonDel.Location = new Point(17, 64); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(126, 36); + buttonDel.TabIndex = 1; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonRef + // + buttonRef.Location = new Point(17, 22); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(126, 36); + buttonRef.TabIndex = 0; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // ID + // + ID.HeaderText = "ID"; + ID.Name = "ID"; + ID.Visible = false; + // + // ComponentName + // + ComponentName.HeaderText = "Название компонента"; + ComponentName.Name = "ComponentName"; + // + // ColumnCost + // + ColumnCost.HeaderText = "Цена"; + ColumnCost.Name = "ColumnCost"; + // + // FormComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(784, 411); + Controls.Add(panel1); + Controls.Add(dataGridView); + Name = "FormComponents"; + Text = "Компоненты"; + Load += FormComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + private DataGridViewTextBoxColumn ID; + private DataGridViewTextBoxColumn ComponentName; + private DataGridViewTextBoxColumn ColumnCost; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs new file mode 100644 index 0000000..a25b038 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs @@ -0,0 +1,118 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ID"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void buttonRef_Click(object sender, EventArgs e) + { + 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 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 buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx new file mode 100644 index 0000000..9086a72 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.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/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..f7b32ab --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.Designer.cs @@ -0,0 +1,143 @@ +namespace PrecastConcretePlantView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelReinforced = new Label(); + labelCount = new Label(); + labelSum = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxCount = new TextBox(); + textBoxSum = new TextBox(); + comboBoxReinforced = new ComboBox(); + SuspendLayout(); + // + // labelReinforced + // + labelReinforced.AutoSize = true; + labelReinforced.Location = new Point(12, 12); + labelReinforced.Name = "labelReinforced"; + labelReinforced.Size = new Size(53, 15); + labelReinforced.TabIndex = 0; + labelReinforced.Text = "Изделие"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(12, 44); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(72, 15); + labelCount.TabIndex = 1; + labelCount.Text = "Количество"; + // + // labelSum + // + labelSum.AutoSize = true; + labelSum.Location = new Point(12, 73); + labelSum.Name = "labelSum"; + labelSum.Size = new Size(45, 15); + labelSum.TabIndex = 2; + labelSum.Text = "Сумма"; + // + // buttonSave + // + buttonSave.Location = new Point(187, 99); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(87, 35); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(280, 99); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(87, 35); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // textBoxCount + // + textBoxCount.Location = new Point(101, 41); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(266, 23); + textBoxCount.TabIndex = 5; + textBoxCount.TextChanged += textBoxCount_TextChanged; + // + // textBoxSum + // + textBoxSum.Location = new Point(101, 70); + textBoxSum.Name = "textBoxSum"; + textBoxSum.Size = new Size(266, 23); + textBoxSum.TabIndex = 6; + // + // comboBoxReinforced + // + comboBoxReinforced.FormattingEnabled = true; + comboBoxReinforced.Location = new Point(101, 12); + comboBoxReinforced.Name = "comboBoxReinforced"; + comboBoxReinforced.Size = new Size(266, 23); + comboBoxReinforced.TabIndex = 7; + comboBoxReinforced.SelectedIndexChanged += comboBoxReinforced_SelectedIndexChanged; + // + // FormCreateOrder + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(379, 145); + Controls.Add(comboBoxReinforced); + Controls.Add(textBoxSum); + Controls.Add(textBoxCount); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelSum); + Controls.Add(labelCount); + Controls.Add(labelReinforced); + Name = "FormCreateOrder"; + Text = "Заказ"; + Load += FormCreateOrder_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelReinforced; + private Label labelCount; + private Label labelSum; + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxCount; + private TextBox textBoxSum; + private ComboBox comboBoxReinforced; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs new file mode 100644 index 0000000..757c550 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.cs @@ -0,0 +1,118 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IReinforcedLogic _logicR; + private readonly IOrderLogic _logicO; + private List? _list; + public FormCreateOrder(ILogger logger, IReinforcedLogic logicP, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicR = logicP; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _list = _logicR.ReadList(null); + if (_list != null) + { + comboBoxReinforced.DisplayMember = "ReinforcedName"; + comboBoxReinforced.ValueMember = "Id"; + comboBoxReinforced.DataSource = _list; + comboBoxReinforced.SelectedItem = null; + _logger.LogInformation("Загрузка изделий для заказа"); + } + } + private void CalcSum() + { + if (comboBoxReinforced.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxReinforced.SelectedValue); + var Reinforced = _logicR.ReadElement(new ReinforcedSearchModel + { + Id = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (Reinforced?.Price ?? 0), 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void textBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void comboBoxReinforced_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxReinforced.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + ReinforcedId = Convert.ToInt32(comboBoxReinforced.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/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/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs new file mode 100644 index 0000000..331b74b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs @@ -0,0 +1,230 @@ +namespace PrecastConcretePlantView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + компонентыToolStripMenuItem = new ToolStripMenuItem(); + жБИзделияToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + Column1 = new DataGridViewTextBoxColumn(); + Column2 = new DataGridViewTextBoxColumn(); + Column3 = new DataGridViewTextBoxColumn(); + Column4 = new DataGridViewTextBoxColumn(); + Column5 = new DataGridViewTextBoxColumn(); + Column6 = new DataGridViewTextBoxColumn(); + Column7 = new DataGridViewTextBoxColumn(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRef = new Button(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(1007, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, жБИзделияToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(87, 20); + справочникиToolStripMenuItem.Text = "Справочник"; + // + // компонентыToolStripMenuItem + // + компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + компонентыToolStripMenuItem.Size = new Size(145, 22); + компонентыToolStripMenuItem.Text = "Компоненты"; + компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; + // + // жБИзделияToolStripMenuItem + // + жБИзделияToolStripMenuItem.Name = "жБИзделияToolStripMenuItem"; + жБИзделияToolStripMenuItem.Size = new Size(145, 22); + жБИзделияToolStripMenuItem.Text = "ЖБ изделия"; + жБИзделияToolStripMenuItem.Click += жБИзделияToolStripMenuItem_Click; + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2, Column3, Column4, Column5, Column6, Column7 }); + dataGridView.Location = new Point(0, 27); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(800, 359); + dataGridView.TabIndex = 1; + // + // Column1 + // + Column1.HeaderText = "Номер"; + Column1.Name = "Column1"; + Column1.ReadOnly = true; + Column1.Width = 55; + // + // Column2 + // + Column2.HeaderText = "Изделие"; + Column2.Name = "Column2"; + Column2.ReadOnly = true; + Column2.Width = 200; + // + // Column3 + // + Column3.HeaderText = "Количество"; + Column3.Name = "Column3"; + Column3.ReadOnly = true; + // + // Column4 + // + Column4.HeaderText = "Сумма"; + Column4.Name = "Column4"; + Column4.ReadOnly = true; + // + // Column5 + // + Column5.HeaderText = "Статус"; + Column5.Name = "Column5"; + Column5.ReadOnly = true; + // + // Column6 + // + Column6.HeaderText = "Дата создания"; + Column6.Name = "Column6"; + Column6.ReadOnly = true; + // + // Column7 + // + Column7.HeaderText = "Дата выполнения"; + Column7.Name = "Column7"; + Column7.ReadOnly = true; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(806, 81); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(189, 40); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += buttonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Location = new Point(806, 127); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(189, 40); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Location = new Point(806, 173); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(189, 40); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += buttonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(806, 219); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(189, 40); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += buttonIssuedOrder_Click; + // + // buttonRef + // + buttonRef.Location = new Point(806, 265); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(189, 40); + buttonRef.TabIndex = 6; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1007, 389); + Controls.Add(buttonRef); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormMain"; + Text = "Завод ЖБИ"; + Load += FormMain_Load; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem жБИзделияToolStripMenuItem; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + private DataGridViewTextBoxColumn Column4; + private DataGridViewTextBoxColumn Column5; + private DataGridViewTextBoxColumn Column6; + private DataGridViewTextBoxColumn Column7; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs new file mode 100644 index 0000000..33480b8 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs @@ -0,0 +1,165 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ReinforcedId"].Visible = false; + dataGridView.Columns["ReinforcedName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + + private void жБИзделияToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedes)); + if (service is FormReinforcedes form) + { + form.ShowDialog(); + } + } + + private void buttonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + + private void buttonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = id + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void buttonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void buttonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ No{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx new file mode 100644 index 0000000..7220a9e --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs new file mode 100644 index 0000000..376e810 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs @@ -0,0 +1,221 @@ +namespace PrecastConcretePlantView +{ + partial class FormReinforced + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelName = new Label(); + labelPrice = new Label(); + textBoxName = new TextBox(); + textBoxPrice = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + groupBoxComponents = new GroupBox(); + buttonAdd = new Button(); + buttonRef = new Button(); + buttonDel = new Button(); + buttonUpd = new Button(); + dataGridView1 = new DataGridView(); + id = new DataGridViewTextBoxColumn(); + Component = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(12, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(59, 15); + labelName.TabIndex = 0; + labelName.Text = "Название"; + // + // labelPrice + // + labelPrice.AutoSize = true; + labelPrice.Location = new Point(12, 38); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(67, 15); + labelPrice.TabIndex = 1; + labelPrice.Text = "Стоимость"; + // + // textBoxName + // + textBoxName.Location = new Point(99, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(307, 23); + textBoxName.TabIndex = 2; + // + // textBoxPrice + // + textBoxPrice.Location = new Point(99, 35); + textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.Size = new Size(183, 23); + textBoxPrice.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(346, 330); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(87, 44); + buttonSave.TabIndex = 5; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + // + // buttonCancel + // + buttonCancel.Location = new Point(439, 330); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(88, 44); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // groupBoxComponents + // + groupBoxComponents.Controls.Add(dataGridView1); + groupBoxComponents.Controls.Add(buttonRef); + groupBoxComponents.Controls.Add(buttonDel); + groupBoxComponents.Controls.Add(buttonUpd); + groupBoxComponents.Controls.Add(buttonAdd); + groupBoxComponents.Location = new Point(12, 64); + groupBoxComponents.Name = "groupBoxComponents"; + groupBoxComponents.Size = new Size(515, 260); + groupBoxComponents.TabIndex = 7; + groupBoxComponents.TabStop = false; + groupBoxComponents.Text = "Компоненты"; + // + // buttonAdd + // + buttonAdd.Location = new Point(410, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(85, 38); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + // + // buttonRef + // + buttonRef.Location = new Point(410, 158); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(85, 37); + buttonRef.TabIndex = 7; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + // + // buttonDel + // + buttonDel.Location = new Point(410, 115); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(85, 37); + buttonDel.TabIndex = 6; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + // + // buttonUpd + // + buttonUpd.Location = new Point(410, 72); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(85, 37); + buttonUpd.TabIndex = 5; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + // + // dataGridView1 + // + dataGridView1.BackgroundColor = SystemColors.ControlLightLight; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { id, Component, Count }); + dataGridView1.Location = new Point(3, 19); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowTemplate.Height = 25; + dataGridView1.Size = new Size(401, 235); + dataGridView1.TabIndex = 8; + // + // id + // + id.HeaderText = "id"; + id.MinimumWidth = 6; + id.Name = "id"; + id.ReadOnly = true; + id.Visible = false; + // + // Component + // + Component.HeaderText = "Компонент"; + Component.MinimumWidth = 6; + Component.Name = "Component"; + Component.ReadOnly = true; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.ReadOnly = true; + // + // FormReinforced + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(539, 386); + Controls.Add(groupBoxComponents); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxPrice); + Controls.Add(textBoxName); + Controls.Add(labelPrice); + Controls.Add(labelName); + Name = "FormReinforced"; + Text = "Изделие"; + groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private Button buttonSave; + private Button buttonCancel; + private GroupBox groupBoxComponents; + private Button buttonAdd; + private DataGridView dataGridView1; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs new file mode 100644 index 0000000..850bd4f --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormReinforced : Form + { + public FormReinforced() + { + InitializeComponent(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx new file mode 100644 index 0000000..1bfa2bf --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs new file mode 100644 index 0000000..9ff349a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace PrecastConcretePlantView +{ + partial class FormReinforcedComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonSave = new Button(); + buttonCancel = new Button(); + labelComponent = new Label(); + labelCount = new Label(); + comboBoxComponent = new ComboBox(); + textBoxCount = new TextBox(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Location = new Point(193, 79); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(80, 36); + buttonSave.TabIndex = 0; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(279, 79); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(80, 36); + buttonCancel.TabIndex = 1; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // labelComponent + // + labelComponent.AutoSize = true; + labelComponent.Location = new Point(12, 15); + labelComponent.Name = "labelComponent"; + labelComponent.Size = new Size(69, 15); + labelComponent.TabIndex = 2; + labelComponent.Text = "Компонент"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(12, 50); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(72, 15); + labelCount.TabIndex = 3; + labelCount.Text = "Количество"; + // + // comboBoxComponent + // + comboBoxComponent.FormattingEnabled = true; + comboBoxComponent.Location = new Point(98, 12); + comboBoxComponent.Name = "comboBoxComponent"; + comboBoxComponent.Size = new Size(261, 23); + comboBoxComponent.TabIndex = 4; + // + // textBoxCount + // + textBoxCount.Location = new Point(98, 50); + textBoxCount.Multiline = true; + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(261, 23); + textBoxCount.TabIndex = 5; + // + // FormReinforcedComponent + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(374, 127); + Controls.Add(textBoxCount); + Controls.Add(comboBoxComponent); + Controls.Add(labelCount); + Controls.Add(labelComponent); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Name = "FormReinforcedComponent"; + Text = "Компонент изделия"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonSave; + private Button buttonCancel; + private Label labelComponent; + private Label labelCount; + private ComboBox comboBoxComponent; + private TextBox textBoxCount; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs new file mode 100644 index 0000000..6a03c3f --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.cs @@ -0,0 +1,85 @@ +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormReinforcedComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } + public FormReinforcedComponent(IComponentLogic logic) + { + InitializeComponent(); + + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedComponent.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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs new file mode 100644 index 0000000..2a07459 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs @@ -0,0 +1,39 @@ +namespace PrecastConcretePlantView +{ + partial class FormReinforcedes + { + /// + /// 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 = "FormReinforcedes"; + } + + #endregion + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs new file mode 100644 index 0000000..fb728fe --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormReinforcedes : Form + { + public FormReinforcedes() + { + InitializeComponent(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj b/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj index 132c02c..3c04878 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj +++ b/PrecastConcretePlant/PrecastConcretePlantView/PrecastConcretePlantView.csproj @@ -1,9 +1,21 @@ - + - net6.0 - enable - enable + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantView/Program.cs b/PrecastConcretePlant/PrecastConcretePlantView/Program.cs new file mode 100644 index 0000000..cb39751 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantView/Program.cs @@ -0,0 +1,55 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using PrecastConcretePlantBusinessLogic.BusinessLogics; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.StoragesContracts; +using PrecastConcretePlantListImplement.Implements; +using PrecastConcretePlantView; +using System; +using System.Drawing; + +namespace PrecastConcretePlant +{ + 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 -- 2.25.1 From acc31a89eefbbb6fa616154a488d085b3ac9c320 Mon Sep 17 00:00:00 2001 From: sofiaivv Date: Tue, 5 Mar 2024 14:41:56 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=20=D0=B8=20=D1=81=D0=B4=D0=B0=D0=BD=D0=BE=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormComponents.Designer.cs | 23 -- .../FormComponents.cs | 1 + .../FormComponents.resx | 9 - .../FormMain.Designer.cs | 59 ---- .../PrecastConcretePlantView/FormMain.cs | 1 + .../PrecastConcretePlantView/FormMain.resx | 21 -- .../FormReinforced.Designer.cs | 297 +++++++++--------- .../FormReinforced.cs | 200 +++++++++++- .../FormReinforced.resx | 9 - .../FormReinforcedes.Designer.cs | 95 +++++- .../FormReinforcedes.cs | 96 +++++- .../FormReinforcedes.resx | 62 +--- 12 files changed, 542 insertions(+), 331 deletions(-) diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs index 9f964ea..0b3dd21 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.Designer.cs @@ -34,9 +34,6 @@ buttonUpd = new Button(); buttonDel = new Button(); buttonRef = new Button(); - ID = new DataGridViewTextBoxColumn(); - ComponentName = new DataGridViewTextBoxColumn(); - ColumnCost = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); panel1.SuspendLayout(); SuspendLayout(); @@ -45,7 +42,6 @@ // dataGridView.BackgroundColor = SystemColors.ControlLightLight; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ComponentName, ColumnCost }); dataGridView.Location = new Point(12, 12); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 51; @@ -104,22 +100,6 @@ buttonRef.UseVisualStyleBackColor = true; buttonRef.Click += buttonRef_Click; // - // ID - // - ID.HeaderText = "ID"; - ID.Name = "ID"; - ID.Visible = false; - // - // ComponentName - // - ComponentName.HeaderText = "Название компонента"; - ComponentName.Name = "ComponentName"; - // - // ColumnCost - // - ColumnCost.HeaderText = "Цена"; - ColumnCost.Name = "ColumnCost"; - // // FormComponents // AutoScaleDimensions = new SizeF(7F, 15F); @@ -143,8 +123,5 @@ private Button buttonUpd; private Button buttonDel; private Button buttonRef; - private DataGridViewTextBoxColumn ID; - private DataGridViewTextBoxColumn ComponentName; - private DataGridViewTextBoxColumn ColumnCost; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs index a25b038..2383ae6 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using PrecastConcretePlant; using PrecastConcretePlantContracts.BindingModels; using PrecastConcretePlantContracts.BusinessLogicsContracts; using System; diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx index 9086a72..f298a7b 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormComponents.resx @@ -57,13 +57,4 @@ 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/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs index 331b74b..286dfd0 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.Designer.cs @@ -33,13 +33,6 @@ компонентыToolStripMenuItem = new ToolStripMenuItem(); жБИзделияToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); - Column1 = new DataGridViewTextBoxColumn(); - Column2 = new DataGridViewTextBoxColumn(); - Column3 = new DataGridViewTextBoxColumn(); - Column4 = new DataGridViewTextBoxColumn(); - Column5 = new DataGridViewTextBoxColumn(); - Column6 = new DataGridViewTextBoxColumn(); - Column7 = new DataGridViewTextBoxColumn(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); buttonOrderReady = new Button(); @@ -83,57 +76,12 @@ // dataGridView.BackgroundColor = SystemColors.ControlLightLight; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2, Column3, Column4, Column5, Column6, Column7 }); dataGridView.Location = new Point(0, 27); dataGridView.Name = "dataGridView"; dataGridView.RowTemplate.Height = 25; dataGridView.Size = new Size(800, 359); dataGridView.TabIndex = 1; // - // Column1 - // - Column1.HeaderText = "Номер"; - Column1.Name = "Column1"; - Column1.ReadOnly = true; - Column1.Width = 55; - // - // Column2 - // - Column2.HeaderText = "Изделие"; - Column2.Name = "Column2"; - Column2.ReadOnly = true; - Column2.Width = 200; - // - // Column3 - // - Column3.HeaderText = "Количество"; - Column3.Name = "Column3"; - Column3.ReadOnly = true; - // - // Column4 - // - Column4.HeaderText = "Сумма"; - Column4.Name = "Column4"; - Column4.ReadOnly = true; - // - // Column5 - // - Column5.HeaderText = "Статус"; - Column5.Name = "Column5"; - Column5.ReadOnly = true; - // - // Column6 - // - Column6.HeaderText = "Дата создания"; - Column6.Name = "Column6"; - Column6.ReadOnly = true; - // - // Column7 - // - Column7.HeaderText = "Дата выполнения"; - Column7.Name = "Column7"; - Column7.ReadOnly = true; - // // buttonCreateOrder // buttonCreateOrder.Location = new Point(806, 81); @@ -214,13 +162,6 @@ private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem жБИзделияToolStripMenuItem; private DataGridView dataGridView; - private DataGridViewTextBoxColumn Column1; - private DataGridViewTextBoxColumn Column2; - private DataGridViewTextBoxColumn Column3; - private DataGridViewTextBoxColumn Column4; - private DataGridViewTextBoxColumn Column5; - private DataGridViewTextBoxColumn Column6; - private DataGridViewTextBoxColumn Column7; private Button buttonCreateOrder; private Button buttonTakeOrderInWork; private Button buttonOrderReady; diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs index 33480b8..6bc055e 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using PrecastConcretePlant; using PrecastConcretePlantContracts.BindingModels; using PrecastConcretePlantContracts.BusinessLogicsContracts; using System; diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx index 7220a9e..938108a 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormMain.resx @@ -60,25 +60,4 @@ 17, 17 - - True - - - True - - - True - - - True - - - True - - - True - - - True - \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs index 376e810..2d1e941 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.Designer.cs @@ -28,194 +28,209 @@ /// private void InitializeComponent() { - labelName = new Label(); - labelPrice = new Label(); - textBoxName = new TextBox(); - textBoxPrice = new TextBox(); - buttonSave = new Button(); - buttonCancel = new Button(); - groupBoxComponents = new GroupBox(); - buttonAdd = new Button(); - buttonRef = new Button(); - buttonDel = new Button(); - buttonUpd = new Button(); - dataGridView1 = new DataGridView(); - id = new DataGridViewTextBoxColumn(); - Component = new DataGridViewTextBoxColumn(); - Count = new DataGridViewTextBoxColumn(); - groupBoxComponents.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); - SuspendLayout(); + this.labelName = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.groupBoxComponents = new System.Windows.Forms.GroupBox(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); // // labelName // - labelName.AutoSize = true; - labelName.Location = new Point(12, 9); - labelName.Name = "labelName"; - labelName.Size = new Size(59, 15); - labelName.TabIndex = 0; - labelName.Text = "Название"; - // - // labelPrice - // - labelPrice.AutoSize = true; - labelPrice.Location = new Point(12, 38); - labelPrice.Name = "labelPrice"; - labelPrice.Size = new Size(67, 15); - labelPrice.TabIndex = 1; - labelPrice.Text = "Стоимость"; + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(16, 15); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(84, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название: "; // // textBoxName // - textBoxName.Location = new Point(99, 6); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(307, 23); - textBoxName.TabIndex = 2; + this.textBoxName.Location = new System.Drawing.Point(112, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(293, 27); + this.textBoxName.TabIndex = 1; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(16, 51); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(90, 20); + this.labelPrice.TabIndex = 2; + this.labelPrice.Text = "Стоимость: "; // // textBoxPrice // - textBoxPrice.Location = new Point(99, 35); - textBoxPrice.Name = "textBoxPrice"; - textBoxPrice.Size = new Size(183, 23); - textBoxPrice.TabIndex = 3; - // - // buttonSave - // - buttonSave.Location = new Point(346, 330); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(87, 44); - buttonSave.TabIndex = 5; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - // - // buttonCancel - // - buttonCancel.Location = new Point(439, 330); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(88, 44); - buttonCancel.TabIndex = 6; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; + this.textBoxPrice.Location = new System.Drawing.Point(112, 51); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(171, 27); + this.textBoxPrice.TabIndex = 3; // // groupBoxComponents // - groupBoxComponents.Controls.Add(dataGridView1); - groupBoxComponents.Controls.Add(buttonRef); - groupBoxComponents.Controls.Add(buttonDel); - groupBoxComponents.Controls.Add(buttonUpd); - groupBoxComponents.Controls.Add(buttonAdd); - groupBoxComponents.Location = new Point(12, 64); - groupBoxComponents.Name = "groupBoxComponents"; - groupBoxComponents.Size = new Size(515, 260); - groupBoxComponents.TabIndex = 7; - groupBoxComponents.TabStop = false; - groupBoxComponents.Text = "Компоненты"; - // - // buttonAdd - // - buttonAdd.Location = new Point(410, 28); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(85, 38); - buttonAdd.TabIndex = 2; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; + this.groupBoxComponents.Controls.Add(this.buttonRef); + this.groupBoxComponents.Controls.Add(this.buttonDel); + this.groupBoxComponents.Controls.Add(this.buttonUpd); + this.groupBoxComponents.Controls.Add(this.buttonAdd); + this.groupBoxComponents.Controls.Add(this.dataGridView); + this.groupBoxComponents.Location = new System.Drawing.Point(12, 84); + this.groupBoxComponents.Name = "groupBoxComponents"; + this.groupBoxComponents.Size = new System.Drawing.Size(661, 319); + this.groupBoxComponents.TabIndex = 4; + this.groupBoxComponents.TabStop = false; + this.groupBoxComponents.Text = "Компоненты"; // // buttonRef // - buttonRef.Location = new Point(410, 158); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(85, 37); - buttonRef.TabIndex = 7; - buttonRef.Text = "Обновить"; - buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Location = new System.Drawing.Point(502, 211); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(126, 34); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); // // buttonDel // - buttonDel.Location = new Point(410, 115); - buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(85, 37); - buttonDel.TabIndex = 6; - buttonDel.Text = "Удалить"; - buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Location = new System.Drawing.Point(502, 157); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(126, 34); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); // // buttonUpd // - buttonUpd.Location = new Point(410, 72); - buttonUpd.Name = "buttonUpd"; - buttonUpd.Size = new Size(85, 37); - buttonUpd.TabIndex = 5; - buttonUpd.Text = "Изменить"; - buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Location = new System.Drawing.Point(502, 102); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(126, 34); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); // - // dataGridView1 + // buttonAdd // - dataGridView1.BackgroundColor = SystemColors.ControlLightLight; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Columns.AddRange(new DataGridViewColumn[] { id, Component, Count }); - dataGridView1.Location = new Point(3, 19); - dataGridView1.Name = "dataGridView1"; - dataGridView1.RowTemplate.Height = 25; - dataGridView1.Size = new Size(401, 235); - dataGridView1.TabIndex = 8; + this.buttonAdd.Location = new System.Drawing.Point(502, 47); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 34); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.Component, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(6, 26); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(476, 287); + this.dataGridView.TabIndex = 0; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // id // - id.HeaderText = "id"; - id.MinimumWidth = 6; - id.Name = "id"; - id.ReadOnly = true; - id.Visible = false; + this.id.HeaderText = "id"; + this.id.MinimumWidth = 6; + this.id.Name = "id"; + this.id.ReadOnly = true; + this.id.Visible = false; // // Component // - Component.HeaderText = "Компонент"; - Component.MinimumWidth = 6; - Component.Name = "Component"; - Component.ReadOnly = true; + this.Component.HeaderText = "Компонент"; + this.Component.MinimumWidth = 6; + this.Component.Name = "Component"; + this.Component.ReadOnly = true; // // Count // - Count.HeaderText = "Количество"; - Count.MinimumWidth = 6; - Count.Name = "Count"; - Count.ReadOnly = true; + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.ReadOnly = true; // // FormReinforced // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(539, 386); - Controls.Add(groupBoxComponents); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(textBoxPrice); - Controls.Add(textBoxName); - Controls.Add(labelPrice); - Controls.Add(labelName); - Name = "FormReinforced"; - Text = "Изделие"; - groupBoxComponents.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(685, 463); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxComponents); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormReinforced"; + this.Text = "Изделие"; + this.Load += new System.EventHandler(this.FormReinforced_Load); + this.groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion private Label labelName; - private Label labelPrice; private TextBox textBoxName; + private Label labelPrice; private TextBox textBoxPrice; - private Button buttonSave; - private Button buttonCancel; private GroupBox groupBoxComponents; - private Button buttonAdd; - private DataGridView dataGridView1; private Button buttonRef; private Button buttonDel; private Button buttonUpd; - private DataGridViewTextBoxColumn id; + private Button buttonAdd; + private DataGridView dataGridView; private DataGridViewTextBoxColumn Component; private DataGridViewTextBoxColumn Count; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewTextBoxColumn id; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs index 850bd4f..39ce853 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.cs @@ -1,4 +1,10 @@ -using System; +using Microsoft.Extensions.Logging; +using PrecastConcretePlant; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantDataModels.Models; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +18,197 @@ namespace PrecastConcretePlantView { public partial class FormReinforced : Form { - public FormReinforced() + private readonly ILogger _logger; + private readonly IReinforcedLogic _logic; + private int? _id; + private Dictionary _ReinforcedComponents; + public int Id { set { _id = value; } } + public FormReinforced(ILogger logger, IReinforcedLogic logic) { InitializeComponent(); + _logger = logger; + _logic = logic; + _ReinforcedComponents = new Dictionary(); + } + private void FormReinforced_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new ReinforcedSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ReinforcedName; + textBoxPrice.Text = view.Price.ToString(); + _ReinforcedComponents = view.ReinforcedComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_ReinforcedComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _ReinforcedComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedComponent)); + if (service is FormReinforcedComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + if (_ReinforcedComponents.ContainsKey(form.Id)) + { + _ReinforcedComponents[form.Id] = (form.ComponentModel, + form.Count); + } + else + { + _ReinforcedComponents.Add(form.Id, (form.ComponentModel, + form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedComponent)); + if (service is FormReinforcedComponent form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _ReinforcedComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + _ReinforcedComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value); + _ReinforcedComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (_ReinforcedComponents == null || _ReinforcedComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new ReinforcedBindingModel + { + Id = _id ?? 0, + ReinforcedName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + ReinforcedComponents = _ReinforcedComponents + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _ReinforcedComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); } } -} +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx index 1bfa2bf..f298a7b 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforced.resx @@ -57,13 +57,4 @@ 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/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs index 2a07459..843c191 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.Designer.cs @@ -28,12 +28,103 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.ToolsPanel = new System.Windows.Forms.Panel(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ToolsPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ToolsPanel + // + this.ToolsPanel.Controls.Add(this.buttonRef); + this.ToolsPanel.Controls.Add(this.buttonDel); + this.ToolsPanel.Controls.Add(this.buttonUpd); + this.ToolsPanel.Controls.Add(this.buttonAdd); + this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Name = "ToolsPanel"; + this.ToolsPanel.Size = new System.Drawing.Size(180, 426); + this.ToolsPanel.TabIndex = 3; + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(31, 206); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(126, 36); + this.buttonRef.TabIndex = 3; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(31, 142); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(126, 36); + this.buttonDel.TabIndex = 2; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(31, 76); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(126, 36); + this.buttonUpd.TabIndex = 1; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.TabIndex = 2; + // + // FormReinforcedes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormReinforcedes"; + this.Controls.Add(this.ToolsPanel); + this.Controls.Add(this.dataGridView); + this.Name = "FormReinforcedes"; + this.Text = "Изделия"; + this.Load += new System.EventHandler(this.FormReinforcedes_Load); + this.ToolsPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + } #endregion + + private Panel ToolsPanel; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs index fb728fe..97c8a84 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.cs @@ -1,4 +1,8 @@ -using System; +using Microsoft.Extensions.Logging; +using PrecastConcretePlant; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +16,95 @@ namespace PrecastConcretePlantView { public partial class FormReinforcedes : Form { - public FormReinforcedes() + private readonly ILogger _logger; + private readonly IReinforcedLogic _logic; + public FormReinforcedes(ILogger logger, IReinforcedLogic logic) { InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReinforcedes_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ReinforcedComponents"].Visible = false; + dataGridView.Columns["ReinforcedName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка изделий"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделий"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforced)); + if (service is FormReinforced form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforced)); + if (service is FormReinforced form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление изделия"); + try + { + if (!_logic.Delete(new ReinforcedBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); } } -} +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx index 1af7de1..f298a7b 100644 --- a/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx +++ b/PrecastConcretePlant/PrecastConcretePlantView/FormReinforcedes.resx @@ -1,64 +1,4 @@ - - - + -- 2.25.1