From 144782f58ac7692a12ae43455ba1cd192f22d01d Mon Sep 17 00:00:00 2001 From: sardq Date: Fri, 19 Apr 2024 18:01:42 +0400 Subject: [PATCH 1/4] =?UTF-8?q?6=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs index e68a231..0fa9508 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs @@ -37,11 +37,6 @@ namespace PlumbingRepairDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - - if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue) - { - return new(); - } using var context = new PlumbingRepairDatabase(); -- 2.25.1 From 3485fb06347c8f2069ecb49ef5f17416a2509912 Mon Sep 17 00:00:00 2001 From: sardq Date: Fri, 19 Apr 2024 18:02:08 +0400 Subject: [PATCH 2/4] =?UTF-8?q?6=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ImplementerLogic.cs | 123 +++++++++++++ .../BusinessLogics/OrderLogic.cs | 57 +++--- .../BusinessLogics/WorkModeling.cs | 146 +++++++++++++++ .../BindingModels/ImplementerBindingModel.cs | 16 ++ .../BindingModels/OrderBindingModel.cs | 1 + .../IImplementerLogic.cs | 19 ++ .../BusinessLogicsContracts/IOrderLogic.cs | 1 + .../BusinessLogicsContracts/IWorkProcess.cs | 10 + .../SearchModels/ImplementerSearchModel.cs | 11 ++ .../SearchModels/OrderSearchModel.cs | 8 +- .../StoragesContracts/IImplementerStorage.cs | 21 +++ .../ViewModels/ImplementerViewModel.cs | 20 ++ .../ViewModels/OrderViewModel.cs | 5 + .../Models/IImplementerModel.cs | 11 ++ .../Implements/ImplementerStorage.cs | 84 +++++++++ .../Implements/OrderStorage.cs | 35 +++- ... => 20240418172421_InitCreate.Designer.cs} | 47 ++++- ...Create.cs => 20240418172421_InitCreate.cs} | 32 +++- .../PlumbingRepairDatabaseModelSnapshot.cs | 43 +++++ .../Models/Implementer.cs | 76 ++++++++ .../Models/Order.cs | 9 + .../PlumbingRepairDatabase.cs | 1 + .../DataFileSingleton.cs | 5 + .../Implements/ImplementerStorage.cs | 87 +++++++++ .../Implements/OrderStorage.cs | 10 +- .../Models/Implementer.cs | 79 ++++++++ .../Models/Order.cs | 7 + .../DataListSingleton.cs | 3 + .../Implements/ImplementerStorage.cs | 108 +++++++++++ .../Implements/OrderStorage.cs | 20 ++ .../Models/Implementer.cs | 52 ++++++ .../Models/Order.cs | 4 + .../Controllers/ImplementerController.cs | 107 +++++++++++ .../PlumbingRepairRestApi/Program.cs | 2 + .../FormImplementer.Designer.cs | 173 ++++++++++++++++++ .../PlumbingRepairView/FormImplementer.cs | 104 +++++++++++ .../PlumbingRepairView/FormImplementer.resx | 60 ++++++ .../FormImplementers.Designer.cs | 127 +++++++++++++ .../PlumbingRepairView/FormImplementers.cs | 102 +++++++++++ .../PlumbingRepairView/FormImplementers.resx | 60 ++++++ .../PlumbingRepairView/FormMain.Designer.cs | 84 ++++----- PlumbingRepair/PlumbingRepairView/FormMain.cs | 91 ++++----- PlumbingRepair/PlumbingRepairView/Program.cs | 9 +- 43 files changed, 1929 insertions(+), 141 deletions(-) create mode 100644 PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/ImplementerLogic.cs create mode 100644 PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/BindingModels/ImplementerBindingModel.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IImplementerLogic.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IWorkProcess.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IImplementerStorage.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs create mode 100644 PlumbingRepair/PlumbingRepairDataModels/Models/IImplementerModel.cs create mode 100644 PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/ImplementerStorage.cs rename PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/{20240405092648_InitialCreate.Designer.cs => 20240418172421_InitCreate.Designer.cs} (82%) rename PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/{20240405092648_InitialCreate.cs => 20240418172421_InitCreate.cs} (81%) create mode 100644 PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Implementer.cs create mode 100644 PlumbingRepair/PlumbingRepairFileImplement/Implements/ImplementerStorage.cs create mode 100644 PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Implements/ImplementerStorage.cs create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Models/Implementer.cs create mode 100644 PlumbingRepair/PlumbingRepairRestApi/Controllers/ImplementerController.cs create mode 100644 PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs create mode 100644 PlumbingRepair/PlumbingRepairView/FormImplementer.cs create mode 100644 PlumbingRepair/PlumbingRepairView/FormImplementer.resx create mode 100644 PlumbingRepair/PlumbingRepairView/FormImplementers.Designer.cs create mode 100644 PlumbingRepair/PlumbingRepairView/FormImplementers.cs create mode 100644 PlumbingRepair/PlumbingRepairView/FormImplementers.resx diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/ImplementerLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/ImplementerLogic.cs new file mode 100644 index 0000000..285ea69 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/ImplementerLogic.cs @@ -0,0 +1,123 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace PlumbingRepairBusinessLogic.BusinessLogics +{ + public class ImplementerLogic : IImplementerLogic + { + private readonly ILogger _logger; + + private readonly IImplementerStorage _implementerStorage; + + public ImplementerLogic(ILogger logger, IImplementerStorage implementerStorage) + { + _logger = logger; + _implementerStorage = implementerStorage; + } + + public List? ReadList(ImplementerSearchModel? model) + { + _logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model?.ImplementerFIO, model?.Id); + var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public ImplementerViewModel? ReadElement(ImplementerSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model.ImplementerFIO, model.Id); + var element = _implementerStorage.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(ImplementerBindingModel model) + { + CheckModel(model); + if (_implementerStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(ImplementerBindingModel model) + { + CheckModel(model); + if (_implementerStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(ImplementerBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_implementerStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + private void CheckModel(ImplementerBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + throw new ArgumentNullException("Нет ФИО клиента", nameof(model.ImplementerFIO)); + } + if (string.IsNullOrEmpty(model.Password)) + { + throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password)); + } + if (model.Qualification <= 0) + { + throw new ArgumentNullException("Квалификация должна быть больше 0", nameof(model.Qualification)); + } + if (model.WorkExperience <= 0) + { + throw new ArgumentNullException("Стаж работы должен быть больше 0", nameof(model.WorkExperience)); + } + _logger.LogInformation("Component. ImplementerFIO:{ImplementerFIO}.Password:{Password}.Qualification:{Qualification}.WorkExperience:{WorkExperience}.", model.ImplementerFIO, model.Password, model.Qualification, model.WorkExperience); + var element = _implementerStorage.GetElement(new ImplementerSearchModel + { + ImplementerFIO = model.ImplementerFIO + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Клиент с таким ФИО уже есть"); + } + } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs index 5e0ba7e..ceaf4eb 100644 --- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs @@ -5,6 +5,7 @@ using PlumbingRepairContracts.ViewModels; using PlumbingRepairContracts.StoragesContracts; using PlumbingRepairDataModels.Enums; using Microsoft.Extensions.Logging; +using System.Xml.Linq; namespace PlumbingRepairBusinessLogic.BusinessLogics @@ -14,11 +15,30 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; + private readonly object _locker =new(); + public OrderLogic(ILogger logger, IOrderStorage orderStorage) { _logger = logger; _orderStorage = orderStorage; } + + public OrderViewModel? ReadElement(OrderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. DateFrom:{DateFrom}.DateTo:{DateTo}. Id:{Id}", model.DateFrom, model.DateTo, model.Id); + var element = _orderStorage.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 CreateOrder(OrderBindingModel model) { CheckModel(model); @@ -61,39 +81,28 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics public bool TakeOrderInWork(OrderBindingModel model) { - return ChangeStatus(model, OrderStatus.Выполняется); + lock (_locker) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } } public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus) { + CheckModel(model, false); var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); if (viewModel == null) { - throw new ArgumentNullException(nameof(model)); - } - if (viewModel.Status + 1 != newStatus) - { - _logger.LogWarning("Change status operation failed"); + _logger.LogWarning("Find order failed"); return false; } + if (viewModel.Status != newStatus - 1) + { + _logger.LogWarning("Status change failed"); + throw new InvalidOperationException("Невозможно перевести состояние заказа"); + } model.Status = newStatus; - model.WorkId = viewModel.WorkId; - model.Count = viewModel.Count; - model.Sum = viewModel.Sum; - model.DateCreate = viewModel.DateCreate; - if (model.Status == OrderStatus.Готов) - { - model.DateImplement = DateTime.Now; - } - else - { - model.DateImplement = viewModel.DateImplement; - } - CheckModel(model, false); - if (_orderStorage.Update(model) == null) - { - _logger.LogWarning("Change status operation failed"); - return false; - } + if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; + _orderStorage.Update(model); return true; } private void CheckModel(OrderBindingModel model, bool withParams = true) diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs new file mode 100644 index 0000000..c7d1998 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs @@ -0,0 +1,146 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.ViewModels; + +using Microsoft.Extensions.Logging; +using PlumbingRepairDataModels.Enums; + +namespace PlumbingRepairBusinessLogic.BusinessLogics +{ + public class WorkModeling : IWorkProcess + { + private readonly ILogger _logger; + + private readonly Random _rnd; + + private IOrderLogic? _orderLogic; + + public WorkModeling(ILogger logger) + { + _logger = logger; + _rnd = new Random(1000); + } + + public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) + { + _orderLogic = orderLogic; + var implementers = implementerLogic.ReadList(null); + if (implementers == null) + { + _logger.LogWarning("DoWork. Implementers is null"); + return; + } + var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят }); + if (orders == null || orders.Count == 0) + { + _logger.LogWarning("DoWork. Orders is null or empty"); + return; + } + _logger.LogDebug("DoWork for {Count} orders", orders.Count); + foreach (var implementer in implementers) + { + Task.Run(() => WorkerWorkAsync(implementer, orders)); + } + } + + /// + /// Иммитация работы исполнителя + /// + /// + /// + private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) + { + if (_orderLogic == null || implementer == null) + { + return; + } + await RunOrderInWork(implementer); + + await Task.Run(() => + { + foreach (var order in orders) + { + try + { + _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); + // пытаемся назначить заказ на исполнителя + _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = order.Id, + ImplementerId = implementer.Id + }); + // делаем работу + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); + _orderLogic.FinishOrder(new OrderBindingModel + { + Id = order.Id + }); + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + // кто-то мог уже перехватить заказ, игнорируем ошибку + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + // заканчиваем выполнение имитации в случае иной ошибки + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + + } + }); + } + + /// + /// Ищем заказ, которые уже в работе (вдруг исполнителя прервали) + /// + /// + /// + private async Task RunOrderInWork(ImplementerViewModel implementer) + { + if (_orderLogic == null || implementer == null) + { + return; + } + try + { + var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel + { + ImplementerId = implementer.Id, + Status = OrderStatus.Выполняется + })); + if (runOrder == null) + { + return; + } + + _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); + // доделываем работу + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); + _orderLogic.FinishOrder(new OrderBindingModel + { + Id = runOrder.Id + }); + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + // заказа может не быть, просто игнорируем ошибку + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/ImplementerBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..d65d926 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,16 @@ +using PlumbingRepairDataModels.Models; + +namespace PlumbingRepairContracts.BindingModels +{ + public class ImplementerBindingModel : IImplementerModel + { + public int Id { get; set; } + + public string ImplementerFIO { get; set; } = string.Empty; + + public string Password { get; set; } = string.Empty; + + public int WorkExperience { get; set; } + public int Qualification { get; set; } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs index eeed65d..8ee10bd 100644 --- a/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/OrderBindingModel.cs @@ -10,6 +10,7 @@ namespace PlumbingRepairContracts.BindingModels public int WorkId { get; set; } public int ClientId { get; set; } + public int? ImplementerId { get; set; } public int Count { get; set; } diff --git a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IImplementerLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IImplementerLogic.cs new file mode 100644 index 0000000..91b9efb --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -0,0 +1,19 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.ViewModels; + +namespace PlumbingRepairContracts.BusinessLogicsContracts +{ + public interface IImplementerLogic + { + List? ReadList(ImplementerSearchModel? model); + + ImplementerViewModel? ReadElement(ImplementerSearchModel model); + + bool Create(ImplementerBindingModel model); + + bool Update(ImplementerBindingModel model); + + bool Delete(ImplementerBindingModel model); + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IOrderLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IOrderLogic.cs index 3588a21..8aba92b 100644 --- a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -7,6 +7,7 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts public interface IOrderLogic { List? ReadList(OrderSearchModel? model); + OrderViewModel? ReadElement(OrderSearchModel model); bool CreateOrder(OrderBindingModel model); diff --git a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IWorkProcess.cs b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IWorkProcess.cs new file mode 100644 index 0000000..7ab6246 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IWorkProcess.cs @@ -0,0 +1,10 @@ +namespace PlumbingRepairContracts.BusinessLogicsContracts +{ + public interface IWorkProcess + { + /// + /// Запуск работ + /// + void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic); + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel.cs b/PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel.cs new file mode 100644 index 0000000..5fdb263 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel.cs @@ -0,0 +1,11 @@ +namespace PlumbingRepairContracts.SearchModels +{ + public class ImplementerSearchModel + { + public int? Id { get; set; } + + public string? ImplementerFIO { get; set; } + + public string? Password { get; set; } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs b/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs index ae2ee14..2b4ffc9 100644 --- a/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/SearchModels/OrderSearchModel.cs @@ -1,10 +1,14 @@ -namespace PlumbingRepairContracts.SearchModels +using PlumbingRepairDataModels.Enums; + +namespace PlumbingRepairContracts.SearchModels { public class OrderSearchModel { public int? Id { get; set; } public int? ClientId { get; set; } + public int? ImplementerId { get; set; } public DateTime? DateFrom { get; set; } - public DateTime? DateTo { get; set; } + public DateTime? DateTo { get; set;} + public OrderStatus? Status { get; set; } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IImplementerStorage.cs b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IImplementerStorage.cs new file mode 100644 index 0000000..d71ec16 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IImplementerStorage.cs @@ -0,0 +1,21 @@ +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.SearchModels; + +namespace PlumbingRepairContracts.StoragesContracts +{ + public interface IImplementerStorage + { + List GetFullList(); + + List GetFilteredList(ImplementerSearchModel model); + + ImplementerViewModel? GetElement(ImplementerSearchModel model); + + ImplementerViewModel? Insert(ImplementerBindingModel model); + + ImplementerViewModel? Update(ImplementerBindingModel model); + + ImplementerViewModel? Delete(ImplementerBindingModel model); + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..dc637e1 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,20 @@ +using PlumbingRepairDataModels.Models; +using System.ComponentModel; + +namespace PlumbingRepairContracts.ViewModels +{ + public class ImplementerViewModel : IImplementerModel + { + public int Id { get; set; } + + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; } = string.Empty; + + [DisplayName("Пароль")] + public string Password { get; set; } = string.Empty; + [DisplayName("Стаж работы")] + public int WorkExperience { get; set; } + [DisplayName("Квалификация")] + public int Qualification { get; set; } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs index 214ebb9..608ac98 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs @@ -17,6 +17,11 @@ namespace PlumbingRepairContracts.ViewModels [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } = string.Empty; + [DisplayName("Исполнитель")] + public int? ImplementerId { get; set; } + [DisplayName("ФИО исполнителя")] + public string? ImplementerFIO { get; set; } = string.Empty; + [DisplayName("Количество")] public int Count { get; set; } diff --git a/PlumbingRepair/PlumbingRepairDataModels/Models/IImplementerModel.cs b/PlumbingRepair/PlumbingRepairDataModels/Models/IImplementerModel.cs new file mode 100644 index 0000000..d86c2a6 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairDataModels/Models/IImplementerModel.cs @@ -0,0 +1,11 @@ + +namespace PlumbingRepairDataModels.Models +{ + public interface IImplementerModel : IId + { + string ImplementerFIO { get; } + string Password { get; } + int WorkExperience { get; } + int Qualification { get; } + } +} diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/ImplementerStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..8129314 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,84 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairDatabaseImplement.Models; + +namespace PlumbingRepairDatabaseImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + public List GetFullList() + { + using var context = new PlumbingRepairDatabase(); + return context.Implementers + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + return new(); + } + using var context = new PlumbingRepairDatabase(); + return context.Implementers + .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue) + { + return null; + } + using var context = new PlumbingRepairDatabase(); + return context.Implementers + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + var newImplementer = Implementer.Create(model); + if (newImplementer == null) + { + return null; + } + using var context = new PlumbingRepairDatabase(); + context.Implementers.Add(newImplementer); + context.SaveChanges(); + return newImplementer.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + using var context = new PlumbingRepairDatabase(); + var component = context.Implementers.FirstOrDefault(x => x.Id == model.Id); + if (component == null) + { + return null; + } + component.Update(model); + context.SaveChanges(); + return component.GetViewModel; + } + + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + using var context = new PlumbingRepairDatabase(); + var element = context.Implementers.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Implementers.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs index 0fa9508..77e871e 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs @@ -29,10 +29,17 @@ namespace PlumbingRepairDatabaseImplement.Implements return null; } using var context = new PlumbingRepairDatabase(); - return AttachNames(context.Orders + if (model.Id.HasValue) + return AttachNames(context.Orders .Include(x => x.Work) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel); + else if (model.ImplementerId.HasValue && model.Status.HasValue) + return AttachNames(context.Orders + .Include(x => x.Implementer) + .FirstOrDefault(x => model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) + ?.GetViewModel); + return null; } public List GetFilteredList(OrderSearchModel model) @@ -46,18 +53,27 @@ namespace PlumbingRepairDatabaseImplement.Implements .Where(x => x.Id == model.Id) .Select(x => AttachNames(x.GetViewModel)).ToList(); } - if (model.ClientId.HasValue) + if (model.Status.HasValue) + { + return context.Orders + .Where(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status) + .Select(x => AttachNames(x.GetViewModel)).ToList(); + } + if (model.ClientId.HasValue) { return context.Orders .Include(x => x.Client). Where(x => x.ClientId == model.ClientId) .Select(x =>AttachNames(x.GetViewModel)).ToList(); } - - return context.Orders. + if (model.DateFrom != null && model.DateTo != null) + { + return context.Orders. Include(x => x.Work) .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) - .Select(x =>AttachNames(x.GetViewModel)).ToList(); + .Select(x => AttachNames(x.GetViewModel)).ToList(); + } + return new(); } @@ -66,6 +82,7 @@ namespace PlumbingRepairDatabaseImplement.Implements using var context = new PlumbingRepairDatabase(); return context.Orders .Include(x => x.Work) + .Include(x => x.Implementer) .Select(x =>AttachNames(x.GetViewModel)) .ToList(); } @@ -119,6 +136,14 @@ namespace PlumbingRepairDatabaseImplement.Implements return model; } } + foreach (var implementer in context.Implementers) + { + if (implementer.Id == model.ImplementerId) + { + model.ImplementerFIO = implementer.ImplementerFIO; + return model; + } + } return model; } } diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240405092648_InitialCreate.Designer.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs similarity index 82% rename from PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240405092648_InitialCreate.Designer.cs rename to PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs index d248b98..aae50bc 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240405092648_InitialCreate.Designer.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs @@ -12,8 +12,8 @@ using PlumbingRepairDatabaseImplement; namespace PlumbingRepairDatabaseImplement.Migrations { [DbContext(typeof(PlumbingRepairDatabase))] - [Migration("20240405092648_InitialCreate")] - partial class InitialCreate + [Migration("20240418172421_InitCreate")] + partial class InitCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -69,6 +69,33 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -89,6 +116,9 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("Status") .HasColumnType("int"); @@ -102,6 +132,8 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("WorkId"); b.ToTable("Orders"); @@ -161,6 +193,10 @@ namespace PlumbingRepairDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PlumbingRepairDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work") .WithMany("Orders") .HasForeignKey("WorkId") @@ -169,6 +205,8 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Work"); }); @@ -201,6 +239,11 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Navigation("WorkComponents"); }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => { b.Navigation("Components"); diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240405092648_InitialCreate.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs similarity index 81% rename from PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240405092648_InitialCreate.cs rename to PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs index 89e4757..caa8136 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240405092648_InitialCreate.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace PlumbingRepairDatabaseImplement.Migrations { - public partial class InitialCreate : Migration + public partial class InitCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -38,6 +38,22 @@ namespace PlumbingRepairDatabaseImplement.Migrations table.PrimaryKey("PK_Components", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false), + Qualification = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Works", columns: table => new @@ -60,6 +76,7 @@ namespace PlumbingRepairDatabaseImplement.Migrations .Annotation("SqlServer:Identity", "1, 1"), WorkId = table.Column(type: "int", nullable: false), ClientId = table.Column(type: "int", nullable: false), + ImplementerId = table.Column(type: "int", nullable: true), Count = table.Column(type: "int", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), @@ -75,6 +92,11 @@ namespace PlumbingRepairDatabaseImplement.Migrations principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + column: x => x.ImplementerId, + principalTable: "Implementers", + principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Works_WorkId", column: x => x.WorkId, @@ -115,6 +137,11 @@ namespace PlumbingRepairDatabaseImplement.Migrations table: "Orders", column: "ClientId"); + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + migrationBuilder.CreateIndex( name: "IX_Orders_WorkId", table: "Orders", @@ -142,6 +169,9 @@ namespace PlumbingRepairDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Clients"); + migrationBuilder.DropTable( + name: "Implementers"); + migrationBuilder.DropTable( name: "Components"); diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs index 02e604b..8137aac 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs @@ -67,6 +67,33 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -87,6 +114,9 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("Status") .HasColumnType("int"); @@ -100,6 +130,8 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("WorkId"); b.ToTable("Orders"); @@ -159,6 +191,10 @@ namespace PlumbingRepairDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PlumbingRepairDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work") .WithMany("Orders") .HasForeignKey("WorkId") @@ -167,6 +203,8 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Work"); }); @@ -199,6 +237,11 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Navigation("WorkComponents"); }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => { b.Navigation("Components"); diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Implementer.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Implementer.cs new file mode 100644 index 0000000..ea0fb22 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Implementer.cs @@ -0,0 +1,76 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace PlumbingRepairDatabaseImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + + [Required] + public string ImplementerFIO { get; private set; } = string.Empty; + [Required] + public string Password { get; private set; } = string.Empty; + + [Required] + public int WorkExperience { get; private set; } + + [Required] + public int Qualification { get; private set; } + + [ForeignKey("ImplementerId")] + public virtual List Orders{ get; set; } = new(); + + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + return new Implementer() + { + Id = model.Id, + ImplementerFIO = model.ImplementerFIO, + Password = model.Password, + WorkExperience = model.WorkExperience, + Qualification = model.Qualification, + }; + } + + public static Implementer Create(ImplementerViewModel model) + { + return new Implementer + { + Id = model.Id, + ImplementerFIO = model.ImplementerFIO, + Password = model.Password, + WorkExperience = model.WorkExperience, + Qualification = model.Qualification, + }; + } + + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + ImplementerFIO = model.ImplementerFIO; + Password = model.Password; + WorkExperience = model.WorkExperience; + Qualification = model.Qualification; + } + + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + ImplementerFIO = ImplementerFIO, + Password = Password, + WorkExperience = WorkExperience, + Qualification= Qualification, + }; + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Order.cs index e699921..b3396dd 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Order.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/Order.cs @@ -12,6 +12,7 @@ namespace PlumbingRepairDatabaseImplement.Models public int WorkId { get; set; } [Required] public int ClientId { get; set; } + public int? ImplementerId { get; set; } [Required] public int Count { get; set; } @@ -28,6 +29,7 @@ namespace PlumbingRepairDatabaseImplement.Models public virtual Work Work { get; set; } public virtual Client Client { get; set; } + public virtual Implementer? Implementer { get; set; } public static Order? Create( OrderBindingModel? model) { @@ -38,6 +40,7 @@ namespace PlumbingRepairDatabaseImplement.Models Id = model.Id, WorkId = model.WorkId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -52,12 +55,18 @@ namespace PlumbingRepairDatabaseImplement.Models return; Status = model.Status; DateImplement = model.DateImplement; + if (model.ImplementerId.HasValue) + { + ImplementerId = model.ImplementerId; + } } public OrderViewModel GetViewModel => new() { WorkId = WorkId, ClientId = ClientId, + ImplementerId= ImplementerId, + ImplementerFIO = Implementer == null ? null : Implementer.ImplementerFIO, Count = Count, Sum = Sum, DateCreate = DateCreate, diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/PlumbingRepairDatabase.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/PlumbingRepairDatabase.cs index c65941b..e795c7c 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/PlumbingRepairDatabase.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/PlumbingRepairDatabase.cs @@ -22,5 +22,6 @@ namespace PlumbingRepairDatabaseImplement public virtual DbSet Orders { set; get; } public virtual DbSet Clients { set; get; } + public virtual DbSet Implementers { set; get; } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairFileImplement/DataFileSingleton.cs b/PlumbingRepair/PlumbingRepairFileImplement/DataFileSingleton.cs index 81ae522..6245027 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/DataFileSingleton.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/DataFileSingleton.cs @@ -13,12 +13,14 @@ namespace PlumbingRepairFileImplement private readonly string WorkFileName = "Work.xml"; private readonly string ClientFileName = "Client.xml"; + private readonly string ImplementerFileName = "Implementer.xml"; public List Components { get; private set; } public List Orders { get; private set; } public List Works { get; private set; } public List Clients { get; private set; } + public List Implementers { get; private set; } public static DataFileSingleton GetInstance() { if (instance == null) @@ -35,12 +37,15 @@ namespace PlumbingRepairFileImplement public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); + public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement); private DataFileSingleton() { Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; Works = LoadData(WorkFileName, "Work", x => Work.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; + Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!; + } private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Implements/ImplementerStorage.cs b/PlumbingRepair/PlumbingRepairFileImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..d3c8601 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairFileImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,87 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairFileImplement.Models; +using System.Net; + +namespace PlumbingRepairFileImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + private readonly DataFileSingleton source; + + public ImplementerStorage() + { + source = DataFileSingleton.GetInstance(); + } + + public List GetFullList() + { + return source.Implementers + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + return new(); + } + return source.Implementers + .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue) + { + return null; + } + return source.Implementers + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x => x.Id) + 1 : 1; + var newImplementer = Implementer.Create(model); + if (newImplementer == null) + { + return null; + } + source.Implementers.Add(newImplementer); + source.SaveImplementers(); + return newImplementer.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + var client = source.Implementers.FirstOrDefault(x => x.Id == model.Id); + if (client == null) + { + return null; + } + client.Update(model); + source.SaveImplementers(); + return client.GetViewModel; + } + + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + var element = source.Implementers.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + source.Implementers.Remove(element); + source.SaveImplementers(); + return element.GetViewModel; + } + return null; + } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairFileImplement/Implements/OrderStorage.cs index d437bc7..1c0bbf6 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Implements/OrderStorage.cs @@ -31,7 +31,11 @@ namespace PlumbingRepairFileImplement.Implements { return null; } - return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)); + if (model.ImplementerId.HasValue && model.Status.HasValue) + return GetViewModel(source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)); + if (model.Id.HasValue) + return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)); + return null; } @@ -47,8 +51,11 @@ namespace PlumbingRepairFileImplement.Implements .ToList(); if (model.ClientId.HasValue) return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => GetViewModel(x)).ToList(); + if (model.ImplementerId.HasValue && model.Status.HasValue) + return source.Orders.Where(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status).Select(x => GetViewModel(x)).ToList(); return source.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo). Select(x => GetViewModel(x)).ToList(); + } public List GetFullList() @@ -92,6 +99,7 @@ namespace PlumbingRepairFileImplement.Implements { viewModel.WorkName = work.WorkName; } + return viewModel; } } diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs new file mode 100644 index 0000000..6bff04e --- /dev/null +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs @@ -0,0 +1,79 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairDataModels.Models; +using System.Xml.Linq; + +namespace PlumbingRepairFileImplement.Models +{ + internal class Implementer : IImplementerModel + { + public int Id { get; private set; } + public string ImplementerFIO { get; private set; } = string.Empty; + + public string Password { get; private set; } = string.Empty; + public int Qualification { get; private set; } + public int WorkExperience { get; private set; } + + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + return new Implementer() + { + Id = model.Id, + ImplementerFIO = model.ImplementerFIO, + Password = model.Password, + Qualification = model.Qualification, + WorkExperience = model.WorkExperience, + }; + } + + public static Implementer? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Implementer() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + ImplementerFIO = element.Element("ImplementerFIO")!.Value, + Password = Convert.ToString(element.Element("Password")!.Value), + Qualification = Convert.ToInt32(element.Attribute("Qualification")!.Value), + WorkExperience = Convert.ToInt32(element.Attribute("WorkExperience")!.Value), + }; + } + + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + ImplementerFIO = model.ImplementerFIO; + Password = model.Password; + Qualification = model.Qualification; + WorkExperience = model.WorkExperience; + } + + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + ImplementerFIO = ImplementerFIO, + Password = Password, + Qualification = Qualification, + WorkExperience = WorkExperience + }; + + public XElement GetXElement => new("Implementer", + new XAttribute("Id", Id), + new XElement("ImplementerFIO", ImplementerFIO), + new XElement("Password", Password), + new XElement("Qualification", Qualification), + new XElement("WorkExperience", WorkExperience) + + ); + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs index 7e68eb8..c0c5d63 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs @@ -11,6 +11,7 @@ namespace PlumbingRepairFileImplement.Models { public int WorkId { get; private set; } public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } public int Count { get; private set; } @@ -33,6 +34,8 @@ namespace PlumbingRepairFileImplement.Models return new Order() { WorkId = model.WorkId, + ClientId= model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -52,6 +55,8 @@ namespace PlumbingRepairFileImplement.Models { Id = Convert.ToInt32(element.Attribute("Id")!.Value), WorkId = Convert.ToInt32(element.Element("WorkId")!.Value), + ClientId = Convert.ToInt32(element.Element("ClientId")!.Value), + ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), @@ -85,6 +90,8 @@ namespace PlumbingRepairFileImplement.Models "Order", new XAttribute("Id", Id), new XElement("WorkId", WorkId.ToString()), + new XElement("ClientId", ClientId.ToString()), + new XElement("ImplementerId", ImplementerId.ToString()), new XElement("Count", Count.ToString()), new XElement("Sum", Sum.ToString()), new XElement("Status", Status.ToString()), diff --git a/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs b/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs index 92fbd38..73b1281 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs +++ b/PlumbingRepair/PlumbingRepairListImplement/DataListSingleton.cs @@ -12,6 +12,8 @@ namespace PlumbingRepairListImplement public List Works { get; set; } public List Clients { get; set; } + public List Implementers { get; set; } + private DataListSingleton() { @@ -19,6 +21,7 @@ namespace PlumbingRepairListImplement Orders = new List(); Works = new List(); Clients = new List(); + Implementers = new List(); } public static DataListSingleton GetInstance() diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/ImplementerStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..df9f020 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,108 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairListImplement.Models; + +namespace PlumbingRepairListImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + private readonly DataListSingleton _source; + + public ImplementerStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + foreach (var client in _source.Implementers) + { + result.Add(client.GetViewModel); + } + return result; + } + + public List GetFilteredList(ImplementerSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + return result; + } + foreach (var client in _source.Implementers) + { + if (client.ImplementerFIO.Contains(model.ImplementerFIO)) + { + result.Add(client.GetViewModel); + } + } + return result; + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue) + { + return null; + } + foreach (var client in _source.Implementers) + { + if ((!string.IsNullOrEmpty(model.ImplementerFIO) && client.ImplementerFIO == model.ImplementerFIO) || + (model.Id.HasValue && client.Id == model.Id)) + { + return client.GetViewModel; + } + } + return null; + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = 1; + foreach (var client in _source.Implementers) + { + if (model.Id <= client.Id) + { + model.Id = client.Id + 1; + } + } + var newImplementer = Implementer.Create(model); + if (newImplementer == null) + { + return null; + } + _source.Implementers.Add(newImplementer); + return newImplementer.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + foreach (var Implementer in _source.Implementers) + { + if (Implementer.Id == model.Id) + { + Implementer.Update(model); + return Implementer.GetViewModel; + } + } + return null; + } + + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + for (int i = 0; i < _source.Implementers.Count; ++i) + { + if (_source.Implementers[i].Id == model.Id) + { + var element = _source.Implementers[i]; + _source.Implementers.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs index e96335a..ca61c94 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/OrderStorage.cs @@ -41,6 +41,26 @@ namespace PlumbingRepairListImplement.Implements return AttachInfo(order.GetViewModel); } } + if (model.Id.HasValue) + { + foreach (var Order in _source.Orders) + { + if (Order.Id == model.Id) + { + return Order.GetViewModel; + } + } + } + else if (model.ImplementerId.HasValue && model.Status.HasValue) + { + foreach (var Order in _source.Orders) + { + if (Order.ImplementerId == model.ImplementerId && Order.Status == model.Status) + { + return Order.GetViewModel; + } + } + } return null; } diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Implementer.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Implementer.cs new file mode 100644 index 0000000..1c3dd9e --- /dev/null +++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Implementer.cs @@ -0,0 +1,52 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.ViewModels; +using PlumbingRepairDataModels.Models; + +namespace PlumbingRepairListImplement.Models +{ + internal class Implementer : IImplementerModel + { + public int Id { get; private set; } + + public string ImplementerFIO { get; private set; } = string.Empty; + public string Password { get; private set; } = string.Empty; + public int Qualification { get; private set; } + public int WorkExperience { get; private set; } + public static Implementer? Create(ImplementerBindingModel? model) + { + if (model == null) + { + return null; + } + return new Implementer() + { + Id = model.Id, + ImplementerFIO = model.ImplementerFIO, + Password = model.Password, + Qualification = model.Qualification, + WorkExperience = model.WorkExperience, + }; + } + + public void Update(ImplementerBindingModel? model) + { + if (model == null) + { + return; + } + ImplementerFIO = model.ImplementerFIO; + Password = model.Password; + Qualification = model.Qualification; + WorkExperience = model.WorkExperience; + } + + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + ImplementerFIO = ImplementerFIO, + Password = Password, + Qualification = Qualification, + WorkExperience = WorkExperience, + }; + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs index 68ce6f6..a4d3af6 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs +++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Order.cs @@ -9,6 +9,7 @@ namespace PlumbingRepairListImplement.Models { public int WorkId { get; private set; } public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } public int Count { get; private set; } @@ -33,6 +34,7 @@ namespace PlumbingRepairListImplement.Models Id = model.Id, WorkId = model.WorkId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -50,6 +52,7 @@ namespace PlumbingRepairListImplement.Models } Status = model.Status; DateImplement= model.DateImplement; + ImplementerId= model.ImplementerId; } public OrderViewModel GetViewModel => new() @@ -58,6 +61,7 @@ namespace PlumbingRepairListImplement.Models WorkId = WorkId, Count = Count, ClientId= ClientId, + ImplementerId = ImplementerId, Sum = Sum, Status = Status, DateCreate = DateCreate, diff --git a/PlumbingRepair/PlumbingRepairRestApi/Controllers/ImplementerController.cs b/PlumbingRepair/PlumbingRepairRestApi/Controllers/ImplementerController.cs new file mode 100644 index 0000000..07a222b --- /dev/null +++ b/PlumbingRepair/PlumbingRepairRestApi/Controllers/ImplementerController.cs @@ -0,0 +1,107 @@ +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; +using PlumbingRepairDataModels.Enums; + +namespace PlumbingRepairRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ImplementerController : Controller + { + private readonly ILogger _logger; + + private readonly IOrderLogic _order; + + private readonly IImplementerLogic _logic; + + public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger logger) + { + _logger = logger; + _order = order; + _logic = logic; + } + + [HttpGet] + public ImplementerViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new ImplementerSearchModel + { + ImplementerFIO = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка авторизации сотрудника"); + throw; + } + } + + [HttpGet] + public List? GetNewOrders() + { + try + { + return _order.ReadList(new OrderSearchModel + { + Status = OrderStatus.Принят + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения новых заказов"); + throw; + } + } + + [HttpGet] + public OrderViewModel? GetImplementerOrder(int implementerId) + { + try + { + return _order.ReadElement(new OrderSearchModel + { + ImplementerId = implementerId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения текущего заказа исполнителя"); + throw; + } + } + + [HttpPost] + public void TakeOrderInWork(OrderBindingModel model) + { + try + { + _order.TakeOrderInWork(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", model.Id); + throw; + } + } + + [HttpPost] + public void FinishOrder(OrderBindingModel model) + { + try + { + _order.FinishOrder(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа с №{Id}", model.Id); + throw; + } + } + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairRestApi/Program.cs b/PlumbingRepair/PlumbingRepairRestApi/Program.cs index 96a8558..fa05907 100644 --- a/PlumbingRepair/PlumbingRepairRestApi/Program.cs +++ b/PlumbingRepair/PlumbingRepairRestApi/Program.cs @@ -13,10 +13,12 @@ builder.Logging.AddLog4Net("log4net.config"); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs new file mode 100644 index 0000000..9f8c11e --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs @@ -0,0 +1,173 @@ +namespace PlumbingRepairView +{ + partial class FormImplementer + { + /// + /// 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.textBoxPassword = new System.Windows.Forms.TextBox(); + this.labelCost = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelName = new System.Windows.Forms.Label(); + this.textBoxWorkExperience = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.textBoxQualification = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // textBoxPassword + // + this.textBoxPassword.Location = new System.Drawing.Point(138, 74); + this.textBoxPassword.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.textBoxPassword.Name = "textBoxPassword"; + this.textBoxPassword.Size = new System.Drawing.Size(334, 31); + this.textBoxPassword.TabIndex = 15; + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(4, 80); + this.labelCost.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(78, 25); + this.labelCost.TabIndex = 14; + this.labelCost.Text = "Пароль:"; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(346, 221); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 45); + this.buttonCancel.TabIndex = 17; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(210, 221); + this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 45); + this.buttonSave.TabIndex = 16; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(138, 26); + this.textBoxName.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(334, 31); + this.textBoxName.TabIndex = 13; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(4, 32); + this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(56, 25); + this.labelName.TabIndex = 12; + this.labelName.Text = "ФИО:"; + // + // textBoxWorkExperience + // + this.textBoxWorkExperience.Location = new System.Drawing.Point(138, 124); + this.textBoxWorkExperience.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.textBoxWorkExperience.Name = "textBoxWorkExperience"; + this.textBoxWorkExperience.Size = new System.Drawing.Size(183, 31); + this.textBoxWorkExperience.TabIndex = 19; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(4, 130); + this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(122, 25); + this.label1.TabIndex = 18; + this.label1.Text = "Стаж работы:"; + // + // textBoxQualification + // + this.textBoxQualification.Location = new System.Drawing.Point(138, 171); + this.textBoxQualification.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.textBoxQualification.Name = "textBoxQualification"; + this.textBoxQualification.Size = new System.Drawing.Size(183, 31); + this.textBoxQualification.TabIndex = 21; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 171); + this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(134, 25); + this.label2.TabIndex = 20; + this.label2.Text = "Квалификация:"; + // + // FormImplementer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(485, 281); + this.Controls.Add(this.textBoxQualification); + this.Controls.Add(this.label2); + this.Controls.Add(this.textBoxWorkExperience); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxPassword); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormImplementer"; + this.Text = "Исполнитель"; + this.Load += new System.EventHandler(this.FormImplementer_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxPassword; + private Label labelCost; + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxName; + private Label labelName; + private TextBox textBoxWorkExperience; + private Label label1; + private TextBox textBoxQualification; + private Label label2; + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormImplementer.cs b/PlumbingRepair/PlumbingRepairView/FormImplementer.cs new file mode 100644 index 0000000..292685a --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormImplementer.cs @@ -0,0 +1,104 @@ +using Microsoft.Extensions.Logging; +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.SearchModels; + +namespace PlumbingRepairView +{ + public partial class FormImplementer : Form + { + private readonly ILogger _logger; + + private readonly IImplementerLogic _logic; + + private int? _id; + + public int Id { set { _id = value; } } + + public FormImplementer(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormImplementer_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение исполнителя"); + var view = _logic.ReadElement(new ImplementerSearchModel { Id = _id.Value }); + if (view != null) + { + textBoxName.Text = view.ImplementerFIO; + textBoxPassword.Text = view.Password; + textBoxQualification.Text = view.Qualification.ToString(); + textBoxWorkExperience.Text = view.WorkExperience.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; + } + if (string.IsNullOrEmpty(textBoxPassword.Text)) + { + MessageBox.Show("Заполните ФИО исполнителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxQualification.Text)) + { + MessageBox.Show("Заполните ФИО исполнителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxWorkExperience.Text)) + { + MessageBox.Show("Заполните ФИО исполнителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение исполнителя"); + try + { + var model = new ImplementerBindingModel + { + Id = _id ?? 0, + ImplementerFIO = textBoxName.Text, + Password= textBoxPassword.Text, + WorkExperience = Convert.ToInt32(textBoxWorkExperience.Text), + Qualification = Convert.ToInt32(textBoxQualification.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/PlumbingRepair/PlumbingRepairView/FormImplementer.resx b/PlumbingRepair/PlumbingRepairView/FormImplementer.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormImplementer.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormImplementers.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormImplementers.Designer.cs new file mode 100644 index 0000000..7cf7c30 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormImplementers.Designer.cs @@ -0,0 +1,127 @@ +namespace PlumbingRepairView +{ + partial class FormImplementers + { + /// + /// 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.Location = new System.Drawing.Point(661, 254); + this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(125, 44); + this.buttonRef.TabIndex = 14; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(661, 175); + this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(125, 44); + this.buttonDel.TabIndex = 13; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(661, 96); + this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(125, 44); + this.buttonUpd.TabIndex = 12; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(661, 23); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(125, 44); + this.buttonAdd.TabIndex = 11; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.RowHeadersWidth = 62; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.Size = new System.Drawing.Size(583, 450); + this.dataGridView.TabIndex = 10; + // + // FormImplementers + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormImplementers"; + this.Text = "Исполнители"; + this.Load += new System.EventHandler(this.FormImplementers_Load); + ((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/PlumbingRepair/PlumbingRepairView/FormImplementers.cs b/PlumbingRepair/PlumbingRepairView/FormImplementers.cs new file mode 100644 index 0000000..2d1e250 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormImplementers.cs @@ -0,0 +1,102 @@ +using Microsoft.Extensions.Logging; +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; + +namespace PlumbingRepairView +{ + public partial class FormImplementers : Form + { + private readonly ILogger _logger; + + private readonly IImplementerLogic _logic; + public FormImplementers(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormImplementers_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["ImplementerFIO"].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(FormImplementer)); + if (service is FormImplementer 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(FormImplementer)); + if (service is FormImplementer 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 ImplementerBindingModel { Id = id })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/PlumbingRepair/PlumbingRepairView/FormImplementers.resx b/PlumbingRepair/PlumbingRepairView/FormImplementers.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormImplementers.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs index 1e840f0..887f566 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs @@ -30,19 +30,19 @@ { this.buttonRef = new System.Windows.Forms.Button(); this.buttonIssuedOrder = new System.Windows.Forms.Button(); - this.buttonOrderReady = new System.Windows.Forms.Button(); - this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.РаботыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.компонентыПоРаботамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.выполнениеРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -50,7 +50,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(1113, 373); + this.buttonRef.Location = new System.Drawing.Point(1284, 219); this.buttonRef.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.buttonRef.Name = "buttonRef"; this.buttonRef.Size = new System.Drawing.Size(249, 45); @@ -62,7 +62,7 @@ // buttonIssuedOrder // this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonIssuedOrder.Location = new System.Drawing.Point(1113, 297); + this.buttonIssuedOrder.Location = new System.Drawing.Point(1284, 143); this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.buttonIssuedOrder.Name = "buttonIssuedOrder"; this.buttonIssuedOrder.Size = new System.Drawing.Size(249, 45); @@ -71,34 +71,10 @@ this.buttonIssuedOrder.UseVisualStyleBackColor = true; this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); // - // buttonOrderReady - // - this.buttonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOrderReady.Location = new System.Drawing.Point(1113, 225); - this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(249, 45); - this.buttonOrderReady.TabIndex = 9; - this.buttonOrderReady.Text = "Заказ готов"; - this.buttonOrderReady.UseVisualStyleBackColor = true; - this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); - // - // buttonTakeOrderInWork - // - this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1113, 158); - this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(249, 45); - this.buttonTakeOrderInWork.TabIndex = 8; - 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(1113, 83); + this.buttonCreateOrder.Location = new System.Drawing.Point(1284, 83); this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Size = new System.Drawing.Size(249, 45); @@ -124,7 +100,7 @@ this.dataGridView.RowHeadersVisible = false; this.dataGridView.RowHeadersWidth = 62; this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView.Size = new System.Drawing.Size(1055, 533); + this.dataGridView.Size = new System.Drawing.Size(1226, 533); this.dataGridView.TabIndex = 6; // // menuStrip1 @@ -132,10 +108,11 @@ this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.справочникиToolStripMenuItem, - this.отчетыToolStripMenuItem}); + this.отчетыToolStripMenuItem, + this.выполнениеРаботToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1377, 33); + this.menuStrip1.Size = new System.Drawing.Size(1548, 33); this.menuStrip1.TabIndex = 12; this.menuStrip1.Text = "menuStrip1"; // @@ -144,7 +121,8 @@ this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.компонентыToolStripMenuItem, this.РаботыToolStripMenuItem, - this.клиентыToolStripMenuItem}); + this.клиентыToolStripMenuItem, + this.исполнителиToolStripMenuItem}); this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29); this.справочникиToolStripMenuItem.Text = "Справочники"; @@ -152,17 +130,31 @@ // компонентыToolStripMenuItem // this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34); + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(220, 34); this.компонентыToolStripMenuItem.Text = "Компоненты"; this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); // // РаботыToolStripMenuItem // this.РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem"; - this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(270, 34); + this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(220, 34); this.РаботыToolStripMenuItem.Text = "Работы"; this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click); // + // клиентыToolStripMenuItem + // + this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; + this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(220, 34); + this.клиентыToolStripMenuItem.Text = "Клиенты"; + this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); + // + // исполнителиToolStripMenuItem + // + this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; + this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(220, 34); + this.исполнителиToolStripMenuItem.Text = "Исполнители"; + this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click); + // // отчетыToolStripMenuItem // this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -185,7 +177,7 @@ this.компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem"; this.компонентыПоРаботамToolStripMenuItem.Size = new System.Drawing.Size(319, 34); this.компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам"; - this.компонентыПоРаботамToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); + this.компонентыПоРаботамToolStripMenuItem.Click += new System.EventHandler(this.ComponentWorksToolStripMenuItem_Click); // // списокЗаказовToolStripMenuItem // @@ -194,22 +186,20 @@ this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); // - // клиентыToolStripMenuItem + // выполнениеРаботToolStripMenuItem // - this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34); - this.клиентыToolStripMenuItem.Text = "Клиенты"; - this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); + this.выполнениеРаботToolStripMenuItem.Name = "выполнениеРаботToolStripMenuItem"; + this.выполнениеРаботToolStripMenuItem.Size = new System.Drawing.Size(136, 29); + this.выполнениеРаботToolStripMenuItem.Text = "Запуск работ"; + this.выполнениеРаботToolStripMenuItem.Click += new System.EventHandler(this.ЗапускРаботToolStripMenuItem_Click); // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1377, 602); + this.ClientSize = new System.Drawing.Size(1548, 602); this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonIssuedOrder); - this.Controls.Add(this.buttonOrderReady); - this.Controls.Add(this.buttonTakeOrderInWork); this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.dataGridView); this.Controls.Add(this.menuStrip1); @@ -229,8 +219,6 @@ private Button buttonRef; private Button buttonIssuedOrder; - private Button buttonOrderReady; - private Button buttonTakeOrderInWork; private Button buttonCreateOrder; private DataGridView dataGridView; private MenuStrip menuStrip1; @@ -242,5 +230,7 @@ private ToolStripMenuItem компонентыПоРаботамToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem; + private ToolStripMenuItem выполнениеРаботToolStripMenuItem; + private ToolStripMenuItem исполнителиToolStripMenuItem; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.cs b/PlumbingRepair/PlumbingRepairView/FormMain.cs index eab578f..22f2268 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMain.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMain.cs @@ -10,16 +10,17 @@ namespace PlumbingRepairView { private readonly ILogger _logger; - private readonly IReportLogic _reportLogic; - private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; + private readonly IWorkProcess _workProcess; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; _reportLogic = reportLogic; + _workProcess = workProcess; } private void FormMain_Load(object sender, EventArgs e) @@ -35,8 +36,10 @@ namespace PlumbingRepairView if (list != null) { dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["WorkId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ImplementerId"].Visible = false; } _logger.LogInformation("Загрузка заказов"); } @@ -64,17 +67,8 @@ namespace PlumbingRepairView 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 ComponentsToolStripMenuItem_Click(object sender, EventArgs e) + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs +e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) @@ -87,9 +81,11 @@ namespace PlumbingRepairView MessageBoxIcon.Information); } } - private void ComponentProductsToolStripMenuItem_Click(object sender, EventArgs e) + private void ComponentWorksToolStripMenuItem_Click(object sender, + EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportWorkComponents)); + var service = + Program.ServiceProvider?.GetService(typeof(FormReportWorkComponents)); if (service is FormReportWorkComponents form) { form.ShowDialog(); @@ -104,49 +100,15 @@ namespace PlumbingRepairView form.ShowDialog(); } } - private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void ButtonOrderReady_Click(object sender, EventArgs e) + + private void ButtonCreateOrder_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - try - { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + form.ShowDialog(); + LoadData(); } } @@ -187,5 +149,22 @@ namespace PlumbingRepairView form.ShowDialog(); } } + + private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); + if (service is FormImplementers form) + { + form.ShowDialog(); + } + + } + private void ЗапускРаботToolStripMenuItem_Click(object sender, EventArgs +e) + { + _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + MessageBox.Show("Процесс обработки запущен", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/Program.cs b/PlumbingRepair/PlumbingRepairView/Program.cs index 3f4cf42..80719e6 100644 --- a/PlumbingRepair/PlumbingRepairView/Program.cs +++ b/PlumbingRepair/PlumbingRepairView/Program.cs @@ -42,13 +42,16 @@ namespace PlumbingRepairView 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(); @@ -63,9 +66,9 @@ namespace PlumbingRepairView 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 3a324a44100a8ec1cb3ba90951ce513676ba51ab Mon Sep 17 00:00:00 2001 From: sardq Date: Sun, 21 Apr 2024 21:39:42 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormImplementer.Designer.cs | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs index 9f8c11e..54dedf9 100644 --- a/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs +++ b/PlumbingRepair/PlumbingRepairView/FormImplementer.Designer.cs @@ -29,15 +29,15 @@ private void InitializeComponent() { this.textBoxPassword = new System.Windows.Forms.TextBox(); - this.labelCost = new System.Windows.Forms.Label(); + this.labelPassword = new System.Windows.Forms.Label(); this.buttonCancel = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button(); this.textBoxName = new System.Windows.Forms.TextBox(); - this.labelName = new System.Windows.Forms.Label(); + this.labelImplementerFIO = new System.Windows.Forms.Label(); this.textBoxWorkExperience = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); + this.labelWorkExperience = new System.Windows.Forms.Label(); this.textBoxQualification = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); + this.labelQualification = new System.Windows.Forms.Label(); this.SuspendLayout(); // // textBoxPassword @@ -48,15 +48,15 @@ this.textBoxPassword.Size = new System.Drawing.Size(334, 31); this.textBoxPassword.TabIndex = 15; // - // labelCost + // labelPassword // - this.labelCost.AutoSize = true; - this.labelCost.Location = new System.Drawing.Point(4, 80); - this.labelCost.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.labelCost.Name = "labelCost"; - this.labelCost.Size = new System.Drawing.Size(78, 25); - this.labelCost.TabIndex = 14; - this.labelCost.Text = "Пароль:"; + this.labelPassword.AutoSize = true; + this.labelPassword.Location = new System.Drawing.Point(4, 80); + this.labelPassword.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.labelPassword.Name = "labelPassword"; + this.labelPassword.Size = new System.Drawing.Size(78, 25); + this.labelPassword.TabIndex = 14; + this.labelPassword.Text = "Пароль:"; // // buttonCancel // @@ -88,15 +88,15 @@ this.textBoxName.Size = new System.Drawing.Size(334, 31); this.textBoxName.TabIndex = 13; // - // labelName + // labelImplementerFIO // - this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(4, 32); - this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(56, 25); - this.labelName.TabIndex = 12; - this.labelName.Text = "ФИО:"; + this.labelImplementerFIO.AutoSize = true; + this.labelImplementerFIO.Location = new System.Drawing.Point(4, 32); + this.labelImplementerFIO.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.labelImplementerFIO.Name = "labelImplementerFIO"; + this.labelImplementerFIO.Size = new System.Drawing.Size(56, 25); + this.labelImplementerFIO.TabIndex = 12; + this.labelImplementerFIO.Text = "ФИО:"; // // textBoxWorkExperience // @@ -106,15 +106,15 @@ this.textBoxWorkExperience.Size = new System.Drawing.Size(183, 31); this.textBoxWorkExperience.TabIndex = 19; // - // label1 + // labelWorkExperience // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(4, 130); - this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(122, 25); - this.label1.TabIndex = 18; - this.label1.Text = "Стаж работы:"; + this.labelWorkExperience.AutoSize = true; + this.labelWorkExperience.Location = new System.Drawing.Point(4, 130); + this.labelWorkExperience.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.labelWorkExperience.Name = "labelWorkExperience"; + this.labelWorkExperience.Size = new System.Drawing.Size(122, 25); + this.labelWorkExperience.TabIndex = 18; + this.labelWorkExperience.Text = "Стаж работы:"; // // textBoxQualification // @@ -124,15 +124,15 @@ this.textBoxQualification.Size = new System.Drawing.Size(183, 31); this.textBoxQualification.TabIndex = 21; // - // label2 + // labelQualification // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(4, 171); - this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(134, 25); - this.label2.TabIndex = 20; - this.label2.Text = "Квалификация:"; + this.labelQualification.AutoSize = true; + this.labelQualification.Location = new System.Drawing.Point(4, 171); + this.labelQualification.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.labelQualification.Name = "labelQualification"; + this.labelQualification.Size = new System.Drawing.Size(134, 25); + this.labelQualification.TabIndex = 20; + this.labelQualification.Text = "Квалификация:"; // // FormImplementer // @@ -140,15 +140,15 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(485, 281); this.Controls.Add(this.textBoxQualification); - this.Controls.Add(this.label2); + this.Controls.Add(this.labelQualification); this.Controls.Add(this.textBoxWorkExperience); - this.Controls.Add(this.label1); + this.Controls.Add(this.labelWorkExperience); this.Controls.Add(this.textBoxPassword); - this.Controls.Add(this.labelCost); + this.Controls.Add(this.labelPassword); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonSave); this.Controls.Add(this.textBoxName); - this.Controls.Add(this.labelName); + this.Controls.Add(this.labelImplementerFIO); this.Name = "FormImplementer"; this.Text = "Исполнитель"; this.Load += new System.EventHandler(this.FormImplementer_Load); @@ -160,14 +160,14 @@ #endregion private TextBox textBoxPassword; - private Label labelCost; + private Label labelPassword; private Button buttonCancel; private Button buttonSave; private TextBox textBoxName; - private Label labelName; + private Label labelImplementerFIO; private TextBox textBoxWorkExperience; - private Label label1; + private Label labelWorkExperience; private TextBox textBoxQualification; - private Label label2; + private Label labelQualification; } } \ No newline at end of file -- 2.25.1 From 6043650fbefea80985d269dc6e8b5edf2c6f4a18 Mon Sep 17 00:00:00 2001 From: sardq Date: Sun, 12 May 2024 13:09:41 +0400 Subject: [PATCH 4/4] =?UTF-8?q?6=20=D1=83=D1=81=D0=BB=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/OrderLogic.cs | 73 ++- .../BusinessLogics/WorkModeling.cs | 61 ++- .../Enums/OrderStatus.cs | 4 +- .../Implements/OrderStorage.cs | 12 +- .../20240501122640_InitCreate.Designer.cs | 338 ------------- .../Migrations/20240501122640_InitCreate.cs | 241 --------- ... => 20240503121400_initCreate.Designer.cs} | 19 +- ...Create.cs => 20240503121400_initCreate.cs} | 40 +- .../PlumbingRepairDatabaseModelSnapshot.cs | 11 +- .../PlumbingRepairRestApi/Program.cs | 6 - .../PlumbingRepairView/FormMain.Designer.cs | 472 ++++++++---------- PlumbingRepair/PlumbingRepairView/FormMain.cs | 100 +--- PlumbingRepair/PlumbingRepairView/Program.cs | 3 - 13 files changed, 358 insertions(+), 1022 deletions(-) delete mode 100644 PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs delete mode 100644 PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs rename PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/{20240418172421_InitCreate.Designer.cs => 20240503121400_initCreate.Designer.cs} (95%) rename PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/{20240418172421_InitCreate.cs => 20240503121400_initCreate.cs} (93%) diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs index 99bbb44..f3d64c7 100644 --- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs @@ -15,16 +15,11 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; -<<<<<<< HEAD private readonly IShopStorage _shopStorage; private readonly IWorkStorage _workStorage; private readonly IShopLogic _shopLogic; - public OrderLogic(ILogger logger, IOrderStorage orderStorage, IShopStorage shopStorage, IWorkStorage workStorage, IShopLogic shopLogic) -======= - private readonly object _locker =new(); - - public OrderLogic(ILogger logger, IOrderStorage orderStorage) ->>>>>>> lab_6 + static readonly object _locker = new object(); + public OrderLogic(ILogger logger, IOrderStorage orderStorage, IShopStorage shopStorage, IWorkStorage workStorage, IShopLogic shopLogic) { _logger = logger; _orderStorage = orderStorage; @@ -105,46 +100,38 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics _logger.LogWarning("Find order failed"); return false; } -<<<<<<< HEAD - if (newStatus == OrderStatus.Выдан) - { - var work = _workStorage.GetElement(new WorkSearchModel() { Id = viewModel.WorkId}); - if (work == null) - { - _logger.LogWarning("Change status operation failed.Work not found"); - return false; - } - if (!_shopLogic.CheckAndSupply(work, viewModel.Count)) - { - _logger.LogWarning("Change status operation failed. Works delivery operation failed"); - return false; - } - } - model.Status = newStatus; - if (model.Status == OrderStatus.Готов) - { - model.DateImplement = DateTime.Now; - } - else - { - model.DateImplement = viewModel.DateImplement; - } - CheckModel(model, false); - if (_orderStorage.Update(model) == null) - { - _logger.LogWarning("Change status operation failed"); - return false; - } -======= - if (viewModel.Status != newStatus - 1) + if (viewModel.Status != newStatus - 1 && viewModel.Status != OrderStatus.Ожидание) { _logger.LogWarning("Status change failed"); throw new InvalidOperationException("Невозможно перевести состояние заказа"); } - model.Status = newStatus; - if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; - _orderStorage.Update(model); ->>>>>>> lab_6 + if (viewModel.ImplementerId != null) + viewModel.ImplementerId = model.ImplementerId; + model.Status = newStatus; + if (model.WorkId == 0) + model.WorkId = viewModel.WorkId; + if (model.Count == 0) + model.Count = viewModel.Count; + if (newStatus == OrderStatus.Готов) + { + var work = _workStorage.GetElement(new WorkSearchModel { Id = model.WorkId }); + if (work == null) + { + _logger.LogWarning("Status change operation failed. Work not found."); + return false; + } + + if (!_shopLogic.CheckAndSupply(work, model.Count)) + { + _logger.LogWarning("Status change operation failed. Shop supply error."); + model.Status = OrderStatus.Ожидание; + if (_orderStorage.Update(model) == null) + _logger.LogWarning("Update operation failed"); + return false; + } + + } + _orderStorage.Update(model); return true; } private void CheckModel(OrderBindingModel model, bool withParams = true) diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs index c7d1998..334ca78 100644 --- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/WorkModeling.cs @@ -32,9 +32,16 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics return; } var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят }); - if (orders == null || orders.Count == 0) + if (orders == null) + { + _logger.LogWarning("DoWork. Orders is null"); + return; + } + orders.AddRange(_orderLogic.ReadList(new() { Status = OrderStatus.Выполняется }) ?? new()); + orders.AddRange(_orderLogic.ReadList(new() { Status = OrderStatus.Ожидание }) ?? new()); + if (orders.Count == 0) { - _logger.LogWarning("DoWork. Orders is null or empty"); + _logger.LogWarning("DoWork. Orders is empty"); return; } _logger.LogDebug("DoWork for {Count} orders", orders.Count); @@ -55,7 +62,8 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics { return; } - await RunOrderInWork(implementer); + await RunWaitingOrder(implementer); + await RunOrderInWork(implementer); await Task.Run(() => { @@ -75,8 +83,9 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); _orderLogic.FinishOrder(new OrderBindingModel { - Id = order.Id - }); + Id = order.Id, + ImplementerId = implementer.Id + }); // отдыхаем Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } @@ -127,8 +136,10 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics { Id = runOrder.Id }); - // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + _logger.LogDebug("DoWork. Worker {Id} delivery order {Order}", implementer.Id, runOrder.Id); + _orderLogic.DeliveryOrder(new() { Id = runOrder.Id }); + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } // заказа может не быть, просто игнорируем ошибку catch (InvalidOperationException ex) @@ -142,5 +153,39 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics throw; } } - } + private async Task RunWaitingOrder(ImplementerViewModel implementer) + { + if (_orderLogic == null || implementer == null) + { + return; + } + try + { + var order = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel + { + ImplementerId = implementer.Id, + Status = OrderStatus.Ожидание + })); + if (order == null) + { + return; + } + _logger.LogDebug("DoWork. Worker {Id} delivery order {Order}", implementer.Id, order.Id); + _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = order.Id + }); + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairDataModels/Enums/OrderStatus.cs b/PlumbingRepair/PlumbingRepairDataModels/Enums/OrderStatus.cs index 8b72a9c..df0aceb 100644 --- a/PlumbingRepair/PlumbingRepairDataModels/Enums/OrderStatus.cs +++ b/PlumbingRepair/PlumbingRepairDataModels/Enums/OrderStatus.cs @@ -10,6 +10,8 @@ Готов = 2, - Выдан = 3 + Выдан = 3, + + Ожидание = 4 } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs index 77e871e..48d857a 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs @@ -55,10 +55,14 @@ namespace PlumbingRepairDatabaseImplement.Implements } if (model.Status.HasValue) { - return context.Orders - .Where(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status) - .Select(x => AttachNames(x.GetViewModel)).ToList(); - } + return context.Orders. + Include(x => x.Work) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => x.Status.Equals(model.Status)) + .Select(x => x.GetViewModel) + .ToList(); + } if (model.ClientId.HasValue) { return context.Orders diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs deleted file mode 100644 index 7c9835c..0000000 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs +++ /dev/null @@ -1,338 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PlumbingRepairDatabaseImplement; - -#nullable disable - -namespace PlumbingRepairDatabaseImplement.Migrations -{ - [DbContext(typeof(PlumbingRepairDatabase))] -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs - [Migration("20240501122640_InitCreate")] -======== - [Migration("20240418172421_InitCreate")] ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs - partial class InitCreate - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.27") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ImplementerId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.Property("WorkId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ImplementerId"); - - b.HasIndex("WorkId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DateOpening") - .HasColumnType("datetime2"); - - b.Property("ShopName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("maxCountWorks") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Shops"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("ShopId") - .HasColumnType("int"); - - b.Property("WorkId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ShopId"); - - b.HasIndex("WorkId"); - - b.ToTable("ShopWorks"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("WorkName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Works"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("WorkId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("WorkId"); - - b.ToTable("WorkComponents"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b => - { - b.HasOne("PlumbingRepairDatabaseImplement.Models.Client", "Client") - .WithMany("Orders") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PlumbingRepairDatabaseImplement.Models.Implementer", "Implementer") - .WithMany("Orders") - .HasForeignKey("ImplementerId"); - - b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work") - .WithMany("Orders") - .HasForeignKey("WorkId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Implementer"); - - b.Navigation("Work"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b => - { - b.HasOne("PlumbingRepairDatabaseImplement.Models.Shop", "Shop") - .WithMany("Works") - .HasForeignKey("ShopId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work") - .WithMany() - .HasForeignKey("WorkId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Shop"); - - b.Navigation("Work"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b => - { - b.HasOne("PlumbingRepairDatabaseImplement.Models.Component", "Component") - .WithMany("WorkComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work") - .WithMany("Components") - .HasForeignKey("WorkId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Work"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b => - { - b.Navigation("WorkComponents"); - }); - -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b => - { - b.Navigation("Works"); -======== - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => - { - b.Navigation("Orders"); ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs deleted file mode 100644 index 340c493..0000000 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs +++ /dev/null @@ -1,241 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PlumbingRepairDatabaseImplement.Migrations -{ - public partial class InitCreate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Components", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - Cost = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Components", x => x.Id); - }); - - migrationBuilder.CreateTable( -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs - name: "Shops", -======== - name: "Implementers", ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs - ShopName = table.Column(type: "nvarchar(max)", nullable: false), - Address = table.Column(type: "nvarchar(max)", nullable: false), - DateOpening = table.Column(type: "datetime2", nullable: false), - maxCountWorks = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Shops", x => x.Id); -======== - ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - WorkExperience = table.Column(type: "int", nullable: false), - Qualification = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Implementers", x => x.Id); ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs - }); - - migrationBuilder.CreateTable( - name: "Works", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Works", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkId = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: false), - ImplementerId = table.Column(type: "int", nullable: true), - Count = table.Column(type: "int", nullable: false), - Sum = table.Column(type: "float", nullable: false), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Orders_Implementers_ImplementerId", - column: x => x.ImplementerId, - principalTable: "Implementers", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_Orders_Works_WorkId", - column: x => x.WorkId, - principalTable: "Works", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ShopWorks", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkId = table.Column(type: "int", nullable: false), - ShopId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ShopWorks", x => x.Id); - table.ForeignKey( - name: "FK_ShopWorks_Shops_ShopId", - column: x => x.ShopId, - principalTable: "Shops", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ShopWorks_Works_WorkId", - column: x => x.WorkId, - principalTable: "Works", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "WorkComponents", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkId = table.Column(type: "int", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WorkComponents", x => x.Id); - table.ForeignKey( - name: "FK_WorkComponents_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_WorkComponents_Works_WorkId", - column: x => x.WorkId, - principalTable: "Works", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ImplementerId", - table: "Orders", - column: "ImplementerId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_WorkId", - table: "Orders", - column: "WorkId"); - - migrationBuilder.CreateIndex( - name: "IX_ShopWorks_ShopId", - table: "ShopWorks", - column: "ShopId"); - - migrationBuilder.CreateIndex( - name: "IX_ShopWorks_WorkId", - table: "ShopWorks", - column: "WorkId"); - - migrationBuilder.CreateIndex( - name: "IX_WorkComponents_ComponentId", - table: "WorkComponents", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_WorkComponents_WorkId", - table: "WorkComponents", - column: "WorkId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "ShopWorks"); - - migrationBuilder.DropTable( - name: "WorkComponents"); - - migrationBuilder.DropTable( - name: "Clients"); - - migrationBuilder.DropTable( -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs - name: "Shops"); -======== - name: "Implementers"); ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs - - migrationBuilder.DropTable( - name: "Components"); - - migrationBuilder.DropTable( - name: "Works"); - } - } -} diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs similarity index 95% rename from PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs rename to PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs index 7c9835c..3867f4a 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs @@ -12,12 +12,8 @@ using PlumbingRepairDatabaseImplement; namespace PlumbingRepairDatabaseImplement.Migrations { [DbContext(typeof(PlumbingRepairDatabase))] -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs - [Migration("20240501122640_InitCreate")] -======== - [Migration("20240418172421_InitCreate")] ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs - partial class InitCreate + [Migration("20240503121400_initCreate")] + partial class initCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -315,15 +311,14 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Navigation("WorkComponents"); }); -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.Designer.cs - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b => - { - b.Navigation("Works"); -======== modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => { b.Navigation("Orders"); ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.Designer.cs + }); + + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b => + { + b.Navigation("Works"); }); modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs similarity index 93% rename from PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs rename to PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs index 340c493..3283641 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace PlumbingRepairDatabaseImplement.Migrations { - public partial class InitCreate : Migration + public partial class initCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -39,25 +39,11 @@ namespace PlumbingRepairDatabaseImplement.Migrations }); migrationBuilder.CreateTable( -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs - name: "Shops", -======== name: "Implementers", ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs - ShopName = table.Column(type: "nvarchar(max)", nullable: false), - Address = table.Column(type: "nvarchar(max)", nullable: false), - DateOpening = table.Column(type: "datetime2", nullable: false), - maxCountWorks = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Shops", x => x.Id); -======== ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), WorkExperience = table.Column(type: "int", nullable: false), @@ -66,7 +52,22 @@ namespace PlumbingRepairDatabaseImplement.Migrations constraints: table => { table.PrimaryKey("PK_Implementers", x => x.Id); ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs + }); + + migrationBuilder.CreateTable( + name: "Shops", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShopName = table.Column(type: "nvarchar(max)", nullable: false), + Address = table.Column(type: "nvarchar(max)", nullable: false), + DateOpening = table.Column(type: "datetime2", nullable: false), + maxCountWorks = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shops", x => x.Id); }); migrationBuilder.CreateTable( @@ -225,11 +226,10 @@ namespace PlumbingRepairDatabaseImplement.Migrations name: "Clients"); migrationBuilder.DropTable( -<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240501122640_InitCreate.cs - name: "Shops"); -======== name: "Implementers"); ->>>>>>>> lab_6:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240418172421_InitCreate.cs + + migrationBuilder.DropTable( + name: "Shops"); migrationBuilder.DropTable( name: "Components"); diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs index cbe4e0a..726c524 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs @@ -309,15 +309,14 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Navigation("WorkComponents"); }); -<<<<<<< HEAD - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b => - { - b.Navigation("Works"); -======= modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => { b.Navigation("Orders"); ->>>>>>> lab_6 + }); + + modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b => + { + b.Navigation("Works"); }); modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => diff --git a/PlumbingRepair/PlumbingRepairRestApi/Program.cs b/PlumbingRepair/PlumbingRepairRestApi/Program.cs index 5476371..cc8f2d7 100644 --- a/PlumbingRepair/PlumbingRepairRestApi/Program.cs +++ b/PlumbingRepair/PlumbingRepairRestApi/Program.cs @@ -13,20 +13,14 @@ builder.Logging.AddLog4Net("log4net.config"); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -<<<<<<< HEAD builder.Services.AddTransient(); -======= builder.Services.AddTransient(); ->>>>>>> lab_6 builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -<<<<<<< HEAD builder.Services.AddTransient(); -======= builder.Services.AddTransient(); ->>>>>>> lab_6 builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs index 705ea5f..5401a6b 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs @@ -28,274 +28,242 @@ /// private void InitializeComponent() { - this.buttonRef = new System.Windows.Forms.Button(); - this.buttonIssuedOrder = 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.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.РаботыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); -<<<<<<< HEAD - this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.пToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.продажаРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); -======= - this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ->>>>>>> lab_6 - this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.компонентыПоРаботамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); -<<<<<<< HEAD - this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.работыПоМагазинамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.списокВсехЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); -======= - this.выполнениеРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ->>>>>>> lab_6 - ((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(1284, 219); - this.buttonRef.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(249, 45); - this.buttonRef.TabIndex = 11; - this.buttonRef.Text = "Обновить список"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); - // - // buttonIssuedOrder - // - this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonIssuedOrder.Location = new System.Drawing.Point(1284, 143); - this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(249, 45); - this.buttonIssuedOrder.TabIndex = 10; - this.buttonIssuedOrder.Text = "Заказ выдан"; - this.buttonIssuedOrder.UseVisualStyleBackColor = true; - this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_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(1284, 83); - this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(249, 45); - this.buttonCreateOrder.TabIndex = 7; - this.buttonCreateOrder.Text = "Создать заказ"; - this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); - // - // dataGridView - // - this.dataGridView.AllowUserToAddRows = false; - this.dataGridView.AllowUserToDeleteRows = false; - this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonIssuedOrder = 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.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.РаботыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.пToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.продажаРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.компонентыПоРаботамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.работыПоМагазинамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокВсехЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.выполнениеРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.исполнителиToolStripMenuItem = 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(1113, 227); + this.buttonRef.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(249, 45); + this.buttonRef.TabIndex = 11; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonIssuedOrder + // + this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonIssuedOrder.Location = new System.Drawing.Point(1113, 151); + this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(249, 45); + this.buttonIssuedOrder.TabIndex = 10; + this.buttonIssuedOrder.Text = "Заказ выдан"; + this.buttonIssuedOrder.UseVisualStyleBackColor = true; + this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_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(1113, 83); + this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(249, 45); + this.buttonCreateOrder.TabIndex = 7; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(2, 44); - this.dataGridView.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); - this.dataGridView.MultiSelect = false; - this.dataGridView.Name = "dataGridView"; - this.dataGridView.ReadOnly = true; - this.dataGridView.RowHeadersVisible = false; - this.dataGridView.RowHeadersWidth = 62; - this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView.Size = new System.Drawing.Size(1226, 533); - this.dataGridView.TabIndex = 6; - // - // menuStrip1 - // - this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(2, 44); + this.dataGridView.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.RowHeadersWidth = 62; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.Size = new System.Drawing.Size(1055, 533); + this.dataGridView.TabIndex = 6; + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.справочникиToolStripMenuItem, this.отчетыToolStripMenuItem, this.выполнениеРаботToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1548, 33); - this.menuStrip1.TabIndex = 12; - this.menuStrip1.Text = "menuStrip1"; - // - // справочникиToolStripMenuItem - // - this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(1377, 33); + this.menuStrip1.TabIndex = 12; + this.menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.компонентыToolStripMenuItem, this.РаботыToolStripMenuItem, -<<<<<<< HEAD this.магазиныToolStripMenuItem, this.пToolStripMenuItem, this.продажаРаботToolStripMenuItem, - this.клиентыToolStripMenuItem}); -======= this.клиентыToolStripMenuItem, this.исполнителиToolStripMenuItem}); ->>>>>>> lab_6 - this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29); - this.справочникиToolStripMenuItem.Text = "Справочники"; - // - // компонентыToolStripMenuItem - // - this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; -<<<<<<< HEAD - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(296, 34); -======= - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(220, 34); ->>>>>>> lab_6 - this.компонентыToolStripMenuItem.Text = "Компоненты"; - this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); - // - // РаботыToolStripMenuItem - // - this.РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem"; -<<<<<<< HEAD - this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(296, 34); - this.РаботыToolStripMenuItem.Text = "Работы"; - this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click); - // - // магазиныToolStripMenuItem - // - this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; - this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(296, 34); - this.магазиныToolStripMenuItem.Text = "Магазины"; - this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click); - // - // пToolStripMenuItem - // - this.пToolStripMenuItem.Name = "пToolStripMenuItem"; - this.пToolStripMenuItem.Size = new System.Drawing.Size(296, 34); - this.пToolStripMenuItem.Text = "Пополнение магазина"; - this.пToolStripMenuItem.Click += new System.EventHandler(this.пополнениеToolStripMenuItem_Click); - // - // продажаРаботToolStripMenuItem - // - this.продажаРаботToolStripMenuItem.Name = "продажаРаботToolStripMenuItem"; - this.продажаРаботToolStripMenuItem.Size = new System.Drawing.Size(296, 34); - this.продажаРаботToolStripMenuItem.Text = "Продажа работ"; - this.продажаРаботToolStripMenuItem.Click += new System.EventHandler(this.продажаРаботToolStripMenuItem_Click); -======= - this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(220, 34); - this.РаботыToolStripMenuItem.Text = "Работы"; - this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click); - // - // клиентыToolStripMenuItem - // - this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(220, 34); - this.клиентыToolStripMenuItem.Text = "Клиенты"; - this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); - // - // исполнителиToolStripMenuItem - // - this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; - this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(220, 34); - this.исполнителиToolStripMenuItem.Text = "Исполнители"; - this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click); ->>>>>>> lab_6 - // - // отчетыToolStripMenuItem - // - this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29); + this.справочникиToolStripMenuItem.Text = "Справочники"; + // + // компонентыToolStripMenuItem + // + this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.компонентыToolStripMenuItem.Text = "Компоненты"; + this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); + // + // РаботыToolStripMenuItem + // + this.РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem"; + this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.РаботыToolStripMenuItem.Text = "Работы"; + this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click); + // + // магазиныToolStripMenuItem + // + this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.магазиныToolStripMenuItem.Text = "Магазины"; + this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click); + // + // пToolStripMenuItem + // + this.пToolStripMenuItem.Name = "пToolStripMenuItem"; + this.пToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.пToolStripMenuItem.Text = "Пополнение магазина"; + this.пToolStripMenuItem.Click += new System.EventHandler(this.пополнениеToolStripMenuItem_Click); + // + // продажаРаботToolStripMenuItem + // + this.продажаРаботToolStripMenuItem.Name = "продажаРаботToolStripMenuItem"; + this.продажаРаботToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.продажаРаботToolStripMenuItem.Text = "Продажа работ"; + this.продажаРаботToolStripMenuItem.Click += new System.EventHandler(this.продажаРаботToolStripMenuItem_Click); + // + // клиентыToolStripMenuItem + // + this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; + this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.клиентыToolStripMenuItem.Text = "Клиенты"; + this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); + // + // отчетыToolStripMenuItem + // + this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.списокКомпонентовToolStripMenuItem, this.компонентыПоРаботамToolStripMenuItem, this.списокЗаказовToolStripMenuItem, this.списокМагазиновToolStripMenuItem, this.работыПоМагазинамToolStripMenuItem, this.списокВсехЗаказовToolStripMenuItem}); - this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(88, 29); - this.отчетыToolStripMenuItem.Text = "Отчеты"; - // - // списокКомпонентовToolStripMenuItem - // - this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(319, 34); - this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; - this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.списокКомпонентовToolStripMenuItem_Click); - // - // компонентыПоРаботамToolStripMenuItem - // - this.компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem"; - this.компонентыПоРаботамToolStripMenuItem.Size = new System.Drawing.Size(319, 34); - this.компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам"; -<<<<<<< HEAD -======= - this.компонентыПоРаботамToolStripMenuItem.Click += new System.EventHandler(this.ComponentWorksToolStripMenuItem_Click); ->>>>>>> lab_6 - // - // списокЗаказовToolStripMenuItem - // - this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34); - this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; - // - // списокМагазиновToolStripMenuItem - // - this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem"; - this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(319, 34); - this.списокМагазиновToolStripMenuItem.Text = "Список магазинов"; - this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click); - // - // работыПоМагазинамToolStripMenuItem - // - this.работыПоМагазинамToolStripMenuItem.Name = "работыПоМагазинамToolStripMenuItem"; - this.работыПоМагазинамToolStripMenuItem.Size = new System.Drawing.Size(319, 34); - this.работыПоМагазинамToolStripMenuItem.Text = "Работы по магазинам"; - this.работыПоМагазинамToolStripMenuItem.Click += new System.EventHandler(this.ShopWorksToolStripMenuItem_Click); - // - // списокВсехЗаказовToolStripMenuItem - // - this.списокВсехЗаказовToolStripMenuItem.Name = "списокВсехЗаказовToolStripMenuItem"; - this.списокВсехЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34); - this.списокВсехЗаказовToolStripMenuItem.Text = "Список всех заказов"; - this.списокВсехЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersByDateToolStripMenuItem_Click); - // - // выполнениеРаботToolStripMenuItem - // -<<<<<<< HEAD - this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(296, 34); - this.клиентыToolStripMenuItem.Text = "Клиенты"; - this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); -======= - this.выполнениеРаботToolStripMenuItem.Name = "выполнениеРаботToolStripMenuItem"; - this.выполнениеРаботToolStripMenuItem.Size = new System.Drawing.Size(136, 29); - this.выполнениеРаботToolStripMenuItem.Text = "Запуск работ"; - this.выполнениеРаботToolStripMenuItem.Click += new System.EventHandler(this.ЗапускРаботToolStripMenuItem_Click); ->>>>>>> lab_6 - // - // FormMain - // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1548, 602); - this.Controls.Add(this.buttonRef); - this.Controls.Add(this.buttonIssuedOrder); - this.Controls.Add(this.buttonCreateOrder); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "FormMain"; - this.Text = "Ремонт труб"; - this.Load += new System.EventHandler(this.FormMain_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(88, 29); + this.отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокКомпонентовToolStripMenuItem + // + this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(319, 34); + this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.списокКомпонентовToolStripMenuItem_Click); + // + // компонентыПоРаботамToolStripMenuItem + // + this.компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem"; + this.компонентыПоРаботамToolStripMenuItem.Size = new System.Drawing.Size(319, 34); + this.компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам"; + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + // + // списокМагазиновToolStripMenuItem + // + this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem"; + this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(319, 34); + this.списокМагазиновToolStripMenuItem.Text = "Список магазинов"; + this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click); + // + // работыПоМагазинамToolStripMenuItem + // + this.работыПоМагазинамToolStripMenuItem.Name = "работыПоМагазинамToolStripMenuItem"; + this.работыПоМагазинамToolStripMenuItem.Size = new System.Drawing.Size(319, 34); + this.работыПоМагазинамToolStripMenuItem.Text = "Работы по магазинам"; + this.работыПоМагазинамToolStripMenuItem.Click += new System.EventHandler(this.ShopWorksToolStripMenuItem_Click); + // + // списокВсехЗаказовToolStripMenuItem + // + this.списокВсехЗаказовToolStripMenuItem.Name = "списокВсехЗаказовToolStripMenuItem"; + this.списокВсехЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34); + this.списокВсехЗаказовToolStripMenuItem.Text = "Список всех заказов"; + this.списокВсехЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersByDateToolStripMenuItem_Click); + // + // выполнениеРаботToolStripMenuItem + // + this.выполнениеРаботToolStripMenuItem.Name = "выполнениеРаботToolStripMenuItem"; + this.выполнениеРаботToolStripMenuItem.Size = new System.Drawing.Size(136, 29); + this.выполнениеРаботToolStripMenuItem.Text = "Запуск работ"; + this.выполнениеРаботToolStripMenuItem.Click += new System.EventHandler(this.выполнениеРаботToolStripMenuItem_Click); + // + // исполнителиToolStripMenuItem + // + this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; + this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(296, 34); + this.исполнителиToolStripMenuItem.Text = "Исполнители"; + this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1377, 602); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonIssuedOrder); + this.Controls.Add(this.buttonCreateOrder); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Name = "FormMain"; + this.Text = "Ремонт труб"; + this.Load += new System.EventHandler(this.FormMain_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -321,6 +289,6 @@ private ToolStripMenuItem списокВсехЗаказовToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem; private ToolStripMenuItem выполнениеРаботToolStripMenuItem; - private ToolStripMenuItem исполнителиToolStripMenuItem; - } + private ToolStripMenuItem исполнителиToolStripMenuItem; + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.cs b/PlumbingRepair/PlumbingRepairView/FormMain.cs index 4ac7fe1..0e97bf3 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMain.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMain.cs @@ -11,11 +11,7 @@ namespace PlumbingRepairView private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; -<<<<<<< HEAD -======= private readonly IWorkProcess _workProcess; ->>>>>>> lab_6 - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) { InitializeComponent(); @@ -39,11 +35,6 @@ namespace PlumbingRepairView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; -<<<<<<< HEAD -======= - dataGridView.Columns["WorkId"].Visible = false; ->>>>>>> lab_6 - dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["ImplementerId"].Visible = false; } _logger.LogInformation("Загрузка заказов"); @@ -73,7 +64,6 @@ namespace PlumbingRepairView form.ShowDialog(); } } -<<<<<<< HEAD private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShops)); @@ -101,72 +91,6 @@ namespace PlumbingRepairView } } - private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } -======= - private void ComponentsToolStripMenuItem_Click(object sender, EventArgs -e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveComponentsToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - } - private void ComponentWorksToolStripMenuItem_Click(object sender, - EventArgs e) - { - var service = - Program.ServiceProvider?.GetService(typeof(FormReportWorkComponents)); - if (service is FormReportWorkComponents form) - { - form.ShowDialog(); - } - } - private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = - Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); ->>>>>>> lab_6 - } - } - - - 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 ButtonIssuedOrder_Click(object sender, EventArgs e) { @@ -285,21 +209,21 @@ e) } } - private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - if (service is FormImplementers form) - { - form.ShowDialog(); - } - - } - private void ЗапускРаботToolStripMenuItem_Click(object sender, EventArgs -e) + private void выполнениеРаботToolStripMenuItem_Click(object sender, EventArgs e) { _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } - } + + private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormImplementers)); + if (service is FormImplementers form) + { + form.ShowDialog(); + } + } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/Program.cs b/PlumbingRepair/PlumbingRepairView/Program.cs index 2922f54..831a407 100644 --- a/PlumbingRepair/PlumbingRepairView/Program.cs +++ b/PlumbingRepair/PlumbingRepairView/Program.cs @@ -70,15 +70,12 @@ namespace PlumbingRepairView services.AddTransient(); services.AddTransient(); services.AddTransient(); -<<<<<<< HEAD services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); -======= ->>>>>>> lab_6 services.AddTransient(); services.AddTransient(); services.AddTransient(); -- 2.25.1