From 4eed09cfffa2d6c08ebfd8c3f29b053b933ee676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B8=D0=BD=D0=B0?= <Алина@DESKTOP-PH8VQJA> Date: Wed, 10 Apr 2024 22:03:41 +0400 Subject: [PATCH] 1 hard laba had finished --- .../BusinessLogics/ShopLogic.cs | 164 ++++++++++ .../BindingModels/ShopBindingModel .cs | 22 ++ .../BusinessLogicsContracts/IShopLogic.cs | 21 ++ .../SearchModels/ShopSearchModel.cs | 14 + .../StoragesContracts/IShopStorage.cs | 16 + .../ViewModels/ShopViewModel.cs | 26 ++ .../TypographyDataModels/Models/IShopModel.cs | 16 + .../DataListSingleton.cs | 3 + .../Implements/ShopStorage .cs | 109 +++++++ .../TypographyListImplement/Models/Shop.cs | 55 ++++ .../TypographyView/FormMain.Designer.cs | 280 ++++++++++-------- Typography/TypographyView/FormMain.cs | 278 +++++++++-------- Typography/TypographyView/FormMain.resx | 62 +++- .../TypographyView/FormShop.Designer.cs | 229 ++++++++++++++ Typography/TypographyView/FormShop.cs | 123 ++++++++ Typography/TypographyView/FormShop.resx | 138 +++++++++ .../TypographyView/FormShops.Designer.cs | 118 ++++++++ Typography/TypographyView/FormShops.cs | 104 +++++++ Typography/TypographyView/FormShops.resx | 60 ++++ .../TypographyView/FormSupplies.Designer.cs | 143 +++++++++ Typography/TypographyView/FormSupplies.cs | 99 +++++++ Typography/TypographyView/FormSupplies.resx | 60 ++++ Typography/TypographyView/Program.cs | 9 +- 23 files changed, 1888 insertions(+), 261 deletions(-) create mode 100644 Typography/TypographyBusinessLogic/BusinessLogics/ShopLogic.cs create mode 100644 Typography/TypographyContracts/BindingModels/ShopBindingModel .cs create mode 100644 Typography/TypographyContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 Typography/TypographyContracts/SearchModels/ShopSearchModel.cs create mode 100644 Typography/TypographyContracts/StoragesContracts/IShopStorage.cs create mode 100644 Typography/TypographyContracts/ViewModels/ShopViewModel.cs create mode 100644 Typography/TypographyDataModels/Models/IShopModel.cs create mode 100644 Typography/TypographyListImplement/Implements/ShopStorage .cs create mode 100644 Typography/TypographyListImplement/Models/Shop.cs create mode 100644 Typography/TypographyView/FormShop.Designer.cs create mode 100644 Typography/TypographyView/FormShop.cs create mode 100644 Typography/TypographyView/FormShop.resx create mode 100644 Typography/TypographyView/FormShops.Designer.cs create mode 100644 Typography/TypographyView/FormShops.cs create mode 100644 Typography/TypographyView/FormShops.resx create mode 100644 Typography/TypographyView/FormSupplies.Designer.cs create mode 100644 Typography/TypographyView/FormSupplies.cs create mode 100644 Typography/TypographyView/FormSupplies.resx diff --git a/Typography/TypographyBusinessLogic/BusinessLogics/ShopLogic.cs b/Typography/TypographyBusinessLogic/BusinessLogics/ShopLogic.cs new file mode 100644 index 0000000..a42e032 --- /dev/null +++ b/Typography/TypographyBusinessLogic/BusinessLogics/ShopLogic.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using TypographyContracts.BindingModels; +using TypographyContracts.BusinessLogicsContracts; +using TypographyContracts.SearchModels; +using TypographyContracts.StoragesContracts; +using TypographyContracts.ViewModels; + +namespace TypographyBusinessLogic.BusinessLogics +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + + public ShopLogic(ILogger logger, IShopStorage shopStorage) + { + _logger = logger; + _shopStorage = shopStorage; + } + + public List? ReadList(ShopSearchModel? model) + { + _logger.LogInformation("ReadList. ShopName: {ShopName}. Id:{Id}", model?.ShopName, model?.Id); + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public ShopViewModel? ReadElement(ShopSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ShopName: {ShopName}. Id: {Id}", model.ShopName, model.Id); + var element = _shopStorage.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(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(ShopBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_shopStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public bool SupplyPrinteds(ShopSearchModel shop, PrintedBindingModel printed, int amount) + { + if (shop == null) + { + throw new ArgumentNullException(nameof(shop)); + } + if (printed == null) + { + throw new ArgumentNullException(nameof(printed)); + } + if (amount <= 0) + { + throw new ArgumentNullException("Кол-во печатных изделий должно быть больше 0", nameof(amount)); + } + + var shopView = _shopStorage.GetElement(shop); + if (shopView == null) + { + _logger.LogWarning("SupplyPrinteds. Shop not found"); + return false; + } + _logger.LogInformation("SupplyPrinteds. Shop find. Id: {Id}", shopView.Id); + + if (shopView.ShopPrinteds.TryGetValue(printed.Id, out var shopPrinted)) + { + shopView.ShopPrinteds[printed.Id] = (printed, shopPrinted.Item2 + amount); + } + else + { + shopView.ShopPrinteds.Add(printed.Id, (printed, amount)); + } + + if (_shopStorage.Update(new ShopBindingModel() + { + Id = shopView.Id, + ShopName = shopView.ShopName, + Address = shopView.Address, + OpeningDate = shopView.OpeningDate, + ShopPrinteds = shopView.ShopPrinteds + }) == null) + { + _logger.LogWarning("SupplyPrinteds. Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(ShopBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName)); + } + if (string.IsNullOrEmpty(model.Address)) + { + throw new ArgumentNullException("Нет адреса магазина", nameof(model.Address)); + } + _logger.LogInformation("Shop. ShopName: {ShopName}. Addres: {Addres}. Id: {Id}", + model.ShopName, model.Address, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } + } +} diff --git a/Typography/TypographyContracts/BindingModels/ShopBindingModel .cs b/Typography/TypographyContracts/BindingModels/ShopBindingModel .cs new file mode 100644 index 0000000..aa6a644 --- /dev/null +++ b/Typography/TypographyContracts/BindingModels/ShopBindingModel .cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TypographyDataModels.Models; + +namespace TypographyContracts.BindingModels +{ + public class ShopBindingModel : IShopModel + { + public int Id { get; set; } + + public string ShopName { get; set; } = string.Empty; + + public string Address { get; set; } = string.Empty; + + public DateTime OpeningDate { get; set; } = DateTime.Now; + + public Dictionary ShopPrinteds { get; set; } = new(); + } +} diff --git a/Typography/TypographyContracts/BusinessLogicsContracts/IShopLogic.cs b/Typography/TypographyContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..56e0aa0 --- /dev/null +++ b/Typography/TypographyContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TypographyContracts.BindingModels; +using TypographyContracts.SearchModels; +using TypographyContracts.ViewModels; + +namespace TypographyContracts.BusinessLogicsContracts +{ + public interface IShopLogic + { + List? ReadList(ShopSearchModel? model); + ShopViewModel? ReadElement(ShopSearchModel model); + bool Create(ShopBindingModel model); + bool Update(ShopBindingModel model); + bool Delete(ShopBindingModel model); + bool SupplyPrinteds(ShopSearchModel shop, PrintedBindingModel printed, int amount); + } +} diff --git a/Typography/TypographyContracts/SearchModels/ShopSearchModel.cs b/Typography/TypographyContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..c76016f --- /dev/null +++ b/Typography/TypographyContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TypographyContracts.SearchModels +{ + public class ShopSearchModel + { + public int? Id { get; set; } + public string? ShopName { get; set; } + } +} diff --git a/Typography/TypographyContracts/StoragesContracts/IShopStorage.cs b/Typography/TypographyContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..9556633 --- /dev/null +++ b/Typography/TypographyContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,16 @@ +using TypographyContracts.BindingModels; +using TypographyContracts.SearchModels; +using TypographyContracts.ViewModels; + +namespace TypographyContracts.StoragesContracts +{ + public interface IShopStorage + { + List GetFullList(); + List GetFilteredList(ShopSearchModel model); + ShopViewModel? GetElement(ShopSearchModel model); + ShopViewModel? Insert(ShopBindingModel model); + ShopViewModel? Update(ShopBindingModel model); + ShopViewModel? Delete(ShopBindingModel model); + } +} diff --git a/Typography/TypographyContracts/ViewModels/ShopViewModel.cs b/Typography/TypographyContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..8099d05 --- /dev/null +++ b/Typography/TypographyContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TypographyDataModels.Models; + +namespace TypographyContracts.ViewModels +{ + public class ShopViewModel : IShopModel + { + public int Id { get; set; } + + [DisplayName("Название магазина")] + public string ShopName { get; set; } = string.Empty; + + [DisplayName("Адрес")] + public string Address { get; set; } = string.Empty; + + [DisplayName("Дата открытия")] + public DateTime OpeningDate { get; set; } = DateTime.Now; + + public Dictionary ShopPrinteds { get; set; } = new(); + } +} diff --git a/Typography/TypographyDataModels/Models/IShopModel.cs b/Typography/TypographyDataModels/Models/IShopModel.cs new file mode 100644 index 0000000..50df113 --- /dev/null +++ b/Typography/TypographyDataModels/Models/IShopModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TypographyDataModels.Models +{ + public interface IShopModel : IId + { + string ShopName { get; } + string Address { get; } + DateTime OpeningDate { get; } + Dictionary ShopPrinteds { get; } + } +} diff --git a/Typography/TypographyListImplement/DataListSingleton.cs b/Typography/TypographyListImplement/DataListSingleton.cs index 5279bda..141f859 100644 --- a/Typography/TypographyListImplement/DataListSingleton.cs +++ b/Typography/TypographyListImplement/DataListSingleton.cs @@ -14,11 +14,14 @@ namespace TypographyListImplement public List Orders { get; set; } public List Printeds { get; set; } + public List Shops { get; set; } + private DataListSingleton() { Components = new List(); Orders = new List(); Printeds = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() diff --git a/Typography/TypographyListImplement/Implements/ShopStorage .cs b/Typography/TypographyListImplement/Implements/ShopStorage .cs new file mode 100644 index 0000000..7ac6108 --- /dev/null +++ b/Typography/TypographyListImplement/Implements/ShopStorage .cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TypographyContracts.BindingModels; +using TypographyContracts.SearchModels; +using TypographyContracts.StoragesContracts; +using TypographyContracts.ViewModels; +using TypographyListImplement.Models; + +namespace TypographyListImplement.Implements +{ + public class ShopStorage : IShopStorage + { + private readonly DataListSingleton _source; + + public ShopStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + foreach (var shop in _source.Shops) + { + result.Add(shop.GetViewModel); + } + return result; + } + public List GetFilteredList(ShopSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ShopName)) + { + return result; + } + foreach (var shop in _source.Shops) + { + if (shop.ShopName.Contains(model.ShopName)) + { + result.Add(shop.GetViewModel); + } + } + return result; + } + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) + { + return null; + } + foreach (var shop in _source.Shops) + { + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || + (model.Id.HasValue && shop.Id == model.Id)) + { + return shop.GetViewModel; + } + } + return null; + } + public ShopViewModel? Insert(ShopBindingModel model) + { + model.Id = 1; + foreach (var shop in _source.Shops) + { + if (model.Id <= shop.Id) + { + model.Id = shop.Id + 1; + } + } + var newShop = Shop.Create(model); + if (newShop == null) + { + return null; + } + _source.Shops.Add(newShop); + return newShop.GetViewModel; + } + public ShopViewModel? Update(ShopBindingModel model) + { + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + shop.Update(model); + return shop.GetViewModel; + } + } + return null; + } + + public ShopViewModel? Delete(ShopBindingModel model) + { + for (int i = 0; i < _source.Shops.Count; ++i) + { + if (_source.Shops[i].Id == model.Id) + { + var element = _source.Shops[i]; + _source.Shops.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/Typography/TypographyListImplement/Models/Shop.cs b/Typography/TypographyListImplement/Models/Shop.cs new file mode 100644 index 0000000..a62caf8 --- /dev/null +++ b/Typography/TypographyListImplement/Models/Shop.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TypographyContracts.BindingModels; +using TypographyContracts.ViewModels; +using TypographyDataModels.Models; + +namespace TypographyListImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Address { get; private set; } = string.Empty; + public DateTime OpeningDate { get; private set; } = DateTime.Now; + public Dictionary ShopPrinteds { get; private set; } = new(); + + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + OpeningDate = model.OpeningDate, + ShopPrinteds = new() + }; + } + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Address = model.Address; + OpeningDate = model.OpeningDate; + ShopPrinteds = model.ShopPrinteds; + } + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + OpeningDate = OpeningDate, + ShopPrinteds = ShopPrinteds + }; + } +} diff --git a/Typography/TypographyView/FormMain.Designer.cs b/Typography/TypographyView/FormMain.Designer.cs index 696e4d3..bc93e30 100644 --- a/Typography/TypographyView/FormMain.Designer.cs +++ b/Typography/TypographyView/FormMain.Designer.cs @@ -1,24 +1,24 @@ namespace TypographyView { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + 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); - } + /// + /// 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 @@ -28,153 +28,175 @@ /// private void InitializeComponent() { - this.buttonCreateOrder = new System.Windows.Forms.Button(); - this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); - this.buttonIssuedOrder = new System.Windows.Forms.Button(); - this.dataGridViewOrders = new System.Windows.Forms.DataGridView(); - this.buttonRef = new System.Windows.Forms.Button(); - this.buttonOrderReady = new System.Windows.Forms.Button(); - this.menuStrip = new System.Windows.Forms.MenuStrip(); - this.directoriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.printedsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridViewOrders)).BeginInit(); - this.menuStrip.SuspendLayout(); - this.SuspendLayout(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonIssuedOrder = new Button(); + dataGridViewOrders = new DataGridView(); + buttonRef = new Button(); + buttonOrderReady = new Button(); + menuStrip = new MenuStrip(); + directoriesToolStripMenuItem = new ToolStripMenuItem(); + componentsToolStripMenuItem = new ToolStripMenuItem(); + printedsToolStripMenuItem = new ToolStripMenuItem(); + shopsToolStripMenuItem = new ToolStripMenuItem(); + supplyToolStripMenuItem = new ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit(); + menuStrip.SuspendLayout(); + SuspendLayout(); // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(1100, 31); - this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(203, 29); - this.buttonCreateOrder.TabIndex = 0; - this.buttonCreateOrder.Text = "Создать заказ"; - this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + buttonCreateOrder.Location = new Point(1224, 70); + buttonCreateOrder.Margin = new Padding(5, 5, 5, 5); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(330, 46); + buttonCreateOrder.TabIndex = 0; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; // // buttonTakeOrderInWork // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1100, 66); - this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(203, 29); - this.buttonTakeOrderInWork.TabIndex = 1; - this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; - this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; - this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + buttonTakeOrderInWork.Location = new Point(1224, 162); + buttonTakeOrderInWork.Margin = new Padding(5, 5, 5, 5); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(330, 46); + buttonTakeOrderInWork.TabIndex = 1; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; // // buttonIssuedOrder // - this.buttonIssuedOrder.Location = new System.Drawing.Point(1100, 136); - this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(203, 29); - this.buttonIssuedOrder.TabIndex = 2; - this.buttonIssuedOrder.Text = "Заказ выдан"; - this.buttonIssuedOrder.UseVisualStyleBackColor = true; - this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + buttonIssuedOrder.Location = new Point(1224, 379); + buttonIssuedOrder.Margin = new Padding(5, 5, 5, 5); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(330, 46); + buttonIssuedOrder.TabIndex = 2; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += ButtonIssuedOrder_Click; // // dataGridViewOrders // - this.dataGridViewOrders.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; - this.dataGridViewOrders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridViewOrders.Location = new System.Drawing.Point(0, 31); - this.dataGridViewOrders.Name = "dataGridViewOrders"; - this.dataGridViewOrders.RowHeadersVisible = false; - this.dataGridViewOrders.RowHeadersWidth = 51; - this.dataGridViewOrders.RowTemplate.Height = 29; - this.dataGridViewOrders.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridViewOrders.Size = new System.Drawing.Size(1078, 402); - this.dataGridViewOrders.TabIndex = 3; + dataGridViewOrders.BackgroundColor = SystemColors.ControlLightLight; + dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewOrders.Location = new Point(0, 50); + dataGridViewOrders.Margin = new Padding(5, 5, 5, 5); + dataGridViewOrders.Name = "dataGridViewOrders"; + dataGridViewOrders.RowHeadersVisible = false; + dataGridViewOrders.RowHeadersWidth = 51; + dataGridViewOrders.RowTemplate.Height = 29; + dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewOrders.Size = new Size(1156, 506); + dataGridViewOrders.TabIndex = 3; // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(1100, 171); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(203, 29); - this.buttonRef.TabIndex = 4; - this.buttonRef.Text = "Обновить список"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + buttonRef.Location = new Point(1224, 487); + buttonRef.Margin = new Padding(5, 5, 5, 5); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(330, 46); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; // // buttonOrderReady // - this.buttonOrderReady.Location = new System.Drawing.Point(1100, 101); - this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(203, 29); - this.buttonOrderReady.TabIndex = 5; - this.buttonOrderReady.Text = "Заказ готов"; - this.buttonOrderReady.UseVisualStyleBackColor = true; - this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + buttonOrderReady.Location = new Point(1224, 265); + buttonOrderReady.Margin = new Padding(5, 5, 5, 5); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(330, 46); + buttonOrderReady.TabIndex = 5; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += ButtonOrderReady_Click; // // menuStrip // - this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); - this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.directoriesToolStripMenuItem}); - this.menuStrip.Location = new System.Drawing.Point(0, 0); - this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(1315, 28); - this.menuStrip.TabIndex = 6; - this.menuStrip.Text = "menuStrip1"; + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { directoriesToolStripMenuItem, supplyToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Padding = new Padding(10, 3, 0, 3); + menuStrip.Size = new Size(1580, 42); + menuStrip.TabIndex = 6; + menuStrip.Text = "menuStrip1"; // // directoriesToolStripMenuItem // - this.directoriesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.componentsToolStripMenuItem, - this.printedsToolStripMenuItem}); - this.directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem"; - this.directoriesToolStripMenuItem.Size = new System.Drawing.Size(117, 24); - this.directoriesToolStripMenuItem.Text = "Справочники"; + directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, printedsToolStripMenuItem, shopsToolStripMenuItem }); + directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem"; + directoriesToolStripMenuItem.Size = new Size(184, 36); + directoriesToolStripMenuItem.Text = "Справочники"; // // componentsToolStripMenuItem // - this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; - this.componentsToolStripMenuItem.Size = new System.Drawing.Size(237, 26); - this.componentsToolStripMenuItem.Text = "Компоненты"; - this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); + componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + componentsToolStripMenuItem.Size = new Size(377, 44); + componentsToolStripMenuItem.Text = "Компоненты"; + componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // // printedsToolStripMenuItem // - this.printedsToolStripMenuItem.Name = "printedsToolStripMenuItem"; - this.printedsToolStripMenuItem.Size = new System.Drawing.Size(237, 26); - this.printedsToolStripMenuItem.Text = "Печатная продукция"; - this.printedsToolStripMenuItem.Click += new System.EventHandler(this.PrintedsToolStripMenuItem_Click); + printedsToolStripMenuItem.Name = "printedsToolStripMenuItem"; + printedsToolStripMenuItem.Size = new Size(377, 44); + printedsToolStripMenuItem.Text = "Печатная продукция"; + printedsToolStripMenuItem.Click += PrintedsToolStripMenuItem_Click; + // + // shopsToolStripMenuItem + // + shopsToolStripMenuItem.Name = "shopsToolStripMenuItem"; + shopsToolStripMenuItem.Size = new Size(377, 44); + shopsToolStripMenuItem.Text = "Магазины"; + shopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; + // + // supplyToolStripMenuItem + // + supplyToolStripMenuItem.Name = "supplyToolStripMenuItem"; + supplyToolStripMenuItem.Size = new Size(282, 36); + supplyToolStripMenuItem.Text = "Пополнение магазина"; + supplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1315, 433); - this.Controls.Add(this.buttonOrderReady); - this.Controls.Add(this.buttonRef); - this.Controls.Add(this.dataGridViewOrders); - this.Controls.Add(this.buttonIssuedOrder); - this.Controls.Add(this.buttonTakeOrderInWork); - this.Controls.Add(this.buttonCreateOrder); - this.Controls.Add(this.menuStrip); - this.MainMenuStrip = this.menuStrip; - this.Name = "FormMain"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Типография"; - this.Load += new System.EventHandler(this.FormMain_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridViewOrders)).EndInit(); - this.menuStrip.ResumeLayout(false); - this.menuStrip.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1580, 605); + Controls.Add(buttonOrderReady); + Controls.Add(buttonRef); + Controls.Add(dataGridViewOrders); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Margin = new Padding(5, 5, 5, 5); + Name = "FormMain"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Типография"; + Load += FormMain_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit(); + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); } #endregion private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonIssuedOrder; - private DataGridView dataGridViewOrders; - private Button buttonRef; - private Button buttonOrderReady; - private MenuStrip menuStrip; - private ToolStripMenuItem directoriesToolStripMenuItem; - private ToolStripMenuItem componentsToolStripMenuItem; - private ToolStripMenuItem printedsToolStripMenuItem; - } + private Button buttonTakeOrderInWork; + private Button buttonIssuedOrder; + private DataGridView dataGridViewOrders; + private Button buttonRef; + private Button buttonOrderReady; + private MenuStrip menuStrip; + private ToolStripMenuItem directoriesToolStripMenuItem; + private ToolStripMenuItem componentsToolStripMenuItem; + private ToolStripMenuItem printedsToolStripMenuItem; + private ToolStripMenuItem shopsToolStripMenuItem; + private ToolStripMenuItem supplyToolStripMenuItem; + } } \ No newline at end of file diff --git a/Typography/TypographyView/FormMain.cs b/Typography/TypographyView/FormMain.cs index 67b11cd..ac8b728 100644 --- a/Typography/TypographyView/FormMain.cs +++ b/Typography/TypographyView/FormMain.cs @@ -5,144 +5,162 @@ using Microsoft.Extensions.Logging; namespace TypographyView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - } + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } - private void LoadData() - { - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridViewOrders.DataSource = list; - dataGridViewOrders.Columns["PrintedId"].Visible = false; - dataGridViewOrders.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + private void LoadData() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridViewOrders.DataSource = list; + dataGridViewOrders.Columns["PrintedId"].Visible = false; + dataGridViewOrders.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } - private void PrintedsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds)); - if (service is FormPrinteds form) - { - form.ShowDialog(); - } - } + private void PrintedsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds)); + if (service is FormPrinteds form) + { + form.ShowDialog(); + } + } - private void ButtonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } + private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } - private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridViewOrders.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + private void SupplyToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSupplies)); + if (service is FormSupplies form) + { + form.ShowDialog(); + } + } - private void ButtonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridViewOrders.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - try - { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } - private void ButtonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridViewOrders.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - try - { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridViewOrders.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } - } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridViewOrders.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridViewOrders.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } } \ No newline at end of file diff --git a/Typography/TypographyView/FormMain.resx b/Typography/TypographyView/FormMain.resx index 81a9e3d..6c82d08 100644 --- a/Typography/TypographyView/FormMain.resx +++ b/Typography/TypographyView/FormMain.resx @@ -1,4 +1,64 @@ - + + + diff --git a/Typography/TypographyView/FormShop.Designer.cs b/Typography/TypographyView/FormShop.Designer.cs new file mode 100644 index 0000000..9b3f2e9 --- /dev/null +++ b/Typography/TypographyView/FormShop.Designer.cs @@ -0,0 +1,229 @@ +namespace TypographyView +{ + partial class FormShop + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonSave = new Button(); + groupBoxPrinteds = new GroupBox(); + dataGridViewPrinteds = new DataGridView(); + dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn(); + ColumnPrintedName = new DataGridViewTextBoxColumn(); + ColumnAmount = new DataGridViewTextBoxColumn(); + buttonRef = new Button(); + labelName = new Label(); + labelAddress = new Label(); + textBoxAddress = new TextBox(); + textBoxName = new TextBox(); + labelDate = new Label(); + dateTimePickerOpening = new DateTimePicker(); + groupBoxPrinteds.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).BeginInit(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(1086, 885); + buttonCancel.Margin = new Padding(5, 5, 5, 5); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(166, 46); + buttonCancel.TabIndex = 0; + buttonCancel.Text = "Закрыть"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(910, 885); + buttonSave.Margin = new Padding(5, 5, 5, 5); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(166, 46); + buttonSave.TabIndex = 1; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // groupBoxPrinteds + // + groupBoxPrinteds.Controls.Add(dataGridViewPrinteds); + groupBoxPrinteds.Controls.Add(buttonRef); + groupBoxPrinteds.Location = new Point(20, 178); + groupBoxPrinteds.Margin = new Padding(5, 5, 5, 5); + groupBoxPrinteds.Name = "groupBoxPrinteds"; + groupBoxPrinteds.Padding = new Padding(5, 5, 5, 5); + groupBoxPrinteds.Size = new Size(1232, 698); + groupBoxPrinteds.TabIndex = 2; + groupBoxPrinteds.TabStop = false; + groupBoxPrinteds.Text = "Печатная продукция"; + // + // dataGridViewPrinteds + // + dataGridViewPrinteds.BackgroundColor = SystemColors.ControlLightLight; + dataGridViewPrinteds.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewPrinteds.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, ColumnPrintedName, ColumnAmount }); + dataGridViewPrinteds.GridColor = SystemColors.ControlLightLight; + dataGridViewPrinteds.Location = new Point(10, 42); + dataGridViewPrinteds.Margin = new Padding(5, 5, 5, 5); + dataGridViewPrinteds.Name = "dataGridViewPrinteds"; + dataGridViewPrinteds.RowHeadersVisible = false; + dataGridViewPrinteds.RowHeadersWidth = 51; + dataGridViewPrinteds.RowTemplate.Height = 29; + dataGridViewPrinteds.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewPrinteds.Size = new Size(1037, 640); + dataGridViewPrinteds.TabIndex = 4; + // + // dataGridViewTextBoxColumn1 + // + dataGridViewTextBoxColumn1.HeaderText = "Id"; + dataGridViewTextBoxColumn1.MinimumWidth = 6; + dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + dataGridViewTextBoxColumn1.Visible = false; + dataGridViewTextBoxColumn1.Width = 125; + // + // ColumnPrintedName + // + ColumnPrintedName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnPrintedName.HeaderText = "Печатное изделие"; + ColumnPrintedName.MinimumWidth = 6; + ColumnPrintedName.Name = "ColumnPrintedName"; + // + // ColumnAmount + // + ColumnAmount.HeaderText = "Количество"; + ColumnAmount.MinimumWidth = 6; + ColumnAmount.Name = "ColumnAmount"; + ColumnAmount.Width = 125; + // + // buttonRef + // + buttonRef.Location = new Point(1056, 42); + buttonRef.Margin = new Padding(5, 5, 5, 5); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(166, 46); + buttonRef.TabIndex = 3; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(20, 24); + labelName.Margin = new Padding(5, 0, 5, 0); + labelName.Name = "labelName"; + labelName.Size = new Size(120, 32); + labelName.TabIndex = 0; + labelName.Text = "Название"; + // + // labelAddress + // + labelAddress.AutoSize = true; + labelAddress.Location = new Point(20, 77); + labelAddress.Margin = new Padding(5, 0, 5, 0); + labelAddress.Name = "labelAddress"; + labelAddress.Size = new Size(80, 32); + labelAddress.TabIndex = 1; + labelAddress.Text = "Адрес"; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(208, 72); + textBoxAddress.Margin = new Padding(5, 5, 5, 5); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(336, 39); + textBoxAddress.TabIndex = 3; + // + // textBoxName + // + textBoxName.Location = new Point(208, 24); + textBoxName.Margin = new Padding(5, 5, 5, 5); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(336, 39); + textBoxName.TabIndex = 4; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(20, 133); + labelDate.Margin = new Padding(5, 0, 5, 0); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(175, 32); + labelDate.TabIndex = 5; + labelDate.Text = "Дата открытия"; + // + // dateTimePickerOpening + // + dateTimePickerOpening.Location = new Point(208, 125); + dateTimePickerOpening.Margin = new Padding(5, 5, 5, 5); + dateTimePickerOpening.Name = "dateTimePickerOpening"; + dateTimePickerOpening.Size = new Size(336, 39); + dateTimePickerOpening.TabIndex = 6; + // + // FormShop + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1271, 949); + Controls.Add(dateTimePickerOpening); + Controls.Add(labelDate); + Controls.Add(labelName); + Controls.Add(labelAddress); + Controls.Add(textBoxName); + Controls.Add(textBoxAddress); + Controls.Add(groupBoxPrinteds); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Margin = new Padding(5, 5, 5, 5); + Name = "FormShop"; + StartPosition = FormStartPosition.CenterParent; + Text = "Магазин"; + Load += FormShop_Load; + groupBoxPrinteds.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private GroupBox groupBoxPrinteds; + private Label labelName; + private Label labelAddress; + private TextBox textBoxAddress; + private TextBox textBoxName; + private Button buttonRef; + private DataGridView dataGridViewPrinteds; + private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; + private DataGridViewTextBoxColumn ColumnPrintedName; + private DataGridViewTextBoxColumn ColumnAmount; + private Label labelDate; + private DateTimePicker dateTimePickerOpening; + } +} \ No newline at end of file diff --git a/Typography/TypographyView/FormShop.cs b/Typography/TypographyView/FormShop.cs new file mode 100644 index 0000000..992e367 --- /dev/null +++ b/Typography/TypographyView/FormShop.cs @@ -0,0 +1,123 @@ +using TypographyContracts.BindingModels; +using TypographyContracts.BusinessLogicsContracts; +using TypographyContracts.SearchModels; +using TypographyDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace TypographyView +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + private int? _id; + private Dictionary _shopPrinteds; + + public int Id { set { _id = value; } } + + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _shopPrinteds = new Dictionary(); + } + + private void FormShop_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка магазина"); + try + { + var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value }); + if (view != null) + { + textBoxName.Text = view.ShopName; + textBoxAddress.Text = view.Address; + dateTimePickerOpening.Value = view.OpeningDate; + _shopPrinteds = view.ShopPrinteds ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка печатной продукции магазина"); + try + { + if (_shopPrinteds != null) + { + dataGridViewPrinteds.Rows.Clear(); + foreach (var pr in _shopPrinteds) + { + dataGridViewPrinteds.Rows.Add(new object[] { pr.Key, + pr.Value.Item1.PrintedName, pr.Value.Item2 }); + } + } + } + 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 ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAddress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Address = textBoxAddress.Text, + OpeningDate = dateTimePickerOpening.Value.Date, + ShopPrinteds = _shopPrinteds + }; + 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(); + } + } +} \ No newline at end of file diff --git a/Typography/TypographyView/FormShop.resx b/Typography/TypographyView/FormShop.resx new file mode 100644 index 0000000..b92e6b9 --- /dev/null +++ b/Typography/TypographyView/FormShop.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Typography/TypographyView/FormShops.Designer.cs b/Typography/TypographyView/FormShops.Designer.cs new file mode 100644 index 0000000..14f349c --- /dev/null +++ b/Typography/TypographyView/FormShops.Designer.cs @@ -0,0 +1,118 @@ +namespace TypographyView +{ + partial class FormShops + { + /// + /// 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() + { + dataGridViewShops = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewShops).BeginInit(); + SuspendLayout(); + // + // dataGridViewShops + // + dataGridViewShops.BackgroundColor = SystemColors.ControlLightLight; + dataGridViewShops.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewShops.Location = new Point(1, 1); + dataGridViewShops.Name = "dataGridViewShops"; + dataGridViewShops.RowHeadersVisible = false; + dataGridViewShops.RowHeadersWidth = 51; + dataGridViewShops.RowTemplate.Height = 29; + dataGridViewShops.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewShops.Size = new Size(650, 402); + dataGridViewShops.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(668, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(102, 29); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(668, 47); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(102, 29); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.Location = new Point(668, 82); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(102, 29); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonRef + // + buttonRef.Location = new Point(668, 117); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(102, 29); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // FormShops + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(782, 403); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridViewShops); + Name = "FormShops"; + StartPosition = FormStartPosition.CenterParent; + Text = "Магазины"; + Load += FormShops_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewShops).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewShops; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/Typography/TypographyView/FormShops.cs b/Typography/TypographyView/FormShops.cs new file mode 100644 index 0000000..06f8390 --- /dev/null +++ b/Typography/TypographyView/FormShops.cs @@ -0,0 +1,104 @@ +using TypographyContracts.BindingModels; +using TypographyContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace TypographyView +{ + public partial class FormShops : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + + public FormShops(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormShops_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridViewShops.DataSource = list; + dataGridViewShops.Columns["Id"].Visible = false; + dataGridViewShops.Columns["ShopPrinteds"].Visible = false; + dataGridViewShops.Columns["ShopName"].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(FormShop)); + if (service is FormShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridViewShops.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + form.Id = Convert.ToInt32(dataGridViewShops.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridViewShops.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == + DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridViewShops.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление магазина"); + try + { + if (!_logic.Delete(new ShopBindingModel { Id = id })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} \ No newline at end of file diff --git a/Typography/TypographyView/FormShops.resx b/Typography/TypographyView/FormShops.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Typography/TypographyView/FormShops.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/Typography/TypographyView/FormSupplies.Designer.cs b/Typography/TypographyView/FormSupplies.Designer.cs new file mode 100644 index 0000000..156580d --- /dev/null +++ b/Typography/TypographyView/FormSupplies.Designer.cs @@ -0,0 +1,143 @@ +namespace TypographyView +{ + partial class FormSupplies + { + /// + /// 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() + { + labelShop = new Label(); + labelPrinted = new Label(); + labelAmount = new Label(); + comboBoxShop = new ComboBox(); + comboBoxPrinted = new ComboBox(); + textBoxAmount = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelShop + // + labelShop.AutoSize = true; + labelShop.Location = new Point(12, 15); + labelShop.Name = "labelShop"; + labelShop.Size = new Size(69, 20); + labelShop.TabIndex = 0; + labelShop.Text = "Магазин"; + // + // labelPrinted + // + labelPrinted.AutoSize = true; + labelPrinted.Location = new Point(12, 49); + labelPrinted.Name = "labelPrinted"; + labelPrinted.Size = new Size(154, 20); + labelPrinted.TabIndex = 1; + labelPrinted.Text = "Печатная продукция"; + // + // labelAmount + // + labelAmount.AutoSize = true; + labelAmount.Location = new Point(12, 83); + labelAmount.Name = "labelAmount"; + labelAmount.Size = new Size(90, 20); + labelAmount.TabIndex = 2; + labelAmount.Text = "Количество"; + // + // comboBoxShop + // + comboBoxShop.FormattingEnabled = true; + comboBoxShop.Location = new Point(172, 12); + comboBoxShop.Name = "comboBoxShop"; + comboBoxShop.Size = new Size(240, 28); + comboBoxShop.TabIndex = 3; + // + // comboBoxPrinted + // + comboBoxPrinted.FormattingEnabled = true; + comboBoxPrinted.Location = new Point(172, 46); + comboBoxPrinted.Name = "comboBoxPrinted"; + comboBoxPrinted.Size = new Size(240, 28); + comboBoxPrinted.TabIndex = 4; + // + // textBoxAmount + // + textBoxAmount.Location = new Point(172, 80); + textBoxAmount.Name = "textBoxAmount"; + textBoxAmount.Size = new Size(240, 27); + textBoxAmount.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(202, 112); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(102, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(310, 112); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(102, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormSupplies + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(427, 153); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxAmount); + Controls.Add(comboBoxPrinted); + Controls.Add(comboBoxShop); + Controls.Add(labelAmount); + Controls.Add(labelPrinted); + Controls.Add(labelShop); + Name = "FormSupplies"; + StartPosition = FormStartPosition.CenterParent; + Text = "Поставка"; + Load += FormSupplies_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelShop; + private Label labelPrinted; + private Label labelAmount; + private ComboBox comboBoxShop; + private ComboBox comboBoxPrinted; + private TextBox textBoxAmount; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Typography/TypographyView/FormSupplies.cs b/Typography/TypographyView/FormSupplies.cs new file mode 100644 index 0000000..f26ade5 --- /dev/null +++ b/Typography/TypographyView/FormSupplies.cs @@ -0,0 +1,99 @@ +using TypographyContracts.BindingModels; +using TypographyContracts.BusinessLogicsContracts; +using TypographyContracts.SearchModels; +using Microsoft.Extensions.Logging; + +namespace TypographyView +{ + public partial class FormSupplies : Form + { + private readonly ILogger _logger; + private readonly IPrintedLogic _logicP; + private readonly IShopLogic _logicS; + + public FormSupplies(ILogger logger, IPrintedLogic logicP, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormSupplies_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка магазинов для поставки"); + var _listS = _logicS.ReadList(null); + if (_listS != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _listS; + comboBoxShop.SelectedItem = null; + } + + _logger.LogInformation("Загрузка печатной продукции для поставки"); + var _listP = _logicP.ReadList(null); + if (_listP != null) + { + comboBoxPrinted.DisplayMember = "PrintedName"; + comboBoxPrinted.ValueMember = "Id"; + comboBoxPrinted.DataSource = _listP; + comboBoxPrinted.SelectedItem = null; + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxPrinted.SelectedValue == null) + { + MessageBox.Show("Выберите печатную продукцию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAmount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.SupplyPrinteds( + new ShopSearchModel() + { + Id = Convert.ToInt32(comboBoxShop.SelectedValue), + ShopName = comboBoxShop.Text + }, + new PrintedBindingModel() + { + Id = Convert.ToInt32(comboBoxPrinted.SelectedValue), + PrintedName = comboBoxPrinted.Text + }, + Convert.ToInt32(textBoxAmount.Text)); + if (!operationResult) + { + throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания поставки"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} \ No newline at end of file diff --git a/Typography/TypographyView/FormSupplies.resx b/Typography/TypographyView/FormSupplies.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Typography/TypographyView/FormSupplies.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/Typography/TypographyView/Program.cs b/Typography/TypographyView/Program.cs index 20a1e90..33b0b9b 100644 --- a/Typography/TypographyView/Program.cs +++ b/Typography/TypographyView/Program.cs @@ -11,6 +11,7 @@ namespace TypographyView { internal static class Program { + private static ServiceProvider? _serviceProvider; public static ServiceProvider? ServiceProvider => _serviceProvider; @@ -28,7 +29,6 @@ namespace TypographyView _serviceProvider = services.BuildServiceProvider(); Application.Run(_serviceProvider.GetRequiredService()); } - private static void ConfigureServices(ServiceCollection services) { services.AddLogging(option => @@ -39,9 +39,13 @@ namespace TypographyView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -49,6 +53,9 @@ namespace TypographyView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file