From 63e5aca18b70155567aa00aef3bb59b49e76e104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Sun, 5 Feb 2023 19:12:17 +0400 Subject: [PATCH 1/9] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D1=8B=20BuisnessLogic,=20Contracts,=20DataModels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrecastConcretePlant/PrecastConcretePlant.sln | 20 +++- .../ComponentLogic.cs | 113 ++++++++++++++++++ .../OrderLogic.cs | 103 ++++++++++++++++ .../PrecastConcretePlantBusinessLogic.csproj | 17 +++ .../ReinforcedLogic.cs | 113 ++++++++++++++++++ .../BindingModels/ComponentBindingModel.cs | 12 ++ .../BindingModels/OrderBindingModel.cs | 16 +++ .../BindingModels/ReinforcedBindingModels.cs | 16 +++ .../IComoinentLogic.cs | 15 +++ .../BusinessLogicsContracts/IOrderLogic.cs | 15 +++ .../IReinforcedLigoc.cs | 15 +++ .../PrecastConcretePlantContracts.csproj | 13 ++ .../SearchModels/ComponentSearchModel.cs | 8 ++ .../SearchModels/OrderSearchModel.cs | 7 ++ .../SearchModels/ReinforcedSearchModel.cs | 8 ++ .../StoragesContract/IComponentStorage.cs | 16 +++ .../StoragesContract/IOrderStorage.cs | 16 +++ .../StoragesContract/IReinforcedStorage.cs | 16 +++ .../ViewModels/ComponentViewModel.cs | 16 +++ .../ViewModels/OrderViewModel.cs | 31 +++++ .../ViewModels/ReinforcedViewModel.cs | 19 +++ .../IComponentModel.cs | 8 ++ .../PrecastConcretePlantDataModels/IId.cs | 7 ++ .../IOrderModel.cs | 14 +++ .../IReinforcedModel.cs | 9 ++ .../OrderStatus.cs | 12 ++ .../PrecastConcretePlantDataModels.csproj | 9 ++ 27 files changed, 663 insertions(+), 1 deletion(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln index f4a799b..55a2881 100644 --- a/PrecastConcretePlant/PrecastConcretePlant.sln +++ b/PrecastConcretePlant/PrecastConcretePlant.sln @@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32901.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{F97343A9-F725-4447-BB24-6B270785836A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +21,18 @@ Global {A2739D9B-5464-45C9-AD64-93CD163EC3CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2739D9B-5464-45C9-AD64-93CD163EC3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {A2739D9B-5464-45C9-AD64-93CD163EC3CD}.Release|Any CPU.Build.0 = Release|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F97343A9-F725-4447-BB24-6B270785836A}.Release|Any CPU.Build.0 = Release|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}.Release|Any CPU.Build.0 = Release|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..cc7f705 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs @@ -0,0 +1,113 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace PrecastConcretePlantBusinessLogic +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id} ", + model?.ComponentName, model?.Id); + var list = (model == null) ? _componentStorage.GetFullList() : + _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", + model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", + model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..786a1b9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -0,0 +1,103 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Enums; + +namespace PrecastConcretePlantBusinessLogic +{ + internal 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 TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется); + public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан); + public bool FinishOrder(OrderBindingModel model) => 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; + } + + 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 vmodel = _orderStorage.GetElement(new() { Id = model.Id }); + if (vmodel == null) + { + throw new ArgumentNullException(nameof(model)); + } + if ((int)vmodel.Status + 1 != (int)orderStatus) + { + throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " + + $"Текущий статус: {vmodel.Status} \n" + + $"Планируемый статус: {orderStatus} \n" + + $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}", + nameof(vmodel)); + } + model.Status = orderStatus; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj new file mode 100644 index 0000000..16b4699 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/PrecastConcretePlantBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs new file mode 100644 index 0000000..ae1fe4a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs @@ -0,0 +1,113 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace ConfectioneryBusinessLogic.BusinessLogics +{ + public class ReinforcedLogic : IReinforcedLogic + { + private readonly ILogger _logger; + private readonly IReinforcedStorage _componentStorage; + public ReinforcedLogic(ILogger logger, IReinforcedStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ReinforcedSearchModel? model) + { + _logger.LogInformation("ReadList. ReinforcedName:{ReinforcedName}.Id:{ Id} ", + model?.ReinforcedName, 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 ReinforcedViewModel? ReadElement(ReinforcedSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ReinforcedName:{ReinforcedName}.Id:{ Id}", + model.ReinforcedName, model.Id); + var element = _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(ReinforcedBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ReinforcedBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ReinforcedBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ReinforcedBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ReinforcedName)) + { + throw new ArgumentNullException("Нет названия железобетонного изделия", + nameof(model.ReinforcedName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена железобетонного изделия должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Reinforced. ReinforcedName:{ReinforcedName}.Price:{ Price}. Id: { Id}", + model.ReinforcedName, model.Price, model.Id); + var element = _componentStorage.GetElement(new ReinforcedSearchModel + { + ReinforcedName = model.ReinforcedName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Железобетонное изделие с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..b21c7dc --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,12 @@ +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..522fe37 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int ReinforcedId { 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; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs new file mode 100644 index 0000000..e33afb7 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReinforcedBindingModels.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantContracts.BindingModels +{ + public class ReinforcedBindingModel : IReinforcedModel + { + public int Id { get; set; } + public string ReinforcedName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary ReinforcedComponents + { + get; + set; + } = new(); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs new file mode 100644 index 0000000..8bf294a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IComoinentLogic.cs @@ -0,0 +1,15 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..93ca57c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs new file mode 100644 index 0000000..8eb560b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReinforcedLigoc.cs @@ -0,0 +1,15 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.BusinessLogicsContracts +{ + public interface IReinforcedLogic + { + List? ReadList(ReinforcedSearchModel? model); + ReinforcedViewModel? ReadElement(ReinforcedSearchModel model); + bool Create(ReinforcedBindingModel model); + bool Update(ReinforcedBindingModel model); + bool Delete(ReinforcedBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj new file mode 100644 index 0000000..51219ff --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/PrecastConcretePlantContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..891ab27 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,8 @@ +namespace PrecastConcretePlantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..b5b956c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace PrecastConcretePlantContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs new file mode 100644 index 0000000..4d98079 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/SearchModels/ReinforcedSearchModel.cs @@ -0,0 +1,8 @@ +namespace PrecastConcretePlantContracts.SearchModels +{ + public class ReinforcedSearchModel + { + public int? Id { get; set; } + public string? ReinforcedName { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs new file mode 100644 index 0000000..a7c3042 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IComponentStorage.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContract +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs new file mode 100644 index 0000000..30ce5fb --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IOrderStorage.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContract +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs new file mode 100644 index 0000000..dc49554 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/StoragesContract/IReinforcedStorage.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantContracts.StoragesContract +{ + public interface IReinforcedStorage + { + List GetFullList(); + List GetFilteredList(ReinforcedSearchModel model); + ReinforcedViewModel? GetElement(ReinforcedSearchModel model); + ReinforcedViewModel? Insert(ReinforcedBindingModel model); + ReinforcedViewModel? Update(ReinforcedBindingModel model); + ReinforcedViewModel? Delete(ReinforcedBindingModel model); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..e010eb4 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,16 @@ +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..fe09ad6 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,31 @@ +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int ReinforcedId { get; set; } + + [DisplayName("Изделие")] + public string ReinforcedName { get; set; } = string.Empty; + + [DisplayName("Количество")] + public int Count { get; set; } + + [DisplayName("Сумма")] + public double Sum { get; set; } + + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs new file mode 100644 index 0000000..252f6ff --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReinforcedViewModel.cs @@ -0,0 +1,19 @@ +using PrecastConcretePlantDataModels.Models; +using System.ComponentModel; + +namespace PrecastConcretePlantContracts.ViewModels +{ + public class ReinforcedViewModel : IReinforcedModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string ReinforcedName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary ReinforcedComponents + { + get; + set; + } = new(); + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs new file mode 100644 index 0000000..6489932 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IComponentModel.cs @@ -0,0 +1,8 @@ +namespace PrecastConcretePlantDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs new file mode 100644 index 0000000..9560ed3 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace PrecastConcretePlantDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs new file mode 100644 index 0000000..09861bc --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IOrderModel.cs @@ -0,0 +1,14 @@ +using PrecastConcretePlantDataModels.Enums; + +namespace PrecastConcretePlantDataModels.Models +{ + public interface IOrderModel : IId + { + int ReinforcedId { 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/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs new file mode 100644 index 0000000..9e99a5d --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/IReinforcedModel.cs @@ -0,0 +1,9 @@ +namespace PrecastConcretePlantDataModels.Models +{ + public interface IReinforcedModel : IId + { + string ReinforcedName { get; } + double Price { get; } + Dictionary ReinforcedComponents { get; } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs new file mode 100644 index 0000000..e3d8d41 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/OrderStatus.cs @@ -0,0 +1,12 @@ +namespace PrecastConcretePlantDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantDataModels/PrecastConcretePlantDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + -- 2.25.1 From bbcdf53d4b049217b2f96d1c839af570b626ebd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Sun, 5 Feb 2023 21:07:54 +0400 Subject: [PATCH 2/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B4=D0=B2=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrecastConcretePlant/PrecastConcretePlant.sln | 14 +- .../PrecastConcretePlant/Form1.Designer.cs | 39 ------ .../PrecastConcretePlant/Form1.cs | 10 -- .../PrecastConcretePlant/Form1.resx | 120 ------------------ .../FormComponent.Designer.cs | 118 +++++++++++++++++ .../PrecastConcretePlant/FormComponent.cs | 86 +++++++++++++ .../PrecastConcretePlant/FormComponent.resx | 60 +++++++++ .../FormComponents.Designer.cs | 120 ++++++++++++++++++ .../PrecastConcretePlant/FormComponents.cs | 108 ++++++++++++++++ .../PrecastConcretePlant/FormComponents.resx | 60 +++++++++ .../PrecastConcretePlant.csproj | 11 -- .../PrecastConcretePlantView.csproj | 22 ++++ .../PrecastConcretePlant/Program.cs | 41 +++++- .../ComponentLogic.cs | 2 +- .../OrderLogic.cs | 4 +- .../ReinforcedLogic.cs | 2 +- .../Component.cs | 42 ++++++ .../ComponentStorage.cs | 103 +++++++++++++++ .../DataListSingleton.cs | 26 ++++ .../Order.cs | 67 ++++++++++ .../OrderStorage.cs | 106 ++++++++++++++++ .../PrecastConcretePlantListImplement.csproj | 14 ++ .../Reinforced.cs | 49 +++++++ .../ReinforcedStorage.cs | 108 ++++++++++++++++ 24 files changed, 1143 insertions(+), 189 deletions(-) delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/Form1.cs delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/Form1.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormComponents.resx delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs diff --git a/PrecastConcretePlant/PrecastConcretePlant.sln b/PrecastConcretePlant/PrecastConcretePlant.sln index 55a2881..eb09aac 100644 --- a/PrecastConcretePlant/PrecastConcretePlant.sln +++ b/PrecastConcretePlant/PrecastConcretePlant.sln @@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32901.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlant", "PrecastConcretePlant\PrecastConcretePlant.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantView", "PrecastConcretePlant\PrecastConcretePlantView.csproj", "{A2739D9B-5464-45C9-AD64-93CD163EC3CD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{F97343A9-F725-4447-BB24-6B270785836A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantDataModels", "PrecastConcretePlantDataModels\PrecastConcretePlantDataModels.csproj", "{F97343A9-F725-4447-BB24-6B270785836A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantContracts", "PrecastConcretePlantContracts\PrecastConcretePlantContracts.csproj", "{F109F172-BAFA-49AB-B97C-4D78DD3A8CA2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantBusinessLogic", "PrecastConcretePlantBusinessLogic\PrecastConcretePlantBusinessLogic.csproj", "{8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecastConcretePlantListImplement", "PrecastConcretePlantListImplement\PrecastConcretePlantListImplement.csproj", "{471A4697-59C0-40C0-8B5E-8BEC01BD20BD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.ActiveCfg = Release|Any CPU {8AA1C140-4A96-4CBE-86E8-9A2E131EB58D}.Release|Any CPU.Build.0 = Release|Any CPU + {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {471A4697-59C0-40C0-8B5E-8BEC01BD20BD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs deleted file mode 100644 index 5704a3c..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace PrecastConcretePlant -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/Form1.cs b/PrecastConcretePlant/PrecastConcretePlant/Form1.cs deleted file mode 100644 index 0d56e73..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace PrecastConcretePlant -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/Form1.resx b/PrecastConcretePlant/PrecastConcretePlant/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs new file mode 100644 index 0000000..9285128 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.Designer.cs @@ -0,0 +1,118 @@ +namespace PrecastConcretePlantView +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelName = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(37, 29); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(105, 26); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(258, 23); + this.textBoxName.TabIndex = 1; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(37, 73); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(38, 15); + this.labelPrice.TabIndex = 2; + this.labelPrice.Text = "Цена:"; + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(105, 73); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(136, 23); + this.textBoxCost.TabIndex = 3; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(207, 111); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(288, 111); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(387, 149); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormComponent"; + this.Text = "FormComponent"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private Label labelPrice; + private TextBox textBoxCost; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs new file mode 100644 index 0000000..6be5883 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.cs @@ -0,0 +1,86 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение компонента"); + var view = _logic.ReadElement(new ComponentSearchModel {Id =_id.Value} ); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение компонента"); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} + diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs new file mode 100644 index 0000000..293e0fe --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs @@ -0,0 +1,120 @@ +namespace PrecastConcretePlantView +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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(493, 150); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(90, 37); + 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(493, 111); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(90, 33); + 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(493, 71); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(90, 34); + 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(493, 35); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 30); + 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.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(475, 321); + this.dataGridView.TabIndex = 10; + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(595, 345); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormComponents"; + this.Text = "FormComponents"; + ((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/PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs new file mode 100644 index 0000000..747221f --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.cs @@ -0,0 +1,108 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlant; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; + +namespace PrecastConcretePlantView +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + + } + } + LoadData(); + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponents.resx b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/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/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj deleted file mode 100644 index b57c89e..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlant.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - - - \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj new file mode 100644 index 0000000..9ebf5ea --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj @@ -0,0 +1,22 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs index aa81da8..9761986 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs @@ -1,7 +1,21 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using PrecastConcretePlantBusinessLogic.BusinessLogic; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantListImplement.Implements; +using PrecastConcretePlantListImplement; +using PrecastConcretePlantView; +using ConfectioneryBusinessLogic.BusinessLogic; + namespace PrecastConcretePlant + { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +25,32 @@ namespace PrecastConcretePlant // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + //services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); } } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs index cc7f705..4f7e77d 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ComponentLogic.cs @@ -5,7 +5,7 @@ using PrecastConcretePlantContracts.StoragesContract; using PrecastConcretePlantContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace PrecastConcretePlantBusinessLogic +namespace PrecastConcretePlantBusinessLogic.BusinessLogic { public class ComponentLogic : IComponentLogic { diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs index 786a1b9..ba445b6 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -6,9 +6,9 @@ using PrecastConcretePlantContracts.StoragesContract; using PrecastConcretePlantContracts.ViewModels; using PrecastConcretePlantDataModels.Enums; -namespace PrecastConcretePlantBusinessLogic +namespace PrecastConcretePlantBusinessLogic.BusinessLogic { - internal class OrderLogic : IOrderLogic + public class OrderLogic : IOrderLogic { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs index ae1fe4a..65224b3 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs @@ -5,7 +5,7 @@ using PrecastConcretePlantContracts.StoragesContract; using PrecastConcretePlantContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace ConfectioneryBusinessLogic.BusinessLogics +namespace ConfectioneryBusinessLogic.BusinessLogic { public class ReinforcedLogic : IReinforcedLogic { diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs new file mode 100644 index 0000000..36f2067 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Component.cs @@ -0,0 +1,42 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; + + +namespace PrecastConcretePlantListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs new file mode 100644 index 0000000..7e813e3 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/ComponentStorage.cs @@ -0,0 +1,103 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs new file mode 100644 index 0000000..64027e4 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/DataListSingleton.cs @@ -0,0 +1,26 @@ +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Reinforced { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Reinforced = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs new file mode 100644 index 0000000..e860a80 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs @@ -0,0 +1,67 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Enums; +using PrecastConcretePlantDataModels.Models; + + +namespace PrecastConcretePlantListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + + public int ReinforcedId { get; private set; } + + public int Count { get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; private set; } + + public DateTime DateCreate { get; private set; } + + public DateTime? DateImplement { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + ReinforcedId = model.ReinforcedId, + 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; + } + ReinforcedId = model.ReinforcedId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + Id = model.Id; + } + public OrderViewModel GetViewModel => new() + { + ReinforcedId = ReinforcedId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + Id = Id, + }; + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs new file mode 100644 index 0000000..9edba7e --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs @@ -0,0 +1,106 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement +{ + public class OrderStorage : IOrderStorage + { + 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 new(); + } + + 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; + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj new file mode 100644 index 0000000..3b2c1a9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/PrecastConcretePlantListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs new file mode 100644 index 0000000..e0163c5 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs @@ -0,0 +1,49 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantListImplement.Models +{ + public class Reinforced : IReinforcedModel + { + public int Id { get; private set; } + public string ReinforcedName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary ReinforcedComponents + { + get; + private set; + } = new Dictionary(); + public static Reinforced? Create(ReinforcedBindingModel? model) + { + if (model == null) + { + return null; + } + return new Reinforced() + { + Id = model.Id, + ReinforcedName = model.ReinforcedName, + Price = model.Price, + ReinforcedComponents = model.ReinforcedComponents + }; + } + public void Update(ReinforcedBindingModel? model) + { + if (model == null) + { + return; + } + ReinforcedName = model.ReinforcedName; + Price = model.Price; + ReinforcedComponents = model.ReinforcedComponents; + } + public ReinforcedViewModel GetViewModel => new() + { + Id = Id, + ReinforcedName = ReinforcedName, + Price = Price, + ReinforcedComponents = ReinforcedComponents + }; + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs new file mode 100644 index 0000000..e8356ce --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/ReinforcedStorage.cs @@ -0,0 +1,108 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.StoragesContract; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantListImplement.Models; + +namespace PrecastConcretePlantListImplement +{ + public class ReinforcedStorage : IReinforcedStorage + { + private readonly DataListSingleton _source; + public ReinforcedStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public ReinforcedViewModel? Delete(ReinforcedBindingModel model) + { + for (int i = 0; i < _source.Reinforced.Count; ++i) + { + if (_source.Reinforced[i].Id == model.Id) + { + var element = _source.Reinforced[i]; + _source.Reinforced.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + + public ReinforcedViewModel? GetElement(ReinforcedSearchModel model) + { + if (string.IsNullOrEmpty(model.ReinforcedName) && !model.Id.HasValue) + { + return null; + } + foreach (var reinforced in _source.Reinforced) + { + if ((!string.IsNullOrEmpty(model.ReinforcedName) && + reinforced.ReinforcedName == model.ReinforcedName) || + (model.Id.HasValue && reinforced.Id == model.Id)) + { + return reinforced.GetViewModel; + } + } + return null; + } + + public List GetFilteredList(ReinforcedSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ReinforcedName)) + { + return result; + } + foreach (var reinforced in _source.Reinforced) + { + if (reinforced.ReinforcedName.Contains(model.ReinforcedName ?? string.Empty)) + { + result.Add(reinforced.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var reinforced in _source.Reinforced) + { + result.Add(reinforced.GetViewModel); + } + return result; + } + + public ReinforcedViewModel? Insert(ReinforcedBindingModel model) + { + model.Id = 1; + foreach (var reinforced in _source.Reinforced) + { + if (model.Id <= reinforced.Id) + { + model.Id = reinforced.Id + 1; + } + } + var newReinforced = Reinforced.Create(model); + if (newReinforced == null) + { + return null; + } + _source.Reinforced.Add(newReinforced); + return newReinforced.GetViewModel; + } + + public ReinforcedViewModel? Update(ReinforcedBindingModel model) + { + foreach (var reinforced in _source.Reinforced) + { + if (reinforced.Id == model.Id) + { + reinforced.Update(model); + return reinforced.GetViewModel; + } + } + return null; + } + } +} -- 2.25.1 From 03d743635ac6ecb2ac33f88a0be0e8ab2efb5f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Sun, 5 Feb 2023 23:40:40 +0400 Subject: [PATCH 3/9] =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=87=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormCreateOrder.Designer.cs | 147 ++++++++++ .../PrecastConcretePlant/FormCreateOrder.cs | 117 ++++++++ .../PrecastConcretePlant/FormCreateOrder.resx | 60 ++++ .../PrecastConcretePlant/FormMain.Designer.cs | 180 ++++++++++++ .../PrecastConcretePlant/FormMain.cs | 162 +++++++++++ .../PrecastConcretePlant/FormMain.resx | 63 ++++ .../FormReinforced.Designer.cs | 271 ++++++++++++++++++ .../PrecastConcretePlant/FormReinforced.cs | 212 ++++++++++++++ .../PrecastConcretePlant/FormReinforced.resx | 69 +++++ .../FormReinforcedComponent.Designer.cs | 119 ++++++++ .../FormReinforcedComponent.cs | 79 +++++ .../FormReinforcedComponent.resx | 60 ++++ .../FormViewReinforced.Designer.cs | 120 ++++++++ .../FormViewReinforced.cs | 107 +++++++ .../FormViewReinforced.resx | 60 ++++ .../PrecastConcretePlant/Program.cs | 12 +- 16 files changed, 1832 insertions(+), 6 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormMain.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormMain.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReinforced.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReinforced.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReinforced.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.resx diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..1fce33c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.Designer.cs @@ -0,0 +1,147 @@ +namespace PrecastConcretePlantView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.textBoxCount = new System.Windows.Forms.NumericUpDown(); + this.comboBoxReinforced = 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, 68); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(214, 23); + this.textBoxSum.TabIndex = 15; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(101, 41); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(214, 23); + this.textBoxCount.TabIndex = 14; + this.textBoxCount.Click += new System.EventHandler(this.TextBoxCount_TextChanged); + // + // comboBoxReinforced + // + this.comboBoxReinforced.FormattingEnabled = true; + this.comboBoxReinforced.Location = new System.Drawing.Point(101, 12); + this.comboBoxReinforced.Name = "comboBoxReinforced"; + this.comboBoxReinforced.Size = new System.Drawing.Size(214, 23); + this.comboBoxReinforced.TabIndex = 13; + this.comboBoxReinforced.Click += new System.EventHandler(this.ComboBoxReinforced_SelectedIndexChanged); + // + // 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(190, 105); + 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.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(273, 105); + 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.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 71); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(48, 15); + this.label3.TabIndex = 10; + this.label3.Text = "Сумма:"; + // + // 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 = 9; + this.label2.Text = "Количество:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(56, 15); + this.label1.TabIndex = 8; + this.label1.Text = "Изделие:"; + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(393, 140); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxReinforced); + 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 = "FormCreateOrder"; + ((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxSum; + private NumericUpDown textBoxCount; + private ComboBox comboBoxReinforced; + private Button buttonSave; + private Button buttonCancel; + private Label label3; + private Label label2; + private Label label1; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs new file mode 100644 index 0000000..39b2bdb --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantContracts.ViewModels; + +namespace PrecastConcretePlantView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IReinforcedLogic _logicP; + private readonly IOrderLogic _logicO; + private readonly List? _list; + + public FormCreateOrder(ILogger logger, IReinforcedLogic logicP, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicO = logicO; + _list = logicP.ReadList(null); + if (_list != null) + { + comboBoxReinforced.DisplayMember = "ReinforcedName"; + comboBoxReinforced.ValueMember = "Id"; + comboBoxReinforced.DataSource = _list; + comboBoxReinforced.SelectedItem = null; + } + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); + foreach (var el in _logicP.ReadList(null) ?? new()) + { + comboBoxReinforced.Items.Add(el.ReinforcedName); + } + } + private void CalcSum() + { + if (comboBoxReinforced.SelectedValue != null && + !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxReinforced.SelectedValue); + var reinforced = _logicP.ReadElement(new ReinforcedSearchModel + { + Id = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (reinforced?.Price ?? 0), + 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ComboBoxReinforced_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxReinforced.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + ReinforcedId = Convert.ToInt32(comboBoxReinforced.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.resx b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs new file mode 100644 index 0000000..a090765 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs @@ -0,0 +1,180 @@ +namespace PrecastConcretePlantView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonFinish = new System.Windows.Forms.Button(); + this.buttonReady = 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 = new System.Windows.Forms.MenuStrip(); + this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reinforcedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.menuStrip1.SuspendLayout(); + 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(610, 294); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(147, 32); + this.buttonRef.TabIndex = 12; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonFinish + // + this.buttonFinish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonFinish.Location = new System.Drawing.Point(610, 235); + this.buttonFinish.Name = "buttonFinish"; + this.buttonFinish.Size = new System.Drawing.Size(147, 32); + this.buttonFinish.TabIndex = 11; + this.buttonFinish.Text = "Заказ выдан"; + this.buttonFinish.UseVisualStyleBackColor = true; + this.buttonFinish.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // buttonReady + // + this.buttonReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonReady.Location = new System.Drawing.Point(610, 177); + this.buttonReady.Name = "buttonReady"; + this.buttonReady.Size = new System.Drawing.Size(147, 32); + this.buttonReady.TabIndex = 10; + this.buttonReady.Text = "Заказ готов"; + this.buttonReady.UseVisualStyleBackColor = true; + this.buttonReady.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(610, 118); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 32); + this.buttonTakeOrderInWork.TabIndex = 9; + this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; + this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + // + // 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(610, 59); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(147, 32); + this.buttonCreateOrder.TabIndex = 8; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_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.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 29); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(592, 348); + this.dataGridView.TabIndex = 7; + // + // 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(786, 24); + this.menuStrip1.TabIndex = 13; + this.menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.reinforcedToolStripMenuItem, + this.componentToolStripMenuItem}); + this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.справочникиToolStripMenuItem.Text = "Справочники"; + // + // reinforcedToolStripMenuItem + // + this.reinforcedToolStripMenuItem.Name = "reinforcedToolStripMenuItem"; + this.reinforcedToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.reinforcedToolStripMenuItem.Text = "Изделия"; + this.reinforcedToolStripMenuItem.Click += new System.EventHandler(this.ReinforcedToolStripMenuItem_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); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(786, 389); + this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonFinish); + this.Controls.Add(this.buttonReady); + this.Controls.Add(this.buttonTakeOrderInWork); + this.Controls.Add(this.buttonCreateOrder); + this.Controls.Add(this.dataGridView); + this.Name = "FormMain"; + this.Text = "FormMain"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonRef; + private Button buttonFinish; + private Button buttonReady; + private Button buttonTakeOrderInWork; + private Button buttonCreateOrder; + private DataGridView dataGridView; + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem reinforcedToolStripMenuItem; + private ToolStripMenuItem componentToolStripMenuItem; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs new file mode 100644 index 0000000..f2fae29 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs @@ -0,0 +1,162 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlant; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantDataModels.Enums; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PrecastConcretePlantView +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs + e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void ReinforcedToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormViewReinforced)); + if (service is FormViewReinforced form) + { + form.ShowDialog(); + } + } + + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + OrderStatus orderStatus = (OrderStatus)dataGridView.SelectedRows[0].Cells["Status"].Value; + _logger.LogInformation("Заказ No{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id, + Status = orderStatus + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ No{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new + OrderBindingModel + { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении.Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ No{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.resx b/PrecastConcretePlant/PrecastConcretePlant/FormMain.resx new file mode 100644 index 0000000..938108a --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/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/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.Designer.cs new file mode 100644 index 0000000..bda4a1c --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.Designer.cs @@ -0,0 +1,271 @@ +namespace PrecastConcretePlantView +{ + partial class FormReinforced + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.buttonRefr = new System.Windows.Forms.Button(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonUpda = 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.buttonAdd = 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.labelPrice = new System.Windows.Forms.Label(); + this.labelName = 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(); + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(89, 40); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(120, 23); + this.textBoxPrice.TabIndex = 11; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(89, 11); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(170, 23); + this.textBoxName.TabIndex = 10; + // + // groupBox1 + // + this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.groupBox1.Controls.Add(this.buttonRefr); + this.groupBox1.Controls.Add(this.buttonDelete); + this.groupBox1.Controls.Add(this.buttonUpda); + this.groupBox1.Controls.Add(this.buttonRef); + this.groupBox1.Controls.Add(this.buttonDel); + this.groupBox1.Controls.Add(this.buttonUpd); + this.groupBox1.Controls.Add(this.buttonAdd); + this.groupBox1.Controls.Add(this.dataGridView); + this.groupBox1.Location = new System.Drawing.Point(12, 69); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.groupBox1.Size = new System.Drawing.Size(776, 330); + this.groupBox1.TabIndex = 9; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Компоненты:"; + // + // buttonRefr + // + this.buttonRefr.Location = new System.Drawing.Point(680, 220); + this.buttonRefr.Name = "buttonRefr"; + this.buttonRefr.Size = new System.Drawing.Size(90, 30); + this.buttonRefr.TabIndex = 7; + this.buttonRefr.Text = "Обновить"; + this.buttonRefr.UseVisualStyleBackColor = true; + this.buttonRefr.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(680, 165); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(90, 30); + this.buttonDelete.TabIndex = 6; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpda + // + this.buttonUpda.Location = new System.Drawing.Point(680, 110); + this.buttonUpda.Name = "buttonUpda"; + this.buttonUpda.Size = new System.Drawing.Size(90, 30); + this.buttonUpda.TabIndex = 5; + this.buttonUpda.Text = "Изменить"; + this.buttonUpda.UseVisualStyleBackColor = true; + this.buttonUpda.Click += new System.EventHandler(this.ButtonUpd_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(1256, 437); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(90, 37); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + // + // 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(1256, 388); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(90, 33); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + // + // 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(1256, 338); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(90, 34); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(680, 62); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 30); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; + 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(571, 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; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(12, 42); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(70, 15); + this.labelPrice.TabIndex = 8; + this.labelPrice.Text = "Стоимость:"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 11); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 7; + this.labelName.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(596, 405); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(90, 35); + this.buttonSave.TabIndex = 13; + 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(692, 405); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(90, 35); + this.buttonCancel.TabIndex = 12; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormReinforced + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelName); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Name = "FormReinforced"; + this.Text = "FormReinforced"; + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxPrice; + private TextBox textBoxName; + private GroupBox groupBox1; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; + private Label labelPrice; + private Label labelName; + private Button buttonSave; + private Button buttonCancel; + private Button buttonRefr; + private Button buttonDelete; + private Button buttonUpda; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.cs new file mode 100644 index 0000000..9378438 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.cs @@ -0,0 +1,212 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlant; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.SearchModels; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantView +{ + public partial class FormReinforced : Form + { + private readonly ILogger _logger; + private readonly IReinforcedLogic _logic; + private int? _id; + private Dictionary _reinforcedComponents; + public int Id { set { _id = value; } } + public FormReinforced(ILogger logger, IReinforcedLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _reinforcedComponents = new Dictionary(); + } + private void FormReinforced_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new ReinforcedSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ReinforcedName; + textBoxPrice.Text = view.Price.ToString(); + _reinforcedComponents = view.ReinforcedComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_reinforcedComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _reinforcedComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedComponent)); + if (service is FormReinforcedComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}", + form.ComponentModel.ComponentName, form.Count); + if (_reinforcedComponents.ContainsKey(form.Id)) + { + _reinforcedComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _reinforcedComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedComponent)); + if (service is FormReinforcedComponent form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _reinforcedComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", + form.ComponentModel.ComponentName, form.Count); + _reinforcedComponents[form.Id] = (form.ComponentModel, + form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента: { ComponentName}- { Count}", + dataGridView.SelectedRows[0].Cells[1].Value); + _reinforcedComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_reinforcedComponents == null || _reinforcedComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new ReinforcedBindingModel + { + Id = _id ?? 0, + ReinforcedName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + ReinforcedComponents = _reinforcedComponents + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _reinforcedComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.resx b/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.resx new file mode 100644 index 0000000..1bfa2bf --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReinforced.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.Designer.cs new file mode 100644 index 0000000..1e52690 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace PrecastConcretePlantView +{ + partial class FormReinforcedComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.labelCount = new System.Windows.Forms.Label(); + this.labelReinforced = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(132, 90); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(95, 23); + this.ButtonSave.TabIndex = 11; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(233, 90); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(104, 23); + this.ButtonCancel.TabIndex = 10; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(106, 46); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(231, 23); + this.textBoxCount.TabIndex = 9; + // + // comboBoxComponent + // + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(106, 12); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(231, 23); + this.comboBoxComponent.TabIndex = 8; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(11, 48); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(75, 15); + this.labelCount.TabIndex = 7; + this.labelCount.Text = "Количество:"; + // + // labelReinforced + // + this.labelReinforced.AutoSize = true; + this.labelReinforced.Location = new System.Drawing.Point(11, 12); + this.labelReinforced.Name = "labelReinforced"; + this.labelReinforced.Size = new System.Drawing.Size(72, 15); + this.labelReinforced.TabIndex = 6; + this.labelReinforced.Text = "Компонент:"; + // + // FormReinforcedComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(374, 134); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxComponent); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelReinforced); + this.Name = "FormReinforcedComponent"; + this.Text = "FormReinforcedComponent"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button ButtonSave; + private Button ButtonCancel; + private TextBox textBoxCount; + private ComboBox comboBoxComponent; + private Label labelCount; + private Label labelReinforced; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.cs new file mode 100644 index 0000000..2512f93 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.cs @@ -0,0 +1,79 @@ +using PrecastConcretePlantContracts.BusinessLogicsContracts; +using PrecastConcretePlantContracts.ViewModels; +using PrecastConcretePlantDataModels.Models; + +namespace PrecastConcretePlantView +{ + public partial class FormReinforcedComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set { textBoxCount.Text = value.ToString(); } + } + public FormReinforcedComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.resx b/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReinforcedComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs new file mode 100644 index 0000000..83bed6f --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs @@ -0,0 +1,120 @@ +namespace PrecastConcretePlantView +{ + partial class FormViewReinforced + { + /// + /// 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(551, 199); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(90, 37); + 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(551, 148); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(90, 33); + 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(551, 99); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(90, 34); + 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(551, 54); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(90, 30); + 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.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(516, 282); + this.dataGridView.TabIndex = 10; + // + // FormViewReinforced + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(653, 306); + 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 = "FormViewReinforced"; + this.Text = "FormViewReinforced"; + ((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/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs new file mode 100644 index 0000000..48d7799 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs @@ -0,0 +1,107 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlant; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; + +namespace PrecastConcretePlantView +{ + public partial class FormViewReinforced : Form + { + private readonly ILogger _logger; + private readonly IReinforcedLogic _logic; + public FormViewReinforced(ILogger logger, IReinforcedLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormViewReinforced_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["ReinforcedName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка изделий"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделий"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReinforced)); + if (service is FormReinforced form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(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 ReinforcedBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления изделия"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.resx b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs index 9761986..523f664 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs @@ -28,7 +28,7 @@ namespace PrecastConcretePlant var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); - Application.Run(_serviceProvider.GetRequiredService()); + Application.Run(_serviceProvider.GetRequiredService()); } private static void ConfigureServices(ServiceCollection services) @@ -44,13 +44,13 @@ namespace PrecastConcretePlant 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(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file -- 2.25.1 From ef03486ce2bb013174d6b72f7877010f601b3234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 6 Feb 2023 22:08:55 +0400 Subject: [PATCH 4/9] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrecastConcretePlant/FormMain.cs | 12 +++--------- .../OrderLogic.cs | 11 ++++++++++- .../OrderStorage.cs | 16 +++++++++++++++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs index f2fae29..4f024b5 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs @@ -3,15 +3,7 @@ using PrecastConcretePlant; using PrecastConcretePlantContracts.BindingModels; using PrecastConcretePlantContracts.BusinessLogicsContracts; using PrecastConcretePlantDataModels.Enums; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; + namespace PrecastConcretePlantView { @@ -38,6 +30,8 @@ namespace PrecastConcretePlantView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ReinforcedName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs index ba445b6..edba0bf 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -37,8 +37,12 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic } public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется); - public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан); public bool FinishOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Готов); + public bool DeliveryOrder(OrderBindingModel model) + { + model.DateImplement = DateTime.Now; + return SetOrderStatus(model, OrderStatus.Выдан); + } public List? ReadList(OrderSearchModel? model) { @@ -92,6 +96,11 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic nameof(vmodel)); } model.Status = orderStatus; + model.Status = orderStatus; + model.DateCreate = vmodel.DateCreate; + model.ReinforcedId = vmodel.ReinforcedId; + model.Sum = vmodel.Sum; + model.Count = vmodel.Count; if (_orderStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs index 9edba7e..653873e 100644 --- a/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/OrderStorage.cs @@ -66,7 +66,7 @@ namespace PrecastConcretePlantListImplement var result = new List(); foreach (var order in _source.Orders) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } return result; } @@ -102,5 +102,19 @@ namespace PrecastConcretePlantListImplement } return null; } + + private OrderViewModel GetViewModel(Order model) + { + var res = model.GetViewModel; + foreach (var pastry in _source.Reinforced) + { + if (pastry.Id == model.ReinforcedId) + { + res.ReinforcedName = pastry.ReinforcedName; + break; + } + } + return res; + } } } -- 2.25.1 From 6a3efca51159a365602d08c0cd3036a8e7193b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 6 Feb 2023 22:09:56 +0400 Subject: [PATCH 5/9] fix --- .../PrecastConcretePlantBusinessLogic/OrderLogic.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs index edba0bf..c4e598a 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -81,7 +81,6 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic private bool SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus) { - // Находим статус заказа по его айди var vmodel = _orderStorage.GetElement(new() { Id = model.Id }); if (vmodel == null) { -- 2.25.1 From f4cf5bf2bae0d343ba560c669d1cdb1c68398630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 20 Feb 2023 19:36:57 +0400 Subject: [PATCH 6/9] fix --- .../FormComponents.Designer.cs | 1 + .../PrecastConcretePlant/FormMain.Designer.cs | 20 +++++++++---------- .../PrecastConcretePlant/FormMain.cs | 6 +++--- .../FormViewReinforced.Designer.cs | 1 + .../FormViewReinforced.cs | 1 + .../OrderLogic.cs | 2 -- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs index 293e0fe..cbc6613 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormComponents.Designer.cs @@ -104,6 +104,7 @@ this.Controls.Add(this.dataGridView); this.Name = "FormComponents"; this.Text = "FormComponents"; + this.Load += new System.EventHandler(this.FormComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs index a090765..a2e34f9 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs @@ -45,7 +45,7 @@ // 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(610, 294); + this.buttonRef.Location = new System.Drawing.Point(823, 294); this.buttonRef.Name = "buttonRef"; this.buttonRef.Size = new System.Drawing.Size(147, 32); this.buttonRef.TabIndex = 12; @@ -56,7 +56,7 @@ // buttonFinish // this.buttonFinish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonFinish.Location = new System.Drawing.Point(610, 235); + this.buttonFinish.Location = new System.Drawing.Point(823, 235); this.buttonFinish.Name = "buttonFinish"; this.buttonFinish.Size = new System.Drawing.Size(147, 32); this.buttonFinish.TabIndex = 11; @@ -67,7 +67,7 @@ // buttonReady // this.buttonReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonReady.Location = new System.Drawing.Point(610, 177); + this.buttonReady.Location = new System.Drawing.Point(823, 177); this.buttonReady.Name = "buttonReady"; this.buttonReady.Size = new System.Drawing.Size(147, 32); this.buttonReady.TabIndex = 10; @@ -78,7 +78,7 @@ // 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(610, 118); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(823, 118); this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 32); this.buttonTakeOrderInWork.TabIndex = 9; @@ -89,7 +89,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(610, 59); + this.buttonCreateOrder.Location = new System.Drawing.Point(823, 59); this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Size = new System.Drawing.Size(147, 32); this.buttonCreateOrder.TabIndex = 8; @@ -106,7 +106,7 @@ this.dataGridView.Location = new System.Drawing.Point(12, 29); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(592, 348); + this.dataGridView.Size = new System.Drawing.Size(805, 348); this.dataGridView.TabIndex = 7; // // menuStrip1 @@ -115,7 +115,7 @@ this.справочникиToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(786, 24); + this.menuStrip1.Size = new System.Drawing.Size(999, 24); this.menuStrip1.TabIndex = 13; this.menuStrip1.Text = "menuStrip1"; // @@ -131,14 +131,14 @@ // reinforcedToolStripMenuItem // this.reinforcedToolStripMenuItem.Name = "reinforcedToolStripMenuItem"; - this.reinforcedToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.reinforcedToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.reinforcedToolStripMenuItem.Text = "Изделия"; this.reinforcedToolStripMenuItem.Click += new System.EventHandler(this.ReinforcedToolStripMenuItem_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); // @@ -146,7 +146,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(786, 389); + this.ClientSize = new System.Drawing.Size(999, 389); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonFinish); diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs index 4f024b5..6961b10 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs @@ -29,7 +29,8 @@ namespace PrecastConcretePlantView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["Id"].HeaderText = "Номер заказа"; + dataGridView.Columns["ReinforcedId"].Visible = false; dataGridView.Columns["ReinforcedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } @@ -105,8 +106,7 @@ namespace PrecastConcretePlantView { var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { - Id = id, - Status = orderStatus + Id = id }); if (!operationResult) { diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs index 83bed6f..7b4f17b 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.Designer.cs @@ -104,6 +104,7 @@ this.Controls.Add(this.dataGridView); this.Name = "FormViewReinforced"; this.Text = "FormViewReinforced"; + this.Load += new System.EventHandler(this.FormViewReinforced_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs index 48d7799..29a50ab 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormViewReinforced.cs @@ -28,6 +28,7 @@ namespace PrecastConcretePlantView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ReinforcedComponents"].Visible = false; dataGridView.Columns["ReinforcedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs index c4e598a..b40d4ad 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -95,8 +95,6 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic nameof(vmodel)); } model.Status = orderStatus; - model.Status = orderStatus; - model.DateCreate = vmodel.DateCreate; model.ReinforcedId = vmodel.ReinforcedId; model.Sum = vmodel.Sum; model.Count = vmodel.Count; -- 2.25.1 From f39a17c84475656f89a96b400751510b65432db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 20 Feb 2023 19:58:35 +0400 Subject: [PATCH 7/9] fix --- PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs index 39b2bdb..8d9e736 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormCreateOrder.cs @@ -31,10 +31,7 @@ namespace PrecastConcretePlantView private void FormCreateOrder_Load(object sender, EventArgs e) { _logger.LogInformation("Загрузка изделий для заказа"); - foreach (var el in _logicP.ReadList(null) ?? new()) - { - comboBoxReinforced.Items.Add(el.ReinforcedName); - } + comboBoxReinforced.DataSource = _logicP.ReadList(null) ?? new(); } private void CalcSum() { -- 2.25.1 From 5b751817583212328885e33c38c46bf856bce2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 20 Feb 2023 20:30:13 +0400 Subject: [PATCH 8/9] fix --- .../PrecastConcretePlantListImplement/Order.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs b/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs index e860a80..7f1a2f1 100644 --- a/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs +++ b/PrecastConcretePlant/PrecastConcretePlantListImplement/Order.cs @@ -45,13 +45,8 @@ namespace PrecastConcretePlantListImplement.Models { return; } - ReinforcedId = model.ReinforcedId; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; - Id = model.Id; } public OrderViewModel GetViewModel => new() { -- 2.25.1 From 8c8934c48c498ea17ae21c9f24096713cb4d83ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Tue, 21 Feb 2023 00:40:32 +0400 Subject: [PATCH 9/9] fix --- PrecastConcretePlant/PrecastConcretePlant/Program.cs | 1 - .../PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs index 523f664..d4552c1 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs @@ -7,7 +7,6 @@ using PrecastConcretePlantContracts.StoragesContract; using PrecastConcretePlantListImplement.Implements; using PrecastConcretePlantListImplement; using PrecastConcretePlantView; -using ConfectioneryBusinessLogic.BusinessLogic; namespace PrecastConcretePlant diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs index 65224b3..bbb5bae 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReinforcedLogic.cs @@ -5,7 +5,7 @@ using PrecastConcretePlantContracts.StoragesContract; using PrecastConcretePlantContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace ConfectioneryBusinessLogic.BusinessLogic +namespace PrecastConcretePlantBusinessLogic.BusinessLogic { public class ReinforcedLogic : IReinforcedLogic { -- 2.25.1