diff --git a/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj b/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj new file mode 100644 index 0000000..e7fbd8e --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..e62b209 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ComponentLogic.cs @@ -0,0 +1,116 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.BusinessLogic +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage + componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/DocumentLogic.cs b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/DocumentLogic.cs new file mode 100644 index 0000000..60eb54e --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/DocumentLogic.cs @@ -0,0 +1,114 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.BusinessLogic +{ + public class DocumentLogic : IDocumentLogic + { + private readonly ILogger _logger; + private readonly IDocumentStorage _documentStorage; + public DocumentLogic(ILogger logger, IDocumentStorage + documentStorage) + { + _logger = logger; + _documentStorage = documentStorage; + } + public List? ReadList(DocumentSearchModel? model) + { + _logger.LogInformation("ReadList. DocumentName:{DocumentName}.Id:{ Id}", model?.DocumentName, model?.Id); + var list = model == null ? _documentStorage.GetFullList() : _documentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public DocumentViewModel? ReadElement(DocumentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. DocumentName:{DocumentName}.Id:{ Id}", model.DocumentName, model.Id); + var element = _documentStorage.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(DocumentBindingModel model) + { + CheckModel(model); + if (_documentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(DocumentBindingModel model) + { + CheckModel(model); + if (_documentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(DocumentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_documentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(DocumentBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.DocumentName)) + { + throw new ArgumentNullException("Нет названия пакета документов", + nameof(model.DocumentName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена пакета документов должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Document. DocumentName:{DocumentName}.Cost:{ Cost}. Id: { Id}", model.DocumentName, model.Price, model.Id); + var element = _documentStorage.GetElement(new DocumentSearchModel + { + DocumentName = model.DocumentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Пакет документов с таким названием уже есть"); + } + } + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..cf6376c --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs @@ -0,0 +1,111 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.BusinessLogic +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : + _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) return false; + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool ChangeStatus(OrderBindingModel model, OrderStatus status) + { + CheckModel(model); + var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (element == null) + { + _logger.LogWarning("Read operation failed"); + return false; + } + if (element.Status != status - 1) + { + _logger.LogWarning("Status change operation failed"); + throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный"); + } + model.Status = status; + if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; + _orderStorage.Update(model); + return true; + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Готов); + } + + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выдан); + } + + private void CheckModel(OrderBindingModel model, bool withParams = +true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count)); + } + _logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id); + } + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/LawFirmBusinessLogic.csproj b/LawFirm/AbstractLawFirmBusinessLogic/LawFirmBusinessLogic.csproj new file mode 100644 index 0000000..b7b3431 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/LawFirmBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts.sln b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts.sln new file mode 100644 index 0000000..9570f3b --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33122.133 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmContracts", "AbstractLawFirmContracts\AbstractLawFirmContracts.csproj", "{32D95EAA-926F-4BFA-A0A9-128BA0260A66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EA33641B-AC1E-42E6-BA74-A1A91DAF198E} + EndGlobalSection +EndGlobal diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/AbstractLawFirmContracts.csproj b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/AbstractLawFirmContracts.csproj new file mode 100644 index 0000000..74a87d8 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/AbstractLawFirmContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/ComponentBindingModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..0546eb8 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,16 @@ +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.BindingModels.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/DocumentBindingModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/DocumentBindingModel.cs new file mode 100644 index 0000000..d4c2535 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/DocumentBindingModel.cs @@ -0,0 +1,17 @@ +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.BindingModels +{ + public class DocumentBindingModel : IDocumentModel + { + public int Id { get; set; } + public string DocumentName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary DocumentComponents { get; set; } = new(); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/OrderBindingModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..e3fa2fd --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,21 @@ +using AbstractLawFirmDataModels.Enums; +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int DocumentId { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..ec69938 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,20 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs new file mode 100644 index 0000000..38550db --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs @@ -0,0 +1,20 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.BusinessLogicsContracts +{ + public interface IDocumentLogic + { + List? ReadList(DocumentSearchModel? model); + DocumentViewModel? ReadElement(DocumentSearchModel model); + bool Create(DocumentBindingModel model); + bool Update(DocumentBindingModel model); + bool Delete(DocumentBindingModel model); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..ab78985 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,20 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/LawFirmContracts.csproj b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/LawFirmContracts.csproj new file mode 100644 index 0000000..975ba62 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/LawFirmContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/ComponentSearchModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..378b6ab --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/DocumentSearchModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/DocumentSearchModel.cs new file mode 100644 index 0000000..9481c87 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/DocumentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.SearchModels +{ + public class DocumentSearchModel + { + public int? Id { get; set; } + public string? DocumentName { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..d568495 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IComponentStorage.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..a1932c8 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IDocumentStorage.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IDocumentStorage.cs new file mode 100644 index 0000000..4e8e876 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IDocumentStorage.cs @@ -0,0 +1,21 @@ +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.StoragesContracts +{ + public interface IDocumentStorage + { + List GetFullList(); + List GetFilteredList(DocumentSearchModel model); + DocumentViewModel? GetElement(DocumentSearchModel model); + DocumentViewModel? Insert(DocumentBindingModel model); + DocumentViewModel? Update(DocumentBindingModel model); + DocumentViewModel? Delete(DocumentBindingModel model); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IOrderStorage.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..60e7dc1 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,21 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ComponentViewModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..0843b72 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/DocumentViewModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/DocumentViewModel.cs new file mode 100644 index 0000000..74d0e5f --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/DocumentViewModel.cs @@ -0,0 +1,25 @@ +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.ViewModels +{ + public class DocumentViewModel : IDocumentModel + { + public int Id { get; set; } + [DisplayName("Название пакета документов")] + public string DocumentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary DocumentComponents + { + get; + set; + } = new(); + + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/OrderViewModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..2acfb53 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,30 @@ +using AbstractLawFirmDataModels.Enums; +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int DocumentId { get; set; } + [DisplayName("Пакет документов")] + public string DocumentName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels.sln b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels.sln new file mode 100644 index 0000000..3c428c6 --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33122.133 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmDataModels", "AbstractLawFirmDataModels\AbstractLawFirmDataModels.csproj", "{9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3F1F2B80-1FE8-42C3-9167-E2E50274FE15} + EndGlobalSection +EndGlobal diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/AbstractLawFirmDataModels.csproj b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/AbstractLawFirmDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/AbstractLawFirmDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Enums/OrderStatus.cs b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..6837f42 --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Enums/OrderStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/IId.cs b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/IId.cs new file mode 100644 index 0000000..52061ba --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/LawFirmDataModels.csproj b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/LawFirmDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/LawFirmDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IComponentModel.cs b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..d2e8e39 --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IComponentModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AbstractLawFirmDataModels; + +namespace AbstractLawFirmDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + + } +} diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IDocumentModel.cs b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IDocumentModel.cs new file mode 100644 index 0000000..3e330c3 --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IDocumentModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AbstractLawFirmDataModels; + +namespace AbstractLawFirmDataModels.Models +{ + public interface IDocumentModel : IId + { + string DocumentName { get; } + double Price { get; } + Dictionary DocumentComponents { get; } + } +} diff --git a/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IOrderModel.cs b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..126df76 --- /dev/null +++ b/LawFirm/AbstractLawFirmDataModels/AbstractLawFirmDataModels/Models/IOrderModel.cs @@ -0,0 +1,21 @@ +using AbstractLawFirmDataModels; +using AbstractLawFirmDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmDataModels.Models +{ + public interface IOrderModel : IId + { + int DocumentId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/AbstractLawFirmListImplement.csproj b/LawFirm/AbstractLawFirmListImplement/AbstractLawFirmListImplement.csproj new file mode 100644 index 0000000..f54052f --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/AbstractLawFirmListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/LawFirm/AbstractLawFirmListImplement/DataListSingleton.cs b/LawFirm/AbstractLawFirmListImplement/DataListSingleton.cs new file mode 100644 index 0000000..ca1efab --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using AbstractLawFirmListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Documents { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Documents = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/Implements/ComponentStorage.cs b/LawFirm/AbstractLawFirmListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..4ef797e --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,108 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/Implements/DocumentStorage.cs b/LawFirm/AbstractLawFirmListImplement/Implements/DocumentStorage.cs new file mode 100644 index 0000000..40ffe93 --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/Implements/DocumentStorage.cs @@ -0,0 +1,109 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement.Implements +{ + public class DocumentStorage : IDocumentStorage + { + private readonly DataListSingleton _source; + public DocumentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var document in _source.Documents) + { + result.Add(document.GetViewModel); + } + return result; + } + public List GetFilteredList(DocumentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.DocumentName)) + { + return result; + } + foreach (var document in _source.Documents) + { + if (document.DocumentName.Contains(model.DocumentName)) + { + result.Add(document.GetViewModel); + } + } + return result; + } + public DocumentViewModel? GetElement(DocumentSearchModel model) + { + if (string.IsNullOrEmpty(model.DocumentName) && !model.Id.HasValue) + { + return null; + } + foreach (var document in _source.Documents) + { + if ((!string.IsNullOrEmpty(model.DocumentName) && + document.DocumentName == model.DocumentName) || + (model.Id.HasValue && document.Id == model.Id)) + { + return document.GetViewModel; + } + } + return null; + } + public DocumentViewModel? Insert(DocumentBindingModel model) + { + model.Id = 1; + foreach (var document in _source.Documents) + { + if (model.Id <= document.Id) + { + model.Id = document.Id + 1; + } + } + var newDocument = Document.Create(model); + if (newDocument == null) + { + return null; + } + _source.Documents.Add(newDocument); + return newDocument.GetViewModel; + } + public DocumentViewModel? Update(DocumentBindingModel model) + { + foreach (var document in _source.Documents) + { + if (document.Id == model.Id) + { + document.Update(model); + return document.GetViewModel; + } + } + return null; + } + public DocumentViewModel? Delete(DocumentBindingModel model) + { + for (int i = 0; i < _source.Documents.Count; ++i) + { + if (_source.Documents[i].Id == model.Id) + { + var element = _source.Documents[i]; + _source.Documents.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/AbstractLawFirmListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..82a0ece --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/Implements/OrderStorage.cs @@ -0,0 +1,118 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmListImplement.Models; +using AbstractLawFirmContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(AccessDocumentStorage(order.GetViewModel)); + } + return result; + } + public List GetFilteredList(OrderSearchModel + model) + { + var result = new List(); + if (!model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(AccessDocumentStorage(order.GetViewModel)); + } + } + return result; + } + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var order in _source.Orders) + { + if (model.Id <= order.Id) + { + model.Id = order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return newOrder.GetViewModel; + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + public OrderViewModel AccessDocumentStorage(OrderViewModel model) + { + foreach (var document in _source.Documents) + { + if (document.Id == model.DocumentId) + { + model.DocumentName = document.DocumentName; + break; + } + } + return model; + } + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/LawFirmListImplement.csproj b/LawFirm/AbstractLawFirmListImplement/LawFirmListImplement.csproj new file mode 100644 index 0000000..c0efba3 --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/LawFirmListImplement.csproj @@ -0,0 +1,15 @@ + + + + net6.0 + enable + enable + + + + + + + + + diff --git a/LawFirm/AbstractLawFirmListImplement/Models/Component.cs b/LawFirm/AbstractLawFirmListImplement/Models/Component.cs new file mode 100644 index 0000000..f30a28d --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/Models/Component.cs @@ -0,0 +1,47 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/Models/Document.cs b/LawFirm/AbstractLawFirmListImplement/Models/Document.cs new file mode 100644 index 0000000..9569f94 --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/Models/Document.cs @@ -0,0 +1,55 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement.Models +{ + public class Document : IDocumentModel + { + public int Id { get; private set; } + public string DocumentName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary DocumentComponents + { + get; + private set; + } = new Dictionary(); + public static Document? Create(DocumentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Document() + { + + Id = model.Id, + DocumentName = model.DocumentName, + Price = model.Price, + DocumentComponents = model.DocumentComponents + }; + } + public void Update(DocumentBindingModel? model) + { + if (model == null) + { + return; + } + DocumentName = model.DocumentName; + Price = model.Price; + DocumentComponents = model.DocumentComponents; + } + public DocumentViewModel GetViewModel => new() + { + Id = Id, + DocumentName = DocumentName, + Price = Price, + DocumentComponents = DocumentComponents + }; + } +} diff --git a/LawFirm/AbstractLawFirmListImplement/Models/Order.cs b/LawFirm/AbstractLawFirmListImplement/Models/Order.cs new file mode 100644 index 0000000..f2c291d --- /dev/null +++ b/LawFirm/AbstractLawFirmListImplement/Models/Order.cs @@ -0,0 +1,65 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmDataModels.Enums; +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int DocumentId { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } + public DateTime DateCreate { get; private set; } + public DateTime? DateImplement { get; private set; } + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + DocumentId = model.DocumentId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Id = model.Id; + DocumentId = model.DocumentId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + DocumentId = DocumentId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + }; + + } +} diff --git a/LawFirm/LawFirm.sln b/LawFirm/LawFirm.sln new file mode 100644 index 0000000..09da4ff --- /dev/null +++ b/LawFirm/LawFirm.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33122.133 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmView", "LawFirmView\LawFirmView.csproj", "{32CEC3FF-22BE-4DCD-8955-E3B14953EA67}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractLawFirmDataModels", "AbstractLawFirmDataModels\AbstractLawFirmDataModels\AbstractLawFirmDataModels.csproj", "{99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractLawFirmContracts", "AbstractLawFirmContracts\AbstractLawFirmContracts\AbstractLawFirmContracts.csproj", "{C0155B2E-5974-4835-996B-6FDF0F5BC06B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmBusinessLogic", "AbstractLawFirmBusinessLogic\AbstractLawFirmBusinessLogic.csproj", "{E48808B1-5381-4774-97B6-CDB107DCF98C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmListImplement", "AbstractLawFirmListImplement\AbstractLawFirmListImplement.csproj", "{86D5FC6F-B262-44A0-9D30-970F9EA93E0A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Release|Any CPU.Build.0 = Release|Any CPU + {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Release|Any CPU.Build.0 = Release|Any CPU + {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Release|Any CPU.Build.0 = Release|Any CPU + {E48808B1-5381-4774-97B6-CDB107DCF98C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E48808B1-5381-4774-97B6-CDB107DCF98C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E48808B1-5381-4774-97B6-CDB107DCF98C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E48808B1-5381-4774-97B6-CDB107DCF98C}.Release|Any CPU.Build.0 = Release|Any CPU + {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9226BA1-1E7A-4E32-A0D3-BB8E1CF929E3} + EndGlobalSection +EndGlobal diff --git a/LawFirm/LawFirmView/FormComponent.cs b/LawFirm/LawFirmView/FormComponent.cs new file mode 100644 index 0000000..9e6014b --- /dev/null +++ b/LawFirm/LawFirmView/FormComponent.cs @@ -0,0 +1,100 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение компонента"); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = + _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение компонента"); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LawFirm/LawFirmView/FormComponent.designer.cs b/LawFirm/LawFirmView/FormComponent.designer.cs new file mode 100644 index 0000000..b3a55fb --- /dev/null +++ b/LawFirm/LawFirmView/FormComponent.designer.cs @@ -0,0 +1,123 @@ +namespace LawFirmView +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + textBoxName = new TextBox(); + textBoxCost = new TextBox(); + label1 = new Label(); + label2 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // textBoxName + // + textBoxName.Location = new Point(82, 16); + textBoxName.Margin = new Padding(3, 4, 3, 4); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(305, 27); + textBoxName.TabIndex = 0; + // + // textBoxCost + // + textBoxCost.Location = new Point(82, 73); + textBoxCost.Margin = new Padding(3, 4, 3, 4); + textBoxCost.Name = "textBoxCost"; + textBoxCost.Size = new Size(163, 27); + textBoxCost.TabIndex = 1; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(2, 16); + label1.Name = "label1"; + label1.Size = new Size(80, 20); + label1.TabIndex = 2; + label1.Text = "Название:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(14, 73); + label2.Name = "label2"; + label2.Size = new Size(48, 20); + label2.TabIndex = 3; + label2.Text = "Цена:"; + // + // buttonSave + // + buttonSave.Location = new Point(182, 135); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(92, 31); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(302, 135); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(521, 185); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxCost); + Controls.Add(textBoxName); + Margin = new Padding(3, 4, 3, 4); + Name = "FormComponent"; + Text = "Компонент"; + Load += FormComponent_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxName; + private TextBox textBoxCost; + private Label label1; + private Label label2; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormComponent.resx b/LawFirm/LawFirmView/FormComponent.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/LawFirm/LawFirmView/FormComponent.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormComponents.cs b/LawFirm/LawFirmView/FormComponents.cs new file mode 100644 index 0000000..b5111e9 --- /dev/null +++ b/LawFirm/LawFirmView/FormComponents.cs @@ -0,0 +1,124 @@ +using AbstractLawFirmContracts.BindingModels.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.VisualBasic.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormComponents : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление компонента"); + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + + } +} diff --git a/LawFirm/LawFirmView/FormComponents.designer.cs b/LawFirm/LawFirmView/FormComponents.designer.cs new file mode 100644 index 0000000..5c5db9f --- /dev/null +++ b/LawFirm/LawFirmView/FormComponents.designer.cs @@ -0,0 +1,114 @@ +namespace LawFirmView +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(439, 442); + this.dataGridView.TabIndex = 0; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(486, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(102, 40); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(486, 58); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(102, 41); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(486, 105); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(102, 42); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(486, 153); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(102, 39); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(632, 443); + this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormComponents"; + this.Text = "FormComponents"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormComponents.resx b/LawFirm/LawFirmView/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormComponents.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormCreateOrder.cs b/LawFirm/LawFirmView/FormCreateOrder.cs new file mode 100644 index 0000000..6f6a410 --- /dev/null +++ b/LawFirm/LawFirmView/FormCreateOrder.cs @@ -0,0 +1,140 @@ +using AbstractLawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using AbstractLawFirmContracts.SearchModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using AbstractLawFirmContracts.BindingModels; + +namespace LawFirmView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IDocumentLogic _logicD; + private readonly IOrderLogic _logicO; + public FormCreateOrder(ILogger logger, IDocumentLogic logicD, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicD = logicD; + _logicO = logicO; + } + + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка пакетов документов для заказа"); + try + { + var list = _logicD.ReadList(null); + if (list != null) + { + comboBoxDocument.DisplayMember = "DocumentName"; + comboBoxDocument.ValueMember = "Id"; + comboBoxDocument.DataSource = list; + comboBoxDocument.SelectedItem = null; + } + _logger.LogInformation("Пакеты документов загружены"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки пакетов документов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void CalcSum() + { + if (comboBoxDocument.SelectedValue != null && + !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxDocument.SelectedValue); + var product = _logicD.ReadElement(new DocumentSearchModel + { + Id + = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), + 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void textBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void comboBoxDocument_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void textBoxSum_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxDocument.SelectedValue == null) + { + MessageBox.Show("Выберите пакет документов", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + DocumentId = Convert.ToInt32(comboBoxDocument.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LawFirm/LawFirmView/FormCreateOrder.designer.cs b/LawFirm/LawFirmView/FormCreateOrder.designer.cs new file mode 100644 index 0000000..8837e68 --- /dev/null +++ b/LawFirm/LawFirmView/FormCreateOrder.designer.cs @@ -0,0 +1,150 @@ +namespace LawFirmView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + comboBoxDocument = new ComboBox(); + textBoxCount = new TextBox(); + textBoxSum = new TextBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxDocument + // + comboBoxDocument.FormattingEnabled = true; + comboBoxDocument.Location = new Point(133, 16); + comboBoxDocument.Margin = new Padding(3, 4, 3, 4); + comboBoxDocument.Name = "comboBoxDocument"; + comboBoxDocument.Size = new Size(226, 28); + comboBoxDocument.TabIndex = 0; + comboBoxDocument.SelectedIndexChanged += comboBoxDocument_SelectedIndexChanged; + // + // textBoxCount + // + textBoxCount.Location = new Point(133, 55); + textBoxCount.Margin = new Padding(3, 4, 3, 4); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(226, 27); + textBoxCount.TabIndex = 1; + textBoxCount.TextChanged += textBoxCount_TextChanged; + // + // textBoxSum + // + textBoxSum.Location = new Point(133, 93); + textBoxSum.Margin = new Padding(3, 4, 3, 4); + textBoxSum.Name = "textBoxSum"; + textBoxSum.Size = new Size(226, 27); + textBoxSum.TabIndex = 2; + textBoxSum.TextChanged += textBoxSum_TextChanged; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(3, 16); + label1.Name = "label1"; + label1.Size = new Size(138, 20); + label1.TabIndex = 3; + label1.Text = "Пакет документов:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(3, 59); + label2.Name = "label2"; + label2.Size = new Size(93, 20); + label2.TabIndex = 4; + label2.Text = "Количество:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(3, 93); + label3.Name = "label3"; + label3.Size = new Size(58, 20); + label3.TabIndex = 5; + label3.Text = "Сумма:"; + // + // buttonSave + // + buttonSave.Location = new Point(206, 163); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(91, 31); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(322, 163); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormCreateOrder + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(509, 211); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxSum); + Controls.Add(textBoxCount); + Controls.Add(comboBoxDocument); + Margin = new Padding(3, 4, 3, 4); + Name = "FormCreateOrder"; + Text = "Заказ"; + Load += FormCreateOrder_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxDocument; + private TextBox textBoxCount; + private TextBox textBoxSum; + private Label label1; + private Label label2; + private Label label3; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormCreateOrder.resx b/LawFirm/LawFirmView/FormCreateOrder.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/LawFirm/LawFirmView/FormCreateOrder.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocument.cs b/LawFirm/LawFirmView/FormDocument.cs new file mode 100644 index 0000000..f73ea35 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocument.cs @@ -0,0 +1,236 @@ +using AbstractLawFirmDataModels.Models; +using Microsoft.Extensions.Logging; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormDocument : Form + { + private readonly ILogger _logger; + private readonly IDocumentLogic _logic; + private int? _id; + private Dictionary _documentComponents; + public int Id { set { _id = value; } } + public FormDocument(ILogger logger, IDocumentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _documentComponents = new Dictionary(); + } + + private void FormDocument_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка изделия"); + try + { + var view = _logic.ReadElement(new DocumentSearchModel + { + Id = + _id.Value + }); + if (view != null) + { + textBoxName.Text = view.DocumentName; + textBoxPrice.Text = view.Price.ToString(); + _documentComponents = view.DocumentComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_documentComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _documentComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, +pc.Value.Item1.ComponentName, pc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormDocumentComponent)); + if (service is FormDocumentComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count); + if (_documentComponents.ContainsKey(form.Id)) + { + _documentComponents[form.Id] = (form.ComponentModel, + form.Count); + } + else + { + _documentComponents.Add(form.Id, (form.ComponentModel, + form.Count)); + } + LoadData(); + } + } + + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormDocumentComponent)); + if (service is FormDocumentComponent form) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _documentComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента:{ ComponentName - { Count}", form.ComponentModel.ComponentName, form.Count); + _documentComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента: { ComponentName} - { Count} ", dataGridView.SelectedRows[0].Cells[1].Value); + + _documentComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_documentComponents == null || _documentComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new DocumentBindingModel + { + Id = _id ?? 0, + DocumentName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + DocumentComponents = _documentComponents + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _documentComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/LawFirm/LawFirmView/FormDocument.designer.cs b/LawFirm/LawFirmView/FormDocument.designer.cs new file mode 100644 index 0000000..54caefc --- /dev/null +++ b/LawFirm/LawFirmView/FormDocument.designer.cs @@ -0,0 +1,238 @@ +namespace LawFirmView +{ + partial class FormDocument + { + /// + /// 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() + { + groupBox1 = new GroupBox(); + buttonRef = new Button(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + Column1 = new DataGridViewTextBoxColumn(); + Column2 = new DataGridViewTextBoxColumn(); + Column3 = new DataGridViewTextBoxColumn(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxName = new TextBox(); + textBoxPrice = new TextBox(); + label1 = new Label(); + label2 = new Label(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // groupBox1 + // + groupBox1.Controls.Add(buttonRef); + groupBox1.Controls.Add(buttonDel); + groupBox1.Controls.Add(buttonUpd); + groupBox1.Controls.Add(buttonAdd); + groupBox1.Controls.Add(dataGridView); + groupBox1.Location = new Point(66, 131); + groupBox1.Margin = new Padding(3, 4, 3, 4); + groupBox1.Name = "groupBox1"; + groupBox1.Padding = new Padding(3, 4, 3, 4); + groupBox1.Size = new Size(691, 384); + groupBox1.TabIndex = 0; + groupBox1.TabStop = false; + groupBox1.Text = "Компоненты"; + // + // buttonRef + // + buttonRef.Location = new Point(544, 208); + buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(86, 31); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // buttonDel + // + buttonDel.Location = new Point(544, 144); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(86, 31); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(544, 81); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(86, 31); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(544, 25); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(86, 31); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2, Column3 }); + dataGridView.Location = new Point(3, 25); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(472, 339); + dataGridView.TabIndex = 0; + // + // Column1 + // + Column1.HeaderText = "id"; + Column1.MinimumWidth = 6; + Column1.Name = "Column1"; + Column1.Visible = false; + // + // Column2 + // + Column2.HeaderText = "Компонент"; + Column2.MinimumWidth = 6; + Column2.Name = "Column2"; + // + // Column3 + // + Column3.HeaderText = "Количество"; + Column3.MinimumWidth = 6; + Column3.Name = "Column3"; + // + // buttonSave + // + buttonSave.Location = new Point(488, 537); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 31); + buttonSave.TabIndex = 1; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(610, 537); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 2; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // textBoxName + // + textBoxName.Location = new Point(117, 16); + textBoxName.Margin = new Padding(3, 4, 3, 4); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(234, 27); + textBoxName.TabIndex = 3; + // + // textBoxPrice + // + textBoxPrice.Location = new Point(117, 55); + textBoxPrice.Margin = new Padding(3, 4, 3, 4); + textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.Size = new Size(172, 27); + textBoxPrice.TabIndex = 4; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(14, 16); + label1.Name = "label1"; + label1.Size = new Size(80, 20); + label1.TabIndex = 5; + label1.Text = "Название:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(14, 55); + label2.Name = "label2"; + label2.Size = new Size(86, 20); + label2.TabIndex = 6; + label2.Text = "Стоимость:"; + // + // FormDocument + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(790, 600); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxPrice); + Controls.Add(textBoxName); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBox1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormDocument"; + Text = "Пакет документов"; + Load += FormDocument_Load; + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private GroupBox groupBox1; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxName; + private TextBox textBoxPrice; + private Label label1; + private Label label2; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocument.resx b/LawFirm/LawFirmView/FormDocument.resx new file mode 100644 index 0000000..dbdd69b --- /dev/null +++ b/LawFirm/LawFirmView/FormDocument.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocumentComponent.cs b/LawFirm/LawFirmView/FormDocumentComponent.cs new file mode 100644 index 0000000..eed845a --- /dev/null +++ b/LawFirm/LawFirmView/FormDocumentComponent.cs @@ -0,0 +1,95 @@ +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.ViewModels; +using AbstractLawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormDocumentComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return + Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set + { textBoxCount.Text = value.ToString(); } + } + + public FormDocumentComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + + } + } +} diff --git a/LawFirm/LawFirmView/FormDocumentComponent.designer.cs b/LawFirm/LawFirmView/FormDocumentComponent.designer.cs new file mode 100644 index 0000000..6380b7d --- /dev/null +++ b/LawFirm/LawFirmView/FormDocumentComponent.designer.cs @@ -0,0 +1,123 @@ +namespace LawFirmView +{ + partial class FormDocumentComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + comboBoxComponent = new ComboBox(); + textBoxCount = new TextBox(); + label1 = new Label(); + label2 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxComponent + // + comboBoxComponent.FormattingEnabled = true; + comboBoxComponent.Location = new Point(106, 16); + comboBoxComponent.Margin = new Padding(3, 4, 3, 4); + comboBoxComponent.Name = "comboBoxComponent"; + comboBoxComponent.Size = new Size(245, 28); + comboBoxComponent.TabIndex = 0; + // + // textBoxCount + // + textBoxCount.Location = new Point(106, 67); + textBoxCount.Margin = new Padding(3, 4, 3, 4); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(166, 27); + textBoxCount.TabIndex = 1; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(14, 16); + label1.Name = "label1"; + label1.Size = new Size(91, 20); + label1.TabIndex = 2; + label1.Text = "Компонент:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(14, 67); + label2.Name = "label2"; + label2.Size = new Size(93, 20); + label2.TabIndex = 3; + label2.Text = "Количество:"; + // + // buttonSave + // + buttonSave.Location = new Point(187, 121); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(95, 31); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(296, 121); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormDocumentComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(439, 181); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxCount); + Controls.Add(comboBoxComponent); + Margin = new Padding(3, 4, 3, 4); + Name = "FormDocumentComponent"; + Text = "Компонент пакета документов"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxComponent; + private TextBox textBoxCount; + private Label label1; + private Label label2; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocumentComponent.resx b/LawFirm/LawFirmView/FormDocumentComponent.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocumentComponent.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocuments.Designer.cs b/LawFirm/LawFirmView/FormDocuments.Designer.cs new file mode 100644 index 0000000..40c7ac6 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocuments.Designer.cs @@ -0,0 +1,114 @@ +namespace LawFirmView +{ + partial class FormDocuments + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(445, 420); + this.dataGridView.TabIndex = 0; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(514, 22); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(95, 37); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(514, 80); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(95, 39); + this.buttonUpd.TabIndex = 2; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(514, 142); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(95, 40); + this.buttonDel.TabIndex = 3; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(514, 205); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(95, 39); + this.buttonRef.TabIndex = 4; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // FormDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(669, 432); + 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 = "FormDocuments"; + this.Text = "Пакеты документов"; + this.Load += new System.EventHandler(this.FormDocuments_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocuments.cs b/LawFirm/LawFirmView/FormDocuments.cs new file mode 100644 index 0000000..cbbdda6 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocuments.cs @@ -0,0 +1,116 @@ +using AbstractLawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using AbstractLawFirmContracts.BindingModels; +using Microsoft.VisualBasic.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormDocuments : Form + { + private readonly ILogger _logger; + private readonly IDocumentLogic _logic; + public FormDocuments(ILogger logger, IDocumentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormDocuments_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["DocumentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DocumentComponents"].Visible = false; + } + _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(FormDocument)); + if (service is FormDocument 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(FormDocument)); + if (service is FormDocument 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 DocumentBindingModel + { + 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/LawFirm/LawFirmView/FormDocuments.resx b/LawFirm/LawFirmView/FormDocuments.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormDocuments.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/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs new file mode 100644 index 0000000..134665b --- /dev/null +++ b/LawFirm/LawFirmView/FormMain.cs @@ -0,0 +1,180 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LawFirmView +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["DocumentId"].Visible = false; + dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + + } + + private void пакетыДокументовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); + if (service is FormDocuments form) + { + form.ShowDialog(); + } + } + + private void buttonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + + } + + private void buttonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + } + + private void buttonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); + try + { + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } + + private void buttonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); + try + { + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) + { + return new OrderBindingModel + { + Id = id, + DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }; + } + } +} diff --git a/LawFirm/LawFirmView/FormMain.designer.cs b/LawFirm/LawFirmView/FormMain.designer.cs new file mode 100644 index 0000000..6d9d80f --- /dev/null +++ b/LawFirm/LawFirmView/FormMain.designer.cs @@ -0,0 +1,174 @@ +namespace LawFirmView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.toolStripMenuItemCatalogs = new System.Windows.Forms.ToolStripMenuItem(); + this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.пакетыДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.buttonCreateOrder = new System.Windows.Forms.Button(); + this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); + this.buttonOrderReady = new System.Windows.Forms.Button(); + this.buttonIssuedOrder = new System.Windows.Forms.Button(); + this.buttonRef = new System.Windows.Forms.Button(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemCatalogs}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(910, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "Справочники"; + // + // toolStripMenuItemCatalogs + // + this.toolStripMenuItemCatalogs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.компонентыToolStripMenuItem, + this.пакетыДокументовToolStripMenuItem}); + this.toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs"; + this.toolStripMenuItemCatalogs.Size = new System.Drawing.Size(94, 20); + this.toolStripMenuItemCatalogs.Text = "Справочники"; + // + // компонентыToolStripMenuItem + // + this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.компонентыToolStripMenuItem.Text = "Компоненты"; + this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click); + // + // пакетыДокументовToolStripMenuItem + // + this.пакетыДокументовToolStripMenuItem.Name = "пакетыДокументовToolStripMenuItem"; + this.пакетыДокументовToolStripMenuItem.Size = new System.Drawing.Size(183, 22); + this.пакетыДокументовToolStripMenuItem.Text = "Пакеты документов"; + this.пакетыДокументовToolStripMenuItem.Click += new System.EventHandler(this.пакетыДокументовToolStripMenuItem_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(0, 27); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(736, 411); + this.dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + this.buttonCreateOrder.Location = new System.Drawing.Point(742, 39); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(156, 26); + this.buttonCreateOrder.TabIndex = 2; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click); + // + // buttonTakeOrderInWork + // + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(742, 71); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(156, 23); + this.buttonTakeOrderInWork.TabIndex = 3; + this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; + this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click); + // + // buttonOrderReady + // + this.buttonOrderReady.Location = new System.Drawing.Point(742, 100); + this.buttonOrderReady.Name = "buttonOrderReady"; + this.buttonOrderReady.Size = new System.Drawing.Size(156, 23); + this.buttonOrderReady.TabIndex = 4; + this.buttonOrderReady.Text = "Заказ готов"; + this.buttonOrderReady.UseVisualStyleBackColor = true; + this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click); + // + // buttonIssuedOrder + // + this.buttonIssuedOrder.Location = new System.Drawing.Point(742, 129); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(156, 23); + this.buttonIssuedOrder.TabIndex = 5; + this.buttonIssuedOrder.Text = "Заказ выдан"; + this.buttonIssuedOrder.UseVisualStyleBackColor = true; + this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click); + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(742, 158); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(156, 23); + this.buttonRef.TabIndex = 6; + this.buttonRef.Text = "Обновить список"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(910, 477); + 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); + this.MainMenuStrip = this.menuStrip1; + this.Name = "FormMain"; + this.Text = "FormMain"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem toolStripMenuItemCatalogs; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem пакетыДокументовToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormMain.resx b/LawFirm/LawFirmView/FormMain.resx new file mode 100644 index 0000000..05252e7 --- /dev/null +++ b/LawFirm/LawFirmView/FormMain.resx @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 25 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/LawFirmView.csproj b/LawFirm/LawFirmView/LawFirmView.csproj new file mode 100644 index 0000000..b6cfc13 --- /dev/null +++ b/LawFirm/LawFirmView/LawFirmView.csproj @@ -0,0 +1,21 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs new file mode 100644 index 0000000..ab37d8c --- /dev/null +++ b/LawFirm/LawFirmView/Program.cs @@ -0,0 +1,53 @@ +using AbstractLawFirmBusinessLogic.BusinessLogic; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using System; + +namespace LawFirmView +{ + internal static class Program + { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/nlog.config b/LawFirm/LawFirmView/nlog.config new file mode 100644 index 0000000..85797a7 --- /dev/null +++ b/LawFirm/LawFirmView/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file