доделать пополнение и поправить представление консервы в магазине

This commit is contained in:
Shtyrkin_Egor 2024-03-06 11:01:55 +04:00
parent c65f7168a8
commit f430bc9773
20 changed files with 37 additions and 116 deletions

View File

@ -1,14 +1,4 @@
using System; using FishFactoryContracts.BindingModels;
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.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;

View File

@ -1,15 +1,5 @@
using System; using Microsoft.Extensions.Logging;
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 FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using Microsoft.VisualBasic.Logging;
using FishFactoryContracts.SearchModels; using FishFactoryContracts.SearchModels;
using FishFactoryContracts.BindingModels; using FishFactoryContracts.BindingModels;

View File

@ -1,15 +1,6 @@
using FishFactoryContracts.BindingModels; using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; 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 namespace FishFactory.Forms
{ {

View File

@ -1,15 +1,6 @@
using FishFactoryContracts.BindingModels; using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; 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 namespace FishFactory.Forms
{ {
@ -82,7 +73,6 @@ namespace FishFactory.Forms
if (service is FormShopReplenish form) if (service is FormShopReplenish form)
{ {
form.ShowDialog(); form.ShowDialog();
LoadData();
} }
} }

View File

@ -1,4 +1,4 @@
namespace FishFactory namespace FishFactory.Forms
{ {
partial class FormShop partial class FormShop
{ {
@ -156,6 +156,7 @@
Controls.Add(label1); Controls.Add(label1);
Name = "FormShop"; Name = "FormShop";
Text = "Магазин"; Text = "Магазин";
Load += FormShop_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();

View File

@ -3,9 +3,8 @@ using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.SearchModels; using FishFactoryContracts.SearchModels;
using FishFactoryDataModel.Models; using FishFactoryDataModel.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Windows.Forms;
namespace FishFactory namespace FishFactory.Forms
{ {
public partial class FormShop : Form public partial class FormShop : Form
{ {

View File

@ -1,4 +1,4 @@
namespace FishFactory namespace FishFactory.Forms
{ {
partial class FormShopReplenish partial class FormShopReplenish
{ {
@ -123,6 +123,7 @@
Controls.Add(label1); Controls.Add(label1);
Name = "FormShopReplenish"; Name = "FormShopReplenish";
Text = "Пополнение магазина"; Text = "Пополнение магазина";
Load += FormShopReplenish_Load;
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }

View File

@ -1,10 +1,9 @@
 using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.ViewModels; using FishFactoryContracts.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace FishFactory namespace FishFactory.Forms
{ {
public partial class FormShopReplenish : Form public partial class FormShopReplenish : Form
{ {
@ -22,7 +21,7 @@ namespace FishFactory
_logicS = logicS; _logicS = logicS;
} }
private void FormCreateReplenish_Load(object sender, EventArgs e) private void FormShopReplenish_Load(object sender, EventArgs e)
{ {
_shopList = _logicS.ReadList(null); _shopList = _logicS.ReadList(null);
_cannedList = _logicP.ReadList(null); _cannedList = _logicP.ReadList(null);

View File

@ -1,4 +1,4 @@
namespace FishFactory namespace FishFactory.Forms
{ {
partial class FormShops partial class FormShops
{ {
@ -105,6 +105,7 @@
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "FormShops"; Name = "FormShops";
Text = "Список магазинов"; Text = "Список магазинов";
Load += FormShops_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -1,18 +1,15 @@
using FishFactory.Forms; using FishFactoryContracts.BindingModels;
using FishFactoryDataModel.Models;
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.SearchModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace FishFactory namespace FishFactory.Forms
{ {
public partial class FormShops : Form public partial class FormShops : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IComponentLogic _logic; private readonly IShopLogic _logic;
public FormShops(ILogger<FormShops> logger, IComponentLogic logic) public FormShops(ILogger<FormShops> logger, IShopLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
@ -82,7 +79,7 @@ namespace FishFactory
_logger.LogInformation("Удаление магазина"); _logger.LogInformation("Удаление магазина");
try try
{ {
if (!_logic.Delete(new ComponentBindingModel if (!_logic.Delete(new ShopBindingModel
{ {
Id = id Id = id
})) }))

View File

@ -140,7 +140,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic
{ {
throw new ArgumentNullException("Нет названия компонента", nameof(model.ShopName)); 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 var element = _shopStorage.GetElement(new ShopSearchModel
{ {
ShopName = model.ShopName ShopName = model.ShopName

View File

@ -1,12 +1,8 @@
using System; using FishFactoryDataModel.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryContracts.BindingModels namespace FishFactoryContracts.BindingModels
{ {
public class ReplenishBindingModel public class ReplenishBindingModel : IReplenishModel
{ {
public int ShopId { get; set; } public int ShopId { get; set; }
public int CannedId { get; set; } public int CannedId { get; set; }

View File

@ -1,13 +1,8 @@
using System; using FishFactoryDataModel.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FishFactoryDataModel.Models;
namespace FishFactoryContracts.BindingModels namespace FishFactoryContracts.BindingModels
{ {
public class ShopBindingModel public class ShopBindingModel : IShopModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string ShopName { get; set; } = string.Empty; public string ShopName { get; set; } = string.Empty;

View File

@ -1,10 +1,4 @@
using System; namespace FishFactoryContracts.SearchModels
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryContracts.SearchModels
{ {
public class OrderSearchModel public class OrderSearchModel
{ {

View File

@ -18,6 +18,5 @@ namespace FishFactoryContracts.ViewModels
[DisplayName("Дата открытия")] [DisplayName("Дата открытия")]
public DateTime OpeningDate { get; set; } public DateTime OpeningDate { get; set; }
public Dictionary<int, (ICannedModel, int)> ShopCanneds { get; set; } = new(); public Dictionary<int, (ICannedModel, int)> ShopCanneds { get; set; } = new();
} }
} }

View File

@ -0,0 +1,9 @@
namespace FishFactoryDataModel.Models
{
public interface IReplenishModel
{
int ShopId { get; }
int CannedId { get; }
int Count { get; }
}
}

View File

@ -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; }
}
}

View File

@ -1,10 +1,4 @@
using System; namespace FishFactoryDataModel.Models
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryDataModel.Models
{ {
public interface IShopModel : IId public interface IShopModel : IId
{ {

View File

@ -3,11 +3,6 @@ using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels; using FishFactoryContracts.ViewModels;
using FishFactoryListImplement.Models; using FishFactoryListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryListImplement.Implements namespace FishFactoryListImplement.Implements
{ {
@ -30,13 +25,13 @@ namespace FishFactoryListImplement.Implements
public List<ShopViewModel> GetFilteredList(ShopSearchModel model) public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{ {
var result = new List<ShopViewModel>(); var result = new List<ShopViewModel>();
if (model == null || !model.Id.HasValue) if (string.IsNullOrEmpty(model.ShopName))
{ {
return result; return result;
} }
foreach (var shop in _source.Shops) foreach (var shop in _source.Shops)
{ {
if (shop.Id == model.Id) if (shop.ShopName.Contains(model.ShopName))
{ {
result.Add(shop.GetViewModel); result.Add(shop.GetViewModel);
} }
@ -45,13 +40,13 @@ namespace FishFactoryListImplement.Implements
} }
public ShopViewModel? GetElement(ShopSearchModel model) public ShopViewModel? GetElement(ShopSearchModel model)
{ {
if (!model.Id.HasValue) if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
{ {
return null; return null;
} }
foreach (var shop in _source.Shops) 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; return shop.GetViewModel;
} }

View File

@ -1,11 +1,6 @@
using FishFactoryContracts.BindingModels; using FishFactoryContracts.BindingModels;
using FishFactoryDataModel.Models; using FishFactoryDataModel.Models;
using FishFactoryContracts.ViewModels; using FishFactoryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryListImplement.Models namespace FishFactoryListImplement.Models
{ {