From f430bc97739ee2de763dac89c0cc2723884e6799 Mon Sep 17 00:00:00 2001 From: Shtyrkin_Egor Date: Wed, 6 Mar 2024 11:01:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D1=80=D0=B5=D0=B4=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D1=8B=20=D0=B2=20=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7?= =?UTF-8?q?=D0=B8=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FormCanneds.cs | 12 +----------- FishFactory/FormComponent.cs | 12 +----------- FishFactory/FormComponents.cs | 9 --------- FishFactory/FormMain.cs | 10 ---------- FishFactory/FormShop.Designer.cs | 3 ++- FishFactory/FormShop.cs | 3 +-- FishFactory/FormShopReplenish.Designer.cs | 3 ++- FishFactory/FormShopReplenish.cs | 7 +++---- FishFactory/FormShops.Designer.cs | 3 ++- FishFactory/FormShops.cs | 13 +++++-------- .../BusinessLogic/ShopLogic.cs | 2 +- .../BindingModels/ReplenishBindingModel.cs | 8 ++------ .../BindingModels/ShopBindingModel.cs | 9 ++------- .../SearchModels/OrderSearchModel.cs | 8 +------- FishFactoryContracts/ViewModels/ShopViewModel.cs | 1 - FishFactoryDataModels/Models/IReplenishModel.cs | 9 +++++++++ FishFactoryDataModels/Models/IShopCannedModel.cs | 15 --------------- FishFactoryDataModels/Models/IShopModel.cs | 8 +------- .../Implements/ShopStorage.cs | 13 ++++--------- FishFactoryListImplement/Models/Shop.cs | 5 ----- 20 files changed, 37 insertions(+), 116 deletions(-) create mode 100644 FishFactoryDataModels/Models/IReplenishModel.cs delete mode 100644 FishFactoryDataModels/Models/IShopCannedModel.cs diff --git a/FishFactory/FormCanneds.cs b/FishFactory/FormCanneds.cs index 6cbeb50..840349f 100644 --- a/FishFactory/FormCanneds.cs +++ b/FishFactory/FormCanneds.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using FishFactory; -using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; diff --git a/FishFactory/FormComponent.cs b/FishFactory/FormComponent.cs index 86b613f..57f0fed 100644 --- a/FishFactory/FormComponent.cs +++ b/FishFactory/FormComponent.cs @@ -1,15 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using FishFactoryContracts.BusinessLogicsContracts; -using Microsoft.VisualBasic.Logging; using FishFactoryContracts.SearchModels; using FishFactoryContracts.BindingModels; diff --git a/FishFactory/FormComponents.cs b/FishFactory/FormComponents.cs index ef3531a..925119a 100644 --- a/FishFactory/FormComponents.cs +++ b/FishFactory/FormComponents.cs @@ -1,15 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; namespace FishFactory.Forms { diff --git a/FishFactory/FormMain.cs b/FishFactory/FormMain.cs index 50e2296..ba5fd14 100644 --- a/FishFactory/FormMain.cs +++ b/FishFactory/FormMain.cs @@ -1,15 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; namespace FishFactory.Forms { @@ -82,7 +73,6 @@ namespace FishFactory.Forms if (service is FormShopReplenish form) { form.ShowDialog(); - LoadData(); } } diff --git a/FishFactory/FormShop.Designer.cs b/FishFactory/FormShop.Designer.cs index 2a0da5b..4724e4e 100644 --- a/FishFactory/FormShop.Designer.cs +++ b/FishFactory/FormShop.Designer.cs @@ -1,4 +1,4 @@ -namespace FishFactory +namespace FishFactory.Forms { partial class FormShop { @@ -156,6 +156,7 @@ Controls.Add(label1); Name = "FormShop"; Text = "Магазин"; + Load += FormShop_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/FishFactory/FormShop.cs b/FishFactory/FormShop.cs index e7dcf3b..2793743 100644 --- a/FishFactory/FormShop.cs +++ b/FishFactory/FormShop.cs @@ -3,9 +3,8 @@ using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.SearchModels; using FishFactoryDataModel.Models; using Microsoft.Extensions.Logging; -using System.Windows.Forms; -namespace FishFactory +namespace FishFactory.Forms { public partial class FormShop : Form { diff --git a/FishFactory/FormShopReplenish.Designer.cs b/FishFactory/FormShopReplenish.Designer.cs index a9e44d9..8a1f13b 100644 --- a/FishFactory/FormShopReplenish.Designer.cs +++ b/FishFactory/FormShopReplenish.Designer.cs @@ -1,4 +1,4 @@ -namespace FishFactory +namespace FishFactory.Forms { partial class FormShopReplenish { @@ -123,6 +123,7 @@ Controls.Add(label1); Name = "FormShopReplenish"; Text = "Пополнение магазина"; + Load += FormShopReplenish_Load; ResumeLayout(false); PerformLayout(); } diff --git a/FishFactory/FormShopReplenish.cs b/FishFactory/FormShopReplenish.cs index 122d9ae..19a45f3 100644 --- a/FishFactory/FormShopReplenish.cs +++ b/FishFactory/FormShopReplenish.cs @@ -1,10 +1,9 @@ - -using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace FishFactory +namespace FishFactory.Forms { public partial class FormShopReplenish : Form { @@ -22,7 +21,7 @@ namespace FishFactory _logicS = logicS; } - private void FormCreateReplenish_Load(object sender, EventArgs e) + private void FormShopReplenish_Load(object sender, EventArgs e) { _shopList = _logicS.ReadList(null); _cannedList = _logicP.ReadList(null); diff --git a/FishFactory/FormShops.Designer.cs b/FishFactory/FormShops.Designer.cs index b7c0239..0b6ebdd 100644 --- a/FishFactory/FormShops.Designer.cs +++ b/FishFactory/FormShops.Designer.cs @@ -1,4 +1,4 @@ -namespace FishFactory +namespace FishFactory.Forms { partial class FormShops { @@ -105,6 +105,7 @@ Controls.Add(dataGridView); Name = "FormShops"; Text = "Список магазинов"; + Load += FormShops_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } diff --git a/FishFactory/FormShops.cs b/FishFactory/FormShops.cs index 2d0c90f..46e8f15 100644 --- a/FishFactory/FormShops.cs +++ b/FishFactory/FormShops.cs @@ -1,18 +1,15 @@ -using FishFactory.Forms; -using FishFactoryDataModel.Models; -using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; -using FishFactoryContracts.SearchModels; using Microsoft.Extensions.Logging; -namespace FishFactory +namespace FishFactory.Forms { public partial class FormShops : Form { private readonly ILogger _logger; - private readonly IComponentLogic _logic; + private readonly IShopLogic _logic; - public FormShops(ILogger logger, IComponentLogic logic) + public FormShops(ILogger logger, IShopLogic logic) { InitializeComponent(); _logger = logger; @@ -82,7 +79,7 @@ namespace FishFactory _logger.LogInformation("Удаление магазина"); try { - if (!_logic.Delete(new ComponentBindingModel + if (!_logic.Delete(new ShopBindingModel { Id = id })) diff --git a/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs index b2cbc12..843fd8e 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/ShopLogic.cs @@ -140,7 +140,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic { throw new ArgumentNullException("Нет названия компонента", nameof(model.ShopName)); } - _logger.LogInformation("Shop. ShopName:{ShopName}.Adress:{Adress}. Id: {Id}", model.ShopName, model.Adress, model.Id); + _logger.LogInformation("Shop. ShopName:{ShopName}.Adress:{Adress}.OpeningDate:{OpeningDate}. Id: {Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id); var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName diff --git a/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs b/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs index f7210d5..f79e120 100644 --- a/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs +++ b/FishFactoryContracts/BindingModels/ReplenishBindingModel.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using FishFactoryDataModel.Models; namespace FishFactoryContracts.BindingModels { - public class ReplenishBindingModel + public class ReplenishBindingModel : IReplenishModel { public int ShopId { get; set; } public int CannedId { get; set; } diff --git a/FishFactoryContracts/BindingModels/ShopBindingModel.cs b/FishFactoryContracts/BindingModels/ShopBindingModel.cs index 7183ee7..d89fa75 100644 --- a/FishFactoryContracts/BindingModels/ShopBindingModel.cs +++ b/FishFactoryContracts/BindingModels/ShopBindingModel.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FishFactoryDataModel.Models; +using FishFactoryDataModel.Models; namespace FishFactoryContracts.BindingModels { - public class ShopBindingModel + public class ShopBindingModel : IShopModel { public int Id { get; set; } public string ShopName { get; set; } = string.Empty; diff --git a/FishFactoryContracts/SearchModels/OrderSearchModel.cs b/FishFactoryContracts/SearchModels/OrderSearchModel.cs index 895b7e1..4d57da6 100644 --- a/FishFactoryContracts/SearchModels/OrderSearchModel.cs +++ b/FishFactoryContracts/SearchModels/OrderSearchModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryContracts.SearchModels +namespace FishFactoryContracts.SearchModels { public class OrderSearchModel { diff --git a/FishFactoryContracts/ViewModels/ShopViewModel.cs b/FishFactoryContracts/ViewModels/ShopViewModel.cs index bd93234..49058c7 100644 --- a/FishFactoryContracts/ViewModels/ShopViewModel.cs +++ b/FishFactoryContracts/ViewModels/ShopViewModel.cs @@ -18,6 +18,5 @@ namespace FishFactoryContracts.ViewModels [DisplayName("Дата открытия")] public DateTime OpeningDate { get; set; } public Dictionary ShopCanneds { get; set; } = new(); - } } diff --git a/FishFactoryDataModels/Models/IReplenishModel.cs b/FishFactoryDataModels/Models/IReplenishModel.cs new file mode 100644 index 0000000..ad1976d --- /dev/null +++ b/FishFactoryDataModels/Models/IReplenishModel.cs @@ -0,0 +1,9 @@ +namespace FishFactoryDataModel.Models +{ + public interface IReplenishModel + { + int ShopId { get; } + int CannedId { get; } + int Count { get; } + } +} diff --git a/FishFactoryDataModels/Models/IShopCannedModel.cs b/FishFactoryDataModels/Models/IShopCannedModel.cs deleted file mode 100644 index aa84a61..0000000 --- a/FishFactoryDataModels/Models/IShopCannedModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryDataModel.Models -{ - public interface IShopCannedModel - { - int ShopId { get; } - int CannedId { get; } - int Count { get; } - } -} diff --git a/FishFactoryDataModels/Models/IShopModel.cs b/FishFactoryDataModels/Models/IShopModel.cs index 1389ba6..eb7381f 100644 --- a/FishFactoryDataModels/Models/IShopModel.cs +++ b/FishFactoryDataModels/Models/IShopModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FishFactoryDataModel.Models +namespace FishFactoryDataModel.Models { public interface IShopModel : IId { diff --git a/FishFactoryListImplement/Implements/ShopStorage.cs b/FishFactoryListImplement/Implements/ShopStorage.cs index 9b19e79..50007f7 100644 --- a/FishFactoryListImplement/Implements/ShopStorage.cs +++ b/FishFactoryListImplement/Implements/ShopStorage.cs @@ -3,11 +3,6 @@ using FishFactoryContracts.SearchModels; using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.ViewModels; using FishFactoryListImplement.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FishFactoryListImplement.Implements { @@ -30,13 +25,13 @@ namespace FishFactoryListImplement.Implements public List GetFilteredList(ShopSearchModel model) { var result = new List(); - if (model == null || !model.Id.HasValue) + if (string.IsNullOrEmpty(model.ShopName)) { return result; } foreach (var shop in _source.Shops) { - if (shop.Id == model.Id) + if (shop.ShopName.Contains(model.ShopName)) { result.Add(shop.GetViewModel); } @@ -45,13 +40,13 @@ namespace FishFactoryListImplement.Implements } public ShopViewModel? GetElement(ShopSearchModel model) { - if (!model.Id.HasValue) + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) { return null; } foreach (var shop in _source.Shops) { - if (model.Id.HasValue && shop.Id == model.Id) + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id)) { return shop.GetViewModel; } diff --git a/FishFactoryListImplement/Models/Shop.cs b/FishFactoryListImplement/Models/Shop.cs index b82b19c..78557b3 100644 --- a/FishFactoryListImplement/Models/Shop.cs +++ b/FishFactoryListImplement/Models/Shop.cs @@ -1,11 +1,6 @@ using FishFactoryContracts.BindingModels; using FishFactoryDataModel.Models; using FishFactoryContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FishFactoryListImplement.Models {