diff --git a/LawFirm/LawFirm.sln b/LawFirm/LawFirm.sln index 21028cb..719916d 100644 --- a/LawFirm/LawFirm.sln +++ b/LawFirm/LawFirm.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33205.214 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirm", "LawFirm\LawFirm.csproj", "{455EB557-0801-48F1-9894-3546D0E54EE9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmBusinessLogic", "LawFirmBusinessLogic\LawFirmBusinessLogic.csproj", "{30183192-1B0E-4152-885C-E7BDE99BBB06}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmListImplement", "LawFirmListImplement\LawFirmListImplement.csproj", "{5C8AA92D-079E-4BAF-BE35-6ED016F9AED3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmContracts", "LawFirmContracts\LawFirmContracts.csproj", "{6F47A7CF-F09A-4B49-8563-9A04CD34A12C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmDataModel", "LawFirmDataModel\LawFirmDataModel.csproj", "{5843A0EE-1B48-47C6-9C14-6BE5CFA958A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmView", "LawFirmView\LawFirmView.csproj", "{9634FC36-04D5-42B8-A51E-085C32C5295F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,10 +19,26 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {455EB557-0801-48F1-9894-3546D0E54EE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {455EB557-0801-48F1-9894-3546D0E54EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {455EB557-0801-48F1-9894-3546D0E54EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {455EB557-0801-48F1-9894-3546D0E54EE9}.Release|Any CPU.Build.0 = Release|Any CPU + {30183192-1B0E-4152-885C-E7BDE99BBB06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30183192-1B0E-4152-885C-E7BDE99BBB06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30183192-1B0E-4152-885C-E7BDE99BBB06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30183192-1B0E-4152-885C-E7BDE99BBB06}.Release|Any CPU.Build.0 = Release|Any CPU + {5C8AA92D-079E-4BAF-BE35-6ED016F9AED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C8AA92D-079E-4BAF-BE35-6ED016F9AED3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C8AA92D-079E-4BAF-BE35-6ED016F9AED3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C8AA92D-079E-4BAF-BE35-6ED016F9AED3}.Release|Any CPU.Build.0 = Release|Any CPU + {6F47A7CF-F09A-4B49-8563-9A04CD34A12C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F47A7CF-F09A-4B49-8563-9A04CD34A12C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F47A7CF-F09A-4B49-8563-9A04CD34A12C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F47A7CF-F09A-4B49-8563-9A04CD34A12C}.Release|Any CPU.Build.0 = Release|Any CPU + {5843A0EE-1B48-47C6-9C14-6BE5CFA958A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5843A0EE-1B48-47C6-9C14-6BE5CFA958A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5843A0EE-1B48-47C6-9C14-6BE5CFA958A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5843A0EE-1B48-47C6-9C14-6BE5CFA958A8}.Release|Any CPU.Build.0 = Release|Any CPU + {9634FC36-04D5-42B8-A51E-085C32C5295F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9634FC36-04D5-42B8-A51E-085C32C5295F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9634FC36-04D5-42B8-A51E-085C32C5295F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9634FC36-04D5-42B8-A51E-085C32C5295F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LawFirm/LawFirm/Form1.Designer.cs b/LawFirm/LawFirm/Form1.Designer.cs deleted file mode 100644 index cbe84f0..0000000 --- a/LawFirm/LawFirm/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace LawFirm -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/LawFirm/LawFirm/Form1.cs b/LawFirm/LawFirm/Form1.cs deleted file mode 100644 index d090cf4..0000000 --- a/LawFirm/LawFirm/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace LawFirm -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/LawFirm/LawFirm/Form1.resx b/LawFirm/LawFirm/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/LawFirm/LawFirm/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/LawFirm/LawFirm/LawFirm.csproj b/LawFirm/LawFirm/LawFirm.csproj deleted file mode 100644 index b57c89e..0000000 --- a/LawFirm/LawFirm/LawFirm.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - - - \ No newline at end of file diff --git a/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs deleted file mode 100644 index 45182ca..0000000 --- a/LawFirm/LawFirm/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace LawFirm -{ - internal static class Program - { - /// - /// 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(); - Application.Run(new Form1()); - } - } -} \ No newline at end of file diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/BlankLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/BlankLogic.cs new file mode 100644 index 0000000..b773b5e --- /dev/null +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/BlankLogic.cs @@ -0,0 +1,115 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace LawFirmBusinessLogic.BusinessLogics +{ + public class BlankLogic : IBlankLogic + { + private readonly ILogger _logger; + private readonly IBlankStorage _blankStorage; + public BlankLogic(ILogger logger, IBlankStorage blankStorage) + { + _logger = logger; + _blankStorage = blankStorage; + } + public List? ReadList(BlankSearchModel? model) + { + _logger.LogInformation("ReadList. BlankName:{BlankName}.Id:{Id}", + model?.BlankName, model?.Id); + var list = model == null ? _blankStorage.GetFullList() : + _blankStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public BlankViewModel? ReadElement(BlankSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. BlankName:{BlankName}.Id:{Id}", + model.BlankName, model.Id); + var element = _blankStorage.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(BlankBindingModel model) + { + CheckModel(model); + if (_blankStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(BlankBindingModel model) + { + CheckModel(model); + if (_blankStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(BlankBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_blankStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(BlankBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.BlankName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.BlankName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", + nameof(model.Price)); + } + _logger.LogInformation("Blank. BlankName:{BlackName}.Price:{Price}. Id: {Id}", + model.BlankName, model.Price, model.Id); + var element = _blankStorage.GetElement( + new BlankSearchModel + { + BlankName = model.BlankName + } + ); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/DocumentLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/DocumentLogic.cs new file mode 100644 index 0000000..049754c --- /dev/null +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/DocumentLogic.cs @@ -0,0 +1,115 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace LawFirmBusinessLogic.BusinessLogics +{ + 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 bool Create(DocumentBindingModel model) + { + CheckModel(model); + if (_documentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert 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; + } + 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 Update(DocumentBindingModel model) + { + CheckModel(model); + if (_documentStorage.Update(model) == null) + { + _logger.LogWarning("Update 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}.Price:{Price}. 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/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..a87b215 --- /dev/null +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,119 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Enums; +using Microsoft.Extensions.Logging; + +namespace LawFirmBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + { + _logger.LogWarning("Insert operation failed. Order status incorrect."); + return false; + } + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + model.Status = OrderStatus.Неизвестен; + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) + { + var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (viewModel == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (viewModel.Status + 1 != newStatus) + { + _logger.LogWarning("Update operation failed. Order status incorrect."); + return false; + } + model.Status = newStatus; + if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now; + else + { + model.DateImplement = viewModel.DateImplement; + } + CheckModel(model); + if (_orderStorage.Update(model) == null) + { + model.Status--; + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool DeliveryOrder(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Выдан); + } + + public bool FinishOrder(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Готов); + } + public bool TakeOrderInWork(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Выполняется); + } + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : + _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if(model.DocumentId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор документа", + nameof(model.DocumentId)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество документов в заказе должно быть больше 0", + nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", + nameof(model.Sum)); + } + _logger.LogInformation("Document. OrderID:{Id}. Sum:{Sum}. DocumentID:{DocumentID}.}", + model.Id, model.Sum, model.DocumentId); + } + } +} diff --git a/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj new file mode 100644 index 0000000..b0452d6 --- /dev/null +++ b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/LawFirm/LawFirmContracts/BindingModels/BlankBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/BlankBindingModel.cs new file mode 100644 index 0000000..8b39821 --- /dev/null +++ b/LawFirm/LawFirmContracts/BindingModels/BlankBindingModel.cs @@ -0,0 +1,11 @@ +using LawFirmDataModels.Models; + +namespace LawFirmContracts.BindingModels +{ + public class BlankBindingModel : IBlankModel + { + public int Id { get; set; } + public string BlankName { get; set; } = string.Empty; + public double Price { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs new file mode 100644 index 0000000..300c3d1 --- /dev/null +++ b/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs @@ -0,0 +1,16 @@ +using LawFirmDataModels.Models; + +namespace LawFirmContracts.BindingModels +{ + public class DocumentBindingModel : IDocumentModel + { + public int Id { get; set; } + public string DocumentName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary DocumentBlanks + { + get; + set; + } = new(); + } +} diff --git a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..4b582fe --- /dev/null +++ b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,16 @@ +using LawFirmDataModels.Enums; +using LawFirmDataModels.Models; + +namespace LawFirmContracts.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/LawFirmContracts/BusinessLogicsContracts/IBlankLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IBlankLogic.cs new file mode 100644 index 0000000..57a05ca --- /dev/null +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IBlankLogic.cs @@ -0,0 +1,15 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmContracts.BusinessLogicsContracts +{ + public interface IBlankLogic + { + List? ReadList(BlankSearchModel? model); + BlankViewModel? ReadElement(BlankSearchModel model); + bool Create(BlankBindingModel model); + bool Update(BlankBindingModel model); + bool Delete(BlankBindingModel model); + } +} diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs new file mode 100644 index 0000000..6224208 --- /dev/null +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs @@ -0,0 +1,15 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmContracts.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/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..62f8519 --- /dev/null +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmContracts.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/LawFirmContracts/LawFirmContracts.csproj b/LawFirm/LawFirmContracts/LawFirmContracts.csproj new file mode 100644 index 0000000..c2d790f --- /dev/null +++ b/LawFirm/LawFirmContracts/LawFirmContracts.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/LawFirm/LawFirmContracts/SearchModels/BlankSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/BlankSearchModel.cs new file mode 100644 index 0000000..ba9ee62 --- /dev/null +++ b/LawFirm/LawFirmContracts/SearchModels/BlankSearchModel.cs @@ -0,0 +1,9 @@ +namespace LawFirmContracts.SearchModels +{ + public class BlankSearchModel + { + public int? Id { get; set; } + public string? BlankName { get; set; } + } + +} diff --git a/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs new file mode 100644 index 0000000..89b5057 --- /dev/null +++ b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs @@ -0,0 +1,8 @@ +namespace LawFirmContracts.SearchModels +{ + public class DocumentSearchModel + { + public int? Id { get; set; } + public string? DocumentName { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..18f7733 --- /dev/null +++ b/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace LawFirmContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IBlankStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IBlankStorage.cs new file mode 100644 index 0000000..7a1d50a --- /dev/null +++ b/LawFirm/LawFirmContracts/StoragesContracts/IBlankStorage.cs @@ -0,0 +1,16 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmContracts.StoragesContracts +{ + public interface IBlankStorage + { + List GetFullList(); + List GetFilteredList(BlankSearchModel model); + BlankViewModel? GetElement(BlankSearchModel model); + BlankViewModel? Insert(BlankBindingModel model); + BlankViewModel? Update(BlankBindingModel model); + BlankViewModel? Delete(BlankBindingModel model); + } +} diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs new file mode 100644 index 0000000..020699c --- /dev/null +++ b/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs @@ -0,0 +1,17 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmContracts.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/LawFirmContracts/StoragesContracts/IOrderStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..30b5419 --- /dev/null +++ b/LawFirm/LawFirmContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,16 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmContracts.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/LawFirmContracts/ViewModels/BlankViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/BlankViewModel.cs new file mode 100644 index 0000000..3ab7f80 --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/BlankViewModel.cs @@ -0,0 +1,14 @@ +using LawFirmDataModels.Models; +using System.ComponentModel; + +namespace LawFirmContracts.ViewModels +{ + public class BlankViewModel : IBlankModel + { + public int Id { get; set; } + [DisplayName("Название бланка")] + public string BlankName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs new file mode 100644 index 0000000..4626821 --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs @@ -0,0 +1,18 @@ +using LawFirmDataModels.Models; +using System.ComponentModel; + +namespace LawFirmContracts.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 DocumentBlanks{ + get; + set; + } = new (); + } +} diff --git a/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..59f4972 --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,25 @@ +using LawFirmDataModels.Enums; +using LawFirmDataModels.Models; +using System.ComponentModel; + +namespace LawFirmContracts.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/LawFirmDataModel/Enums/OrderStatus.cs b/LawFirm/LawFirmDataModel/Enums/OrderStatus.cs new file mode 100644 index 0000000..b143f39 --- /dev/null +++ b/LawFirm/LawFirmDataModel/Enums/OrderStatus.cs @@ -0,0 +1,11 @@ +namespace LawFirmDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/LawFirm/LawFirmDataModel/IId.cs b/LawFirm/LawFirmDataModel/IId.cs new file mode 100644 index 0000000..ac340f5 --- /dev/null +++ b/LawFirm/LawFirmDataModel/IId.cs @@ -0,0 +1,7 @@ +namespace LawFirmDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/LawFirm/LawFirmDataModel/LawFirmDataModel.csproj b/LawFirm/LawFirmDataModel/LawFirmDataModel.csproj new file mode 100644 index 0000000..6ea4cf5 --- /dev/null +++ b/LawFirm/LawFirmDataModel/LawFirmDataModel.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/LawFirm/LawFirmDataModel/Models/IBlankModel.cs b/LawFirm/LawFirmDataModel/Models/IBlankModel.cs new file mode 100644 index 0000000..52e26c4 --- /dev/null +++ b/LawFirm/LawFirmDataModel/Models/IBlankModel.cs @@ -0,0 +1,8 @@ +namespace LawFirmDataModels.Models +{ + public interface IBlankModel : IId + { + string BlankName { get; } + double Price { get; } + } +} diff --git a/LawFirm/LawFirmDataModel/Models/IDocumentModel.cs b/LawFirm/LawFirmDataModel/Models/IDocumentModel.cs new file mode 100644 index 0000000..93ca743 --- /dev/null +++ b/LawFirm/LawFirmDataModel/Models/IDocumentModel.cs @@ -0,0 +1,9 @@ +namespace LawFirmDataModels.Models +{ + public interface IDocumentModel : IId + { + string DocumentName { get; } + double Price { get; } + Dictionary DocumentBlanks { get; } + } +} diff --git a/LawFirm/LawFirmDataModel/Models/IOrderModel.cs b/LawFirm/LawFirmDataModel/Models/IOrderModel.cs new file mode 100644 index 0000000..32dab54 --- /dev/null +++ b/LawFirm/LawFirmDataModel/Models/IOrderModel.cs @@ -0,0 +1,14 @@ +using LawFirmDataModels.Enums; + +namespace LawFirmDataModels.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/LawFirmListImplement/DataListSingleton.cs b/LawFirm/LawFirmListImplement/DataListSingleton.cs new file mode 100644 index 0000000..52f5fb5 --- /dev/null +++ b/LawFirm/LawFirmListImplement/DataListSingleton.cs @@ -0,0 +1,26 @@ +using LawFirmListImplement.Models; + +namespace LawFirmListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Blanks { get; set; } + public List Orders { get; set; } + public List Documents { get; set; } + private DataListSingleton() + { + Blanks = new List(); + Orders = new List(); + Documents = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/LawFirm/LawFirmListImplement/Implements/BlankStorage.cs b/LawFirm/LawFirmListImplement/Implements/BlankStorage.cs new file mode 100644 index 0000000..dcefaa3 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Implements/BlankStorage.cs @@ -0,0 +1,102 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmListImplement.Models; + +namespace LawFirmListImplement.Implements +{ + public class BlankStorage : IBlankStorage + { + private readonly DataListSingleton _source; + public BlankStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var blank in _source.Blanks) + { + result.Add(blank.GetViewModel); + } + return result; + } + public List GetFilteredList(BlankSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.BlankName)) + { + return result; + } + foreach (var component in _source.Blanks) + { + if (component.BlankName.Contains(model.BlankName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public BlankViewModel? GetElement(BlankSearchModel model) + { + if (string.IsNullOrEmpty(model.BlankName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Blanks) + { + if ((!string.IsNullOrEmpty(model.BlankName) && + component.BlankName == model.BlankName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public BlankViewModel? Insert(BlankBindingModel model) + { + model.Id = 1; + foreach (var blank in _source.Blanks) + { + if (model.Id <= blank.Id) + { + model.Id = blank.Id + 1; + } + } + var newBlank = Blank.Create(model); + if (newBlank == null) + { + return null; + } + _source.Blanks.Add(newBlank); + return newBlank.GetViewModel; + } + public BlankViewModel? Update(BlankBindingModel model) + { + foreach (var blank in _source.Blanks) + { + if (blank.Id == model.Id) + { + blank.Update(model); + return blank.GetViewModel; + } + } + return null; + } + public BlankViewModel? Delete(BlankBindingModel model) + { + for (int i = 0; i < _source.Blanks.Count; ++i) + { + if (_source.Blanks[i].Id == model.Id) + { + var element = _source.Blanks[i]; + _source.Blanks.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs b/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs new file mode 100644 index 0000000..f0801df --- /dev/null +++ b/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs @@ -0,0 +1,102 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmListImplement.Models; + +namespace LawFirmListImplement.Implements +{ + public class DocumentStorage : IDocumentStorage + { + private readonly DataListSingleton _source; + public DocumentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var blank in _source.Documents) + { + result.Add(blank.GetViewModel); + } + return result; + } + public List GetFilteredList(DocumentSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.DocumentName)) + { + return result; + } + foreach (var component in _source.Documents) + { + if (component.DocumentName.Contains(model.DocumentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public DocumentViewModel? GetElement(DocumentSearchModel model) + { + if (string.IsNullOrEmpty(model.DocumentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Documents) + { + if ((!string.IsNullOrEmpty(model.DocumentName) && + component.DocumentName == model.DocumentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public DocumentViewModel? Insert(DocumentBindingModel model) + { + model.Id = 1; + foreach (var blank in _source.Documents) + { + if (model.Id <= blank.Id) + { + model.Id = blank.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 blank in _source.Documents) + { + if (blank.Id == model.Id) + { + blank.Update(model); + return blank.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/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..73c22d4 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs @@ -0,0 +1,114 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmListImplement.Models; + +namespace LawFirmListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var blank in _source.Orders) + { + result.Add(GetViewModel(blank)); + } + 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(GetViewModel(order)); + } + } + 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 GetViewModel(order); + } + } + 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 GetViewModel(newOrder); + } + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return GetViewModel(order); + } + } + 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 GetViewModel(element); + } + } + return null; + } + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + foreach (var document in _source.Documents) + { + if (document.Id == order.DocumentId) + { + viewModel.DocumentName = document.DocumentName; + break; + } + } + return viewModel; + } + } +} diff --git a/LawFirm/LawFirmListImplement/LawFirmListImplement.csproj b/LawFirm/LawFirmListImplement/LawFirmListImplement.csproj new file mode 100644 index 0000000..d14d455 --- /dev/null +++ b/LawFirm/LawFirmListImplement/LawFirmListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/LawFirm/LawFirmListImplement/Models/Blank.cs b/LawFirm/LawFirmListImplement/Models/Blank.cs new file mode 100644 index 0000000..1be6457 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Models/Blank.cs @@ -0,0 +1,41 @@ +using LawFirmDataModels.Models; +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; + +namespace LawFirmListImplement.Models +{ + public class Blank : IBlankModel + { + public int Id { get; private set; } + public string BlankName { get; private set; } = string.Empty; + public double Price { get; set; } + public static Blank? Create(BlankBindingModel? model) + { + if (model == null) + { + return null; + } + return new Blank() + { + Id = model.Id, + BlankName = model.BlankName, + Price = model.Price + }; + } + public void Update(BlankBindingModel? model) + { + if (model == null) + { + return; + } + BlankName = model.BlankName; + Price = model.Price; + } + public BlankViewModel GetViewModel => new() + { + Id = Id, + BlankName = BlankName, + Price = Price + }; + } +} diff --git a/LawFirm/LawFirmListImplement/Models/Document.cs b/LawFirm/LawFirmListImplement/Models/Document.cs new file mode 100644 index 0000000..2f12d7b --- /dev/null +++ b/LawFirm/LawFirmListImplement/Models/Document.cs @@ -0,0 +1,50 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; + +namespace LawFirmListImplement.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 DocumentBlanks + { + 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, + DocumentBlanks = model.DocumentBlanks + }; + } + public void Update(DocumentBindingModel? model) + { + if (model == null) + { + return; + } + DocumentName = model.DocumentName; + Price = model.Price; + DocumentBlanks = model.DocumentBlanks; + } + public DocumentViewModel GetViewModel => new() + { + Id = Id, + DocumentName = DocumentName, + Price = Price, + DocumentBlanks = DocumentBlanks + }; + + } +} diff --git a/LawFirm/LawFirmListImplement/Models/Order.cs b/LawFirm/LawFirmListImplement/Models/Order.cs new file mode 100644 index 0000000..6140c15 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Models/Order.cs @@ -0,0 +1,54 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Enums; +using LawFirmDataModels.Models; + +namespace LawFirmListImplement.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; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; private set; } = DateTime.Now; + public DateTime? DateImplement { get; private set; } + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + 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; + } + Status = model.Status; + 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/LawFirmView/FormBlank.Designer.cs b/LawFirm/LawFirmView/FormBlank.Designer.cs new file mode 100644 index 0000000..e0c5102 --- /dev/null +++ b/LawFirm/LawFirmView/FormBlank.Designer.cs @@ -0,0 +1,119 @@ +namespace LawFirmView +{ + partial class FormBlank + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelName = new System.Windows.Forms.Label(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 9); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(12, 40); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(38, 15); + this.labelPrice.TabIndex = 1; + this.labelPrice.Text = "Цена:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(86, 6); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(245, 23); + this.textBoxName.TabIndex = 2; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(86, 37); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(245, 23); + this.textBoxPrice.TabIndex = 3; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(175, 69); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 4; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(256, 69); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormBlank + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(343, 103); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelName); + this.Name = "FormBlank"; + this.Text = "Бланк"; + this.Load += new System.EventHandler(this.FormBlank_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormBlank.cs b/LawFirm/LawFirmView/FormBlank.cs new file mode 100644 index 0000000..0949728 --- /dev/null +++ b/LawFirm/LawFirmView/FormBlank.cs @@ -0,0 +1,88 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using Microsoft.Extensions.Logging; + +namespace LawFirmView +{ + public partial class FormBlank : Form + { + private readonly ILogger _logger; + private readonly IBlankLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormBlank(ILogger logger, IBlankLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormBlank_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение бланка"); + var view = _logic.ReadElement(new BlankSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.BlankName; + textBoxPrice.Text = view.Price.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 BlankBindingModel + { + Id = _id ?? 0, + BlankName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.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/FormBlank.resx b/LawFirm/LawFirmView/FormBlank.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormBlank.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/FormBlanks.Designer.cs b/LawFirm/LawFirmView/FormBlanks.Designer.cs new file mode 100644 index 0000000..e92dca0 --- /dev/null +++ b/LawFirm/LawFirmView/FormBlanks.Designer.cs @@ -0,0 +1,118 @@ +namespace LawFirmView +{ + partial class FormBlanks + { + /// + /// 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.buttonChange = new System.Windows.Forms.Button(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonUpdate = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(499, 426); + this.dataGridView.TabIndex = 0; + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(517, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(136, 23); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // buttonChange + // + this.buttonChange.Location = new System.Drawing.Point(517, 41); + this.buttonChange.Name = "buttonChange"; + this.buttonChange.Size = new System.Drawing.Size(136, 23); + this.buttonChange.TabIndex = 2; + this.buttonChange.Text = "Изменить"; + this.buttonChange.UseVisualStyleBackColor = true; + this.buttonChange.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(517, 70); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(136, 23); + this.buttonDelete.TabIndex = 3; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(517, 99); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(136, 23); + this.buttonUpdate.TabIndex = 4; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // FormBlanks + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(663, 450); + this.Controls.Add(this.buttonUpdate); + this.Controls.Add(this.buttonDelete); + this.Controls.Add(this.buttonChange); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormBlanks"; + this.Text = "Бланки"; + this.Load += new System.EventHandler(this.FormBlanks_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonChange; + private Button buttonDelete; + private Button buttonUpdate; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormBlanks.cs b/LawFirm/LawFirmView/FormBlanks.cs new file mode 100644 index 0000000..3c3bce6 --- /dev/null +++ b/LawFirm/LawFirmView/FormBlanks.cs @@ -0,0 +1,102 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace LawFirmView +{ + public partial class FormBlanks : Form + { + private readonly ILogger _logger; + private readonly IBlankLogic _logic; + public FormBlanks(ILogger logger, IBlankLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormBlanks_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["BlankName"].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(FormBlank)); + if (service is FormBlank 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(FormBlank)); + if (service is FormBlank 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 BlankBindingModel + { + 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/FormBlanks.resx b/LawFirm/LawFirmView/FormBlanks.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormBlanks.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.Designer.cs b/LawFirm/LawFirmView/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..5c44730 --- /dev/null +++ b/LawFirm/LawFirmView/FormCreateOrder.Designer.cs @@ -0,0 +1,146 @@ +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() + { + this.labelDocument = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.labelSum = new System.Windows.Forms.Label(); + this.comboBoxDocument = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelDocument + // + this.labelDocument.AutoSize = true; + this.labelDocument.Location = new System.Drawing.Point(12, 9); + this.labelDocument.Name = "labelDocument"; + this.labelDocument.Size = new System.Drawing.Size(64, 15); + this.labelDocument.TabIndex = 0; + this.labelDocument.Text = "Документ:"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 38); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(75, 15); + this.labelCount.TabIndex = 1; + this.labelCount.Text = "Количество:"; + // + // labelSum + // + this.labelSum.AutoSize = true; + this.labelSum.Location = new System.Drawing.Point(12, 67); + this.labelSum.Name = "labelSum"; + this.labelSum.Size = new System.Drawing.Size(48, 15); + this.labelSum.TabIndex = 2; + this.labelSum.Text = "Сумма:"; + // + // comboBoxDocument + // + this.comboBoxDocument.FormattingEnabled = true; + this.comboBoxDocument.Location = new System.Drawing.Point(95, 6); + this.comboBoxDocument.Name = "comboBoxDocument"; + this.comboBoxDocument.Size = new System.Drawing.Size(196, 23); + this.comboBoxDocument.TabIndex = 3; + this.comboBoxDocument.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDocument_SelectedIndexChanged); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(95, 35); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(196, 23); + this.textBoxCount.TabIndex = 4; + this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); + // + // textBoxSum + // + this.textBoxSum.Enabled = false; + this.textBoxSum.Location = new System.Drawing.Point(95, 64); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.ReadOnly = true; + this.textBoxSum.Size = new System.Drawing.Size(196, 23); + this.textBoxSum.TabIndex = 5; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(216, 93); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(135, 93); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(304, 126); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxDocument); + this.Controls.Add(this.labelSum); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelDocument); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelDocument; + private Label labelCount; + private Label labelSum; + private ComboBox comboBoxDocument; + private TextBox textBoxCount; + private TextBox textBoxSum; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormCreateOrder.cs b/LawFirm/LawFirmView/FormCreateOrder.cs new file mode 100644 index 0000000..e971622 --- /dev/null +++ b/LawFirm/LawFirmView/FormCreateOrder.cs @@ -0,0 +1,117 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using Microsoft.Extensions.Logging; + +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; + } + } + 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 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.resx b/LawFirm/LawFirmView/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormCreateOrder.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocument.Designer.cs b/LawFirm/LawFirmView/FormDocument.Designer.cs new file mode 100644 index 0000000..477387e --- /dev/null +++ b/LawFirm/LawFirmView/FormDocument.Designer.cs @@ -0,0 +1,235 @@ +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() + { + this.labelName = new System.Windows.Forms.Label(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.groupBox = new System.Windows.Forms.GroupBox(); + this.buttonUpdate = new System.Windows.Forms.Button(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonChange = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.Blank = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BlankId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSave = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 9); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название:"; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(12, 38); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(70, 15); + this.labelPrice.TabIndex = 1; + this.labelPrice.Text = "Стоимость:"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(98, 6); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(188, 23); + this.textBoxName.TabIndex = 2; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(98, 35); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.ReadOnly = true; + this.textBoxPrice.Size = new System.Drawing.Size(188, 23); + this.textBoxPrice.TabIndex = 3; + // + // groupBox + // + this.groupBox.Controls.Add(this.buttonUpdate); + this.groupBox.Controls.Add(this.buttonDelete); + this.groupBox.Controls.Add(this.buttonChange); + this.groupBox.Controls.Add(this.buttonAdd); + this.groupBox.Controls.Add(this.dataGridView); + this.groupBox.Location = new System.Drawing.Point(12, 73); + this.groupBox.Name = "groupBox"; + this.groupBox.Size = new System.Drawing.Size(592, 342); + this.groupBox.TabIndex = 4; + this.groupBox.TabStop = false; + this.groupBox.Text = "Бланки"; + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(479, 109); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(75, 23); + this.buttonUpdate.TabIndex = 4; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(479, 80); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(75, 23); + this.buttonDelete.TabIndex = 3; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonChange + // + this.buttonChange.Location = new System.Drawing.Point(479, 51); + this.buttonChange.Name = "buttonChange"; + this.buttonChange.Size = new System.Drawing.Size(75, 23); + this.buttonChange.TabIndex = 2; + this.buttonChange.Text = "Изменить"; + this.buttonChange.UseVisualStyleBackColor = true; + this.buttonChange.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(479, 22); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Blank, + this.Count, + this.BlankId}); + this.dataGridView.Location = new System.Drawing.Point(6, 22); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(434, 314); + this.dataGridView.TabIndex = 0; + // + // Blank + // + this.Blank.HeaderText = "Бланк"; + this.Blank.Name = "Blank"; + this.Blank.ReadOnly = true; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.Name = "Count"; + this.Count.ReadOnly = true; + // + // BlankId + // + this.BlankId.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.BlankId.HeaderText = "Id"; + this.BlankId.Name = "BlankId"; + this.BlankId.ReadOnly = true; + this.BlankId.Visible = false; + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(448, 421); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 5; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(529, 421); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormDocument + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(618, 450); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBox); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelName); + this.Name = "FormDocument"; + this.Text = "Документ"; + this.Load += new System.EventHandler(this.FormDocument_Load); + this.groupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private GroupBox groupBox; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonChange; + private Button buttonAdd; + private DataGridView dataGridView; + private Button buttonSave; + private Button buttonCancel; + private DataGridViewTextBoxColumn Blank; + private DataGridViewTextBoxColumn Count; + private DataGridViewTextBoxColumn BlankId; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocument.cs b/LawFirm/LawFirmView/FormDocument.cs new file mode 100644 index 0000000..c44eb56 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocument.cs @@ -0,0 +1,213 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace LawFirmView +{ + public partial class FormDocument : Form + { + private readonly ILogger _logger; + private readonly IDocumentLogic _logic; + private int? _id; + private Dictionary _documentBlanks; + public int Id { set { _id = value; } } + public FormDocument(ILogger logger, IDocumentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _documentBlanks = 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(); + _documentBlanks = view.DocumentBlanks ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки документа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка бланков документа"); + try + { + if (_documentBlanks != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _documentBlanks) + { + dataGridView.Rows.Add(new object[] { pc.Value.Item1.BlankName, pc.Value.Item2, pc.Key }); + } + 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(FormDocumentBlank)); + if (service is FormDocumentBlank form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.BlankModel == null) + { + return; + } + _logger.LogInformation("Добавление нового бланка:{BlankName} - { Count}", + form.BlankModel.BlankName, form.Count); + if (_documentBlanks.ContainsKey(form.Id)) + { + _documentBlanks[form.Id] = (form.BlankModel, + form.Count); + } + else + { + _documentBlanks.Add(form.Id, (form.BlankModel, + form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDocumentBlank)); + if (service is FormDocumentBlank form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _documentBlanks[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.BlankModel == null) + { + return; + } + _logger.LogInformation("Изменение бланка: {BlankName} - { Count}", + form.BlankModel.BlankName, form.Count); + _documentBlanks[form.Id] = (form.BlankModel, 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("Удаление бланка: {BlankName} - { Count}", + dataGridView.SelectedRows[0].Cells[1].Value); + _documentBlanks?.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 (_documentBlanks == null || _documentBlanks.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), + DocumentBlanks = _documentBlanks + }; + 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 _documentBlanks) + { + price += ((elem.Value.Item1?.Price ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/LawFirm/LawFirmView/FormDocument.resx b/LawFirm/LawFirmView/FormDocument.resx new file mode 100644 index 0000000..be1ee73 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocument.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 + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs b/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs new file mode 100644 index 0000000..dcbc492 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs @@ -0,0 +1,119 @@ +namespace LawFirmView +{ + partial class FormDocumentBlank + { + /// + /// 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.labelBlank = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.comboBoxBlank = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.labelCancel = new System.Windows.Forms.Button(); + this.labelSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelBlank + // + this.labelBlank.AutoSize = true; + this.labelBlank.Location = new System.Drawing.Point(12, 9); + this.labelBlank.Name = "labelBlank"; + this.labelBlank.Size = new System.Drawing.Size(43, 15); + this.labelBlank.TabIndex = 0; + this.labelBlank.Text = "Бланк:"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 43); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(75, 15); + this.labelCount.TabIndex = 1; + this.labelCount.Text = "Количество:"; + // + // comboBoxBlank + // + this.comboBoxBlank.FormattingEnabled = true; + this.comboBoxBlank.Location = new System.Drawing.Point(93, 6); + this.comboBoxBlank.Name = "comboBoxBlank"; + this.comboBoxBlank.Size = new System.Drawing.Size(223, 23); + this.comboBoxBlank.TabIndex = 2; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(93, 40); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(223, 23); + this.textBoxCount.TabIndex = 3; + // + // labelCancel + // + this.labelCancel.Location = new System.Drawing.Point(241, 69); + this.labelCancel.Name = "labelCancel"; + this.labelCancel.Size = new System.Drawing.Size(75, 23); + this.labelCancel.TabIndex = 4; + this.labelCancel.Text = "Отмена"; + this.labelCancel.UseVisualStyleBackColor = true; + this.labelCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // labelSave + // + this.labelSave.Location = new System.Drawing.Point(160, 69); + this.labelSave.Name = "labelSave"; + this.labelSave.Size = new System.Drawing.Size(75, 23); + this.labelSave.TabIndex = 5; + this.labelSave.Text = "Сохранить"; + this.labelSave.UseVisualStyleBackColor = true; + this.labelSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormDocumentBlank + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(330, 100); + this.Controls.Add(this.labelSave); + this.Controls.Add(this.labelCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxBlank); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelBlank); + this.Name = "FormDocumentBlank"; + this.Text = "Компонент изделия"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelBlank; + private Label labelCount; + private ComboBox comboBoxBlank; + private TextBox textBoxCount; + private Button labelCancel; + private Button labelSave; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocumentBlank.cs b/LawFirm/LawFirmView/FormDocumentBlank.cs new file mode 100644 index 0000000..6b637e6 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocumentBlank.cs @@ -0,0 +1,80 @@ +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; + +namespace LawFirmView +{ + public partial class FormDocumentBlank : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxBlank.SelectedValue); + } + set + { + comboBoxBlank.SelectedValue = value; + } + } + public IBlankModel? BlankModel + { + 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 FormDocumentBlank(IBlankLogic logic) + { + InitializeComponent(); + + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxBlank.DisplayMember = "BlankName"; + comboBoxBlank.ValueMember = "Id"; + comboBoxBlank.DataSource = _list; + comboBoxBlank.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxBlank.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/FormDocumentBlank.resx b/LawFirm/LawFirmView/FormDocumentBlank.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormDocumentBlank.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/FormDocuments.Designer.cs b/LawFirm/LawFirmView/FormDocuments.Designer.cs new file mode 100644 index 0000000..543bb14 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocuments.Designer.cs @@ -0,0 +1,118 @@ +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.buttonUpdate = new System.Windows.Forms.Button(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonChange = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(517, 99); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(136, 23); + this.buttonUpdate.TabIndex = 9; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(517, 70); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(136, 23); + this.buttonDelete.TabIndex = 8; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonChange + // + this.buttonChange.Location = new System.Drawing.Point(517, 41); + this.buttonChange.Name = "buttonChange"; + this.buttonChange.Size = new System.Drawing.Size(136, 23); + this.buttonChange.TabIndex = 7; + this.buttonChange.Text = "Изменить"; + this.buttonChange.UseVisualStyleBackColor = true; + this.buttonChange.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(517, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(136, 23); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(499, 426); + this.dataGridView.TabIndex = 5; + // + // FormDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(662, 450); + this.Controls.Add(this.buttonUpdate); + this.Controls.Add(this.buttonDelete); + this.Controls.Add(this.buttonChange); + 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 Button buttonUpdate; + private Button buttonDelete; + private Button buttonChange; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormDocuments.cs b/LawFirm/LawFirmView/FormDocuments.cs new file mode 100644 index 0000000..77542b9 --- /dev/null +++ b/LawFirm/LawFirmView/FormDocuments.cs @@ -0,0 +1,103 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +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["DocumentBlanks"].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.Designer.cs b/LawFirm/LawFirmView/FormMain.Designer.cs new file mode 100644 index 0000000..66ad50d --- /dev/null +++ b/LawFirm/LawFirmView/FormMain.Designer.cs @@ -0,0 +1,177 @@ +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.справочникиToolStripMenuItem = 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.buttonUpdate = 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.справочникиToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(800, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.бланкиToolStripMenuItem, + this.документыToolStripMenuItem}); + this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.справочникиToolStripMenuItem.Text = "Справочники"; + // + // бланкиToolStripMenuItem + // + this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem"; + this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.бланкиToolStripMenuItem.Text = "Бланки"; + this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click); + // + // документыToolStripMenuItem + // + this.документыToolStripMenuItem.Name = "документыToolStripMenuItem"; + this.документыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.документыToolStripMenuItem.Text = "Документы"; + this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 27); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(566, 411); + this.dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + this.buttonCreateOrder.Location = new System.Drawing.Point(605, 27); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(168, 23); + 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(605, 56); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(168, 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(605, 85); + this.buttonOrderReady.Name = "buttonOrderReady"; + this.buttonOrderReady.Size = new System.Drawing.Size(168, 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(605, 114); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(168, 23); + this.buttonIssuedOrder.TabIndex = 5; + this.buttonIssuedOrder.Text = "Заказ выдан"; + this.buttonIssuedOrder.UseVisualStyleBackColor = true; + this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(605, 143); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(168, 23); + this.buttonUpdate.TabIndex = 6; + this.buttonUpdate.Text = "Обновить список"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.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(800, 450); + this.Controls.Add(this.buttonUpdate); + 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 = "Юридическая фирма"; + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonUpdate; + private ToolStripMenuItem бланкиToolStripMenuItem; + private ToolStripMenuItem документыToolStripMenuItem; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs new file mode 100644 index 0000000..62fa289 --- /dev/null +++ b/LawFirm/LawFirmView/FormMain.cs @@ -0,0 +1,166 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmDataModels.Enums; +using Microsoft.Extensions.Logging; +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; + } + _logger.LogInformation("Загрузка прошла успешно"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{ + Id = id, + 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()) + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id, + 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()) + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new + OrderBindingModel + { + Id = id, + 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()) + }); + 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 void BlanksToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormBlanks)); + if (service is FormBlanks form) + { + form.ShowDialog(); + } + } + private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); + if (service is FormDocuments form) + { + form.ShowDialog(); + } + } + } +} diff --git a/LawFirm/LawFirmView/FormMain.resx b/LawFirm/LawFirmView/FormMain.resx new file mode 100644 index 0000000..938108a --- /dev/null +++ b/LawFirm/LawFirmView/FormMain.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/LawFirmView.csproj b/LawFirm/LawFirmView/LawFirmView.csproj new file mode 100644 index 0000000..489d098 --- /dev/null +++ b/LawFirm/LawFirmView/LawFirmView.csproj @@ -0,0 +1,23 @@ + + + + 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..ce6f4f6 --- /dev/null +++ b/LawFirm/LawFirmView/Program.cs @@ -0,0 +1,53 @@ +using LawFirmBusinessLogic.BusinessLogics; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.StoragesContracts; +using LawFirmListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + +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