From 516888ce7551f055234353f4c4182c0e1e43fb75 Mon Sep 17 00:00:00 2001 From: ValAnn Date: Wed, 14 Feb 2024 13:15:42 +0400 Subject: [PATCH 1/3] process --- SushiBar/SushiBarBusinessLogic_/ShopLogic.cs | 160 +++++++++++++++ .../BindingModels/ShopBindingModel.cs | 19 ++ .../BindingModels/SupplyBindingModel.cs | 16 ++ .../BusinessLogicsContracts/IShopLogic.cs | 21 ++ .../SearchModels/ShopSearchModel.cs | 14 ++ .../StoragesContracts/IShopStorage.cs | 21 ++ .../ViewModels/ShopViewModel.cs | 22 ++ .../SushiBarDataModels/Models/IShopModel.cs | 16 ++ .../SushiBarDataModels/Models/ISupplyModel.cs | 15 ++ .../DataListSingleton.cs | 2 + .../Implements/ShopStorage.cs | 113 ++++++++++ .../SushiBarListImplement_/Models/Shop.cs | 59 ++++++ .../SushiBarView/FormCreateSupply.Designer.cs | 149 ++++++++++++++ SushiBar/SushiBarView/FormCreateSupply.cs | 99 +++++++++ SushiBar/SushiBarView/FormCreateSupply.resx | 60 ++++++ SushiBar/SushiBarView/FormMain.Designer.cs | 22 +- SushiBar/SushiBarView/FormMain.cs | 18 ++ SushiBar/SushiBarView/FormShop.Designer.cs | 193 ++++++++++++++++++ SushiBar/SushiBarView/FormShop.cs | 128 ++++++++++++ SushiBar/SushiBarView/FormShop.resx | 120 +++++++++++ SushiBar/SushiBarView/FormShops.Designer.cs | 130 ++++++++++++ SushiBar/SushiBarView/FormShops.cs | 116 +++++++++++ SushiBar/SushiBarView/FormShops.resx | 120 +++++++++++ SushiBar/SushiBarView/Program.cs | 6 + 24 files changed, 1638 insertions(+), 1 deletion(-) create mode 100644 SushiBar/SushiBarBusinessLogic_/ShopLogic.cs create mode 100644 SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs create mode 100644 SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs create mode 100644 SushiBar/SushiBarDataModels/Models/IShopModel.cs create mode 100644 SushiBar/SushiBarDataModels/Models/ISupplyModel.cs create mode 100644 SushiBar/SushiBarListImplement_/Implements/ShopStorage.cs create mode 100644 SushiBar/SushiBarListImplement_/Models/Shop.cs create mode 100644 SushiBar/SushiBarView/FormCreateSupply.Designer.cs create mode 100644 SushiBar/SushiBarView/FormCreateSupply.cs create mode 100644 SushiBar/SushiBarView/FormCreateSupply.resx create mode 100644 SushiBar/SushiBarView/FormShop.Designer.cs create mode 100644 SushiBar/SushiBarView/FormShop.cs create mode 100644 SushiBar/SushiBarView/FormShop.resx create mode 100644 SushiBar/SushiBarView/FormShops.Designer.cs create mode 100644 SushiBar/SushiBarView/FormShops.cs create mode 100644 SushiBar/SushiBarView/FormShops.resx diff --git a/SushiBar/SushiBarBusinessLogic_/ShopLogic.cs b/SushiBar/SushiBarBusinessLogic_/ShopLogic.cs new file mode 100644 index 0000000..645b4e2 --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic_/ShopLogic.cs @@ -0,0 +1,160 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarContracts.BusinessLogicsContracts; + +namespace SushiBarBusinessLogic.BusinessLogics +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + private readonly ISushiStorage _sushiStorage; + + public ShopLogic(ILogger logger, IShopStorage shopStorage, ISushiStorage sushiStorage) + { + _logger = logger; + _shopStorage = shopStorage; + _sushiStorage = sushiStorage; + } + + 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 MakeSupply(SupplyBindingModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий должно быть больше 0"); + } + var shop = _shopStorage.GetElement(new ShopSearchModel + { + Id = model.ShopId + }); + if (shop == null) + { + throw new ArgumentException("Магазина не существует"); + } + if (shop.ShopSushis.ContainsKey(model.SushiId)) + { + var oldValue = shop.ShopSushis[model.SushiId]; + oldValue.Item2 += model.Count; + shop.ShopSushis[model.SushiId] = oldValue; + } + else + { + var sushi = _sushiStorage.GetElement(new SushiSearchModel + { + Id = model.SushiId + }); + if (sushi == null) + { + throw new ArgumentException($"Поставка: Товар с id:{model.SushiId} не найденн"); + } + shop.ShopSushis.Add(model.SushiId, (sushi, model.Count)); + } + 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.Adress)) + { + throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Adress)); + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel + { + ShopName = model.ShopName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } + } +} diff --git a/SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..6ac3b93 --- /dev/null +++ b/SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarDataModels.Models; + +namespace SushiBarContracts.BindingModels +{ + public class ShopBindingModel : IShopModel + { + public int Id { get; set; } + public string ShopName { get; set; } = string.Empty; + public string Adress { get; set; } = string.Empty; + public DateTime OpeningDate { get; set; } = DateTime.Now; + public Dictionary ShopSushis { get; set; } = new(); + + } +} diff --git a/SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs new file mode 100644 index 0000000..4143488 --- /dev/null +++ b/SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarDataModels.Models; + +namespace SushiBarContracts.BindingModels +{ + public class SupplyBindingModel : ISupplyModel + { + public int ShopId { get; set; } + public int SushiId { get; set; } + public int Count { get; set; } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..8bec166 --- /dev/null +++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,21 @@ +using SushiBarContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; + +namespace SushiBarContracts.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 MakeSupply(SupplyBindingModel model); + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..8ab0e48 --- /dev/null +++ b/SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.SearchModels +{ + public class ShopSearchModel + { + public int? Id { get; set; } + public string? ShopName { get; set; } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..f3eda9d --- /dev/null +++ b/SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,21 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.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/SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..c09f97a --- /dev/null +++ b/SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarDataModels.Models; + +namespace SushiBarContracts.ViewModels +{ + public class ShopViewModel + { + public int Id { get; set; } + [DisplayName("Название")] + public string ShopName { get; set; } = string.Empty; + [DisplayName("Адрес")] + public string Adress { get; set; } = string.Empty; + [DisplayName("Дата открытия")] + public DateTime OpeningDate { get; set; } + public Dictionary ShopSushis { get; set; } = new(); + } +} diff --git a/SushiBar/SushiBarDataModels/Models/IShopModel.cs b/SushiBar/SushiBarDataModels/Models/IShopModel.cs new file mode 100644 index 0000000..df7cf9c --- /dev/null +++ b/SushiBar/SushiBarDataModels/Models/IShopModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarDataModels.Models +{ + public interface IShopModel : IId + { + string ShopName { get; } + string Adress { get; } + DateTime OpeningDate { get; } + Dictionary ShopSushis { get; } + } +} diff --git a/SushiBar/SushiBarDataModels/Models/ISupplyModel.cs b/SushiBar/SushiBarDataModels/Models/ISupplyModel.cs new file mode 100644 index 0000000..d8b8348 --- /dev/null +++ b/SushiBar/SushiBarDataModels/Models/ISupplyModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarDataModels.Models +{ + public interface ISupplyModel + { + int ShopId { get; } + int SushiId { get; } + int Count { get; } + } +} diff --git a/SushiBar/SushiBarListImplement_/DataListSingleton.cs b/SushiBar/SushiBarListImplement_/DataListSingleton.cs index 6eabe76..7893d08 100644 --- a/SushiBar/SushiBarListImplement_/DataListSingleton.cs +++ b/SushiBar/SushiBarListImplement_/DataListSingleton.cs @@ -13,11 +13,13 @@ namespace SushiBarListImplement public List Components { get; set; } public List Orders { get; set; } public List Sushis { get; set; } + public List Shops { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); Sushis = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() { diff --git a/SushiBar/SushiBarListImplement_/Implements/ShopStorage.cs b/SushiBar/SushiBarListImplement_/Implements/ShopStorage.cs new file mode 100644 index 0000000..446bd8a --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Implements/ShopStorage.cs @@ -0,0 +1,113 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.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/SushiBar/SushiBarListImplement_/Models/Shop.cs b/SushiBar/SushiBarListImplement_/Models/Shop.cs new file mode 100644 index 0000000..0c7501d --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Models/Shop.cs @@ -0,0 +1,59 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarDataModels.Enums; + +namespace SushiBarListImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Adress { get; private set; } = string.Empty; + public DateTime OpeningDate { get; private set; } + public Dictionary ShopSushis { get; private set; } = new(); + + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Adress = model.Adress, + OpeningDate = model.OpeningDate + }; + } + + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Adress = model.Adress; + OpeningDate = model.OpeningDate; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Adress = Adress, + OpeningDate = OpeningDate, + ShopSushis = ShopSushis + }; + } +} diff --git a/SushiBar/SushiBarView/FormCreateSupply.Designer.cs b/SushiBar/SushiBarView/FormCreateSupply.Designer.cs new file mode 100644 index 0000000..6f3c091 --- /dev/null +++ b/SushiBar/SushiBarView/FormCreateSupply.Designer.cs @@ -0,0 +1,149 @@ +namespace SushiBarView +{ + partial class FormCreateSupply + { + /// + /// 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.comboBoxShop = new System.Windows.Forms.ComboBox(); + this.labelShop = new System.Windows.Forms.Label(); + this.labelSushi = new System.Windows.Forms.Label(); + this.comboBoxSushi = new System.Windows.Forms.ComboBox(); + this.labelCount = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBoxShop + // + this.comboBoxShop.FormattingEnabled = true; + this.comboBoxShop.Location = new System.Drawing.Point(101, 9); + this.comboBoxShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxShop.Name = "comboBoxShop"; + this.comboBoxShop.Size = new System.Drawing.Size(302, 23); + this.comboBoxShop.TabIndex = 0; + // + // labelShop + // + this.labelShop.AutoSize = true; + this.labelShop.Location = new System.Drawing.Point(10, 11); + this.labelShop.Name = "labelShop"; + this.labelShop.Size = new System.Drawing.Size(60, 15); + this.labelShop.TabIndex = 1; + this.labelShop.Text = "Магазин: "; + // + // labelSushi + // + this.labelSushi.AutoSize = true; + this.labelSushi.Location = new System.Drawing.Point(10, 37); + this.labelSushi.Name = "labelSushi"; + this.labelSushi.Size = new System.Drawing.Size(59, 15); + this.labelSushi.TabIndex = 2; + this.labelSushi.Text = "Изделие: "; + // + // comboBoxSushi + // + this.comboBoxSushi.FormattingEnabled = true; + this.comboBoxSushi.Location = new System.Drawing.Point(101, 34); + this.comboBoxSushi.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxSushi.Name = "comboBoxSushi"; + this.comboBoxSushi.Size = new System.Drawing.Size(302, 23); + this.comboBoxSushi.TabIndex = 3; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(10, 62); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(78, 15); + this.labelCount.TabIndex = 4; + this.labelCount.Text = "Количество: "; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(101, 60); + this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(302, 23); + this.textBoxCount.TabIndex = 5; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(262, 85); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(102, 29); + 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(147, 85); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(102, 29); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormCreateSupply + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(412, 123); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.comboBoxSushi); + this.Controls.Add(this.labelSushi); + this.Controls.Add(this.labelShop); + this.Controls.Add(this.comboBoxShop); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormCreateSupply"; + this.Text = "Создание поставки"; + this.Load += new System.EventHandler(this.FormCreateSupply_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private ComboBox comboBoxShop; + private Label labelShop; + private Label labelSushi; + private ComboBox comboBoxSushi; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormCreateSupply.cs b/SushiBar/SushiBarView/FormCreateSupply.cs new file mode 100644 index 0000000..6dfeba4 --- /dev/null +++ b/SushiBar/SushiBarView/FormCreateSupply.cs @@ -0,0 +1,99 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.ViewModels; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace SushiBarView +{ + public partial class FormCreateSupply : Form + { + private readonly ILogger _logger; + private readonly ISushiLogic _logicP; + private readonly IShopLogic _logicS; + private List _shopList = new List(); + private List _sushiList = new List(); + + public FormCreateSupply(ILogger logger, ISushiLogic logicP, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormCreateSupply_Load(object sender, EventArgs e) + { + _shopList = _logicS.ReadList(null); + _sushiList = _logicP.ReadList(null); + if (_shopList != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _shopList; + comboBoxShop.SelectedItem = null; + _logger.LogInformation("Загрузка магазинов для поставок"); + } + if (_sushiList != null) + { + comboBoxSushi.DisplayMember = "SushiName"; + comboBoxSushi.ValueMember = "Id"; + comboBoxSushi.DataSource = _sushiList; + comboBoxSushi.SelectedItem = null; + _logger.LogInformation("Загрузка пиццы для поставок"); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxSushi.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.MakeSupply(new SupplyBindingModel + { + ShopId = Convert.ToInt32(comboBoxShop.SelectedValue), + SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue), + Count = Convert.ToInt32(textBoxCount.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/SushiBar/SushiBarView/FormCreateSupply.resx b/SushiBar/SushiBarView/FormCreateSupply.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormCreateSupply.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/SushiBar/SushiBarView/FormMain.Designer.cs b/SushiBar/SushiBarView/FormMain.Designer.cs index 0c2348d..023ca27 100644 --- a/SushiBar/SushiBarView/FormMain.Designer.cs +++ b/SushiBar/SushiBarView/FormMain.Designer.cs @@ -38,6 +38,8 @@ this.componentsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sushiToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); + this.shopsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.transactionToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -106,7 +108,9 @@ // this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.componentsToolStripMenuItemToolStripMenuItem, - this.sushiToolStripMenuItemToolStripMenuItem}); + this.sushiToolStripMenuItemToolStripMenuItem, + this.shopsToolStripMenuItemToolStripMenuItem, + this.transactionToolStripMenuItemToolStripMenuItem}); this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Size = new System.Drawing.Size(94, 20); this.toolStripMenuItem1.Text = "Справочники"; @@ -135,6 +139,20 @@ this.dataGridView.Size = new System.Drawing.Size(647, 344); this.dataGridView.TabIndex = 6; // + // shopsToolStripMenuItemToolStripMenuItem + // + this.shopsToolStripMenuItemToolStripMenuItem.Name = "shopsToolStripMenuItemToolStripMenuItem"; + this.shopsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.shopsToolStripMenuItemToolStripMenuItem.Text = "Магазины"; + this.shopsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click); + // + // transactionToolStripMenuItemToolStripMenuItem + // + this.transactionToolStripMenuItemToolStripMenuItem.Name = "transactionToolStripMenuItemToolStripMenuItem"; + this.transactionToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.transactionToolStripMenuItemToolStripMenuItem.Text = "Транзакции"; + this.transactionToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.transactionToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -171,5 +189,7 @@ private ToolStripMenuItem componentsToolStripMenuItemToolStripMenuItem; private ToolStripMenuItem sushiToolStripMenuItemToolStripMenuItem; private DataGridView dataGridView; + private ToolStripMenuItem shopsToolStripMenuItemToolStripMenuItem; + private ToolStripMenuItem transactionToolStripMenuItemToolStripMenuItem; } } \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormMain.cs b/SushiBar/SushiBarView/FormMain.cs index 0ca85b9..0c83f6d 100644 --- a/SushiBar/SushiBarView/FormMain.cs +++ b/SushiBar/SushiBarView/FormMain.cs @@ -167,5 +167,23 @@ MessageBoxIcon.Error); 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 transactionToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply)); + if (service is FormCreateSupply form) + { + form.ShowDialog(); + } + } + } } diff --git a/SushiBar/SushiBarView/FormShop.Designer.cs b/SushiBar/SushiBarView/FormShop.Designer.cs new file mode 100644 index 0000000..ab0a1a2 --- /dev/null +++ b/SushiBar/SushiBarView/FormShop.Designer.cs @@ -0,0 +1,193 @@ +namespace SushiBarView +{ + 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() + { + this.labelName = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxAdress = new System.Windows.Forms.TextBox(); + this.labelAdress = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SushiName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.label1 = new System.Windows.Forms.Label(); + this.dateTimeOpen = new System.Windows.Forms.DateTimePicker(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(11, 15); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(84, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название: "; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(102, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(276, 27); + this.textBoxName.TabIndex = 1; + // + // textBoxAdress + // + this.textBoxAdress.Location = new System.Drawing.Point(102, 59); + this.textBoxAdress.Name = "textBoxAdress"; + this.textBoxAdress.Size = new System.Drawing.Size(427, 27); + this.textBoxAdress.TabIndex = 3; + // + // labelAdress + // + this.labelAdress.AutoSize = true; + this.labelAdress.Location = new System.Drawing.Point(11, 61); + this.labelAdress.Name = "labelAdress"; + this.labelAdress.Size = new System.Drawing.Size(58, 20); + this.labelAdress.TabIndex = 2; + this.labelAdress.Text = "Адрес: "; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(451, 457); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(130, 44); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(315, 457); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(130, 44); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.SushiName, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(12, 144); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; + this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(569, 307); + this.dataGridView.TabIndex = 7; + // + // id + // + this.id.HeaderText = "id"; + this.id.MinimumWidth = 6; + this.id.Name = "id"; + this.id.ReadOnly = true; + this.id.Visible = false; + // + // SushiName + // + this.SushiName.HeaderText = "Пицца"; + this.SushiName.MinimumWidth = 6; + this.SushiName.Name = "SushiName"; + this.SushiName.ReadOnly = true; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.ReadOnly = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 103); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 20); + this.label1.TabIndex = 8; + this.label1.Text = "Дата открытия"; + // + // dateTimeOpen + // + this.dateTimeOpen.Location = new System.Drawing.Point(128, 103); + this.dateTimeOpen.Name = "dateTimeOpen"; + this.dateTimeOpen.Size = new System.Drawing.Size(401, 27); + this.dateTimeOpen.TabIndex = 9; + // + // FormShop + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(593, 513); + this.Controls.Add(this.dateTimeOpen); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxAdress); + this.Controls.Add(this.labelAdress); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormShop"; + this.Text = "Магазин"; + this.Load += new System.EventHandler(this.FormShop_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private TextBox textBoxAdress; + private Label labelAdress; + private Button buttonCancel; + private Button buttonSave; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn SushiName; + private DataGridViewTextBoxColumn Count; + private Label label1; + private DateTimePicker dateTimeOpen; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormShop.cs b/SushiBar/SushiBarView/FormShop.cs new file mode 100644 index 0000000..79ea3cb --- /dev/null +++ b/SushiBar/SushiBarView/FormShop.cs @@ -0,0 +1,128 @@ +using SushiBarDataModels.Models; +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SushiBarView +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + private Dictionary _ShopSushis; + private DateTime? _openingDate = null; + + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _ShopSushis = 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; + textBoxAdress.Text = view.Adress; + dateTimeOpen.Value = view.OpeningDate; + _ShopSushis = view.ShopSushis ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка изделий в магазине"); + try + { + if (_ShopSushis != null) + { + dataGridView.Rows.Clear(); + foreach (var sr in _ShopSushis) + { + dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.SushiName, sr.Value.Item2 }); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделий магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAdress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Adress = textBoxAdress.Text, + OpeningDate = dateTimeOpen.Value + }; + 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/SushiBar/SushiBarView/FormShop.resx b/SushiBar/SushiBarView/FormShop.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SushiBar/SushiBarView/FormShop.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormShops.Designer.cs b/SushiBar/SushiBarView/FormShops.Designer.cs new file mode 100644 index 0000000..b54a130 --- /dev/null +++ b/SushiBar/SushiBarView/FormShops.Designer.cs @@ -0,0 +1,130 @@ +namespace SushiBarView +{ + 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() + { + this.ToolsPanel = new System.Windows.Forms.Panel(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ToolsPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ToolsPanel + // + this.ToolsPanel.Controls.Add(this.buttonRef); + this.ToolsPanel.Controls.Add(this.buttonDel); + this.ToolsPanel.Controls.Add(this.buttonUpd); + this.ToolsPanel.Controls.Add(this.buttonAdd); + this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Name = "ToolsPanel"; + this.ToolsPanel.Size = new System.Drawing.Size(180, 426); + this.ToolsPanel.TabIndex = 3; + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(31, 206); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(126, 36); + this.buttonRef.TabIndex = 3; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(31, 142); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(126, 36); + this.buttonDel.TabIndex = 2; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(31, 76); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(126, 36); + this.buttonUpd.TabIndex = 1; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.TabIndex = 0; + 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.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.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.TabIndex = 2; + // + // FormShops + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.ToolsPanel); + this.Controls.Add(this.dataGridView); + this.Name = "FormShops"; + this.Text = "Магазины"; + this.Load += new System.EventHandler(this.FormShops_Load); + this.ToolsPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel ToolsPanel; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormShops.cs b/SushiBar/SushiBarView/FormShops.cs new file mode 100644 index 0000000..7e899d2 --- /dev/null +++ b/SushiBar/SushiBarView/FormShops.cs @@ -0,0 +1,116 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SushiBarView +{ + 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) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ShopSushis"].Visible = false; + dataGridView.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 (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop 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 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(); + } + } +} diff --git a/SushiBar/SushiBarView/FormShops.resx b/SushiBar/SushiBarView/FormShops.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SushiBar/SushiBarView/FormShops.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/Program.cs b/SushiBar/SushiBarView/Program.cs index 8a031e0..6eb85ab 100644 --- a/SushiBar/SushiBarView/Program.cs +++ b/SushiBar/SushiBarView/Program.cs @@ -47,6 +47,12 @@ namespace SushiBarView services.AddTransient(); services.AddTransient(); services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file From 66e503a07648dee10ed8cf142369e9a74bc978ed Mon Sep 17 00:00:00 2001 From: ValAnn Date: Wed, 14 Feb 2024 13:58:48 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D1=81=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBarView/FormShop.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SushiBar/SushiBarView/FormShop.Designer.cs b/SushiBar/SushiBarView/FormShop.Designer.cs index ab0a1a2..c12987b 100644 --- a/SushiBar/SushiBarView/FormShop.Designer.cs +++ b/SushiBar/SushiBarView/FormShop.Designer.cs @@ -124,7 +124,7 @@ // // SushiName // - this.SushiName.HeaderText = "Пицца"; + this.SushiName.HeaderText = "Суши"; this.SushiName.MinimumWidth = 6; this.SushiName.Name = "SushiName"; this.SushiName.ReadOnly = true; From d4a7c79d04764a4d7e4194ccb859b5de0a58a7c1 Mon Sep 17 00:00:00 2001 From: ValAnn Date: Wed, 14 Feb 2024 15:49:23 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B4=D0=BE=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBarView/FormMain.Designer.cs | 40 ++++++------- SushiBar/SushiBarView/FormShop.Designer.cs | 48 +++++++++------- SushiBar/SushiBarView/FormShop.resx | 62 +-------------------- SushiBar/SushiBarView/FormShops.Designer.cs | 36 +++++++----- SushiBar/SushiBarView/FormShops.resx | 62 +-------------------- 5 files changed, 72 insertions(+), 176 deletions(-) diff --git a/SushiBar/SushiBarView/FormMain.Designer.cs b/SushiBar/SushiBarView/FormMain.Designer.cs index 023ca27..1999a78 100644 --- a/SushiBar/SushiBarView/FormMain.Designer.cs +++ b/SushiBar/SushiBarView/FormMain.Designer.cs @@ -37,9 +37,9 @@ this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.componentsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sushiToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.dataGridView = new System.Windows.Forms.DataGridView(); this.shopsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.transactionToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dataGridView = new System.Windows.Forms.DataGridView(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -97,7 +97,8 @@ // menuStrip // this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem1}); + this.toolStripMenuItem1, + this.пополнениеМагазинаToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Size = new System.Drawing.Size(922, 24); @@ -109,8 +110,7 @@ this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.componentsToolStripMenuItemToolStripMenuItem, this.sushiToolStripMenuItemToolStripMenuItem, - this.shopsToolStripMenuItemToolStripMenuItem, - this.transactionToolStripMenuItemToolStripMenuItem}); + this.shopsToolStripMenuItemToolStripMenuItem}); this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Size = new System.Drawing.Size(94, 20); this.toolStripMenuItem1.Text = "Справочники"; @@ -129,6 +129,20 @@ this.sushiToolStripMenuItemToolStripMenuItem.Text = "Суши"; this.sushiToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.sushiToolStripMenuItem_Click); // + // shopsToolStripMenuItemToolStripMenuItem + // + this.shopsToolStripMenuItemToolStripMenuItem.Name = "shopsToolStripMenuItemToolStripMenuItem"; + this.shopsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.shopsToolStripMenuItemToolStripMenuItem.Text = "Магазины"; + this.shopsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click); + // + // пополнениеМагазинаToolStripMenuItem + // + this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; + this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(143, 20); + this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина"; + this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.transactionToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.BackgroundColor = System.Drawing.Color.White; @@ -139,20 +153,6 @@ this.dataGridView.Size = new System.Drawing.Size(647, 344); this.dataGridView.TabIndex = 6; // - // shopsToolStripMenuItemToolStripMenuItem - // - this.shopsToolStripMenuItemToolStripMenuItem.Name = "shopsToolStripMenuItemToolStripMenuItem"; - this.shopsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.shopsToolStripMenuItemToolStripMenuItem.Text = "Магазины"; - this.shopsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click); - // - // transactionToolStripMenuItemToolStripMenuItem - // - this.transactionToolStripMenuItemToolStripMenuItem.Name = "transactionToolStripMenuItemToolStripMenuItem"; - this.transactionToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.transactionToolStripMenuItemToolStripMenuItem.Text = "Транзакции"; - this.transactionToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.transactionToolStripMenuItem_Click); - // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -190,6 +190,6 @@ private ToolStripMenuItem sushiToolStripMenuItemToolStripMenuItem; private DataGridView dataGridView; private ToolStripMenuItem shopsToolStripMenuItemToolStripMenuItem; - private ToolStripMenuItem transactionToolStripMenuItemToolStripMenuItem; + private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; } } \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormShop.Designer.cs b/SushiBar/SushiBarView/FormShop.Designer.cs index c12987b..5cf4b69 100644 --- a/SushiBar/SushiBarView/FormShop.Designer.cs +++ b/SushiBar/SushiBarView/FormShop.Designer.cs @@ -46,40 +46,43 @@ // labelName // this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(11, 15); + this.labelName.Location = new System.Drawing.Point(10, 11); this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(84, 20); + this.labelName.Size = new System.Drawing.Size(65, 15); this.labelName.TabIndex = 0; this.labelName.Text = "Название: "; // // textBoxName // - this.textBoxName.Location = new System.Drawing.Point(102, 12); + this.textBoxName.Location = new System.Drawing.Point(89, 9); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(276, 27); + this.textBoxName.Size = new System.Drawing.Size(242, 23); this.textBoxName.TabIndex = 1; // // textBoxAdress // - this.textBoxAdress.Location = new System.Drawing.Point(102, 59); + this.textBoxAdress.Location = new System.Drawing.Point(89, 44); + this.textBoxAdress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxAdress.Name = "textBoxAdress"; - this.textBoxAdress.Size = new System.Drawing.Size(427, 27); + this.textBoxAdress.Size = new System.Drawing.Size(374, 23); this.textBoxAdress.TabIndex = 3; // // labelAdress // this.labelAdress.AutoSize = true; - this.labelAdress.Location = new System.Drawing.Point(11, 61); + this.labelAdress.Location = new System.Drawing.Point(10, 46); this.labelAdress.Name = "labelAdress"; - this.labelAdress.Size = new System.Drawing.Size(58, 20); + this.labelAdress.Size = new System.Drawing.Size(46, 15); this.labelAdress.TabIndex = 2; this.labelAdress.Text = "Адрес: "; // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(451, 457); + this.buttonCancel.Location = new System.Drawing.Point(395, 343); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(130, 44); + this.buttonCancel.Size = new System.Drawing.Size(114, 33); this.buttonCancel.TabIndex = 5; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; @@ -87,9 +90,10 @@ // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(315, 457); + this.buttonSave.Location = new System.Drawing.Point(276, 343); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(130, 44); + this.buttonSave.Size = new System.Drawing.Size(114, 33); this.buttonSave.TabIndex = 6; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; @@ -100,18 +104,20 @@ 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.id, this.SushiName, this.Count}); - this.dataGridView.Location = new System.Drawing.Point(12, 144); + this.dataGridView.Location = new System.Drawing.Point(10, 108); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView"; this.dataGridView.ReadOnly = true; this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(569, 307); + this.dataGridView.Size = new System.Drawing.Size(498, 230); this.dataGridView.TabIndex = 7; // // id @@ -139,24 +145,25 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 103); + this.label1.Location = new System.Drawing.Point(10, 77); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(110, 20); + this.label1.Size = new System.Drawing.Size(87, 15); this.label1.TabIndex = 8; this.label1.Text = "Дата открытия"; // // dateTimeOpen // - this.dateTimeOpen.Location = new System.Drawing.Point(128, 103); + this.dateTimeOpen.Location = new System.Drawing.Point(112, 77); + this.dateTimeOpen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dateTimeOpen.Name = "dateTimeOpen"; - this.dateTimeOpen.Size = new System.Drawing.Size(401, 27); + this.dateTimeOpen.Size = new System.Drawing.Size(351, 23); this.dateTimeOpen.TabIndex = 9; // // FormShop // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(593, 513); + this.ClientSize = new System.Drawing.Size(519, 385); this.Controls.Add(this.dateTimeOpen); this.Controls.Add(this.label1); this.Controls.Add(this.dataGridView); @@ -166,6 +173,7 @@ this.Controls.Add(this.labelAdress); this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelName); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormShop"; this.Text = "Магазин"; this.Load += new System.EventHandler(this.FormShop_Load); diff --git a/SushiBar/SushiBarView/FormShop.resx b/SushiBar/SushiBarView/FormShop.resx index 1af7de1..f298a7b 100644 --- a/SushiBar/SushiBarView/FormShop.resx +++ b/SushiBar/SushiBarView/FormShop.resx @@ -1,64 +1,4 @@ - - - + diff --git a/SushiBar/SushiBarView/FormShops.Designer.cs b/SushiBar/SushiBarView/FormShops.Designer.cs index b54a130..f668a5f 100644 --- a/SushiBar/SushiBarView/FormShops.Designer.cs +++ b/SushiBar/SushiBarView/FormShops.Designer.cs @@ -44,16 +44,18 @@ this.ToolsPanel.Controls.Add(this.buttonDel); this.ToolsPanel.Controls.Add(this.buttonUpd); this.ToolsPanel.Controls.Add(this.buttonAdd); - this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Location = new System.Drawing.Point(532, 9); + this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ToolsPanel.Name = "ToolsPanel"; - this.ToolsPanel.Size = new System.Drawing.Size(180, 426); + this.ToolsPanel.Size = new System.Drawing.Size(158, 320); this.ToolsPanel.TabIndex = 3; // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(31, 206); + this.buttonRef.Location = new System.Drawing.Point(27, 154); + this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(126, 36); + this.buttonRef.Size = new System.Drawing.Size(110, 27); this.buttonRef.TabIndex = 3; this.buttonRef.Text = "Обновить"; this.buttonRef.UseVisualStyleBackColor = true; @@ -61,9 +63,10 @@ // // buttonDel // - this.buttonDel.Location = new System.Drawing.Point(31, 142); + this.buttonDel.Location = new System.Drawing.Point(27, 106); + this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonDel.Name = "buttonDel"; - this.buttonDel.Size = new System.Drawing.Size(126, 36); + this.buttonDel.Size = new System.Drawing.Size(110, 27); this.buttonDel.TabIndex = 2; this.buttonDel.Text = "Удалить"; this.buttonDel.UseVisualStyleBackColor = true; @@ -71,9 +74,10 @@ // // buttonUpd // - this.buttonUpd.Location = new System.Drawing.Point(31, 76); + this.buttonUpd.Location = new System.Drawing.Point(27, 57); + this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonUpd.Name = "buttonUpd"; - this.buttonUpd.Size = new System.Drawing.Size(126, 36); + this.buttonUpd.Size = new System.Drawing.Size(110, 27); this.buttonUpd.TabIndex = 1; this.buttonUpd.Text = "Изменить"; this.buttonUpd.UseVisualStyleBackColor = true; @@ -81,9 +85,10 @@ // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Location = new System.Drawing.Point(27, 12); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.Size = new System.Drawing.Size(110, 27); this.buttonAdd.TabIndex = 0; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; @@ -93,22 +98,25 @@ // 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.Location = new System.Drawing.Point(10, 9); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView"; this.dataGridView.ReadOnly = true; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.Size = new System.Drawing.Size(516, 320); this.dataGridView.TabIndex = 2; // // FormShops // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(700, 338); this.Controls.Add(this.ToolsPanel); this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormShops"; this.Text = "Магазины"; this.Load += new System.EventHandler(this.FormShops_Load); diff --git a/SushiBar/SushiBarView/FormShops.resx b/SushiBar/SushiBarView/FormShops.resx index 1af7de1..f298a7b 100644 --- a/SushiBar/SushiBarView/FormShops.resx +++ b/SushiBar/SushiBarView/FormShops.resx @@ -1,64 +1,4 @@ - - - +