Merge branch 'LabWorkHard02' into LabWorkHard03
This commit is contained in:
commit
1b27ec3be2
@ -12,11 +12,13 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopLogic _shopLogic;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
@ -45,7 +47,7 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
public bool ChangeStatus(OrderBindingModel model, OrderStatus targetStatus)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
@ -54,18 +56,20 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Read operation failed");
|
_logger.LogWarning("Read operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (element.Status != status - 1)
|
if (element.Status != targetStatus - 1)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status change operation failed");
|
_logger.LogWarning("Status change operation failed");
|
||||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||||
}
|
}
|
||||||
OrderStatus oldStatus = model.Status;
|
if (targetStatus == OrderStatus.Выдан)
|
||||||
model.Status = status;
|
{
|
||||||
|
_shopLogic.SupplySecures();
|
||||||
|
}
|
||||||
|
model.Status = targetStatus;
|
||||||
if (model.Status == OrderStatus.Выдан)
|
if (model.Status == OrderStatus.Выдан)
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status = oldStatus;
|
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,209 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ShopLogic : IShopLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
|
||||||
|
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement. Shop Name:{0}, ID:{1}", model.Name, model.Id);
|
||||||
|
|
||||||
|
var element = _shopStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement. element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement found. Id:{Id}", element.Id);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Shop Name:{0}, ID:{1} ", model?.Name, 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 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);
|
||||||
|
|
||||||
|
if (_shopStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия магазина!", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Shop. Name: {0}, Address: {1}, ID: {2}", model.Name, model.Address, model.Id);
|
||||||
|
|
||||||
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Name = model.Name
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool SupplySecures(ShopSearchModel model, ISecureModel secure, int count)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secure == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(secure));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Количество продукта для пополнения должно быть больше 0", nameof(count));
|
||||||
|
}
|
||||||
|
|
||||||
|
var shopElement = _shopStorage.GetElement(model);
|
||||||
|
|
||||||
|
if (shopElement == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Required shop element not found in storage");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Shop element found. ID: {0}, Name: {1}", shopElement.Id, shopElement.Name);
|
||||||
|
|
||||||
|
if (shopElement.ShopSecures.TryGetValue(secure.Id, out var sameSecure))
|
||||||
|
{
|
||||||
|
shopElement.ShopSecures[secure.Id] = (secure, sameSecure.Item2 + count);
|
||||||
|
_logger.LogInformation("Same secure found by supply. Added {0} of {1} in {2} shop", count, secure.SecureName, shopElement.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shopElement.ShopSecures[secure.Id] = (secure, count);
|
||||||
|
_logger.LogInformation("New secure added by supply. Added {0} of {1} in {2} shop", count, secure.SecureName, shopElement.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = shopElement.Id,
|
||||||
|
Name = shopElement.Name,
|
||||||
|
Address = shopElement.Address,
|
||||||
|
OpeningDate = shopElement.OpeningDate,
|
||||||
|
ShopSecures = shopElement.ShopSecures,
|
||||||
|
MaxSecuresCount = shopElement.MaxSecuresCount
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool SupplySecures(ISecureModel secure, int count) => throw new NotImplementedException();
|
||||||
|
public bool SellSecures(ISecureModel model, int count) => throw new NotImplementedException();
|
||||||
|
public bool CheckSecuresCount(ISecureModel model, int count)
|
||||||
|
{
|
||||||
|
int securesInShops = _shopStorage.GetFullList()
|
||||||
|
.Select(x => x.ShopSecures.Select(y => y.Value.Item1.Id == model.Id ? y.Value.Item2 : 0).Sum()).Sum();
|
||||||
|
return securesInShops >= count;
|
||||||
|
}
|
||||||
|
public bool CheckSupplySecures(ShopSearchModel shopSearchModel, int count)
|
||||||
|
{
|
||||||
|
if (shopSearchModel == null)
|
||||||
|
throw new ArgumentNullException(nameof(shopSearchModel));
|
||||||
|
|
||||||
|
var shop = _shopStorage.GetElement(shopSearchModel);
|
||||||
|
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Required shop element not found in storage");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int securesInShop = _shopStorage.GetFullList().Select(x => x.ShopSecures.Select(y => y.Value.Item2).Sum()).Sum();
|
||||||
|
|
||||||
|
return securesInShop + count <= shop.MaxSecuresCount;
|
||||||
|
}
|
||||||
|
public bool CheckSupplySecures(int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ShopBindingModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; set; }
|
||||||
|
public int MaxSecuresCount { get; set; }
|
||||||
|
public Dictionary<int, (ISecureModel, int)> ShopSecures { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IShopLogic
|
||||||
|
{
|
||||||
|
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||||
|
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||||
|
bool Create(ShopBindingModel model);
|
||||||
|
bool Update(ShopBindingModel model);
|
||||||
|
bool Delete(ShopBindingModel model);
|
||||||
|
/// <summary>
|
||||||
|
/// Продает продукт со всех магазинов в заданном количестве
|
||||||
|
/// </summary>
|
||||||
|
bool SellSecures(ISecureModel model, int count);
|
||||||
|
/// <summary>
|
||||||
|
/// Проверяет наличие определенного количества продукта суммарно по всем магазинам
|
||||||
|
/// </summary>
|
||||||
|
bool CheckSecuresCount(ISecureModel model, int count);
|
||||||
|
/// <summary>
|
||||||
|
/// Проверяет можно ли пополнить конкретный магазин продукцией в указанном количестве
|
||||||
|
/// </summary>
|
||||||
|
bool CheckSupplySecures(ShopSearchModel shopSearchModel, int count);
|
||||||
|
/// <summary>
|
||||||
|
/// Проверяет можно ли распределить во все магазины продукты в указанном количестве
|
||||||
|
/// </summary>
|
||||||
|
bool CheckSupplySecures(int count);
|
||||||
|
/// <summary>
|
||||||
|
/// Пополняет конкретный магазин продуктом в указанном количестве
|
||||||
|
/// </summary>
|
||||||
|
bool SupplySecures(ShopSearchModel model, ISecureModel secure, int count);
|
||||||
|
/// <summary>
|
||||||
|
/// Рапределяет по всем магазинам продукт в указанном количестве
|
||||||
|
/// </summary>
|
||||||
|
bool SupplySecures(ISecureModel secure, int count);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
namespace SecuritySystemContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ShopSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IShopStorage
|
||||||
|
{
|
||||||
|
ShopViewModel? GetElement(ShopSearchModel model);
|
||||||
|
List<ShopViewModel> GetFullList();
|
||||||
|
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||||
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ShopViewModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Адрес")]
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Макс. кол-во товара")]
|
||||||
|
public int MaxSecuresCount { get; set; }
|
||||||
|
[DisplayName("Дата открытия")]
|
||||||
|
public DateTime OpeningDate { get; set; }
|
||||||
|
public Dictionary<int, (ISecureModel, int)> ShopSecures { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
11
SecuritySystem/SecuritySystemDataModels/Models/IShopModel.cs
Normal file
11
SecuritySystem/SecuritySystemDataModels/Models/IShopModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace SecuritySystemDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IShopModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
string Address { get; }
|
||||||
|
DateTime OpeningDate { get; }
|
||||||
|
int MaxSecuresCount { get; }
|
||||||
|
Dictionary<int, (ISecureModel, int)> ShopSecures { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -9,9 +9,11 @@ namespace SecuritySystemFileImplement
|
|||||||
private readonly string ComponentFileName = "Component.xml";
|
private readonly string ComponentFileName = "Component.xml";
|
||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string SecureFileName = "Secure.xml";
|
private readonly string SecureFileName = "Secure.xml";
|
||||||
|
private readonly string ShopFileName = "Shop.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Secure> Secures { get; private set; }
|
public List<Secure> Secures { get; private set; }
|
||||||
|
public List<Shop> Shops { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -23,11 +25,13 @@ namespace SecuritySystemFileImplement
|
|||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||||
public void SaveSecures() => SaveData(Secures, SecureFileName, "Secures", x => x.GetXElement);
|
public void SaveSecures() => SaveData(Secures, SecureFileName, "Secures", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
|
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
Secures = LoadData(SecureFileName, "Secure", x => Secure.Create(x)!)!;
|
Secures = LoadData(SecureFileName, "Secure", x => Secure.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||||
Func<XElement, T> selectFunction)
|
Func<XElement, T> selectFunction)
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
using SecuritySystemFileImplement.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return source.Shops.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return source.Shops
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.Where(x => x.Name.Contains(model.Name ?? string.Empty))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Shops.Select(shop => shop.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
source.Shops.Add(newShop);
|
||||||
|
source.SaveShops();
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
shop.Update(model);
|
||||||
|
source.SaveShops();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
source.Shops.Remove(shop);
|
||||||
|
source.SaveShops();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
111
SecuritySystem/SecuritySystemFileImplement/Models/Shop.cs
Normal file
111
SecuritySystem/SecuritySystemFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
using SecuritySystemFileImplement;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace SecuritySystemFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
public int MaxSecuresCount { get; private set; }
|
||||||
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
public Dictionary<int, int> Secures { get; private set; } = new();
|
||||||
|
private Dictionary<int, (ISecureModel, int)>? _shopSecures = null;
|
||||||
|
public Dictionary<int, (ISecureModel, int)> ShopSecures
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopSecures == null)
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
_shopSecures = Secures.ToDictionary(
|
||||||
|
x => x.Key,
|
||||||
|
y => ((source.Secures.FirstOrDefault(z => z.Id == y.Key) as ISecureModel)!, y.Value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _shopSecures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Address = model.Address,
|
||||||
|
MaxSecuresCount = model.MaxSecuresCount,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
Secures = model.ShopSecures.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Shop? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
Name = element.Element("Name")!.Value,
|
||||||
|
Address = element.Element("Address")!.Value,
|
||||||
|
MaxSecuresCount = Convert.ToInt32(element.Element("MaxSecuresCount")!.Value),
|
||||||
|
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
||||||
|
Secures = element.Element("ShopSecures")!.Elements("ShopSecure").ToDictionary(
|
||||||
|
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||||
|
x => Convert.ToInt32(x.Element("Value")?.Value)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
Address = model.Address;
|
||||||
|
MaxSecuresCount = model.MaxSecuresCount;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
if (model.ShopSecures.Count > 0)
|
||||||
|
{
|
||||||
|
Secures = model.ShopSecures.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||||
|
_shopSecures = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Address = Address,
|
||||||
|
MaxSecuresCount = MaxSecuresCount,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopSecures = ShopSecures,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new(
|
||||||
|
"Shop",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("Name", Name),
|
||||||
|
new XElement("Address", Address),
|
||||||
|
new XElement("MaxSecuresCount", MaxSecuresCount),
|
||||||
|
new XElement("OpeningDate", OpeningDate.ToString()),
|
||||||
|
new XElement("ShopSecures", Secures.Select(x =>
|
||||||
|
new XElement("ShopSecure",
|
||||||
|
new XElement("Key", x.Key),
|
||||||
|
new XElement("Value", x.Value)))
|
||||||
|
.ToArray()));
|
||||||
|
}
|
||||||
|
}
|
@ -8,11 +8,13 @@ namespace SecuritySystemListImplement
|
|||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Secure> Secures { get; set; }
|
public List<Secure> Secures { get; set; }
|
||||||
|
public List<Shop> Shops { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Secures = new List<Secure>();
|
Secures = new List<Secure>();
|
||||||
|
Shops = new List<Shop>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,121 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemListImplement.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.Name) && shop.Name == model.Name) || (model.Id.HasValue && shop.Id == model.Id))
|
||||||
|
{
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.Name.Contains(model.Name))
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
SecuritySystem/SecuritySystemListImplement/Models/Shop.cs
Normal file
57
SecuritySystem/SecuritySystemListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.ViewModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemListImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
public int MaxSecuresCount { get; private set; }
|
||||||
|
public Dictionary<int, (ISecureModel, int)> ShopSecures { get; private set; } = new();
|
||||||
|
public static Shop? Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Address = model.Address,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
MaxSecuresCount = model.MaxSecuresCount,
|
||||||
|
ShopSecures = new()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Name = model.Name;
|
||||||
|
Address = model.Address;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
MaxSecuresCount = model.MaxSecuresCount;
|
||||||
|
ShopSecures = model.ShopSecures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Address = Address,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
MaxSecuresCount = MaxSecuresCount,
|
||||||
|
ShopSecures = ShopSecures
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -41,14 +41,14 @@
|
|||||||
textBoxComponentName.Location = new Point(98, 6);
|
textBoxComponentName.Location = new Point(98, 6);
|
||||||
textBoxComponentName.Name = "textBoxComponentName";
|
textBoxComponentName.Name = "textBoxComponentName";
|
||||||
textBoxComponentName.Size = new Size(372, 27);
|
textBoxComponentName.Size = new Size(372, 27);
|
||||||
textBoxComponentName.TabIndex = 0;
|
textBoxComponentName.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// textBoxComponentCost
|
// textBoxComponentCost
|
||||||
//
|
//
|
||||||
textBoxComponentCost.Location = new Point(98, 41);
|
textBoxComponentCost.Location = new Point(98, 41);
|
||||||
textBoxComponentCost.Name = "textBoxComponentCost";
|
textBoxComponentCost.Name = "textBoxComponentCost";
|
||||||
textBoxComponentCost.Size = new Size(125, 27);
|
textBoxComponentCost.Size = new Size(125, 27);
|
||||||
textBoxComponentCost.TabIndex = 1;
|
textBoxComponentCost.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// labelComponentName
|
// labelComponentName
|
||||||
//
|
//
|
||||||
@ -73,7 +73,7 @@
|
|||||||
buttonSaveComponent.Location = new Point(211, 80);
|
buttonSaveComponent.Location = new Point(211, 80);
|
||||||
buttonSaveComponent.Name = "buttonSaveComponent";
|
buttonSaveComponent.Name = "buttonSaveComponent";
|
||||||
buttonSaveComponent.Size = new Size(115, 29);
|
buttonSaveComponent.Size = new Size(115, 29);
|
||||||
buttonSaveComponent.TabIndex = 1;
|
buttonSaveComponent.TabIndex = 3;
|
||||||
buttonSaveComponent.Text = "Сохранить";
|
buttonSaveComponent.Text = "Сохранить";
|
||||||
buttonSaveComponent.UseVisualStyleBackColor = true;
|
buttonSaveComponent.UseVisualStyleBackColor = true;
|
||||||
buttonSaveComponent.Click += ButtonSaveComponent_Click;
|
buttonSaveComponent.Click += ButtonSaveComponent_Click;
|
||||||
@ -83,7 +83,7 @@
|
|||||||
buttonCancel.Location = new Point(348, 80);
|
buttonCancel.Location = new Point(348, 80);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(122, 29);
|
buttonCancel.Size = new Size(122, 29);
|
||||||
buttonCancel.TabIndex = 5;
|
buttonCancel.TabIndex = 4;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
@ -32,12 +32,14 @@
|
|||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
SecuresToolStripMenuItem = new ToolStripMenuItem();
|
SecuresToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
button4 = new Button();
|
button4 = new Button();
|
||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
|
пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -45,7 +47,7 @@
|
|||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, пополнениеМагазинаToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(1043, 28);
|
menuStrip.Size = new Size(1043, 28);
|
||||||
@ -54,7 +56,7 @@
|
|||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, SecuresToolStripMenuItem });
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, SecuresToolStripMenuItem, магазиныToolStripMenuItem });
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
@ -62,17 +64,24 @@
|
|||||||
// ComponentsToolStripMenuItem
|
// ComponentsToolStripMenuItem
|
||||||
//
|
//
|
||||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||||
ComponentsToolStripMenuItem.Size = new Size(182, 26);
|
ComponentsToolStripMenuItem.Size = new Size(224, 26);
|
||||||
ComponentsToolStripMenuItem.Text = "Компоненты";
|
ComponentsToolStripMenuItem.Text = "Компоненты";
|
||||||
ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// SecuresToolStripMenuItem
|
// SecuresToolStripMenuItem
|
||||||
//
|
//
|
||||||
SecuresToolStripMenuItem.Name = "SecuresToolStripMenuItem";
|
SecuresToolStripMenuItem.Name = "SecuresToolStripMenuItem";
|
||||||
SecuresToolStripMenuItem.Size = new Size(182, 26);
|
SecuresToolStripMenuItem.Size = new Size(224, 26);
|
||||||
SecuresToolStripMenuItem.Text = "Изделия";
|
SecuresToolStripMenuItem.Text = "Изделия";
|
||||||
SecuresToolStripMenuItem.Click += SecuresToolStripMenuItem_Click;
|
SecuresToolStripMenuItem.Click += SecuresToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// магазиныToolStripMenuItem
|
||||||
|
//
|
||||||
|
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
|
магазиныToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
магазиныToolStripMenuItem.Text = "Магазины";
|
||||||
|
магазиныToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
@ -142,6 +151,13 @@
|
|||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
//
|
//
|
||||||
|
// пополнениеМагазинаToolStripMenuItem
|
||||||
|
//
|
||||||
|
пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
|
||||||
|
пополнениеМагазинаToolStripMenuItem.Size = new Size(182, 24);
|
||||||
|
пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
|
||||||
|
пополнениеМагазинаToolStripMenuItem.Click += SupplyShopToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -177,5 +193,7 @@
|
|||||||
private Button buttonOrderReady;
|
private Button buttonOrderReady;
|
||||||
private Button button4;
|
private Button button4;
|
||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -136,5 +136,23 @@ namespace SecuritySystemView
|
|||||||
{
|
{
|
||||||
LoadData();
|
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 SupplyShopToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
|
||||||
|
if (service is FormShopSupply form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
comboBoxSecure.Location = new Point(110, 9);
|
comboBoxSecure.Location = new Point(110, 9);
|
||||||
comboBoxSecure.Name = "comboBoxSecure";
|
comboBoxSecure.Name = "comboBoxSecure";
|
||||||
comboBoxSecure.Size = new Size(462, 28);
|
comboBoxSecure.Size = new Size(462, 28);
|
||||||
comboBoxSecure.TabIndex = 3;
|
comboBoxSecure.TabIndex = 1;
|
||||||
comboBoxSecure.SelectedIndexChanged += ComboBoxSecure_SelectedIndexChanged;
|
comboBoxSecure.SelectedIndexChanged += ComboBoxSecure_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
@ -80,7 +80,7 @@
|
|||||||
textBoxCount.Location = new Point(110, 43);
|
textBoxCount.Location = new Point(110, 43);
|
||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(462, 27);
|
textBoxCount.Size = new Size(462, 27);
|
||||||
textBoxCount.TabIndex = 4;
|
textBoxCount.TabIndex = 2;
|
||||||
textBoxCount.TextChanged += TextBoxCount_TextChanged;
|
textBoxCount.TextChanged += TextBoxCount_TextChanged;
|
||||||
//
|
//
|
||||||
// textBoxSum
|
// textBoxSum
|
||||||
@ -96,7 +96,7 @@
|
|||||||
buttonSave.Location = new Point(370, 118);
|
buttonSave.Location = new Point(370, 118);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(94, 29);
|
buttonSave.Size = new Size(94, 29);
|
||||||
buttonSave.TabIndex = 1;
|
buttonSave.TabIndex = 3;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += ButtonSave_Click;
|
buttonSave.Click += ButtonSave_Click;
|
||||||
@ -106,7 +106,7 @@
|
|||||||
buttonCancel.Location = new Point(478, 118);
|
buttonCancel.Location = new Point(478, 118);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(94, 29);
|
buttonCancel.Size = new Size(94, 29);
|
||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 4;
|
||||||
buttonCancel.Text = "Отменить";
|
buttonCancel.Text = "Отменить";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
@ -39,6 +39,8 @@ namespace SecuritySystemView
|
|||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISecureLogic, SecureLogic>();
|
services.AddTransient<ISecureLogic, SecureLogic>();
|
||||||
|
services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
|
services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
@ -46,6 +48,9 @@ namespace SecuritySystemView
|
|||||||
services.AddTransient<FormSecure>();
|
services.AddTransient<FormSecure>();
|
||||||
services.AddTransient<FormSecureComponent>();
|
services.AddTransient<FormSecureComponent>();
|
||||||
services.AddTransient<FormSecures>();
|
services.AddTransient<FormSecures>();
|
||||||
|
services.AddTransient<FormShop>();
|
||||||
|
services.AddTransient<FormShops>();
|
||||||
|
services.AddTransient<FormShopSupply>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -70,7 +70,7 @@
|
|||||||
textBoxName.Location = new Point(108, 6);
|
textBoxName.Location = new Point(108, 6);
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(368, 27);
|
textBoxName.Size = new Size(368, 27);
|
||||||
textBoxName.TabIndex = 2;
|
textBoxName.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// textBoxPrice
|
// textBoxPrice
|
||||||
//
|
//
|
||||||
@ -78,7 +78,7 @@
|
|||||||
textBoxPrice.Location = new Point(108, 43);
|
textBoxPrice.Location = new Point(108, 43);
|
||||||
textBoxPrice.Name = "textBoxPrice";
|
textBoxPrice.Name = "textBoxPrice";
|
||||||
textBoxPrice.Size = new Size(143, 27);
|
textBoxPrice.Size = new Size(143, 27);
|
||||||
textBoxPrice.TabIndex = 3;
|
textBoxPrice.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// groupBoxComponentsControl
|
// groupBoxComponentsControl
|
||||||
//
|
//
|
||||||
@ -99,7 +99,7 @@
|
|||||||
buttonRefresh.Location = new Point(668, 197);
|
buttonRefresh.Location = new Point(668, 197);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(94, 29);
|
buttonRefresh.Size = new Size(94, 29);
|
||||||
buttonRefresh.TabIndex = 4;
|
buttonRefresh.TabIndex = 6;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
@ -109,7 +109,7 @@
|
|||||||
buttonDelete.Location = new Point(668, 147);
|
buttonDelete.Location = new Point(668, 147);
|
||||||
buttonDelete.Name = "buttonDelete";
|
buttonDelete.Name = "buttonDelete";
|
||||||
buttonDelete.Size = new Size(94, 29);
|
buttonDelete.Size = new Size(94, 29);
|
||||||
buttonDelete.TabIndex = 3;
|
buttonDelete.TabIndex = 5;
|
||||||
buttonDelete.Text = "Удалить";
|
buttonDelete.Text = "Удалить";
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
@ -119,7 +119,7 @@
|
|||||||
buttonEdit.Location = new Point(668, 99);
|
buttonEdit.Location = new Point(668, 99);
|
||||||
buttonEdit.Name = "buttonEdit";
|
buttonEdit.Name = "buttonEdit";
|
||||||
buttonEdit.Size = new Size(94, 29);
|
buttonEdit.Size = new Size(94, 29);
|
||||||
buttonEdit.TabIndex = 2;
|
buttonEdit.TabIndex = 4;
|
||||||
buttonEdit.Text = "Изменить";
|
buttonEdit.Text = "Изменить";
|
||||||
buttonEdit.UseVisualStyleBackColor = true;
|
buttonEdit.UseVisualStyleBackColor = true;
|
||||||
buttonEdit.Click += ButtonEdit_Click;
|
buttonEdit.Click += ButtonEdit_Click;
|
||||||
@ -129,7 +129,7 @@
|
|||||||
buttonAdd.Location = new Point(668, 48);
|
buttonAdd.Location = new Point(668, 48);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(94, 29);
|
buttonAdd.Size = new Size(94, 29);
|
||||||
buttonAdd.TabIndex = 1;
|
buttonAdd.TabIndex = 3;
|
||||||
buttonAdd.Text = "Добавить";
|
buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
@ -173,7 +173,7 @@
|
|||||||
buttonSave.Location = new Point(537, 409);
|
buttonSave.Location = new Point(537, 409);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(108, 29);
|
buttonSave.Size = new Size(108, 29);
|
||||||
buttonSave.TabIndex = 1;
|
buttonSave.TabIndex = 7;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += ButtonSave_Click;
|
buttonSave.Click += ButtonSave_Click;
|
||||||
@ -183,7 +183,7 @@
|
|||||||
buttonCancel.Location = new Point(665, 409);
|
buttonCancel.Location = new Point(665, 409);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(109, 29);
|
buttonCancel.Size = new Size(109, 29);
|
||||||
buttonCancel.TabIndex = 6;
|
buttonCancel.TabIndex = 8;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
@ -61,21 +61,21 @@
|
|||||||
comboBoxComponents.Location = new Point(109, 6);
|
comboBoxComponents.Location = new Point(109, 6);
|
||||||
comboBoxComponents.Name = "comboBoxComponents";
|
comboBoxComponents.Name = "comboBoxComponents";
|
||||||
comboBoxComponents.Size = new Size(315, 28);
|
comboBoxComponents.Size = new Size(315, 28);
|
||||||
comboBoxComponents.TabIndex = 2;
|
comboBoxComponents.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(109, 41);
|
textBoxCount.Location = new Point(109, 41);
|
||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(315, 27);
|
textBoxCount.Size = new Size(315, 27);
|
||||||
textBoxCount.TabIndex = 3;
|
textBoxCount.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(230, 84);
|
buttonSave.Location = new Point(230, 84);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(94, 29);
|
buttonSave.Size = new Size(94, 29);
|
||||||
buttonSave.TabIndex = 1;
|
buttonSave.TabIndex = 3;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += ButtonSave_Click;
|
buttonSave.Click += ButtonSave_Click;
|
||||||
@ -85,7 +85,7 @@
|
|||||||
buttonCancel.Location = new Point(330, 84);
|
buttonCancel.Location = new Point(330, 84);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(94, 29);
|
buttonCancel.Size = new Size(94, 29);
|
||||||
buttonCancel.TabIndex = 5;
|
buttonCancel.TabIndex = 4;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
@ -56,7 +56,7 @@
|
|||||||
buttonRefresh.Location = new Point(739, 162);
|
buttonRefresh.Location = new Point(739, 162);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(94, 29);
|
buttonRefresh.Size = new Size(94, 29);
|
||||||
buttonRefresh.TabIndex = 8;
|
buttonRefresh.TabIndex = 4;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += ButtonRefreshSecures_Click;
|
buttonRefresh.Click += ButtonRefreshSecures_Click;
|
||||||
@ -67,7 +67,7 @@
|
|||||||
buttonDelete.Location = new Point(739, 114);
|
buttonDelete.Location = new Point(739, 114);
|
||||||
buttonDelete.Name = "buttonDelete";
|
buttonDelete.Name = "buttonDelete";
|
||||||
buttonDelete.Size = new Size(94, 29);
|
buttonDelete.Size = new Size(94, 29);
|
||||||
buttonDelete.TabIndex = 7;
|
buttonDelete.TabIndex = 3;
|
||||||
buttonDelete.Text = "Удалить";
|
buttonDelete.Text = "Удалить";
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
buttonDelete.Click += ButtonDeleteSecure_Click;
|
buttonDelete.Click += ButtonDeleteSecure_Click;
|
||||||
@ -78,7 +78,7 @@
|
|||||||
buttonEdit.Location = new Point(739, 64);
|
buttonEdit.Location = new Point(739, 64);
|
||||||
buttonEdit.Name = "buttonEdit";
|
buttonEdit.Name = "buttonEdit";
|
||||||
buttonEdit.Size = new Size(94, 29);
|
buttonEdit.Size = new Size(94, 29);
|
||||||
buttonEdit.TabIndex = 6;
|
buttonEdit.TabIndex = 2;
|
||||||
buttonEdit.Text = "Изменить";
|
buttonEdit.Text = "Изменить";
|
||||||
buttonEdit.UseVisualStyleBackColor = true;
|
buttonEdit.UseVisualStyleBackColor = true;
|
||||||
buttonEdit.Click += ButtonEditSecure_Click;
|
buttonEdit.Click += ButtonEditSecure_Click;
|
194
SecuritySystem/SecuritySystemView/Shop/FormShop.Designer.cs
generated
Normal file
194
SecuritySystem/SecuritySystemView/Shop/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
namespace SecuritySystemView
|
||||||
|
{
|
||||||
|
partial class FormShop
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
labelName = new Label();
|
||||||
|
labelAddress = new Label();
|
||||||
|
labelOpeningDate = new Label();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
textBoxAddress = new TextBox();
|
||||||
|
dateTimePickerOpeningDate = new DateTimePicker();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
ColumnId = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnName = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
|
colorDialog1 = new ColorDialog();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(12, 9);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(80, 20);
|
||||||
|
labelName.TabIndex = 0;
|
||||||
|
labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// labelAddress
|
||||||
|
//
|
||||||
|
labelAddress.AutoSize = true;
|
||||||
|
labelAddress.Location = new Point(12, 41);
|
||||||
|
labelAddress.Name = "labelAddress";
|
||||||
|
labelAddress.Size = new Size(54, 20);
|
||||||
|
labelAddress.TabIndex = 1;
|
||||||
|
labelAddress.Text = "Адрес:";
|
||||||
|
//
|
||||||
|
// labelOpeningDate
|
||||||
|
//
|
||||||
|
labelOpeningDate.AutoSize = true;
|
||||||
|
labelOpeningDate.Location = new Point(12, 75);
|
||||||
|
labelOpeningDate.Name = "labelOpeningDate";
|
||||||
|
labelOpeningDate.Size = new Size(113, 20);
|
||||||
|
labelOpeningDate.TabIndex = 2;
|
||||||
|
labelOpeningDate.Text = "Дата открытия:";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxName.Location = new Point(98, 6);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(562, 27);
|
||||||
|
textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// textBoxAddress
|
||||||
|
//
|
||||||
|
textBoxAddress.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxAddress.Location = new Point(98, 38);
|
||||||
|
textBoxAddress.Name = "textBoxAddress";
|
||||||
|
textBoxAddress.Size = new Size(562, 27);
|
||||||
|
textBoxAddress.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// dateTimePickerOpeningDate
|
||||||
|
//
|
||||||
|
dateTimePickerOpeningDate.Location = new Point(131, 71);
|
||||||
|
dateTimePickerOpeningDate.Name = "dateTimePickerOpeningDate";
|
||||||
|
dateTimePickerOpeningDate.Size = new Size(185, 27);
|
||||||
|
dateTimePickerOpeningDate.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnCount });
|
||||||
|
dataGridView.Location = new Point(12, 104);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(517, 334);
|
||||||
|
dataGridView.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// ColumnId
|
||||||
|
//
|
||||||
|
ColumnId.HeaderText = "Id";
|
||||||
|
ColumnId.MinimumWidth = 6;
|
||||||
|
ColumnId.Name = "ColumnId";
|
||||||
|
ColumnId.Visible = false;
|
||||||
|
//
|
||||||
|
// ColumnName
|
||||||
|
//
|
||||||
|
ColumnName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
ColumnName.HeaderText = "Изделие";
|
||||||
|
ColumnName.MinimumWidth = 6;
|
||||||
|
ColumnName.Name = "ColumnName";
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.MinimumWidth = 6;
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
ColumnCount.Width = 119;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonSave.Location = new Point(549, 145);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(94, 29);
|
||||||
|
buttonSave.TabIndex = 4;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(549, 219);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 5;
|
||||||
|
buttonCancel.Text = "Закрыть";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormShop
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(672, 450);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(dateTimePickerOpeningDate);
|
||||||
|
Controls.Add(textBoxAddress);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(labelOpeningDate);
|
||||||
|
Controls.Add(labelAddress);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Name = "FormShop";
|
||||||
|
Text = "Магазин";
|
||||||
|
Load += FormShop_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelAddress;
|
||||||
|
private Label labelOpeningDate;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxAddress;
|
||||||
|
private DateTimePicker dateTimePickerOpeningDate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn ColumnId;
|
||||||
|
private DataGridViewTextBoxColumn ColumnName;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
private ColorDialog colorDialog1;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
125
SecuritySystem/SecuritySystemView/Shop/FormShop.cs
Normal file
125
SecuritySystem/SecuritySystemView/Shop/FormShop.cs
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecuritySystemView
|
||||||
|
{
|
||||||
|
public partial class FormShop : Form
|
||||||
|
{
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private Dictionary<int, (ISecureModel, int)> _shopSecures;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_shopSecures = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormShop_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Loading shop");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value });
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.Name;
|
||||||
|
textBoxAddress.Text = view.Address;
|
||||||
|
dateTimePickerOpeningDate.Value = view.OpeningDate;
|
||||||
|
_shopSecures = view.ShopSecures ?? new Dictionary<int, (ISecureModel, int)>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка магазина");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_shopSecures != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var secure in _shopSecures)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { secure.Key, secure.Value.Item1.SecureName, secure.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(textBoxAddress.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Сохранение магазина");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Address = textBoxAddress.Text,
|
||||||
|
OpeningDate = dateTimePickerOpeningDate.Value.Date,
|
||||||
|
ShopSecures = _shopSecures
|
||||||
|
};
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
132
SecuritySystem/SecuritySystemView/Shop/FormShop.resx
Normal file
132
SecuritySystem/SecuritySystemView/Shop/FormShop.resx
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
148
SecuritySystem/SecuritySystemView/Shop/FormShopSupply.Designer.cs
generated
Normal file
148
SecuritySystem/SecuritySystemView/Shop/FormShopSupply.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
namespace SecuritySystemView
|
||||||
|
{
|
||||||
|
partial class FormShopSupply
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
comboBoxShop = new ComboBox();
|
||||||
|
comboBoxSecure = new ComboBox();
|
||||||
|
labelShop = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
buttonSupply = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
textBoxCount = new TextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxShop
|
||||||
|
//
|
||||||
|
comboBoxShop.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxShop.FormattingEnabled = true;
|
||||||
|
comboBoxShop.Location = new Point(125, 6);
|
||||||
|
comboBoxShop.Name = "comboBoxShop";
|
||||||
|
comboBoxShop.Size = new Size(432, 28);
|
||||||
|
comboBoxShop.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// comboBoxSecure
|
||||||
|
//
|
||||||
|
comboBoxSecure.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
comboBoxSecure.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxSecure.FormattingEnabled = true;
|
||||||
|
comboBoxSecure.Location = new Point(125, 47);
|
||||||
|
comboBoxSecure.Name = "comboBoxSecure";
|
||||||
|
comboBoxSecure.Size = new Size(432, 28);
|
||||||
|
comboBoxSecure.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// labelShop
|
||||||
|
//
|
||||||
|
labelShop.AutoSize = true;
|
||||||
|
labelShop.Location = new Point(12, 9);
|
||||||
|
labelShop.Name = "labelShop";
|
||||||
|
labelShop.Size = new Size(72, 20);
|
||||||
|
labelShop.TabIndex = 3;
|
||||||
|
labelShop.Text = "Магазин:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(12, 50);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(71, 20);
|
||||||
|
label2.TabIndex = 4;
|
||||||
|
label2.Text = "Изделие:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(12, 89);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(93, 20);
|
||||||
|
label3.TabIndex = 5;
|
||||||
|
label3.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// buttonSupply
|
||||||
|
//
|
||||||
|
buttonSupply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonSupply.Location = new Point(342, 130);
|
||||||
|
buttonSupply.Name = "buttonSupply";
|
||||||
|
buttonSupply.Size = new Size(94, 29);
|
||||||
|
buttonSupply.TabIndex = 4;
|
||||||
|
buttonSupply.Text = "Поставить";
|
||||||
|
buttonSupply.UseVisualStyleBackColor = true;
|
||||||
|
buttonSupply.Click += buttonSupply_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(463, 130);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 5;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
textBoxCount.Location = new Point(125, 89);
|
||||||
|
textBoxCount.Name = "textBoxCount";
|
||||||
|
textBoxCount.Size = new Size(167, 27);
|
||||||
|
textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// FormShopSupply
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(569, 169);
|
||||||
|
Controls.Add(textBoxCount);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSupply);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(labelShop);
|
||||||
|
Controls.Add(comboBoxSecure);
|
||||||
|
Controls.Add(comboBoxShop);
|
||||||
|
Name = "FormShopSupply";
|
||||||
|
Text = "Поставка изделия";
|
||||||
|
Load += FormShopSupply_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxShop;
|
||||||
|
private ComboBox comboBoxSecure;
|
||||||
|
private Label labelShop;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Button buttonSupply;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
}
|
||||||
|
}
|
117
SecuritySystem/SecuritySystemView/Shop/FormShopSupply.cs
Normal file
117
SecuritySystem/SecuritySystemView/Shop/FormShopSupply.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.SearchModels;
|
||||||
|
|
||||||
|
namespace SecuritySystemView
|
||||||
|
{
|
||||||
|
public partial class FormShopSupply : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ISecureLogic _logicSecure;
|
||||||
|
private readonly IShopLogic _logicShop;
|
||||||
|
|
||||||
|
public FormShopSupply(ILogger<FormShopSupply> logger, ISecureLogic logicSecure, IShopLogic logicShop)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicSecure = logicSecure;
|
||||||
|
_logicShop = logicShop;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormShopSupply_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка secure для пополнения");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicSecure.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxSecure.DisplayMember = "SecureName";
|
||||||
|
comboBoxSecure.ValueMember = "Id";
|
||||||
|
comboBoxSecure.DataSource = list;
|
||||||
|
comboBoxSecure.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка secure");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Загрузка магазинов для пополнения");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicShop.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxShop.DisplayMember = "Name";
|
||||||
|
comboBoxShop.ValueMember = "Id";
|
||||||
|
comboBoxShop.DataSource = list;
|
||||||
|
comboBoxShop.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка магазинов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSupply_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comboBoxSecure.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите secure", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comboBoxShop.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Создание поставки");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicShop.SupplySecures(
|
||||||
|
new ShopSearchModel { Id = Convert.ToInt32(comboBoxShop.SelectedValue), Name = comboBoxShop.Text },
|
||||||
|
new SecureBindingModel { Id = Convert.ToInt32(comboBoxSecure.SelectedValue), SecureName = comboBoxSecure.Text },
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
SecuritySystem/SecuritySystemView/Shop/FormShopSupply.resx
Normal file
120
SecuritySystem/SecuritySystemView/Shop/FormShopSupply.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
124
SecuritySystem/SecuritySystemView/Shop/FormShops.Designer.cs
generated
Normal file
124
SecuritySystem/SecuritySystemView/Shop/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
namespace SecuritySystemView
|
||||||
|
{
|
||||||
|
partial class FormShops
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonRefresh = new Button();
|
||||||
|
buttonDelete = new Button();
|
||||||
|
buttonEdit = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(716, 406);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonRefresh.Location = new Point(735, 261);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(94, 29);
|
||||||
|
buttonRefresh.TabIndex = 4;
|
||||||
|
buttonRefresh.Text = "Обновить";
|
||||||
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += buttonRefresh_Click;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
buttonDelete.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonDelete.Location = new Point(735, 213);
|
||||||
|
buttonDelete.Name = "buttonDelete";
|
||||||
|
buttonDelete.Size = new Size(94, 29);
|
||||||
|
buttonDelete.TabIndex = 3;
|
||||||
|
buttonDelete.Text = "Удалить";
|
||||||
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
buttonEdit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonEdit.Location = new Point(735, 163);
|
||||||
|
buttonEdit.Name = "buttonEdit";
|
||||||
|
buttonEdit.Size = new Size(94, 29);
|
||||||
|
buttonEdit.TabIndex = 2;
|
||||||
|
buttonEdit.Text = "Изменить";
|
||||||
|
buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
buttonEdit.Click += buttonEdit_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonAdd.Location = new Point(735, 111);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(94, 29);
|
||||||
|
buttonAdd.TabIndex = 1;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// FormShops
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(841, 406);
|
||||||
|
Controls.Add(buttonRefresh);
|
||||||
|
Controls.Add(buttonDelete);
|
||||||
|
Controls.Add(buttonEdit);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormShops";
|
||||||
|
Text = "Магазины";
|
||||||
|
Load += FormShops_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonRefresh;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonAdd;
|
||||||
|
}
|
||||||
|
}
|
111
SecuritySystem/SecuritySystemView/Shop/FormShops.cs
Normal file
111
SecuritySystem/SecuritySystemView/Shop/FormShops.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace SecuritySystemView
|
||||||
|
{
|
||||||
|
public partial class FormShops : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
|
||||||
|
public FormShops(ILogger<FormShops> 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["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ShopSecures"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 buttonEdit_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 buttonDelete_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
SecuritySystem/SecuritySystemView/Shop/FormShops.resx
Normal file
120
SecuritySystem/SecuritySystemView/Shop/FormShops.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
Loading…
x
Reference in New Issue
Block a user