From 2d0eccdcff89c552d0eff05785d2912d3ad7a16c Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Mon, 6 Feb 2023 16:15:16 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=B1=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D1=87=D0=B0=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SoftwareInstallation/SoftwareInstallation.sln | 34 ++- .../ComponentLogic.cs | 108 ++++++++ .../OrderLogic.cs | 6 + .../PackageLogic.cs | 7 + .../SoftwareInstallationBusinessLogic.csproj | 17 ++ .../BindingModels/ComponentBindingModel.cs | 11 + .../BindingModels/OrderBindingModel.cs | 15 ++ .../BindingModels/PackageBindingModel.cs | 15 ++ .../IComponentLogic.cs | 15 ++ .../BusinessLogicsContracts/IOrderLogic.cs | 15 ++ .../BusinessLogicsContracts/IPackageLogic.cs | 15 ++ .../SearchModels/ComponentSearchModel.cs | 8 + .../SearchModels/OrderSearchModel.cs | 7 + .../SearchModels/PackageSearchModel.cs | 8 + .../SoftwareInstallationContracts.csproj | 13 + .../StoragesContracts/IComponentStorage.cs | 16 ++ .../StoragesContracts/IOrderStorage.cs | 16 ++ .../StoragesContracts/IProductStorage.cs | 16 ++ .../ViewModels/ComponentViewModel.cs | 14 ++ .../ViewModels/OrderViewModel.cs | 26 ++ .../ViewModels/PackageViewModel.cs | 19 ++ .../IComponentModel.cs | 8 + .../SoftwareInstallationDataModels/IId.cs | 7 + .../IOrderModel.cs | 14 ++ .../IPackageModel.cs | 9 + .../OrderStatus.cs | 11 + .../SoftwareInstallationDataModels.csproj | 9 + .../Component.cs | 41 +++ .../ComponentStorage.cs | 102 ++++++++ .../DataListSingleton.cs | 26 ++ .../Order.cs | 7 + .../OrderStorage.cs | 7 + .../Package.cs | 49 ++++ .../PackageStorage.cs | 7 + .../SoftwareInstallationListImplement.csproj | 14 ++ .../FormComponent.Designer.cs | 116 +++++++++ .../SoftwareInstallationView/FormComponent.cs | 85 +++++++ .../FormComponent.resx | 60 +++++ .../FormComponents.Designer.cs | 114 +++++++++ .../FormComponents.cs | 107 ++++++++ .../FormComponents.resx | 60 +++++ .../FormCreateOrder.Designer.cs | 152 +++++++++++ .../FormCreateOrder.cs | 93 +++++++ .../FormCreateOrder.resx | 60 +++++ .../FormMain.Designer.cs | 174 +++++++++++++ .../SoftwareInstallationView/FormMain.cs | 122 +++++++++ .../SoftwareInstallationView/FormMain.resx | 63 +++++ .../FormPackage.Designer.cs | 237 ++++++++++++++++++ .../SoftwareInstallationView/FormPackage.cs | 198 +++++++++++++++ .../SoftwareInstallationView/FormPackage.resx | 78 ++++++ .../FormPackageComponent.Designer.cs | 118 +++++++++ .../FormPackageComponent.cs | 80 ++++++ .../FormPackageComponent.resx | 60 +++++ .../FormPackages.Designer.cs | 39 +++ .../SoftwareInstallationView/FormPackages.cs | 20 ++ .../FormPackages.resx | 120 +++++++++ .../SoftwareInstallationView/Program.cs | 51 ++++ .../SoftwareInstallationView.csproj | 24 ++ 58 files changed, 2938 insertions(+), 5 deletions(-) create mode 100644 SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs create mode 100644 SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs create mode 100644 SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs create mode 100644 SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IProductStorage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationDataModels/IComponentModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationDataModels/IId.cs create mode 100644 SoftwareInstallation/SoftwareInstallationDataModels/IOrderModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationDataModels/IPackageModel.cs create mode 100644 SoftwareInstallation/SoftwareInstallationDataModels/OrderStatus.cs create mode 100644 SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/Component.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/ComponentStorage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/Order.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/Package.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormComponent.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormComponent.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormComponents.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormComponents.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormMain.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormMain.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackage.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackage.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackages.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/FormPackages.resx create mode 100644 SoftwareInstallation/SoftwareInstallationView/Program.cs create mode 100644 SoftwareInstallation/SoftwareInstallationView/SoftwareInstallationView.csproj diff --git a/SoftwareInstallation/SoftwareInstallation.sln b/SoftwareInstallation/SoftwareInstallation.sln index 9710b5c..9e530be 100644 --- a/SoftwareInstallation/SoftwareInstallation.sln +++ b/SoftwareInstallation/SoftwareInstallation.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.2.32526.322 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallation", "SoftwareInstallation\SoftwareInstallation.csproj", "{B5F5DF22-B5D8-4D1C-8B50-2D6D7EE8213D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationDataModels", "SoftwareInstallationDataModels\SoftwareInstallationDataModels.csproj", "{5D69A21A-C0E7-4C62-AA10-902E7DA5E547}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationContracts", "SoftwareInstallationContracts\SoftwareInstallationContracts.csproj", "{8B0EB0D9-4A0D-490F-81D6-E683C616FDD3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationBusinessLogic", "SoftwareInstallationBusinessLogic\SoftwareInstallationBusinessLogic.csproj", "{1A47CC1D-D0D2-4C8C-BE04-172727C64A70}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationListImplement", "SoftwareInstallationListImplement\SoftwareInstallationListImplement.csproj", "{D509FACD-08DF-43A7-8C79-D0A943FAC389}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationView", "SoftwareInstallationView\SoftwareInstallationView.csproj", "{564F09E4-FA75-4090-BBC8-656F23FC8F3E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,10 +19,26 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B5F5DF22-B5D8-4D1C-8B50-2D6D7EE8213D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B5F5DF22-B5D8-4D1C-8B50-2D6D7EE8213D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B5F5DF22-B5D8-4D1C-8B50-2D6D7EE8213D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B5F5DF22-B5D8-4D1C-8B50-2D6D7EE8213D}.Release|Any CPU.Build.0 = Release|Any CPU + {5D69A21A-C0E7-4C62-AA10-902E7DA5E547}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D69A21A-C0E7-4C62-AA10-902E7DA5E547}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D69A21A-C0E7-4C62-AA10-902E7DA5E547}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D69A21A-C0E7-4C62-AA10-902E7DA5E547}.Release|Any CPU.Build.0 = Release|Any CPU + {8B0EB0D9-4A0D-490F-81D6-E683C616FDD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B0EB0D9-4A0D-490F-81D6-E683C616FDD3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B0EB0D9-4A0D-490F-81D6-E683C616FDD3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B0EB0D9-4A0D-490F-81D6-E683C616FDD3}.Release|Any CPU.Build.0 = Release|Any CPU + {1A47CC1D-D0D2-4C8C-BE04-172727C64A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A47CC1D-D0D2-4C8C-BE04-172727C64A70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A47CC1D-D0D2-4C8C-BE04-172727C64A70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A47CC1D-D0D2-4C8C-BE04-172727C64A70}.Release|Any CPU.Build.0 = Release|Any CPU + {D509FACD-08DF-43A7-8C79-D0A943FAC389}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D509FACD-08DF-43A7-8C79-D0A943FAC389}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D509FACD-08DF-43A7-8C79-D0A943FAC389}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D509FACD-08DF-43A7-8C79-D0A943FAC389}.Release|Any CPU.Build.0 = Release|Any CPU + {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..b7cf0f5 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs @@ -0,0 +1,108 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using Microsoft.Extensions.Logging; +namespace SoftwareInstallationBusinessLogic.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/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..5c3c275 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs @@ -0,0 +1,6 @@ +namespace SoftwareInstallationBusinessLogic +{ + internal class OrderLogic + { + } +} diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs new file mode 100644 index 0000000..6621be9 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs @@ -0,0 +1,7 @@ +namespace SoftwareInstallationBusinessLogic +{ + public class PackageLogic + { + //ToDO + } +} diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj new file mode 100644 index 0000000..a2e83f0 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..298f622 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,11 @@ +using SoftwareInstallationDataModels.Models; + +namespace SoftwareInstallationContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..0d872f9 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,15 @@ +using SoftwareInstallationDataModels.Enums; +using SoftwareInstallationDataModels.Models; +namespace SoftwareInstallationContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int PackageId { 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/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs new file mode 100644 index 0000000..84309fe --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs @@ -0,0 +1,15 @@ +using SoftwareInstallationDataModels.Models; +namespace SoftwareInstallationContracts.BindingModels +{ + public class PackageBindingModel : IPackageModel + { + public int Id { get; set; } + public string PackageName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary PackageComponents + { + get; + set; + } = new(); + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..402c984 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,15 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; + +namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..49c13ab --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; + +namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs new file mode 100644 index 0000000..5f7fb38 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs @@ -0,0 +1,15 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; + +namespace SoftwareInstallationContracts.BusinessLogicsContracts +{ + public interface IPackageLogic + { + List? ReadList(PackageSearchModel? model); + PackageViewModel? ReadElement(PackageSearchModel model); + bool Create(PackageBindingModel model); + bool Update(PackageBindingModel model); + bool Delete(PackageBindingModel model); + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..f13543a --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,8 @@ +namespace SoftwareInstallationContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..414ec2d --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace SoftwareInstallationContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs new file mode 100644 index 0000000..8f72375 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs @@ -0,0 +1,8 @@ +namespace SoftwareInstallationContracts.SearchModels +{ + public class PackageSearchModel + { + public int? Id { get; set; } + public string? PackageName { get; set; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj b/SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj new file mode 100644 index 0000000..5e550d4 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..8630937 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,16 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; + +namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..80d5fa5 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,16 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; + +namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IProductStorage.cs b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IProductStorage.cs new file mode 100644 index 0000000..c4b9a36 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IProductStorage.cs @@ -0,0 +1,16 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; + +namespace SoftwareInstallationContracts.StoragesContracts +{ + public interface IPackageStorage + { + List GetFullList(); + List GetFilteredList(PackageSearchModel model); + PackageViewModel? GetElement(PackageSearchModel model); + PackageViewModel? Insert(PackageBindingModel model); + PackageViewModel? Update(PackageBindingModel model); + PackageViewModel? Delete(PackageBindingModel model); + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..4deb00f --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,14 @@ +using SoftwareInstallationDataModels.Models; +using System.ComponentModel; + +namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..5b46436 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,26 @@ +using SoftwareInstallationDataModels.Enums; +using SoftwareInstallationDataModels.Models; +using System.ComponentModel; + + +namespace SoftwareInstallationContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int PackageId { get; set; } + [DisplayName("Изделие")] + public string PackageName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs new file mode 100644 index 0000000..ac62c88 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs @@ -0,0 +1,19 @@ +using SoftwareInstallationDataModels.Models; +using System.ComponentModel; + +namespace SoftwareInstallationContracts.ViewModels +{ + public class PackageViewModel : IPackageModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string PackageName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary PackageComponents + { + get; + set; + } = new(); + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/IComponentModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/IComponentModel.cs new file mode 100644 index 0000000..df7ad10 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataModels/IComponentModel.cs @@ -0,0 +1,8 @@ +namespace SoftwareInstallationDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/IId.cs b/SoftwareInstallation/SoftwareInstallationDataModels/IId.cs new file mode 100644 index 0000000..b1a50f6 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace SoftwareInstallationDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/IOrderModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/IOrderModel.cs new file mode 100644 index 0000000..2eb9b8e --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataModels/IOrderModel.cs @@ -0,0 +1,14 @@ +using SoftwareInstallationDataModels.Enums; + +namespace SoftwareInstallationDataModels.Models +{ + public interface IOrderModel : IId + { + int PackageId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/IPackageModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/IPackageModel.cs new file mode 100644 index 0000000..7b25e94 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataModels/IPackageModel.cs @@ -0,0 +1,9 @@ +namespace SoftwareInstallationDataModels.Models +{ + public interface IPackageModel : IId + { + string PackageName { get; } + double Price { get; } + Dictionary PackageComponents { get; } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/OrderStatus.cs b/SoftwareInstallation/SoftwareInstallationDataModels/OrderStatus.cs new file mode 100644 index 0000000..6fd9cb3 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataModels/OrderStatus.cs @@ -0,0 +1,11 @@ +namespace SoftwareInstallationDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj b/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Component.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Component.cs new file mode 100644 index 0000000..4a114fb --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Component.cs @@ -0,0 +1,41 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationDataModels.Models; + +namespace SoftwareInstallationListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/ComponentStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/ComponentStorage.cs new file mode 100644 index 0000000..b09bb6b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/ComponentStorage.cs @@ -0,0 +1,102 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationListImplement.Models; + +namespace SoftwareInstallationListImplement.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/SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs b/SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs new file mode 100644 index 0000000..c28c395 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs @@ -0,0 +1,26 @@ +using SoftwareInstallationListImplement.Models; + +namespace SoftwareInstallationListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Packages { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Packages = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs new file mode 100644 index 0000000..2de3006 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs @@ -0,0 +1,7 @@ +namespace SoftwareInstallationListImplement +{ + public class Order + { + //ToDO + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs new file mode 100644 index 0000000..971d62a --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs @@ -0,0 +1,7 @@ +namespace SoftwareInstallationListImplement +{ + public class OrderStorage + { + //ToDO + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Package.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Package.cs new file mode 100644 index 0000000..5d7c03e --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Package.cs @@ -0,0 +1,49 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationDataModels.Models; + +namespace SoftwareInstallationListImplement.Models +{ + public class Package : IPackageModel + { + public int Id { get; private set; } + public string PackageName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary PackageComponents + { + get; + private set; + } = new Dictionary(); + public static Package? Create(PackageBindingModel? model) + { + if (model == null) + { + return null; + } + return new Package() + { + Id = model.Id, + PackageName = model.PackageName, + Price = model.Price, + PackageComponents = model.PackageComponents + }; + } + public void Update(PackageBindingModel? model) + { + if (model == null) + { + return; + } + PackageName = model.PackageName; + Price = model.Price; + PackageComponents = model.PackageComponents; + } + public PackageViewModel GetViewModel => new() + { + Id = Id, + PackageName = PackageName, + Price = Price, + PackageComponents = PackageComponents + }; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs new file mode 100644 index 0000000..d2111dd --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs @@ -0,0 +1,7 @@ +namespace SoftwareInstallationListImplement +{ + public class PackageStorage + { + //ToDO + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj new file mode 100644 index 0000000..3a28f9a --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs new file mode 100644 index 0000000..b0353be --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs @@ -0,0 +1,116 @@ +namespace SoftwareInstallationView +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(171, 67); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 32); + this.buttonSave.TabIndex = 11; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(252, 67); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 32); + this.buttonCancel.TabIndex = 10; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(78, 41); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(149, 23); + this.textBoxCost.TabIndex = 9; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(78, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(249, 23); + this.textBoxName.TabIndex = 8; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 44); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(38, 15); + this.label2.TabIndex = 7; + this.label2.Text = "Цена:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(10, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 15); + this.label1.TabIndex = 6; + this.label1.Text = "Название:"; + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(344, 101); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormComponent"; + this.Text = "Компонент"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxCost; + private TextBox textBoxName; + private Label label2; + private Label label1; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponent.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponent.cs new file mode 100644 index 0000000..39e20f2 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponent.cs @@ -0,0 +1,85 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using Microsoft.Extensions.Logging; + +namespace SoftwareInstallationView +{ + 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/SoftwareInstallation/SoftwareInstallationView/FormComponent.resx b/SoftwareInstallation/SoftwareInstallationView/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/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/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs new file mode 100644 index 0000000..dd80144 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs @@ -0,0 +1,114 @@ +namespace SoftwareInstallationView +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.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(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonRef + // + this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRef.Location = new System.Drawing.Point(469, 157); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(90, 37); + this.buttonRef.TabIndex = 13; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + // + // buttonDel + // + this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDel.Location = new System.Drawing.Point(469, 106); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(90, 33); + this.buttonDel.TabIndex = 12; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + // + // buttonUpd + // + this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUpd.Location = new System.Drawing.Point(469, 57); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(90, 34); + this.buttonUpd.TabIndex = 11; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + // + // buttonAdd + // + this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAdd.Location = new System.Drawing.Point(469, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 30); + this.buttonAdd.TabIndex = 10; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(440, 440); + this.dataGridView.TabIndex = 14; + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(584, 441); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Name = "FormComponents"; + this.Text = "Компоненты"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs new file mode 100644 index 0000000..6d54eb5 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs @@ -0,0 +1,107 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + + +namespace SoftwareInstallationView +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponents.resx b/SoftwareInstallation/SoftwareInstallationView/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..4adca17 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs @@ -0,0 +1,152 @@ +namespace SoftwareInstallationView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.textBoxCount = new System.Windows.Forms.NumericUpDown(); + this.comboBoxPackage = new System.Windows.Forms.ComboBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).BeginInit(); + this.SuspendLayout(); + // + // textBoxSum + // + this.textBoxSum.Location = new System.Drawing.Point(101, 65); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(214, 23); + this.textBoxSum.TabIndex = 15; + this.textBoxSum.UseWaitCursor = true; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(101, 38); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(214, 23); + this.textBoxCount.TabIndex = 14; + this.textBoxCount.UseWaitCursor = true; + // + // comboBoxPackage + // + this.comboBoxPackage.FormattingEnabled = true; + this.comboBoxPackage.Location = new System.Drawing.Point(101, 9); + this.comboBoxPackage.Name = "comboBoxPackage"; + this.comboBoxPackage.Size = new System.Drawing.Size(214, 23); + this.comboBoxPackage.TabIndex = 13; + this.comboBoxPackage.UseWaitCursor = true; + // + // buttonSave + // + this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSave.Location = new System.Drawing.Point(141, 95); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(77, 23); + this.buttonSave.TabIndex = 12; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.UseWaitCursor = true; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.Location = new System.Drawing.Point(221, 95); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(95, 23); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.UseWaitCursor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 68); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(48, 15); + this.label3.TabIndex = 10; + this.label3.Text = "Сумма:"; + this.label3.UseWaitCursor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 40); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(75, 15); + this.label2.TabIndex = 9; + this.label2.Text = "Количество:"; + this.label2.UseWaitCursor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(56, 15); + this.label1.TabIndex = 8; + this.label1.Text = "Изделие:"; + this.label1.UseWaitCursor = true; + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(328, 130); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxPackage); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.UseWaitCursor = true; + ((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxSum; + private NumericUpDown textBoxCount; + private ComboBox comboBoxPackage; + private Button buttonSave; + private Button buttonCancel; + private Label label3; + private Label label2; + private Label label1; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs new file mode 100644 index 0000000..78d2faf --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs @@ -0,0 +1,93 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using Microsoft.Extensions.Logging; + + +namespace SoftwareInstallationView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IPackageLogic _logicP; + private readonly IOrderLogic _logicO; + public FormCreateOrder(ILogger logger, IPackageLogic logicP, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); + // прописать логику ToDO + } + private void CalcSum() + { + if (comboBoxPackage.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxPackage.SelectedValue); + var package = _logicP.ReadElement(new PackageSearchModel + { + Id = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (package?.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 ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxPackage.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + PackageId = Convert.ToInt32(comboBoxPackage.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(); + } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.resx b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/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/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs new file mode 100644 index 0000000..92460c5 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs @@ -0,0 +1,174 @@ +namespace SoftwareInstallationView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pastryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.button4 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); + this.buttonCreateOrder = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.справочникиToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(584, 24); + this.menuStrip1.TabIndex = 1; + this.menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.pastryToolStripMenuItem, + this.componentToolStripMenuItem}); + this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.справочникиToolStripMenuItem.Text = "Справочники"; + // + // pastryToolStripMenuItem + // + this.pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; + this.pastryToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.pastryToolStripMenuItem.Text = "Изделия"; + // + // componentToolStripMenuItem + // + this.componentToolStripMenuItem.Name = "componentToolStripMenuItem"; + this.componentToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.componentToolStripMenuItem.Text = "Компоненты"; + // + // button4 + // + this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button4.Location = new System.Drawing.Point(425, 374); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(147, 55); + this.button4.TabIndex = 12; + this.button4.Text = "Обновить список"; + this.button4.UseVisualStyleBackColor = true; + // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button3.Location = new System.Drawing.Point(425, 284); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(147, 55); + this.button3.TabIndex = 11; + this.button3.Text = "Заказ выдан"; + this.button3.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button2.Location = new System.Drawing.Point(425, 194); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(147, 55); + this.button2.TabIndex = 10; + this.button2.Text = "Заказ готов"; + this.button2.UseVisualStyleBackColor = true; + // + // buttonTakeOrderInWork + // + this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(425, 112); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 55); + this.buttonTakeOrderInWork.TabIndex = 9; + this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; + this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + // + // buttonCreateOrder + // + this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCreateOrder.Location = new System.Drawing.Point(425, 27); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(147, 55); + this.buttonCreateOrder.TabIndex = 8; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + // + // dataGridView + // + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 27); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(407, 402); + this.dataGridView.TabIndex = 7; + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(584, 441); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.buttonTakeOrderInWork); + this.Controls.Add(this.buttonCreateOrder); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.menuStrip1); + this.Name = "FormMain"; + this.Text = "Установка ПО"; + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem pastryToolStripMenuItem; + private ToolStripMenuItem componentToolStripMenuItem; + private Button button4; + private Button button3; + private Button button2; + private Button buttonTakeOrderInWork; + private Button buttonCreateOrder; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs new file mode 100644 index 0000000..73d8922 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs @@ -0,0 +1,122 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace SoftwareInstallationView +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + // прописать логику ToDO + } + 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) + { + // прописать логику + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении.Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении.Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.resx b/SoftwareInstallation/SoftwareInstallationView/FormMain.resx new file mode 100644 index 0000000..938108a --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs new file mode 100644 index 0000000..d7cf95b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs @@ -0,0 +1,237 @@ +namespace SoftwareInstallationView +{ + partial class FormPackage + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.groupBox1.Controls.Add(this.buttonAdd); + this.groupBox1.Controls.Add(this.buttonRef); + this.groupBox1.Controls.Add(this.buttonDel); + this.groupBox1.Controls.Add(this.buttonUpd); + this.groupBox1.Controls.Add(this.dataGridView); + this.groupBox1.Location = new System.Drawing.Point(12, 61); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.groupBox1.Size = new System.Drawing.Size(600, 330); + this.groupBox1.TabIndex = 3; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Компоненты:"; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(504, 22); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 34); + this.buttonAdd.TabIndex = 5; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // buttonRef + // + this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRef.Location = new System.Drawing.Point(504, 141); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(90, 37); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDel.Location = new System.Drawing.Point(504, 102); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(90, 33); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUpd.Location = new System.Drawing.Point(504, 62); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(90, 34); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // dataGridView + // + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + 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(7, 22); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(491, 302); + this.dataGridView.TabIndex = 0; + // + // id + // + this.id.HeaderText = "id"; + this.id.Name = "id"; + this.id.Visible = false; + // + // Component + // + this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Component.FillWeight = 1000F; + this.Component.HeaderText = "Компонент"; + this.Component.Name = "Component"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.Name = "Count"; + this.Count.Width = 97; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(96, 35); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(120, 23); + this.textBoxPrice.TabIndex = 8; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(96, 6); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(239, 23); + this.textBoxName.TabIndex = 7; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(19, 35); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(70, 15); + this.label2.TabIndex = 6; + this.label2.Text = "Стоимость:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(19, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 15); + this.label1.TabIndex = 5; + this.label1.Text = "Название:"; + // + // buttonSave + // + this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSave.Location = new System.Drawing.Point(416, 396); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(90, 35); + this.buttonSave.TabIndex = 10; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.Location = new System.Drawing.Point(512, 396); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(90, 35); + this.buttonCancel.TabIndex = 9; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormPackage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(624, 441); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.groupBox1); + this.Name = "FormPackage"; + this.Text = "Изделие"; + this.Load += new System.EventHandler(this.FormPackage_Load_1); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private GroupBox groupBox1; + private Button buttonAdd; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; + private TextBox textBoxPrice; + private TextBox textBoxName; + private Label label2; + private Label label1; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackage.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackage.cs new file mode 100644 index 0000000..cdafca3 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackage.cs @@ -0,0 +1,198 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace SoftwareInstallationView +{ + public partial class FormPackage : Form + { + private readonly ILogger _logger; + private readonly IPackageLogic _logic; + private int? _id; + private Dictionary _packageComponents; + public int Id { set { _id = value; } } + public FormPackage(ILogger logger, IPackageLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _packageComponents = new Dictionary(); + } + private void FormPackage_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new PackageSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.PackageName; + textBoxPrice.Text = view.Price.ToString(); + _packageComponents = view.PackageComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_packageComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _packageComponents) + { + 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(FormPackageComponent)); + if (service is FormPackageComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + if (_packageComponents.ContainsKey(form.Id)) + { + _packageComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _packageComponents.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(FormPackageComponent)); + if (service is FormPackageComponent form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _packageComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + _packageComponents[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); + _packageComponents?.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 (_packageComponents == null || _packageComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new PackageBindingModel + { + Id = _id ?? 0, + PackageName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + PackageComponents = _packageComponents + }; + 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 _packageComponents) + { + 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/SoftwareInstallation/SoftwareInstallationView/FormPackage.resx b/SoftwareInstallation/SoftwareInstallationView/FormPackage.resx new file mode 100644 index 0000000..05ebf2d --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackage.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs new file mode 100644 index 0000000..1dbad39 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs @@ -0,0 +1,118 @@ +namespace SoftwareInstallationView +{ + partial class FormPackageComponent + { + /// + /// 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.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.comboBoxComponent = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(107, 72); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(106, 27); + this.ButtonSave.TabIndex = 11; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(219, 72); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(119, 27); + this.ButtonCancel.TabIndex = 10; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(107, 43); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(231, 23); + this.textBoxCount.TabIndex = 9; + // + // comboBoxComponent + // + this.comboBoxComponent.ForeColor = System.Drawing.SystemColors.InactiveCaptionText; + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(107, 9); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(231, 23); + this.comboBoxComponent.TabIndex = 8; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 43); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(75, 15); + this.label2.TabIndex = 7; + this.label2.Text = "Количество:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(72, 15); + this.label1.TabIndex = 6; + this.label1.Text = "Компонент:"; + // + // FormPackageComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(344, 101); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxComponent); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormPackageComponent"; + this.Text = "Компонент изделия"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button ButtonSave; + private Button ButtonCancel; + private TextBox textBoxCount; + private ComboBox comboBoxComponent; + private Label label2; + private Label label1; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.cs new file mode 100644 index 0000000..58bb46d --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.cs @@ -0,0 +1,80 @@ +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationDataModels.Models; + +namespace SoftwareInstallationView +{ + public partial class FormPackageComponent : 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 FormPackageComponent(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/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.resx b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.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/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs new file mode 100644 index 0000000..db84241 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs @@ -0,0 +1,39 @@ +namespace SoftwareInstallationView +{ + partial class FormPackages + { + /// + /// 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 = "FormPackages"; + } + + #endregion + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs new file mode 100644 index 0000000..3207214 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.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 SoftwareInstallationView +{ + public partial class FormPackages : Form + { + public FormPackages() + { + InitializeComponent(); + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackages.resx b/SoftwareInstallation/SoftwareInstallationView/FormPackages.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.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/SoftwareInstallation/SoftwareInstallationView/Program.cs b/SoftwareInstallation/SoftwareInstallationView/Program.cs new file mode 100644 index 0000000..ad3ecc1 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/Program.cs @@ -0,0 +1,51 @@ +using SoftwareInstallationBusinessLogic.BusinessLogics; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + +namespace SoftwareInstallationView +{ + internal static class Program + { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/SoftwareInstallationView.csproj b/SoftwareInstallation/SoftwareInstallationView/SoftwareInstallationView.csproj new file mode 100644 index 0000000..08ea107 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationView/SoftwareInstallationView.csproj @@ -0,0 +1,24 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From 09dda036beb02937dfabf7ed3bef650b765a463b Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Mon, 6 Feb 2023 18:29:57 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=81=D1=82=D0=B2=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComponentLogic.cs | 3 +- .../OrderLogic.cs | 112 ++++++++++++++++- .../PackageLogic.cs | 115 +++++++++++++++++- .../Order.cs | 68 ++++++++++- .../OrderStorage.cs | 99 ++++++++++++++- .../PackageStorage.cs | 107 +++++++++++++++- .../FormComponent.Designer.cs | 2 + .../FormComponents.Designer.cs | 4 + .../FormCreateOrder.Designer.cs | 4 + .../FormCreateOrder.cs | 19 ++- .../FormMain.Designer.cs | 21 ++-- .../SoftwareInstallationView/FormMain.cs | 30 +++-- .../FormPackage.Designer.cs | 2 +- .../FormPackageComponent.Designer.cs | 2 + .../FormPackages.Designer.cs | 88 +++++++++++++- .../SoftwareInstallationView/FormPackages.cs | 100 +++++++++++++-- .../FormPackages.resx | 62 +--------- 17 files changed, 729 insertions(+), 109 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs index b7cf0f5..d739f04 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/ComponentLogic.cs @@ -10,8 +10,7 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics { private readonly ILogger _logger; private readonly IComponentStorage _componentStorage; - public ComponentLogic(ILogger logger, IComponentStorage - componentStorage) + public ComponentLogic(ILogger logger, IComponentStorage componentStorage) { _logger = logger; _componentStorage = componentStorage; diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs index 5c3c275..e27c78b 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs @@ -1,6 +1,112 @@ -namespace SoftwareInstallationBusinessLogic +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationDataModels.Enums; +using Microsoft.Extensions.Logging; + +namespace SoftwareInstallationBusinessLogic.BusinessLogics { - internal class OrderLogic + public class OrderLogic : IOrderLogic { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + + if (model.Status != OrderStatus.Неизвестен) + { + throw new ArgumentException( + $"Статус заказа должен быть {OrderStatus.Неизвестен}", nameof(model)); + } + model.Status = OrderStatus.Принят; + model.DateCreate = DateTime.Now; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool DeliveryOrder(OrderBindingModel model) + { + return SetOrderStatus(model, OrderStatus.Выдан); + } + + public bool FinishOrder(OrderBindingModel model) + { + return SetOrderStatus(model, OrderStatus.Выполняется); + } + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderName.Id:{ Id} ", model?.Id); + var list = (model == null) ? _orderStorage.GetFullList() : + _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + return SetOrderStatus(model, OrderStatus.Выполняется); + } + private bool CheckModel(OrderBindingModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum)); + } + if (model.DateCreate > model.DateImplement) + { + throw new ArgumentException("Время создания заказа не может быть больше времени его выполнения", nameof(model.DateImplement)); + } + return true; + } + private bool SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus) + { + var viewModel = _orderStorage.GetElement(new() { Id = model.Id }); + if (viewModel == null) + { + throw new ArgumentNullException(nameof(model)); + } + if ((int)viewModel.Status + 1 != (int)orderStatus) + { + throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " + + $"Текущий статус: {viewModel.Status} \n" + + $"Планируемый статус: {orderStatus} \n" + + $"Доступный статус: {(OrderStatus)((int)viewModel.Status + 1)}", + nameof(viewModel)); + } + model.Status = orderStatus; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Ошибка операции обновления"); + return false; + } + return true; + } } -} +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs index 6621be9..2545127 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/PackageLogic.cs @@ -1,7 +1,114 @@ -namespace SoftwareInstallationBusinessLogic +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace SoftwareInstallationBusinessLogic.BusinessLogics { - public class PackageLogic + public class PackageLogic : IPackageLogic { - //ToDO + private readonly ILogger _logger; + private readonly IPackageStorage _componentStorage; + public PackageLogic(ILogger logger, IPackageStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + + public bool Create(PackageBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(PackageBindingModel 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; + } + + public PackageViewModel? ReadElement(PackageSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{ Id}", model.PackageName, 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 List? ReadList(PackageSearchModel? model) + { + _logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{ Id} ", model?.PackageName, 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 bool Update(PackageBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + private void CheckModel(PackageBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.PackageName)) + { + throw new ArgumentNullException("Нет названия кондитерского изделия", + nameof(model.PackageName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена кондитерского изделия должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Package. PackageName:{PackageName}.Cost:{ Cost}. Id: { Id}", + model.PackageName, model.Price, model.Id); + var element = _componentStorage.GetElement(new PackageSearchModel + { + PackageName = model.PackageName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Кондитерское изделие с таким названием уже есть"); + } + } } -} +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs index 2de3006..8bf09c7 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs @@ -1,7 +1,69 @@ -namespace SoftwareInstallationListImplement +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationDataModels.Models; +using SoftwareInstallationDataModels.Enums; + +namespace SoftwareInstallationListImplement.Models { - public class Order + public class Order : IOrderModel { - //ToDO + public int PackageId { get; private set; } + + public int Count { get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; private set; } + + public DateTime DateCreate { get; private set; } + + public DateTime? DateImplement { get; private set; } + + public int Id { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + PackageId = model.PackageId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + Id = model.Id, + + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + PackageId = model.PackageId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + Id = model.Id; + } + + public OrderViewModel GetViewModel => new() + { + PackageId = PackageId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + Id = Id, + }; } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs index 971d62a..d146868 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs @@ -1,7 +1,100 @@ -namespace SoftwareInstallationListImplement +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationListImplement.Models; + +namespace SoftwareInstallationListImplement.Implements { - public class OrderStorage + public class OrderStorage : IOrderStorage { - //ToDO + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return order.GetViewModel; + } + } + return null; + } + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (!model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + return new() { order.GetViewModel }; + } + } + return result; + } + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(order.GetViewModel); + } + return result; + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var order in _source.Orders) + { + if (model.Id <= order.Id) + { + model.Id = order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return newOrder.GetViewModel; + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return order.GetViewModel; + } + } + return null; + } } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs index d2111dd..4d942c8 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/PackageStorage.cs @@ -1,7 +1,108 @@ -namespace SoftwareInstallationListImplement +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.StoragesContracts; +using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationListImplement.Models; + +namespace SoftwareInstallationListImplement.Implements { - public class PackageStorage + public class PackageStorage : IPackageStorage { - //ToDO + private readonly DataListSingleton _source; + public PackageStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public PackageViewModel? Delete(PackageBindingModel model) + { + for (int i = 0; i < _source.Packages.Count; ++i) + { + if (_source.Packages[i].Id == model.Id) + { + var element = _source.Packages[i]; + _source.Packages.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + + public PackageViewModel? GetElement(PackageSearchModel model) + { + if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue) + { + return null; + } + foreach (var package in _source.Packages) + { + if ((!string.IsNullOrEmpty(model.PackageName) && + package.PackageName == model.PackageName) || + (model.Id.HasValue && package.Id == model.Id)) + { + return package.GetViewModel; + } + } + return null; + } + + public List GetFilteredList(PackageSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.PackageName)) + { + return result; + } + foreach (var package in _source.Packages) + { + if (package.PackageName.Contains(model.PackageName ?? string.Empty)) + { + result.Add(package.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var package in _source.Packages) + { + result.Add(package.GetViewModel); + } + return result; + } + + public PackageViewModel? Insert(PackageBindingModel model) + { + model.Id = 1; + foreach (var package in _source.Packages) + { + if (model.Id <= package.Id) + { + model.Id = package.Id + 1; + } + } + var newPackage = Package.Create(model); + if (newPackage == null) + { + return null; + } + _source.Packages.Add(newPackage); + return newPackage.GetViewModel; + } + + public PackageViewModel? Update(PackageBindingModel model) + { + foreach (var package in _source.Packages) + { + if (package.Id == model.Id) + { + package.Update(model); + return package.GetViewModel; + } + } + return null; + } } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs index b0353be..cfbc00b 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponent.Designer.cs @@ -44,6 +44,7 @@ this.buttonSave.TabIndex = 11; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // buttonCancel // @@ -53,6 +54,7 @@ this.buttonCancel.TabIndex = 10; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // textBoxCost // diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs index dd80144..709c661 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.Designer.cs @@ -45,6 +45,7 @@ this.buttonRef.TabIndex = 13; this.buttonRef.Text = "Обновить"; this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); // // buttonDel // @@ -55,6 +56,7 @@ this.buttonDel.TabIndex = 12; this.buttonDel.Text = "Удалить"; this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); // // buttonUpd // @@ -65,6 +67,7 @@ this.buttonUpd.TabIndex = 11; this.buttonUpd.Text = "Изменить"; this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); // // buttonAdd // @@ -75,6 +78,7 @@ this.buttonAdd.TabIndex = 10; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // // dataGridView // diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs index 4adca17..5a3516f 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs @@ -54,6 +54,7 @@ this.textBoxCount.Size = new System.Drawing.Size(214, 23); this.textBoxCount.TabIndex = 14; this.textBoxCount.UseWaitCursor = true; + this.textBoxCount.Click += new System.EventHandler(this.TextBoxCount_TextChanged); // // comboBoxPackage // @@ -63,6 +64,7 @@ this.comboBoxPackage.Size = new System.Drawing.Size(214, 23); this.comboBoxPackage.TabIndex = 13; this.comboBoxPackage.UseWaitCursor = true; + this.comboBoxPackage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPackage_SelectedIndexChanged); // // buttonSave // @@ -74,6 +76,7 @@ this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseWaitCursor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // buttonCancel // @@ -85,6 +88,7 @@ this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseWaitCursor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // label3 // diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs index 78d2faf..1e4bdcd 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs @@ -1,6 +1,7 @@ using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.SearchModels; +using SoftwareInstallationContracts.ViewModels; using Microsoft.Extensions.Logging; @@ -11,17 +12,29 @@ namespace SoftwareInstallationView private readonly ILogger _logger; private readonly IPackageLogic _logicP; private readonly IOrderLogic _logicO; + private readonly List? _list; public FormCreateOrder(ILogger logger, IPackageLogic logicP, IOrderLogic logicO) { InitializeComponent(); _logger = logger; _logicP = logicP; _logicO = logicO; + _list = logicP.ReadList(null); + if (_list != null) + { + comboBoxPackage.DisplayMember = "PackageName"; + comboBoxPackage.ValueMember = "Id"; + comboBoxPackage.DataSource = _list; + comboBoxPackage.SelectedItem = null; + } } private void FormCreateOrder_Load(object sender, EventArgs e) { _logger.LogInformation("Загрузка изделий для заказа"); - // прописать логику ToDO + foreach (var el in _logicP.ReadList(null) ?? new()) + { + comboBoxPackage.Items.Add(el.PackageName); + } } private void CalcSum() { @@ -49,6 +62,10 @@ namespace SoftwareInstallationView { CalcSum(); } + private void ComboBoxPackage_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } private void ButtonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCount.Text)) diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs index 92460c5..6dcc55b 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs @@ -30,7 +30,7 @@ { this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pastryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.packageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); @@ -55,23 +55,25 @@ // справочникиToolStripMenuItem // this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.pastryToolStripMenuItem, + this.packageToolStripMenuItem, this.componentToolStripMenuItem}); this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); this.справочникиToolStripMenuItem.Text = "Справочники"; // - // pastryToolStripMenuItem + // packageToolStripMenuItem // - this.pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; - this.pastryToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.pastryToolStripMenuItem.Text = "Изделия"; + this.packageToolStripMenuItem.Name = "packageToolStripMenuItem"; + this.packageToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.packageToolStripMenuItem.Text = "Изделия"; + this.packageToolStripMenuItem.Click += new System.EventHandler(this.PackagesToolStripMenuItem_Click); // // componentToolStripMenuItem // this.componentToolStripMenuItem.Name = "componentToolStripMenuItem"; this.componentToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.componentToolStripMenuItem.Text = "Компоненты"; + this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); // // button4 // @@ -82,6 +84,7 @@ this.button4.TabIndex = 12; this.button4.Text = "Обновить список"; this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.ButtonRef_Click); // // button3 // @@ -92,6 +95,7 @@ this.button3.TabIndex = 11; this.button3.Text = "Заказ выдан"; this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); // // button2 // @@ -102,6 +106,7 @@ this.button2.TabIndex = 10; this.button2.Text = "Заказ готов"; this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.ButtonOrderReady_Click); // // buttonTakeOrderInWork // @@ -112,6 +117,7 @@ this.buttonTakeOrderInWork.TabIndex = 9; this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); // // buttonCreateOrder // @@ -122,6 +128,7 @@ this.buttonCreateOrder.TabIndex = 8; this.buttonCreateOrder.Text = "Создать заказ"; this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); // // dataGridView // @@ -162,7 +169,7 @@ private MenuStrip menuStrip1; private ToolStripMenuItem справочникиToolStripMenuItem; - private ToolStripMenuItem pastryToolStripMenuItem; + private ToolStripMenuItem packageToolStripMenuItem; private ToolStripMenuItem componentToolStripMenuItem; private Button button4; private Button button3; diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs index 73d8922..70f93ed 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs @@ -20,21 +20,37 @@ namespace SoftwareInstallationView } private void LoadData() { - _logger.LogInformation("Загрузка заказов"); - // прописать логику ToDO + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } - private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormComponents)); + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); if (service is FormComponents form) { form.ShowDialog(); } } - private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) + private void PackagesToolStripMenuItem_Click(object sender, EventArgs e) { - // прописать логику + var service = Program.ServiceProvider?.GetService(typeof(FormPackages)); + if (service is FormPackages form) + { + form.ShowDialog(); + } } private void ButtonCreateOrder_Click(object sender, EventArgs e) { diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs index d7cf95b..c4fe538 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackage.Designer.cs @@ -208,7 +208,7 @@ this.Controls.Add(this.groupBox1); this.Name = "FormPackage"; this.Text = "Изделие"; - this.Load += new System.EventHandler(this.FormPackage_Load_1); + this.Load += new System.EventHandler(this.FormPackage_Load); this.groupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs index 1dbad39..30f364d 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackageComponent.Designer.cs @@ -44,6 +44,7 @@ this.ButtonSave.TabIndex = 11; this.ButtonSave.Text = "Сохранить"; this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // ButtonCancel // @@ -53,6 +54,7 @@ this.ButtonCancel.TabIndex = 10; this.ButtonCancel.Text = "Отмена"; this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // textBoxCount // diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs index db84241..ebcc51a 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.Designer.cs @@ -28,12 +28,94 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + 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(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonRef + // + this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRef.Location = new System.Drawing.Point(482, 172); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(90, 52); + this.buttonRef.TabIndex = 14; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDel.Location = new System.Drawing.Point(482, 118); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(90, 48); + this.buttonDel.TabIndex = 13; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUpd.Location = new System.Drawing.Point(482, 63); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(90, 49); + this.buttonUpd.TabIndex = 12; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAdd.Location = new System.Drawing.Point(482, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 45); + this.buttonAdd.TabIndex = 11; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(464, 417); + this.dataGridView.TabIndex = 10; + // + // FormPackages + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormPackages"; + this.ClientSize = new System.Drawing.Size(584, 441); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormPackages"; + this.Text = "Изделия"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + } #endregion + + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs index 3207214..6759b73 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs @@ -1,20 +1,98 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; namespace SoftwareInstallationView { public partial class FormPackages : Form { - public FormPackages() + private readonly ILogger _logger; + private readonly IPackageLogic _logic; + public FormPackages(ILogger logger, IPackageLogic logic) { InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormViewPackage_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["PackageName"].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(FormPackage)); + if (service is FormPackage form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + } + 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 PackageBindingModel + { + 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/SoftwareInstallation/SoftwareInstallationView/FormPackages.resx b/SoftwareInstallation/SoftwareInstallationView/FormPackages.resx index 1af7de1..f298a7b 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormPackages.resx +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.resx @@ -1,64 +1,4 @@ - - - + -- 2.25.1 From 5de3202afc8e548d612b9253aeb05b74491aeef8 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Mon, 6 Feb 2023 22:03:49 +0400 Subject: [PATCH 3/5] fix --- .../OrderLogic.cs | 7 ++++++- .../OrderStorage.cs | 15 ++++++++++++++- .../SoftwareInstallationView/FormComponents.cs | 12 ++++-------- .../SoftwareInstallationView/FormMain.cs | 6 +++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs index e27c78b..4b53c5f 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs @@ -39,12 +39,13 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics public bool DeliveryOrder(OrderBindingModel model) { + model.DateImplement = DateTime.Now; return SetOrderStatus(model, OrderStatus.Выдан); } public bool FinishOrder(OrderBindingModel model) { - return SetOrderStatus(model, OrderStatus.Выполняется); + return SetOrderStatus(model, OrderStatus.Готов); } public List? ReadList(OrderSearchModel? model) @@ -101,6 +102,10 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics nameof(viewModel)); } model.Status = orderStatus; + model.Sum = viewModel.Sum; + model.Count = viewModel.Count; + model.DateCreate = viewModel.DateCreate; + model.PackageId = viewModel.PackageId; if (_orderStorage.Update(model) == null) { _logger.LogWarning("Ошибка операции обновления"); diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs index d146868..85f1ea4 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs @@ -62,7 +62,7 @@ namespace SoftwareInstallationListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } return result; } @@ -96,5 +96,18 @@ namespace SoftwareInstallationListImplement.Implements } return null; } + private OrderViewModel GetViewModel(Order model) + { + var res = model.GetViewModel; + foreach (var package in _source.Packages) + { + if (package.Id == model.PackageId) + { + res.PackageName = package.PackageName; + break; + } + } + return res; + } } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs index 6d54eb5..3648177 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs @@ -28,16 +28,14 @@ namespace SoftwareInstallationView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки компонентов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void ButtonAdd_Click(object sender, EventArgs e) @@ -73,11 +71,9 @@ namespace SoftwareInstallationView { if (dataGridView.SelectedRows.Count == 1) { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление компонента"); try { diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs index 70f93ed..c44068a 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs @@ -27,6 +27,7 @@ namespace SoftwareInstallationView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -54,8 +55,7 @@ namespace SoftwareInstallationView } private void ButtonCreateOrder_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); if (service is FormCreateOrder form) { form.ShowDialog(); @@ -68,7 +68,7 @@ namespace SoftwareInstallationView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try + try { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); if (!operationResult) -- 2.25.1 From d91170392ea3c830ddddcfe41f394974412d1e56 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Mon, 6 Feb 2023 22:04:33 +0400 Subject: [PATCH 4/5] super fix --- .../SoftwareInstallationView/FormCreateOrder.Designer.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs index 5a3516f..0e0b172 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.Designer.cs @@ -45,7 +45,6 @@ this.textBoxSum.Name = "textBoxSum"; this.textBoxSum.Size = new System.Drawing.Size(214, 23); this.textBoxSum.TabIndex = 15; - this.textBoxSum.UseWaitCursor = true; // // textBoxCount // @@ -53,7 +52,6 @@ this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Size = new System.Drawing.Size(214, 23); this.textBoxCount.TabIndex = 14; - this.textBoxCount.UseWaitCursor = true; this.textBoxCount.Click += new System.EventHandler(this.TextBoxCount_TextChanged); // // comboBoxPackage @@ -63,7 +61,6 @@ this.comboBoxPackage.Name = "comboBoxPackage"; this.comboBoxPackage.Size = new System.Drawing.Size(214, 23); this.comboBoxPackage.TabIndex = 13; - this.comboBoxPackage.UseWaitCursor = true; this.comboBoxPackage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPackage_SelectedIndexChanged); // // buttonSave @@ -75,7 +72,6 @@ this.buttonSave.TabIndex = 12; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.UseWaitCursor = true; this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // buttonCancel @@ -87,7 +83,6 @@ this.buttonCancel.TabIndex = 11; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.UseWaitCursor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // label3 @@ -98,7 +93,6 @@ this.label3.Size = new System.Drawing.Size(48, 15); this.label3.TabIndex = 10; this.label3.Text = "Сумма:"; - this.label3.UseWaitCursor = true; // // label2 // @@ -108,7 +102,6 @@ this.label2.Size = new System.Drawing.Size(75, 15); this.label2.TabIndex = 9; this.label2.Text = "Количество:"; - this.label2.UseWaitCursor = true; // // label1 // @@ -118,7 +111,6 @@ this.label1.Size = new System.Drawing.Size(56, 15); this.label1.TabIndex = 8; this.label1.Text = "Изделие:"; - this.label1.UseWaitCursor = true; // // FormCreateOrder // @@ -135,7 +127,6 @@ this.Controls.Add(this.label1); this.Name = "FormCreateOrder"; this.Text = "Заказ"; - this.UseWaitCursor = true; ((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); -- 2.25.1 From c0bbf317eb2e6ded867c5aec47ecfe9bcc30adad Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Mon, 20 Feb 2023 20:37:31 +0400 Subject: [PATCH 5/5] fix --- .../OrderLogic.cs | 4 +- .../Order.cs | 5 -- .../FormComponents.cs | 1 + .../FormCreateOrder.cs | 5 +- .../FormMain.Designer.cs | 86 +++++++++---------- .../SoftwareInstallationView/FormMain.cs | 2 +- .../SoftwareInstallationView/FormPackages.cs | 2 + 7 files changed, 50 insertions(+), 55 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs index 4b53c5f..413fb3c 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs @@ -39,12 +39,12 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics public bool DeliveryOrder(OrderBindingModel model) { - model.DateImplement = DateTime.Now; return SetOrderStatus(model, OrderStatus.Выдан); } public bool FinishOrder(OrderBindingModel model) { + model.DateImplement = DateTime.Now; return SetOrderStatus(model, OrderStatus.Готов); } @@ -101,10 +101,10 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics $"Доступный статус: {(OrderStatus)((int)viewModel.Status + 1)}", nameof(viewModel)); } + if (model.DateImplement == null) model.DateImplement = viewModel.DateImplement; model.Status = orderStatus; model.Sum = viewModel.Sum; model.Count = viewModel.Count; - model.DateCreate = viewModel.DateCreate; model.PackageId = viewModel.PackageId; if (_orderStorage.Update(model) == null) { diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs index 8bf09c7..9855e43 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Order.cs @@ -46,13 +46,8 @@ namespace SoftwareInstallationListImplement.Models { return; } - PackageId = model.PackageId; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; - Id = model.Id; } public OrderViewModel GetViewModel => new() diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs index 3648177..eb05670 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs @@ -14,6 +14,7 @@ namespace SoftwareInstallationView InitializeComponent(); _logger = logger; _logic = logic; + LoadData(); } private void FormComponents_Load(object sender, EventArgs e) { diff --git a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs index 1e4bdcd..52f9d93 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormCreateOrder.cs @@ -31,10 +31,7 @@ namespace SoftwareInstallationView private void FormCreateOrder_Load(object sender, EventArgs e) { _logger.LogInformation("Загрузка изделий для заказа"); - foreach (var el in _logicP.ReadList(null) ?? new()) - { - comboBoxPackage.Items.Add(el.PackageName); - } + comboBoxPackage.DataSource = _logicP.ReadList(null) ?? new(); } private void CalcSum() { diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs index 6dcc55b..06898ce 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.Designer.cs @@ -32,9 +32,9 @@ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.packageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.button4 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); + this.ButtonRef = new System.Windows.Forms.Button(); + this.ButtonIssuedOrder = new System.Windows.Forms.Button(); + this.ButtonOrderReady = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); @@ -48,7 +48,7 @@ this.справочникиToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(584, 24); + this.menuStrip1.Size = new System.Drawing.Size(1125, 24); this.menuStrip1.TabIndex = 1; this.menuStrip1.Text = "menuStrip1"; // @@ -64,54 +64,54 @@ // packageToolStripMenuItem // this.packageToolStripMenuItem.Name = "packageToolStripMenuItem"; - this.packageToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.packageToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.packageToolStripMenuItem.Text = "Изделия"; this.packageToolStripMenuItem.Click += new System.EventHandler(this.PackagesToolStripMenuItem_Click); // // componentToolStripMenuItem // this.componentToolStripMenuItem.Name = "componentToolStripMenuItem"; - this.componentToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.componentToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.componentToolStripMenuItem.Text = "Компоненты"; this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); // - // button4 + // ButtonRef // - this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button4.Location = new System.Drawing.Point(425, 374); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(147, 55); - this.button4.TabIndex = 12; - this.button4.Text = "Обновить список"; - this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.ButtonRef_Click); + this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonRef.Location = new System.Drawing.Point(966, 374); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(147, 55); + this.ButtonRef.TabIndex = 12; + this.ButtonRef.Text = "Обновить список"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); // - // button3 + // ButtonIssuedOrder // - this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button3.Location = new System.Drawing.Point(425, 284); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(147, 55); - this.button3.TabIndex = 11; - this.button3.Text = "Заказ выдан"; - this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonIssuedOrder.Location = new System.Drawing.Point(966, 284); + this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; + this.ButtonIssuedOrder.Size = new System.Drawing.Size(147, 55); + this.ButtonIssuedOrder.TabIndex = 11; + this.ButtonIssuedOrder.Text = "Заказ выдан"; + this.ButtonIssuedOrder.UseVisualStyleBackColor = true; + this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); // - // button2 + // ButtonOrderReady // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button2.Location = new System.Drawing.Point(425, 194); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(147, 55); - this.button2.TabIndex = 10; - this.button2.Text = "Заказ готов"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.ButtonOrderReady_Click); + this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonOrderReady.Location = new System.Drawing.Point(966, 194); + this.ButtonOrderReady.Name = "ButtonOrderReady"; + this.ButtonOrderReady.Size = new System.Drawing.Size(147, 55); + this.ButtonOrderReady.TabIndex = 10; + this.ButtonOrderReady.Text = "Заказ готов"; + this.ButtonOrderReady.UseVisualStyleBackColor = true; + this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); // // buttonTakeOrderInWork // this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(425, 112); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(966, 112); this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 55); this.buttonTakeOrderInWork.TabIndex = 9; @@ -122,7 +122,7 @@ // buttonCreateOrder // this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCreateOrder.Location = new System.Drawing.Point(425, 27); + this.buttonCreateOrder.Location = new System.Drawing.Point(966, 27); this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Size = new System.Drawing.Size(147, 55); this.buttonCreateOrder.TabIndex = 8; @@ -140,17 +140,17 @@ this.dataGridView.Location = new System.Drawing.Point(12, 27); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(407, 402); + this.dataGridView.Size = new System.Drawing.Size(948, 402); this.dataGridView.TabIndex = 7; // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(584, 441); - this.Controls.Add(this.button4); - this.Controls.Add(this.button3); - this.Controls.Add(this.button2); + this.ClientSize = new System.Drawing.Size(1125, 441); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonIssuedOrder); + this.Controls.Add(this.ButtonOrderReady); this.Controls.Add(this.buttonTakeOrderInWork); this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.dataGridView); @@ -171,9 +171,9 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem packageToolStripMenuItem; private ToolStripMenuItem componentToolStripMenuItem; - private Button button4; - private Button button3; - private Button button2; + private Button ButtonRef; + private Button ButtonIssuedOrder; + private Button ButtonOrderReady; private Button buttonTakeOrderInWork; private Button buttonCreateOrder; private DataGridView dataGridView; diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs index c44068a..7998d07 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs @@ -26,7 +26,7 @@ namespace SoftwareInstallationView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["PackageId"].Visible = false; dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); diff --git a/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs b/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs index 6759b73..fa95cfc 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormPackages.cs @@ -13,6 +13,7 @@ namespace SoftwareInstallationView InitializeComponent(); _logger = logger; _logic = logic; + LoadData(); } private void FormViewPackage_Load(object sender, EventArgs e) { @@ -27,6 +28,7 @@ namespace SoftwareInstallationView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["PackageComponents"].Visible = false; dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } -- 2.25.1