3 хард лаба ща будет
This commit is contained in:
commit
d80a995117
@ -31,6 +31,10 @@ namespace AircraftPlantListImplement
|
||||
/// Список классов-моделей изделий
|
||||
/// </summary>
|
||||
public List<Plane> Planes { get; set; }
|
||||
/// <summary>
|
||||
/// Список классов-моделей магазинов
|
||||
/// </summary>
|
||||
public List<Shop> Shops { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -40,6 +44,7 @@ namespace AircraftPlantListImplement
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Planes = new List<Plane>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить ссылку на класс
|
||||
|
97
AircraftPlant/AbstractShopListImplement/Shop.cs
Normal file
97
AircraftPlant/AbstractShopListImplement/Shop.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantListImplement.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Сущность "Магазин"
|
||||
/// </summary>
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
public int Id { get; private set; }
|
||||
/// <summary>
|
||||
/// Название магазина
|
||||
/// </summary>
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Адрес магазина
|
||||
/// </summary>
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Дата открытия магазина
|
||||
/// </summary>
|
||||
public DateTime DateOpening { get; private set; }
|
||||
/// <summary>
|
||||
/// Коллекция изделий в магазине
|
||||
/// </summary>
|
||||
public Dictionary<int, (IPlaneModel, int)> ShopPlanes
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = new Dictionary<int, (IPlaneModel, int)>();
|
||||
/// <summary>
|
||||
/// Максимальное количество изделий
|
||||
/// </summary>
|
||||
public int MaxPlanes { get; private set; }
|
||||
/// <summary>
|
||||
/// Создание модели магазина
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpening = model.DateOpening,
|
||||
ShopPlanes = model.ShopPlanes,
|
||||
MaxPlanes = model.MaxPlanes
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение модели магазина
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpening = model.DateOpening;
|
||||
ShopPlanes = model.ShopPlanes;
|
||||
MaxPlanes = model.MaxPlanes;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение модели магазина
|
||||
/// </summary>
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpening = DateOpening,
|
||||
ShopPlanes = ShopPlanes,
|
||||
MaxPlanes = MaxPlanes
|
||||
};
|
||||
}
|
||||
}
|
170
AircraftPlant/AbstractShopListImplement/ShopStorage.cs
Normal file
170
AircraftPlant/AbstractShopListImplement/ShopStorage.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantContracts.StoragesContracts;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantListImplement.Implements
|
||||
{
|
||||
/// <summary>
|
||||
/// Реализация интерфейса хранилища для магазина
|
||||
/// </summary>
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Хранилище
|
||||
/// </summary>
|
||||
private readonly DataListSingleton _source;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение полного списка
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение фильтрованного списка
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.ShopName))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение элемента
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление элемента
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Редактирование элемента
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Продажа изделий
|
||||
/// </summary>
|
||||
/// <param name="plane"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public bool SellPlanes(IPlaneModel model, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка наличия в нужном количестве
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public bool CheckCount(IPlaneModel model, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantContracts.StoragesContracts;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Enums;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -13,36 +14,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
/// <summary>
|
||||
/// Реализация интерфейса бизнес-логики для заказов
|
||||
/// </summary>
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Взаимодействие с хранилищем заказов
|
||||
/// </summary>
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="orderStorage"></param>
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private IShopStorage _shopStorage;
|
||||
private IShopLogic _shopLogic;
|
||||
private IPlaneStorage _planeStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage, IShopLogic shopLogic, IPlaneStorage planeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
_shopLogic = shopLogic;
|
||||
_planeStorage = planeStorage;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Order.Id:{ Id}", model?.Id);
|
||||
@ -57,11 +43,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание заказа
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
@ -80,38 +61,18 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена статуса заказа (Выполняется)
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена статуса заказа (Выдан)
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена статуса заказа (Готов)
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Готов);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка модели заказа
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="withParams"></param>
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
@ -136,12 +97,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
_logger.LogInformation("Order. OrderID:{Id}.Sum:{ Sum}. PlaneId: { PlaneId}", model.Id, model.Sum, model.PlaneId);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена статуса заказа
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="newStatus"></param>
|
||||
/// <returns></returns>
|
||||
private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel
|
||||
@ -160,6 +115,21 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
|
||||
model.Status = newStatus;
|
||||
|
||||
if (newStatus == OrderStatus.Выдан)
|
||||
{
|
||||
var plane = _planeStorage.GetElement(new PlaneSearchModel { Id = element.PlaneId });
|
||||
if (plane == null)
|
||||
{
|
||||
_logger.LogWarning("Status change error. Plane not found");
|
||||
return false;
|
||||
}
|
||||
if (!CheckSupply(plane, element.Count))
|
||||
{
|
||||
_logger.LogWarning("Status change error. Shop is overflowed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
@ -176,5 +146,72 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool CheckSupply(IPlaneModel model, int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
_logger.LogWarning("Check supply operation error. Planes count < 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
int sumCapacity = _shopStorage.GetFullList().Select(x => x.MaxPlanes).Sum();
|
||||
int sumCount = _shopStorage.GetFullList().Select(x => x.ShopPlanes.Select(y => y.Value.Item2).Sum()).Sum();
|
||||
int free = sumCapacity - sumCount;
|
||||
if (free < count)
|
||||
{
|
||||
_logger.LogWarning("Check supply error. No place for new planes");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in _shopStorage.GetFullList())
|
||||
{
|
||||
free = shop.MaxPlanes;
|
||||
foreach (var plane in shop.ShopPlanes)
|
||||
{
|
||||
free -= plane.Value.Item2;
|
||||
}
|
||||
|
||||
if (free == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (free >= count)
|
||||
{
|
||||
if (_shopLogic.AddPlaneInShop(new()
|
||||
{
|
||||
Id = shop.Id
|
||||
}, model, count))
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Supply error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_shopLogic.AddPlaneInShop(new()
|
||||
{
|
||||
Id = shop.Id
|
||||
}, model, free))
|
||||
{
|
||||
count -= free;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Supply error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,36 +12,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
{
|
||||
/// <summary>
|
||||
/// Реализация интерфейса бизнес-логики для изделия
|
||||
/// </summary>
|
||||
public class PlaneLogic : IPlaneLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Взаимодействие с хранилищем изделий
|
||||
/// </summary>
|
||||
private readonly IPlaneStorage _planeStorage;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="planeStorage"></param>
|
||||
public PlaneLogic(ILogger<PlaneLogic> logger, IPlaneStorage planeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_planeStorage = planeStorage;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public List<PlaneViewModel>? ReadList(PlaneSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PlaneName:{PlaneName}.Id:{ Id}", model?.PlaneName, model?.Id);
|
||||
@ -56,12 +35,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение отдельной записи
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public PlaneViewModel? ReadElement(PlaneSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -81,11 +54,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание записи
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool Create(PlaneBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
@ -97,11 +65,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение записи
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool Update(PlaneBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
@ -113,11 +76,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление записи
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public bool Delete(PlaneBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
@ -130,11 +88,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка модели изделия
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="withParams"></param>
|
||||
private void CheckModel(PlaneBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
|
184
AircraftPlant/AircraftPlantBusinessLogic/ShopLogic.cs
Normal file
184
AircraftPlant/AircraftPlantBusinessLogic/ShopLogic.cs
Normal file
@ -0,0 +1,184 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantContracts.StoragesContracts;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantBusinessLogic.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 List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id);
|
||||
|
||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||
|
||||
var element = _shopStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool AddPlaneInShop(ShopSearchModel model, IPlaneModel plane, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddPlaneInShop. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddPlaneInShop element not found");
|
||||
return false;
|
||||
}
|
||||
_logger.LogInformation("AddPlaneInShop find. Id:{Id}", element.Id);
|
||||
|
||||
var countPlanes = element.ShopPlanes.Select(x => x.Value.Item2).Sum();
|
||||
if (element.MaxPlanes - countPlanes < count)
|
||||
{
|
||||
_logger.LogWarning("Shop is overflowed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (element.ShopPlanes.TryGetValue(plane.Id, out var pair))
|
||||
{
|
||||
element.ShopPlanes[plane.Id] = (plane, count + pair.Item2);
|
||||
_logger.LogInformation("AddPlaneInShop. Added {count} {plane} to '{ShopName}' shop", count, plane.PlaneName, element.ShopName);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.ShopPlanes[plane.Id] = (plane, count);
|
||||
_logger.LogInformation("AddPlaneInShop. Added {count} new plane {plane} to '{ShopName}' shop", count, plane.PlaneName, element.ShopName);
|
||||
}
|
||||
|
||||
_shopStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
Address = element.Address,
|
||||
ShopName = element.ShopName,
|
||||
DateOpening = element.DateOpening,
|
||||
ShopPlanes = element.ShopPlanes,
|
||||
MaxPlanes = element.MaxPlanes
|
||||
});
|
||||
return true;
|
||||
}
|
||||
public bool SellPlanes(IPlaneModel plane, int count)
|
||||
{
|
||||
if (plane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(plane));
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
|
||||
if (_shopStorage.SellPlanes(plane, count))
|
||||
{
|
||||
_logger.LogInformation("Selling sucsess");
|
||||
return true;
|
||||
}
|
||||
_logger.LogInformation("Selling failed");
|
||||
return false;
|
||||
}
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}.Address:{ Address}. Id:{ Id}", model.ShopName, model.Address, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
ShopName = model.ShopName
|
||||
});
|
||||
if (element != null && element.Id != model.Id && element.ShopName == model.ShopName)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IPlaneModel, int)> ShopPlanes
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
public int MaxPlanes { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
bool Create(ShopBindingModel model);
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
bool AddPlaneInShop(ShopSearchModel model, IPlaneModel plane, int count);
|
||||
bool SellPlanes(IPlaneModel plane, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
bool SellPlanes(IPlaneModel model, int count);
|
||||
bool CheckCount(IPlaneModel model, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IPlaneModel, int)> ShopPlanes
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
[DisplayName("Максимальное количество изделий")]
|
||||
public int MaxPlanes { get; set; }
|
||||
}
|
||||
}
|
17
AircraftPlant/AircraftPlantDataModels/IShopModel.cs
Normal file
17
AircraftPlant/AircraftPlantDataModels/IShopModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpening { get; }
|
||||
Dictionary<int, (IPlaneModel, int)> ShopPlanes { get; }
|
||||
int MaxPlanes { get; }
|
||||
}
|
||||
}
|
@ -14,9 +14,12 @@ namespace AircraftPlantFileImplement
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string PlaneFileName = "Plane.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Plane> Planes { get; private set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -28,11 +31,13 @@ namespace AircraftPlantFileImplement
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SavePlanes() => SaveData(Planes, PlaneFileName, "Planes", 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()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Planes = LoadData(PlaneFileName, "Plane", x => Plane.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, Func<XElement, T> selectFunction)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AircraftPlantFileImplement.Implements
|
||||
{
|
||||
@ -20,7 +21,9 @@ namespace AircraftPlantFileImplement.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return _source.Orders.Select(x => GetViewModel(x)).ToList();
|
||||
return _source.Orders
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
@ -28,7 +31,11 @@ namespace AircraftPlantFileImplement.Implements
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
|
||||
|
||||
return _source.Orders
|
||||
.Where(x => x.Id.Equals(model.Id))
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
@ -36,6 +43,7 @@ namespace AircraftPlantFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetViewModel(_source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -47,6 +55,7 @@ namespace AircraftPlantFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Orders.Add(newOrder);
|
||||
_source.SaveOrders();
|
||||
return GetViewModel(newOrder);
|
||||
@ -58,6 +67,7 @@ namespace AircraftPlantFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
order.Update(model);
|
||||
_source.SaveOrders();
|
||||
return GetViewModel(order);
|
||||
@ -77,7 +87,10 @@ namespace AircraftPlantFileImplement.Implements
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var plane = _source.Planes.FirstOrDefault(x => x.Id == order.PlaneId);
|
||||
viewModel.PlaneName = plane?.PlaneName;
|
||||
if (plane != null)
|
||||
{
|
||||
viewModel.PlaneName = plane.PlaneName;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
102
AircraftPlant/AircraftPlantFileImplement/Shop.cs
Normal file
102
AircraftPlant/AircraftPlantFileImplement/Shop.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AircraftPlantFileImplement
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public DateTime DateOpening { get; private set; }
|
||||
public Dictionary<int, int> Planes { get; private set; } = new();
|
||||
private Dictionary<int, (IPlaneModel, int)>? _shopPlanes = null;
|
||||
public Dictionary<int, (IPlaneModel, int)> ShopPlanes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopPlanes == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_shopPlanes = Planes.ToDictionary(x => x.Key, y => ((source.Planes.FirstOrDefault(z => z.Id == y.Key) as IPlaneModel)!, y.Value));
|
||||
}
|
||||
return _shopPlanes;
|
||||
}
|
||||
}
|
||||
public int MaxPlanes { get; private set; }
|
||||
public static Shop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
|
||||
Planes = element.Element("ShopPlanes")!.Elements("ShopPlanes")!
|
||||
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value)),
|
||||
MaxPlanes = Convert.ToInt32(element.Element("MaxPlanes")!.Value)
|
||||
};
|
||||
}
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpening = model.DateOpening,
|
||||
Planes = model.ShopPlanes.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
MaxPlanes = model.MaxPlanes
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpening = model.DateOpening;
|
||||
Planes = model.ShopPlanes.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
MaxPlanes = model.MaxPlanes;
|
||||
_shopPlanes = null;
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpening = DateOpening,
|
||||
ShopPlanes = ShopPlanes,
|
||||
MaxPlanes = MaxPlanes
|
||||
};
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("DateOpening", DateOpening.ToString()),
|
||||
new XElement("ShopPlanes", Planes.Select(x =>
|
||||
new XElement("ShopPlanes",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))).ToArray()),
|
||||
new XElement("MaxPlanes", MaxPlanes.ToString()));
|
||||
}
|
||||
}
|
138
AircraftPlant/AircraftPlantFileImplement/ShopStorage.cs
Normal file
138
AircraftPlant/AircraftPlantFileImplement/ShopStorage.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantContracts.StoragesContracts;
|
||||
using AircraftPlantContracts.ViewModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantFileImplement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftPlantFileImplement
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
return _source.Shops
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
return _source.Shops
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _source.Shops
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ShopName) &&
|
||||
x.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
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 element = _source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
_source.Shops.Remove(element);
|
||||
_source.SaveShops();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool SellPlanes(IPlaneModel model, int count)
|
||||
{
|
||||
var plane = _source.Planes.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (plane == null || !CheckCount(model, count))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
var planes = shop.ShopPlanes;
|
||||
foreach (var elem in planes.Where(x => x.Value.Item1.Id == plane.Id))
|
||||
{
|
||||
var selling = Math.Min(elem.Value.Item2, count);
|
||||
planes[elem.Value.Item1.Id] = (elem.Value.Item1, elem.Value.Item2 - selling);
|
||||
count -= selling;
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
shop.Update(new ShopBindingModel
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpening = shop.DateOpening,
|
||||
ShopPlanes = planes,
|
||||
MaxPlanes = shop.MaxPlanes
|
||||
});
|
||||
}
|
||||
|
||||
_source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
public bool CheckCount(IPlaneModel model, int count)
|
||||
{
|
||||
int store = _source.Shops
|
||||
.Select(x => x.ShopPlanes
|
||||
.Select(y => (y.Value.Item1.Id == model.Id ? y.Value.Item2 : 0))
|
||||
.Sum()).Sum();
|
||||
return store >= count;
|
||||
}
|
||||
}
|
||||
}
|
251
AircraftPlant/AircraftPlantView/FormMain.Designer.cs
generated
251
AircraftPlant/AircraftPlantView/FormMain.Designer.cs
generated
@ -28,143 +28,183 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.ButtonOrderReady = new System.Windows.Forms.Button();
|
||||
this.ButtonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
dataGridView = new DataGridView();
|
||||
ButtonCreateOrder = new Button();
|
||||
ButtonTakeOrderInWork = new Button();
|
||||
ButtonOrderReady = new Button();
|
||||
ButtonIssuedOrder = new Button();
|
||||
ButtonRef = new Button();
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
изделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonAddPlane = new Button();
|
||||
buttonSellPlanes = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.dataGridView.GridColor = System.Drawing.Color.White;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 24);
|
||||
this.dataGridView.MultiSelect = false;
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(780, 377);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.GridColor = Color.White;
|
||||
dataGridView.Location = new Point(0, 30);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(891, 505);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonCreateOrder
|
||||
//
|
||||
this.ButtonCreateOrder.Location = new System.Drawing.Point(804, 42);
|
||||
this.ButtonCreateOrder.Name = "ButtonCreateOrder";
|
||||
this.ButtonCreateOrder.Size = new System.Drawing.Size(153, 23);
|
||||
this.ButtonCreateOrder.TabIndex = 1;
|
||||
this.ButtonCreateOrder.Text = "Создать заказ";
|
||||
this.ButtonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
||||
ButtonCreateOrder.Location = new Point(919, 56);
|
||||
ButtonCreateOrder.Margin = new Padding(3, 4, 3, 4);
|
||||
ButtonCreateOrder.Name = "ButtonCreateOrder";
|
||||
ButtonCreateOrder.Size = new Size(175, 31);
|
||||
ButtonCreateOrder.TabIndex = 1;
|
||||
ButtonCreateOrder.Text = "Создать заказ";
|
||||
ButtonCreateOrder.UseVisualStyleBackColor = true;
|
||||
ButtonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// ButtonTakeOrderInWork
|
||||
//
|
||||
this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(804, 89);
|
||||
this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
||||
this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(153, 23);
|
||||
this.ButtonTakeOrderInWork.TabIndex = 2;
|
||||
this.ButtonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
||||
ButtonTakeOrderInWork.Location = new Point(919, 119);
|
||||
ButtonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4);
|
||||
ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
||||
ButtonTakeOrderInWork.Size = new Size(175, 31);
|
||||
ButtonTakeOrderInWork.TabIndex = 2;
|
||||
ButtonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||
//
|
||||
// ButtonOrderReady
|
||||
//
|
||||
this.ButtonOrderReady.Location = new System.Drawing.Point(804, 139);
|
||||
this.ButtonOrderReady.Name = "ButtonOrderReady";
|
||||
this.ButtonOrderReady.Size = new System.Drawing.Size(153, 23);
|
||||
this.ButtonOrderReady.TabIndex = 3;
|
||||
this.ButtonOrderReady.Text = "Заказ готов";
|
||||
this.ButtonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
ButtonOrderReady.Location = new Point(919, 185);
|
||||
ButtonOrderReady.Margin = new Padding(3, 4, 3, 4);
|
||||
ButtonOrderReady.Name = "ButtonOrderReady";
|
||||
ButtonOrderReady.Size = new Size(175, 31);
|
||||
ButtonOrderReady.TabIndex = 3;
|
||||
ButtonOrderReady.Text = "Заказ готов";
|
||||
ButtonOrderReady.UseVisualStyleBackColor = true;
|
||||
ButtonOrderReady.Click += ButtonOrderReady_Click;
|
||||
//
|
||||
// ButtonIssuedOrder
|
||||
//
|
||||
this.ButtonIssuedOrder.Location = new System.Drawing.Point(804, 187);
|
||||
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
||||
this.ButtonIssuedOrder.Size = new System.Drawing.Size(153, 23);
|
||||
this.ButtonIssuedOrder.TabIndex = 4;
|
||||
this.ButtonIssuedOrder.Text = "Заказ выдан";
|
||||
this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
ButtonIssuedOrder.Location = new Point(919, 249);
|
||||
ButtonIssuedOrder.Margin = new Padding(3, 4, 3, 4);
|
||||
ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
||||
ButtonIssuedOrder.Size = new Size(175, 31);
|
||||
ButtonIssuedOrder.TabIndex = 4;
|
||||
ButtonIssuedOrder.Text = "Заказ выдан";
|
||||
ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
ButtonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(804, 236);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(153, 23);
|
||||
this.ButtonRef.TabIndex = 5;
|
||||
this.ButtonRef.Text = "Обновить список";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
ButtonRef.Location = new Point(919, 315);
|
||||
ButtonRef.Margin = new Padding(3, 4, 3, 4);
|
||||
ButtonRef.Name = "ButtonRef";
|
||||
ButtonRef.Size = new Size(175, 31);
|
||||
ButtonRef.TabIndex = 5;
|
||||
ButtonRef.Text = "Обновить список";
|
||||
ButtonRef.UseVisualStyleBackColor = true;
|
||||
ButtonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.справочникиToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(977, 24);
|
||||
this.menuStrip1.TabIndex = 6;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Padding = new Padding(7, 3, 0, 3);
|
||||
menuStrip1.Size = new Size(1117, 30);
|
||||
menuStrip1.TabIndex = 6;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.компонентыToolStripMenuItem,
|
||||
this.изделияToolStripMenuItem});
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, магазиныToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// изделияToolStripMenuItem
|
||||
//
|
||||
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||
this.изделияToolStripMenuItem.Text = "Изделия";
|
||||
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
изделияToolStripMenuItem.Size = new Size(224, 26);
|
||||
изделияToolStripMenuItem.Text = "Изделия";
|
||||
изделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
магазиныToolStripMenuItem.Size = new Size(224, 26);
|
||||
магазиныToolStripMenuItem.Text = "Магазины";
|
||||
магазиныToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonAddPlane
|
||||
//
|
||||
buttonAddPlane.Location = new Point(919, 393);
|
||||
buttonAddPlane.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAddPlane.Name = "buttonAddPlane";
|
||||
buttonAddPlane.Size = new Size(186, 30);
|
||||
buttonAddPlane.TabIndex = 7;
|
||||
buttonAddPlane.Text = "Пополнение магазина";
|
||||
buttonAddPlane.UseVisualStyleBackColor = true;
|
||||
buttonAddPlane.Click += buttonAddPlane_Click;
|
||||
//
|
||||
// buttonSellPlanes
|
||||
//
|
||||
buttonSellPlanes.Location = new Point(919, 431);
|
||||
buttonSellPlanes.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSellPlanes.Name = "buttonSellPlanes";
|
||||
buttonSellPlanes.Size = new Size(186, 31);
|
||||
buttonSellPlanes.TabIndex = 8;
|
||||
buttonSellPlanes.Text = "Продать изделия";
|
||||
buttonSellPlanes.UseVisualStyleBackColor = true;
|
||||
buttonSellPlanes.Click += buttonSellPlanes_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(977, 401);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonIssuedOrder);
|
||||
this.Controls.Add(this.ButtonOrderReady);
|
||||
this.Controls.Add(this.ButtonTakeOrderInWork);
|
||||
this.Controls.Add(this.ButtonCreateOrder);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Авиационный завод";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1117, 535);
|
||||
Controls.Add(buttonSellPlanes);
|
||||
Controls.Add(buttonAddPlane);
|
||||
Controls.Add(ButtonRef);
|
||||
Controls.Add(ButtonIssuedOrder);
|
||||
Controls.Add(ButtonOrderReady);
|
||||
Controls.Add(ButtonTakeOrderInWork);
|
||||
Controls.Add(ButtonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormMain";
|
||||
Text = "Авиационный завод";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -179,5 +219,8 @@
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private Button buttonAddPlane;
|
||||
private Button buttonSellPlanes;
|
||||
}
|
||||
}
|
@ -74,6 +74,19 @@ namespace AircraftPlantView
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Показать список всех магазинов
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Создать заказ"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
@ -202,5 +215,31 @@ namespace AircraftPlantView
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Пополнение магазина"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddPlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSupply));
|
||||
if (service is FormSupply form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Продать изделия"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonSellPlanes_Click(object sender, EventArgs e)
|
||||
{
|
||||
var services = Program.ServiceProvider?.GetService(typeof(FormSell));
|
||||
if (services is FormSell form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?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">
|
||||
|
119
AircraftPlant/AircraftPlantView/FormSell.Designer.cs
generated
Normal file
119
AircraftPlant/AircraftPlantView/FormSell.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
partial class FormSell
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelPlane = new Label();
|
||||
labelCount = new Label();
|
||||
comboBoxPlane = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelPlane
|
||||
//
|
||||
labelPlane.AutoSize = true;
|
||||
labelPlane.Location = new Point(12, 18);
|
||||
labelPlane.Name = "labelPlane";
|
||||
labelPlane.Size = new Size(71, 20);
|
||||
labelPlane.TabIndex = 0;
|
||||
labelPlane.Text = "Изделие:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(12, 54);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(93, 20);
|
||||
labelCount.TabIndex = 1;
|
||||
labelCount.Text = "Количество:";
|
||||
//
|
||||
// comboBoxPlane
|
||||
//
|
||||
comboBoxPlane.FormattingEnabled = true;
|
||||
comboBoxPlane.Location = new Point(115, 15);
|
||||
comboBoxPlane.Name = "comboBoxPlane";
|
||||
comboBoxPlane.Size = new Size(267, 28);
|
||||
comboBoxPlane.TabIndex = 2;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(115, 54);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(267, 27);
|
||||
textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(178, 100);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(288, 100);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// FormSell
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 146);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxPlane);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelPlane);
|
||||
Name = "FormSell";
|
||||
Text = "FormSell";
|
||||
Load += FormSell_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelPlane;
|
||||
private Label labelCount;
|
||||
private ComboBox comboBoxPlane;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
87
AircraftPlant/AircraftPlantView/FormSell.cs
Normal file
87
AircraftPlant/AircraftPlantView/FormSell.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
public partial class FormSell : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPlaneLogic _logicP;
|
||||
private readonly IShopLogic _logicS;
|
||||
public FormSell(ILogger<FormSell> logger, IPlaneLogic planeLogic, IShopLogic shopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicP = planeLogic;
|
||||
_logicS = shopLogic;
|
||||
}
|
||||
private void FormSell_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий для продажи");
|
||||
try
|
||||
{
|
||||
var list = _logicP.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxPlane.DisplayMember = "PlaneName";
|
||||
comboBoxPlane.ValueMember = "Id";
|
||||
comboBoxPlane.DataSource = list;
|
||||
comboBoxPlane.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
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(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxPlane.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Продажа изделий");
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicS.SellPlanes(
|
||||
_logicP.ReadElement(new() { Id = Convert.ToInt32(comboBoxPlane.SelectedValue) }),
|
||||
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
AircraftPlant/AircraftPlantView/FormSell.resx
Normal file
120
AircraftPlant/AircraftPlantView/FormSell.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>
|
220
AircraftPlant/AircraftPlantView/FormShop.Designer.cs
generated
Normal file
220
AircraftPlant/AircraftPlantView/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,220 @@
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
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();
|
||||
labelDate = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxAddress = new TextBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
dataGridViewShop = new DataGridView();
|
||||
ColumnID = new DataGridViewTextBoxColumn();
|
||||
ColumnPlane = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelMaxPlanes = new Label();
|
||||
numericUpDownMaxPlanes = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewShop).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxPlanes).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(14, 12);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(80, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название:";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(14, 52);
|
||||
labelAddress.Name = "labelAddress";
|
||||
labelAddress.Size = new Size(54, 20);
|
||||
labelAddress.TabIndex = 1;
|
||||
labelAddress.Text = "Адрес:";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(14, 99);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(113, 20);
|
||||
labelDate.TabIndex = 2;
|
||||
labelDate.Text = "Дата открытия:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(133, 8);
|
||||
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(228, 27);
|
||||
textBoxName.TabIndex = 3;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
textBoxAddress.Location = new Point(133, 52);
|
||||
textBoxAddress.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxAddress.Name = "textBoxAddress";
|
||||
textBoxAddress.Size = new Size(228, 27);
|
||||
textBoxAddress.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(133, 99);
|
||||
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(228, 27);
|
||||
dateTimePicker.TabIndex = 5;
|
||||
//
|
||||
// dataGridViewShop
|
||||
//
|
||||
dataGridViewShop.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewShop.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewShop.Columns.AddRange(new DataGridViewColumn[] { ColumnID, ColumnPlane, ColumnCount });
|
||||
dataGridViewShop.Location = new Point(30, 195);
|
||||
dataGridViewShop.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridViewShop.Name = "dataGridViewShop";
|
||||
dataGridViewShop.RowHeadersWidth = 51;
|
||||
dataGridViewShop.RowTemplate.Height = 25;
|
||||
dataGridViewShop.Size = new Size(588, 433);
|
||||
dataGridViewShop.TabIndex = 6;
|
||||
//
|
||||
// ColumnID
|
||||
//
|
||||
ColumnID.HeaderText = "ID";
|
||||
ColumnID.MinimumWidth = 6;
|
||||
ColumnID.Name = "ColumnID";
|
||||
ColumnID.Visible = false;
|
||||
//
|
||||
// ColumnPlane
|
||||
//
|
||||
ColumnPlane.HeaderText = "Изделие";
|
||||
ColumnPlane.MinimumWidth = 6;
|
||||
ColumnPlane.Name = "ColumnPlane";
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(399, 640);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(99, 31);
|
||||
buttonSave.TabIndex = 7;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(519, 640);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(99, 31);
|
||||
buttonCancel.TabIndex = 8;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// labelMaxPlanes
|
||||
//
|
||||
labelMaxPlanes.AutoSize = true;
|
||||
labelMaxPlanes.Location = new Point(14, 148);
|
||||
labelMaxPlanes.Name = "labelMaxPlanes";
|
||||
labelMaxPlanes.Size = new Size(103, 20);
|
||||
labelMaxPlanes.TabIndex = 9;
|
||||
labelMaxPlanes.Text = "Вместимость:";
|
||||
//
|
||||
// numericUpDownMaxPlanes
|
||||
//
|
||||
numericUpDownMaxPlanes.Location = new Point(133, 146);
|
||||
numericUpDownMaxPlanes.Name = "numericUpDownMaxPlanes";
|
||||
numericUpDownMaxPlanes.Size = new Size(228, 27);
|
||||
numericUpDownMaxPlanes.TabIndex = 10;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(645, 684);
|
||||
Controls.Add(numericUpDownMaxPlanes);
|
||||
Controls.Add(labelMaxPlanes);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(dataGridViewShop);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(labelName);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormShop";
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewShop).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxPlanes).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn Plane;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelName;
|
||||
private Label labelAddress;
|
||||
private Label labelDate;
|
||||
private DataGridView dataGridViewShops;
|
||||
private DataGridViewTextBoxColumn ColumnID;
|
||||
private DataGridViewTextBoxColumn ColumnPlane;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private DataGridView dataGridViewShop;
|
||||
private Label labelMaxPlanes;
|
||||
private NumericUpDown numericUpDownMaxPlanes;
|
||||
}
|
||||
}
|
165
AircraftPlant/AircraftPlantView/FormShop.cs
Normal file
165
AircraftPlant/AircraftPlantView/FormShop.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма для магазина
|
||||
/// </summary>
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
/// <summary>
|
||||
/// Бизнес-логика для магазинов
|
||||
/// </summary>
|
||||
private readonly IShopLogic _logic;
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
/// <summary>
|
||||
/// Список изделий в магазине
|
||||
/// </summary>
|
||||
private Dictionary<int, (IPlaneModel, int)> _shopPlanes;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="logic"></param>
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopPlanes = new Dictionary<int, (IPlaneModel, int)>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка списка изделий в магазине
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
dateTimePicker.Text = view.DateOpening.ToString();
|
||||
numericUpDownMaxPlanes.Value = view.MaxPlanes;
|
||||
_shopPlanes = view.ShopPlanes ?? new Dictionary<int, (IPlaneModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Сохранить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening = dateTimePicker.Value.Date,
|
||||
ShopPlanes = _shopPlanes,
|
||||
MaxPlanes = Convert.ToInt32(numericUpDownMaxPlanes.Value)
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Отмена"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод загрузки изделий магазина
|
||||
/// </summary>
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий магазина");
|
||||
try
|
||||
{
|
||||
if (_shopPlanes != null)
|
||||
{
|
||||
dataGridViewShop.Rows.Clear();
|
||||
foreach (var elem in _shopPlanes)
|
||||
{
|
||||
dataGridViewShop.Rows.Add(new object[]
|
||||
{
|
||||
elem.Key,
|
||||
elem.Value.Item1.PlaneName,
|
||||
elem.Value.Item2
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
AircraftPlant/AircraftPlantView/FormShop.resx
Normal file
129
AircraftPlant/AircraftPlantView/FormShop.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?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="ColumnPlane.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>
|
||||
</root>
|
115
AircraftPlant/AircraftPlantView/FormShops.Designer.cs
generated
Normal file
115
AircraftPlant/AircraftPlantView/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,115 @@
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
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()
|
||||
{
|
||||
this.dataGridViewShops = new System.Windows.Forms.DataGridView();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonRefresh = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewShops)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridViewShops
|
||||
//
|
||||
this.dataGridViewShops.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridViewShops.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridViewShops.Name = "dataGridViewShops";
|
||||
this.dataGridViewShops.RowTemplate.Height = 25;
|
||||
this.dataGridViewShops.Size = new System.Drawing.Size(495, 449);
|
||||
this.dataGridViewShops.TabIndex = 0;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(524, 22);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonAdd.TabIndex = 1;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(524, 71);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonUpdate.TabIndex = 2;
|
||||
this.buttonUpdate.Text = "Изменить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(524, 123);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonDelete.TabIndex = 3;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
this.buttonRefresh.Location = new System.Drawing.Point(524, 174);
|
||||
this.buttonRefresh.Name = "buttonRefresh";
|
||||
this.buttonRefresh.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonRefresh.TabIndex = 4;
|
||||
this.buttonRefresh.Text = "Обновить";
|
||||
this.buttonRefresh.UseVisualStyleBackColor = true;
|
||||
this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(624, 450);
|
||||
this.Controls.Add(this.buttonRefresh);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridViewShops);
|
||||
this.Name = "FormShops";
|
||||
this.Text = "Магазины";
|
||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewShops)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRefresh;
|
||||
private DataGridView dataGridViewShops;
|
||||
}
|
||||
}
|
145
AircraftPlant/AircraftPlantView/FormShops.cs
Normal file
145
AircraftPlant/AircraftPlantView/FormShops.cs
Normal file
@ -0,0 +1,145 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма для вывода всех магазинов
|
||||
/// </summary>
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
/// <summary>
|
||||
/// Бизнес-логика для магазина
|
||||
/// </summary>
|
||||
private readonly IShopLogic _logic;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка списка магазинов
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Добавить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Изменить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridViewShops.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridViewShops.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Удалить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridViewShops.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridViewShops.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление магазина");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ShopBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Обновить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод загрузки списка магазинов
|
||||
/// </summary>
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridViewShops.DataSource = list;
|
||||
dataGridViewShops.Columns["Id"].Visible = false;
|
||||
dataGridViewShops.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridViewShops.Columns["ShopPlanes"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
AircraftPlant/AircraftPlantView/FormShops.resx
Normal file
60
AircraftPlant/AircraftPlantView/FormShops.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
145
AircraftPlant/AircraftPlantView/FormSupply.Designer.cs
generated
Normal file
145
AircraftPlant/AircraftPlantView/FormSupply.Designer.cs
generated
Normal file
@ -0,0 +1,145 @@
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
partial class FormSupply
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.labelPlane = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxPlane = new System.Windows.Forms.ComboBox();
|
||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(12, 9);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(57, 15);
|
||||
this.labelShop.TabIndex = 0;
|
||||
this.labelShop.Text = "Магазин:";
|
||||
//
|
||||
// labelPlane
|
||||
//
|
||||
this.labelPlane.AutoSize = true;
|
||||
this.labelPlane.Location = new System.Drawing.Point(12, 44);
|
||||
this.labelPlane.Name = "labelPlane";
|
||||
this.labelPlane.Size = new System.Drawing.Size(56, 15);
|
||||
this.labelPlane.TabIndex = 1;
|
||||
this.labelPlane.Text = "Изделие:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 81);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||
this.labelCount.TabIndex = 2;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
this.comboBoxShop.FormattingEnabled = true;
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(97, 9);
|
||||
this.comboBoxShop.Name = "comboBoxShop";
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(229, 23);
|
||||
this.comboBoxShop.TabIndex = 3;
|
||||
//
|
||||
// comboBoxPlane
|
||||
//
|
||||
this.comboBoxPlane.FormattingEnabled = true;
|
||||
this.comboBoxPlane.Location = new System.Drawing.Point(97, 44);
|
||||
this.comboBoxPlane.Name = "comboBoxPlane";
|
||||
this.comboBoxPlane.Size = new System.Drawing.Size(229, 23);
|
||||
this.comboBoxPlane.TabIndex = 4;
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
this.numericUpDownCount.Location = new System.Drawing.Point(98, 79);
|
||||
this.numericUpDownCount.Name = "numericUpDownCount";
|
||||
this.numericUpDownCount.Size = new System.Drawing.Size(228, 23);
|
||||
this.numericUpDownCount.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(170, 108);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(251, 108);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// FormSupply
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(341, 140);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.numericUpDownCount);
|
||||
this.Controls.Add(this.comboBoxPlane);
|
||||
this.Controls.Add(this.comboBoxShop);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelPlane);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Name = "FormSupply";
|
||||
this.Text = "Поступление";
|
||||
this.Load += new System.EventHandler(this.FormSupply_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelShop;
|
||||
private Label labelPlane;
|
||||
private Label labelCount;
|
||||
private ComboBox comboBoxShop;
|
||||
private ComboBox comboBoxPlane;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
145
AircraftPlant/AircraftPlantView/FormSupply.cs
Normal file
145
AircraftPlant/AircraftPlantView/FormSupply.cs
Normal file
@ -0,0 +1,145 @@
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
public partial class FormSupply : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
/// <summary>
|
||||
/// Бизнес-логика для магазина
|
||||
/// </summary>
|
||||
private readonly IShopLogic _logicS;
|
||||
/// <summary>
|
||||
/// Бизнес-логика для изделий
|
||||
/// </summary>
|
||||
private readonly IPlaneLogic _logicP;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="logicS"></param>
|
||||
/// <param name="logicP"></param>
|
||||
public FormSupply(ILogger<FormSupply> logger, IShopLogic logicS, IPlaneLogic logicP)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicS = logicS;
|
||||
_logicP = logicP;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка списков магазинов и изделий
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FormSupply_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
try
|
||||
{
|
||||
var listShops = _logicS.ReadList(null);
|
||||
if (listShops != null)
|
||||
{
|
||||
comboBoxShop.DisplayMember = "ShopName";
|
||||
comboBoxShop.ValueMember = "Id";
|
||||
comboBoxShop.DataSource = listShops;
|
||||
comboBoxShop.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
try
|
||||
{
|
||||
var listPlanes = _logicP.ReadList(null);
|
||||
if (listPlanes != null)
|
||||
{
|
||||
comboBoxPlane.DisplayMember = "PlaneName";
|
||||
comboBoxPlane.ValueMember = "Id";
|
||||
comboBoxPlane.DataSource = listPlanes;
|
||||
comboBoxPlane.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Сохранить"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxShop.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxPlane.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление изделия в магазин");
|
||||
try
|
||||
{
|
||||
var plane = _logicP.ReadElement(new()
|
||||
{
|
||||
Id = (int)comboBoxPlane.SelectedValue
|
||||
});
|
||||
if (plane == null)
|
||||
{
|
||||
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
||||
}
|
||||
var resultOperation = _logicS.AddPlaneInShop(
|
||||
new ShopSearchModel
|
||||
{
|
||||
Id = (int)comboBoxShop.SelectedValue
|
||||
},
|
||||
plane,
|
||||
(int)numericUpDownCount.Value
|
||||
);
|
||||
if (!resultOperation)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Кнопка "Отмена"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
AircraftPlant/AircraftPlantView/FormSupply.resx
Normal file
60
AircraftPlant/AircraftPlantView/FormSupply.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -1,7 +1,8 @@
|
||||
using AircraftPlantBusinessLogic.BusinessLogics;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.StoragesContracts;
|
||||
using AircraftPlantDatabaseImplement.Implements;
|
||||
using AircraftPlantFileImplement;
|
||||
using AircraftPlantFileImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
@ -49,10 +50,12 @@ namespace AircraftPlantView
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IPlaneStorage, PlaneStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IPlaneLogic, PlaneLogic>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
@ -61,6 +64,10 @@ namespace AircraftPlantView
|
||||
services.AddTransient<FormPlane>();
|
||||
services.AddTransient<FormPlaneComponent>();
|
||||
services.AddTransient<FormPlanes>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormSupply>();
|
||||
services.AddTransient<FormSell>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user