готово
This commit is contained in:
parent
64799e3a09
commit
f3cf15a27a
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -12,13 +12,13 @@ namespace MotorPlantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
|
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
|
||||||
@ -31,7 +31,6 @@ namespace MotorPlantBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
@ -48,22 +47,34 @@ namespace MotorPlantBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
return ToNextStatus(model, OrderStatus.Выполняется);
|
return ToNextStatus(model, OrderStatus.Выполняется);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
return ToNextStatus(model, OrderStatus.Готов);
|
return ToNextStatus(model, OrderStatus.Готов);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
var order = _orderStorage.GetElement(new OrderSearchModel
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
});
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(order));
|
||||||
|
}
|
||||||
|
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
||||||
|
{
|
||||||
|
EngineId = order.EngineId,
|
||||||
|
Count = order.Count
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Недостаточно места");
|
||||||
|
}
|
||||||
return ToNextStatus(model, OrderStatus.Выдан);
|
return ToNextStatus(model, OrderStatus.Выдан);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus)
|
public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
@ -75,26 +86,22 @@ namespace MotorPlantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(element));
|
throw new ArgumentNullException(nameof(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.EngineId = element.EngineId;
|
model.EngineId = element.EngineId;
|
||||||
model.DateCreate = element.DateCreate;
|
model.DateCreate = element.DateCreate;
|
||||||
model.DateImplement = element.DateImplement;
|
model.DateImplement = element.DateImplement;
|
||||||
model.Status = element.Status;
|
model.Status = element.Status;
|
||||||
model.Count = element.Count;
|
model.Count = element.Count;
|
||||||
model.Sum = element.Sum;
|
model.Sum = element.Sum;
|
||||||
|
|
||||||
if (model.Status != orderStatus - 1)
|
if (model.Status != orderStatus - 1)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update to " + orderStatus + " operation failed");
|
_logger.LogWarning("Status update to " + orderStatus + " operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = orderStatus;
|
model.Status = orderStatus;
|
||||||
|
|
||||||
if (model.Status == OrderStatus.Выдан)
|
if (model.Status == OrderStatus.Выдан)
|
||||||
{
|
{
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status--;
|
model.Status--;
|
||||||
@ -103,7 +110,6 @@ namespace MotorPlantBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -12,141 +12,170 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantBusinessLogic.BusinessLogics
|
namespace MotorPlantBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ShopLogic : IShopLogic
|
public class ShopLogic : IShopLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IShopStorage _shopStorage;
|
private readonly IShopStorage _shopStorage;
|
||||||
private readonly IEngineStorage _EngineStorage;
|
private readonly IEngineStorage _EngineStorage;
|
||||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, IEngineStorage EngineStorage)
|
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, IEngineStorage EngineStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_shopStorage = shopStorage;
|
_shopStorage = shopStorage;
|
||||||
_EngineStorage = EngineStorage;
|
_EngineStorage = EngineStorage;
|
||||||
}
|
}
|
||||||
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id);
|
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id);
|
||||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||||
var element = _shopStorage.GetElement(model);
|
var element = _shopStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
public bool Create(ShopBindingModel model)
|
public bool Create(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_shopStorage.Insert(model) == null)
|
if (_shopStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool Update(ShopBindingModel model)
|
public bool Update(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_shopStorage.Update(model) == null)
|
if (_shopStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool Delete(ShopBindingModel model)
|
public bool Delete(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_shopStorage.Delete(model) == null)
|
if (_shopStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool MakeSupply(SupplyBindingModel model)
|
public bool MakeSupply(SupplyBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
if (model.Count <= 0)
|
if (model.Count <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Количество изделий должно быть больше 0");
|
throw new ArgumentException("Количество изделий должно быть больше 0");
|
||||||
}
|
}
|
||||||
var shop = _shopStorage.GetElement(new ShopSearchModel
|
var shop = _shopStorage.GetElement(new ShopSearchModel
|
||||||
{
|
{
|
||||||
Id = model.ShopId
|
Id = model.ShopId
|
||||||
});
|
});
|
||||||
if (shop == null)
|
if (shop == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Магазина не существует");
|
throw new ArgumentException("Магазина не существует");
|
||||||
}
|
}
|
||||||
if (shop.ShopEngines.ContainsKey(model.EngineId))
|
if (shop.ShopEngines.ContainsKey(model.EngineId))
|
||||||
{
|
{
|
||||||
var oldValue = shop.ShopEngines[model.EngineId];
|
var oldValue = shop.ShopEngines[model.EngineId];
|
||||||
oldValue.Item2 += model.Count;
|
oldValue.Item2 += model.Count;
|
||||||
shop.ShopEngines[model.EngineId] = oldValue;
|
shop.ShopEngines[model.EngineId] = oldValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var Engine = _EngineStorage.GetElement(new EngineSearchModel
|
var Engine = _EngineStorage.GetElement(new EngineSearchModel
|
||||||
{
|
{
|
||||||
Id = model.EngineId
|
Id = model.EngineId
|
||||||
});
|
});
|
||||||
if (Engine == null)
|
if (Engine == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"Поставка: Товар с id:{model.EngineId} не найденн");
|
throw new ArgumentException($"Поставка: Товар с id:{model.EngineId} не найденн");
|
||||||
}
|
}
|
||||||
shop.ShopEngines.Add(model.EngineId, (Engine, model.Count));
|
if (shop.ShopEngines.Sum(kv => kv.Value.Item2) + model.Count > shop.EngineMaxCount)
|
||||||
}
|
{
|
||||||
return true;
|
throw new ArgumentException("Превышена максимальная вместимость магазина");
|
||||||
}
|
}
|
||||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
shop.ShopEngines.Add(model.EngineId, (Engine, model.Count));
|
||||||
{
|
}
|
||||||
if (model == null)
|
_shopStorage.Update(new ShopBindingModel()
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
Id = shop.Id,
|
||||||
}
|
ShopName = shop.ShopName,
|
||||||
if (!withParams)
|
Adress = shop.Adress,
|
||||||
{
|
OpeningDate = shop.OpeningDate,
|
||||||
return;
|
ShopEngines = shop.ShopEngines,
|
||||||
}
|
EngineMaxCount = shop.EngineMaxCount,
|
||||||
if (string.IsNullOrEmpty(model.Adress))
|
});
|
||||||
{
|
|
||||||
throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Adress));
|
return true;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.ShopName))
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName));
|
if (model == null)
|
||||||
}
|
{
|
||||||
_logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id);
|
throw new ArgumentNullException(nameof(model));
|
||||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
}
|
||||||
{
|
if (!withParams)
|
||||||
ShopName = model.ShopName
|
{
|
||||||
});
|
return;
|
||||||
if (element != null && element.Id != model.Id)
|
}
|
||||||
{
|
if (string.IsNullOrEmpty(model.Adress))
|
||||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
{
|
||||||
}
|
throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Adress));
|
||||||
}
|
}
|
||||||
}
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.EngineId.HasValue || !model.Count.HasValue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Check Engine count in all shops");
|
||||||
|
if (_shopStorage.Sale(model))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Selling sucsess");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Selling failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantContracts.BindingModels
|
namespace MotorPlantContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class ShopBindingModel : IShopModel
|
public class ShopBindingModel : IShopModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string ShopName { get; set; } = string.Empty;
|
public string ShopName { get; set; } = string.Empty;
|
||||||
public string Adress { get; set; } = string.Empty;
|
public string Adress { get; set; } = string.Empty;
|
||||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; set; } = new();
|
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; set; } = new();
|
||||||
}
|
public int EngineMaxCount { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantContracts.BindingModels
|
namespace MotorPlantContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class SupplyBindingModel : ISupplyModel
|
public class SupplyBindingModel : ISupplyModel
|
||||||
{
|
{
|
||||||
public int ShopId { get; set; }
|
public int ShopId { get; set; }
|
||||||
public int EngineId { get; set; }
|
public int EngineId { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,14 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantContracts.BusinessLogicsContracts
|
namespace MotorPlantContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
public interface IShopLogic
|
public interface IShopLogic
|
||||||
{
|
{
|
||||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||||
bool Create(ShopBindingModel model);
|
bool Create(ShopBindingModel model);
|
||||||
bool Update(ShopBindingModel model);
|
bool Update(ShopBindingModel model);
|
||||||
bool Delete(ShopBindingModel model);
|
bool Delete(ShopBindingModel model);
|
||||||
bool MakeSupply(SupplyBindingModel model);
|
bool MakeSupply(SupplyBindingModel model);
|
||||||
}
|
bool Sale(SupplySearchModel model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantContracts.SearchModels
|
namespace MotorPlantContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class ShopSearchModel
|
public class ShopSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? ShopName { get; set; }
|
public string? ShopName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MotorPlantContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class SupplySearchModel
|
||||||
|
{
|
||||||
|
public int? EngineId { get; set; }
|
||||||
|
public int? Count { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -9,13 +9,15 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantContracts.StoragesContracts
|
namespace MotorPlantContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IShopStorage
|
public interface IShopStorage
|
||||||
{
|
{
|
||||||
List<ShopViewModel> GetFullList();
|
List<ShopViewModel> GetFullList();
|
||||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||||
ShopViewModel? GetElement(ShopSearchModel model);
|
ShopViewModel? GetElement(ShopSearchModel model);
|
||||||
ShopViewModel? Insert(ShopBindingModel model);
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
ShopViewModel? Update(ShopBindingModel model);
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
ShopViewModel? Delete(ShopBindingModel model);
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
}
|
bool Sale(SupplySearchModel model);
|
||||||
|
bool RestockingShops(SupplyBindingModel model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,17 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ShopViewModel : IShopModel
|
public class ShopViewModel : IShopModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название")]
|
[DisplayName("Название")]
|
||||||
public string ShopName { get; set; } = string.Empty;
|
public string ShopName { get; set; } = string.Empty;
|
||||||
[DisplayName("Адрес")]
|
[DisplayName("Адрес")]
|
||||||
public string Adress { get; set; } = string.Empty;
|
public string Adress { get; set; } = string.Empty;
|
||||||
[DisplayName("Дата открытия")]
|
[DisplayName("Дата открытия")]
|
||||||
public DateTime OpeningDate { get; set; }
|
public DateTime OpeningDate { get; set; }
|
||||||
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; set; } = new();
|
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; set; } = new();
|
||||||
}
|
[DisplayName("Вместимость")]
|
||||||
|
public int EngineMaxCount { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantDataModels.Models
|
namespace MotorPlantDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IShopModel : IId
|
public interface IShopModel : IId
|
||||||
{
|
{
|
||||||
string ShopName { get; }
|
string ShopName { get; }
|
||||||
string Adress { get; }
|
string Adress { get; }
|
||||||
DateTime OpeningDate { get; }
|
DateTime OpeningDate { get; }
|
||||||
Dictionary<int, (IEngineModel, int)> ShopEngines { get; }
|
Dictionary<int, (IEngineModel, int)> ShopEngines { get; }
|
||||||
}
|
public int EngineMaxCount { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantDataModels.Models
|
namespace MotorPlantDataModels.Models
|
||||||
{
|
{
|
||||||
public interface ISupplyModel
|
public interface ISupplyModel
|
||||||
{
|
{
|
||||||
int ShopId { get; }
|
int ShopId { get; }
|
||||||
int EngineId { get; }
|
int EngineId { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -9,9 +9,11 @@ namespace MotorPlantFileImplement
|
|||||||
private readonly string ComponentFileName = "Component.xml";
|
private readonly string ComponentFileName = "Component.xml";
|
||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string EngineFileName = "Engine.xml";
|
private readonly string EngineFileName = "Engine.xml";
|
||||||
|
private readonly string ShopFileName = "Shop.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Engine> Engines { get; private set; }
|
public List<Engine> Engines { get; private set; }
|
||||||
|
public List<Shop> Shops { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -23,11 +25,13 @@ namespace MotorPlantFileImplement
|
|||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||||
public void SaveEngines() => SaveData(Engines, EngineFileName, "Engines", x => x.GetXElement);
|
public void SaveEngines() => SaveData(Engines, EngineFileName, "Engines", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
|
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
Engines = LoadData(EngineFileName, "Engine", x => Engine.Create(x)!)!;
|
Engines = LoadData(EngineFileName, "Engine", x => Engine.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -71,14 +71,8 @@ namespace MotorPlantFileImplement.Implements
|
|||||||
private OrderViewModel GetViewModel(Order order)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
{
|
{
|
||||||
var viewModel = order.GetViewModel;
|
var viewModel = order.GetViewModel;
|
||||||
foreach (var comp in source.Engines)
|
var engine = source.Engines.FirstOrDefault(x => x.Id == order.EngineId);
|
||||||
{
|
viewModel.EngineName = engine?.EngineName;
|
||||||
if (comp.Id == order.EngineId)
|
|
||||||
{
|
|
||||||
viewModel.EngineName = comp.EngineName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
103
MotorPlant/MotorPlantFileImplement/Shop.cs
Normal file
103
MotorPlant/MotorPlantFileImplement/Shop.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using MotorPlantContracts.BindingModels;
|
||||||
|
using MotorPlantContracts.ViewModels;
|
||||||
|
using MotorPlantDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace MotorPlantFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string ShopName { get; private set; } = string.Empty;
|
||||||
|
public string Adress { get; private set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
public Dictionary<int, int> Engines { get; private set; } = new();
|
||||||
|
private Dictionary<int, (IEngineModel, int)>? _shopEngines = null;
|
||||||
|
public Dictionary<int, (IEngineModel, int)> ShopEngines
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopEngines == null)
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
_shopEngines = Engines.ToDictionary(x => x.Key, y => ((source.Engines.FirstOrDefault(z => z.Id == y.Key) as IEngineModel)!, y.Value));
|
||||||
|
}
|
||||||
|
return _shopEngines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int EngineMaxCount { get; private set; }
|
||||||
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Adress = model.Adress,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
Engines = model.ShopEngines.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||||
|
EngineMaxCount = model.EngineMaxCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
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,
|
||||||
|
Adress = element.Element("Adress")!.Value,
|
||||||
|
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
||||||
|
Engines = element.Element("ShopEngines")!.Elements("ShopEngine")!.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||||
|
x => Convert.ToInt32(x.Element("Value")?.Value)),
|
||||||
|
EngineMaxCount = Convert.ToInt32(element.Element("EngineMaxCount")!.Value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Adress = model.Adress;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
EngineMaxCount = model.EngineMaxCount;
|
||||||
|
Engines = model.ShopEngines.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||||
|
_shopEngines = null;
|
||||||
|
}
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Adress = Adress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopEngines = ShopEngines,
|
||||||
|
EngineMaxCount = EngineMaxCount
|
||||||
|
};
|
||||||
|
public XElement GetXElement => new("Shop",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ShopName", ShopName),
|
||||||
|
new XElement("Adress", Adress),
|
||||||
|
new XElement("OpeningDate", OpeningDate.ToString()),
|
||||||
|
new XElement("ShopEngines", Engines.Select(
|
||||||
|
x => new XElement("ShopEngine", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()),
|
||||||
|
new XElement("EngineMaxCount", EngineMaxCount.ToString())
|
||||||
|
);
|
||||||
|
public void EnginesUpdate()
|
||||||
|
{
|
||||||
|
_shopEngines = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
MotorPlant/MotorPlantFileImplement/ShopStorage.cs
Normal file
145
MotorPlant/MotorPlantFileImplement/ShopStorage.cs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
using MotorPlantContracts.BindingModels;
|
||||||
|
using MotorPlantContracts.SearchModels;
|
||||||
|
using MotorPlantContracts.StoragesContracts;
|
||||||
|
using MotorPlantContracts.ViewModels;
|
||||||
|
using MotorPlantFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MotorPlantFileImplement.Implements
|
||||||
|
{
|
||||||
|
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 shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop != null)
|
||||||
|
{
|
||||||
|
source.Shops.Remove(shop);
|
||||||
|
source.SaveShops();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null || !model.EngineId.HasValue || !model.Count.HasValue)
|
||||||
|
return false;
|
||||||
|
int remainingSpace = source.Shops.Select(x => x.Engines.ContainsKey(model.EngineId.Value) ? x.Engines[model.EngineId.Value] : 0).Sum();
|
||||||
|
if (remainingSpace < model.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var shops = source.Shops.Where(x => x.Engines.ContainsKey(model.EngineId.Value)).OrderByDescending(x => x.Engines[model.EngineId.Value]).ToList();
|
||||||
|
foreach (var shop in shops)
|
||||||
|
{
|
||||||
|
int residue = model.Count.Value - shop.Engines[model.EngineId.Value];
|
||||||
|
if (residue > 0)
|
||||||
|
{
|
||||||
|
shop.Engines.Remove(model.EngineId.Value);
|
||||||
|
shop.EnginesUpdate();
|
||||||
|
model.Count = residue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (residue == 0)
|
||||||
|
{
|
||||||
|
shop.Engines.Remove(model.EngineId.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.Engines[model.EngineId.Value] = -residue;
|
||||||
|
}
|
||||||
|
shop.EnginesUpdate();
|
||||||
|
source.SaveShops();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source.SaveShops();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public bool RestockingShops(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null || source.Shops.Select(x => x.EngineMaxCount - x.ShopEngines.Select(y => y.Value.Item2).Sum()).Sum() < model.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach (Shop shop in source.Shops)
|
||||||
|
{
|
||||||
|
int free_places = shop.EngineMaxCount - shop.ShopEngines.Select(x => x.Value.Item2).Sum();
|
||||||
|
if (free_places <= 0)
|
||||||
|
continue;
|
||||||
|
free_places = Math.Min(free_places, model.Count);
|
||||||
|
model.Count -= free_places;
|
||||||
|
if (shop.Engines.ContainsKey(model.EngineId))
|
||||||
|
{
|
||||||
|
shop.Engines[model.EngineId] += free_places;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.Engines.Add(model.EngineId, free_places);
|
||||||
|
}
|
||||||
|
shop.EnginesUpdate();
|
||||||
|
if (model.Count == 0)
|
||||||
|
{
|
||||||
|
source.SaveShops();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,14 +8,14 @@ namespace MotorPlantListImplement
|
|||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Engine> Engines { get; set; }
|
public List<Engine> Engines { get; set; }
|
||||||
public List<Shop> Shops { get; set; }
|
public List<Shop> Shops { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Engines = new List<Engine>();
|
Engines = new List<Engine>();
|
||||||
Shops = new List<Shop>();
|
Shops = new List<Shop>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (_instance == null)
|
if (_instance == null)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -37,11 +37,7 @@ namespace MotorPlantListImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EngineId = model.EngineId;
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
}
|
}
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
|
@ -9,44 +9,49 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantListImplement.Models
|
namespace MotorPlantListImplement.Models
|
||||||
{
|
{
|
||||||
public class Shop : IShopModel
|
public class Shop : IShopModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string ShopName { get; private set; } = string.Empty;
|
public string ShopName { get; private set; } = string.Empty;
|
||||||
public string Adress { get; private set; } = string.Empty;
|
public string Adress { get; private set; } = string.Empty;
|
||||||
public DateTime OpeningDate { get; private set; }
|
public DateTime OpeningDate { get; private set; }
|
||||||
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; private set; } = new();
|
public Dictionary<int, (IEngineModel, int)> ShopEngines { get; private set; } = new();
|
||||||
public static Shop? Create(ShopBindingModel? model)
|
public int EngineMaxCount { get; private set; }
|
||||||
{
|
|
||||||
if (model == null)
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
{
|
{
|
||||||
return null;
|
if (model == null)
|
||||||
}
|
{
|
||||||
return new Shop()
|
return null;
|
||||||
{
|
}
|
||||||
Id = model.Id,
|
return new Shop()
|
||||||
ShopName = model.ShopName,
|
{
|
||||||
Adress = model.Adress,
|
Id = model.Id,
|
||||||
OpeningDate = model.OpeningDate
|
ShopName = model.ShopName,
|
||||||
};
|
Adress = model.Adress,
|
||||||
}
|
OpeningDate = model.OpeningDate,
|
||||||
public void Update(ShopBindingModel? model)
|
EngineMaxCount = model.EngineMaxCount,
|
||||||
{
|
};
|
||||||
if (model == null)
|
}
|
||||||
{
|
public void Update(ShopBindingModel? model)
|
||||||
return;
|
{
|
||||||
}
|
if (model == null)
|
||||||
ShopName = model.ShopName;
|
{
|
||||||
Adress = model.Adress;
|
return;
|
||||||
OpeningDate = model.OpeningDate;
|
}
|
||||||
}
|
ShopName = model.ShopName;
|
||||||
public ShopViewModel GetViewModel => new()
|
Adress = model.Adress;
|
||||||
{
|
OpeningDate = model.OpeningDate;
|
||||||
Id = Id,
|
EngineMaxCount = model.EngineMaxCount;
|
||||||
ShopName = ShopName,
|
}
|
||||||
Adress = Adress,
|
public ShopViewModel GetViewModel => new()
|
||||||
OpeningDate = OpeningDate,
|
{
|
||||||
ShopEngines = ShopEngines
|
Id = Id,
|
||||||
};
|
ShopName = ShopName,
|
||||||
}
|
Adress = Adress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopEngines = ShopEngines,
|
||||||
|
EngineMaxCount = EngineMaxCount,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,96 +11,104 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantListImplement.Implements
|
namespace MotorPlantListImplement.Implements
|
||||||
{
|
{
|
||||||
public class ShopStorage : IShopStorage
|
public class ShopStorage : IShopStorage
|
||||||
{
|
{
|
||||||
private readonly DataListSingleton _source;
|
private readonly DataListSingleton _source;
|
||||||
public ShopStorage()
|
public ShopStorage()
|
||||||
{
|
{
|
||||||
_source = DataListSingleton.GetInstance();
|
_source = DataListSingleton.GetInstance();
|
||||||
}
|
}
|
||||||
public List<ShopViewModel> GetFullList()
|
public List<ShopViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
var result = new List<ShopViewModel>();
|
var result = new List<ShopViewModel>();
|
||||||
foreach (var shop in _source.Shops)
|
foreach (var shop in _source.Shops)
|
||||||
{
|
{
|
||||||
result.Add(shop.GetViewModel);
|
result.Add(shop.GetViewModel);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<ShopViewModel>();
|
var result = new List<ShopViewModel>();
|
||||||
if (string.IsNullOrEmpty(model.ShopName))
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
foreach (var shop in _source.Shops)
|
foreach (var shop in _source.Shops)
|
||||||
{
|
{
|
||||||
if (shop.ShopName.Contains(model.ShopName))
|
if (shop.ShopName.Contains(model.ShopName))
|
||||||
{
|
{
|
||||||
result.Add(shop.GetViewModel);
|
result.Add(shop.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (var shop in _source.Shops)
|
foreach (var shop in _source.Shops)
|
||||||
{
|
{
|
||||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) ||
|
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) ||
|
||||||
(model.Id.HasValue && shop.Id == model.Id))
|
(model.Id.HasValue && shop.Id == model.Id))
|
||||||
{
|
{
|
||||||
return shop.GetViewModel;
|
return shop.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public ShopViewModel? Insert(ShopBindingModel model)
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = 1;
|
model.Id = 1;
|
||||||
foreach (var shop in _source.Shops)
|
foreach (var shop in _source.Shops)
|
||||||
{
|
{
|
||||||
if (model.Id <= shop.Id)
|
if (model.Id <= shop.Id)
|
||||||
{
|
{
|
||||||
model.Id = shop.Id + 1;
|
model.Id = shop.Id + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var newShop = Shop.Create(model);
|
var newShop = Shop.Create(model);
|
||||||
if (newShop == null)
|
if (newShop == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_source.Shops.Add(newShop);
|
_source.Shops.Add(newShop);
|
||||||
return newShop.GetViewModel;
|
return newShop.GetViewModel;
|
||||||
}
|
}
|
||||||
public ShopViewModel? Update(ShopBindingModel model)
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
foreach (var shop in _source.Shops)
|
foreach (var shop in _source.Shops)
|
||||||
{
|
{
|
||||||
if (shop.Id == model.Id)
|
if (shop.Id == model.Id)
|
||||||
{
|
{
|
||||||
shop.Update(model);
|
shop.Update(model);
|
||||||
return shop.GetViewModel;
|
return shop.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public ShopViewModel? Delete(ShopBindingModel model)
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||||
{
|
{
|
||||||
if (_source.Shops[i].Id == model.Id)
|
if (_source.Shops[i].Id == model.Id)
|
||||||
{
|
{
|
||||||
var element = _source.Shops[i];
|
var element = _source.Shops[i];
|
||||||
_source.Shops.RemoveAt(i);
|
_source.Shops.RemoveAt(i);
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public bool RestockingShops(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
270
MotorPlant/MotorPlantView/FormCreateSupply.Designer.cs
generated
270
MotorPlant/MotorPlantView/FormCreateSupply.Designer.cs
generated
@ -1,143 +1,143 @@
|
|||||||
namespace MotorPlantView
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
partial class FormCreateSupply
|
partial class FormCreateSupply
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||||
this.labelShop = new System.Windows.Forms.Label();
|
this.labelShop = new System.Windows.Forms.Label();
|
||||||
this.labelEngine = new System.Windows.Forms.Label();
|
this.labelEngine = new System.Windows.Forms.Label();
|
||||||
this.comboBoxEngine = new System.Windows.Forms.ComboBox();
|
this.comboBoxEngine = new System.Windows.Forms.ComboBox();
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// comboBoxShop
|
// comboBoxShop
|
||||||
//
|
//
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
this.comboBoxShop.FormattingEnabled = true;
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(115, 12);
|
this.comboBoxShop.Location = new System.Drawing.Point(115, 12);
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
this.comboBoxShop.Name = "comboBoxShop";
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(344, 28);
|
this.comboBoxShop.Size = new System.Drawing.Size(344, 28);
|
||||||
this.comboBoxShop.TabIndex = 0;
|
this.comboBoxShop.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// labelShop
|
// labelShop
|
||||||
//
|
//
|
||||||
this.labelShop.AutoSize = true;
|
this.labelShop.AutoSize = true;
|
||||||
this.labelShop.Location = new System.Drawing.Point(12, 15);
|
this.labelShop.Location = new System.Drawing.Point(12, 15);
|
||||||
this.labelShop.Name = "labelShop";
|
this.labelShop.Name = "labelShop";
|
||||||
this.labelShop.Size = new System.Drawing.Size(76, 20);
|
this.labelShop.Size = new System.Drawing.Size(76, 20);
|
||||||
this.labelShop.TabIndex = 1;
|
this.labelShop.TabIndex = 1;
|
||||||
this.labelShop.Text = "Магазин: ";
|
this.labelShop.Text = "Магазин: ";
|
||||||
//
|
//
|
||||||
// labelEngine
|
// labelEngine
|
||||||
//
|
//
|
||||||
this.labelEngine.AutoSize = true;
|
this.labelEngine.AutoSize = true;
|
||||||
this.labelEngine.Location = new System.Drawing.Point(12, 49);
|
this.labelEngine.Location = new System.Drawing.Point(12, 49);
|
||||||
this.labelEngine.Name = "labelEngine";
|
this.labelEngine.Name = "labelEngine";
|
||||||
this.labelEngine.Size = new System.Drawing.Size(75, 20);
|
this.labelEngine.Size = new System.Drawing.Size(75, 20);
|
||||||
this.labelEngine.TabIndex = 2;
|
this.labelEngine.TabIndex = 2;
|
||||||
this.labelEngine.Text = "Изделие: ";
|
this.labelEngine.Text = "Изделие: ";
|
||||||
//
|
//
|
||||||
// comboBoxEngine
|
// comboBoxEngine
|
||||||
//
|
//
|
||||||
this.comboBoxEngine.FormattingEnabled = true;
|
this.comboBoxEngine.FormattingEnabled = true;
|
||||||
this.comboBoxEngine.Location = new System.Drawing.Point(115, 46);
|
this.comboBoxEngine.Location = new System.Drawing.Point(115, 46);
|
||||||
this.comboBoxEngine.Name = "comboBoxEngine";
|
this.comboBoxEngine.Name = "comboBoxEngine";
|
||||||
this.comboBoxEngine.Size = new System.Drawing.Size(344, 28);
|
this.comboBoxEngine.Size = new System.Drawing.Size(344, 28);
|
||||||
this.comboBoxEngine.TabIndex = 3;
|
this.comboBoxEngine.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
this.labelCount.AutoSize = true;
|
this.labelCount.AutoSize = true;
|
||||||
this.labelCount.Location = new System.Drawing.Point(12, 83);
|
this.labelCount.Location = new System.Drawing.Point(12, 83);
|
||||||
this.labelCount.Name = "labelCount";
|
this.labelCount.Name = "labelCount";
|
||||||
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||||
this.labelCount.TabIndex = 4;
|
this.labelCount.TabIndex = 4;
|
||||||
this.labelCount.Text = "Количество: ";
|
this.labelCount.Text = "Количество: ";
|
||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(115, 80);
|
this.textBoxCount.Location = new System.Drawing.Point(115, 80);
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(344, 27);
|
this.textBoxCount.Size = new System.Drawing.Size(344, 27);
|
||||||
this.textBoxCount.TabIndex = 5;
|
this.textBoxCount.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(300, 113);
|
this.buttonCancel.Location = new System.Drawing.Point(300, 113);
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(116, 39);
|
this.buttonCancel.Size = new System.Drawing.Size(116, 39);
|
||||||
this.buttonCancel.TabIndex = 6;
|
this.buttonCancel.TabIndex = 6;
|
||||||
this.buttonCancel.Text = "Отмена";
|
this.buttonCancel.Text = "Отмена";
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
this.buttonSave.Location = new System.Drawing.Point(168, 113);
|
this.buttonSave.Location = new System.Drawing.Point(168, 113);
|
||||||
this.buttonSave.Name = "buttonSave";
|
this.buttonSave.Name = "buttonSave";
|
||||||
this.buttonSave.Size = new System.Drawing.Size(116, 39);
|
this.buttonSave.Size = new System.Drawing.Size(116, 39);
|
||||||
this.buttonSave.TabIndex = 7;
|
this.buttonSave.TabIndex = 7;
|
||||||
this.buttonSave.Text = "Сохранить";
|
this.buttonSave.Text = "Сохранить";
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
//
|
//
|
||||||
// FormCreateSupply
|
// FormCreateSupply
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(471, 164);
|
this.ClientSize = new System.Drawing.Size(471, 164);
|
||||||
this.Controls.Add(this.buttonSave);
|
this.Controls.Add(this.buttonSave);
|
||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.textBoxCount);
|
this.Controls.Add(this.textBoxCount);
|
||||||
this.Controls.Add(this.labelCount);
|
this.Controls.Add(this.labelCount);
|
||||||
this.Controls.Add(this.comboBoxEngine);
|
this.Controls.Add(this.comboBoxEngine);
|
||||||
this.Controls.Add(this.labelEngine);
|
this.Controls.Add(this.labelEngine);
|
||||||
this.Controls.Add(this.labelShop);
|
this.Controls.Add(this.labelShop);
|
||||||
this.Controls.Add(this.comboBoxShop);
|
this.Controls.Add(this.comboBoxShop);
|
||||||
this.Name = "FormCreateSupply";
|
this.Name = "FormCreateSupply";
|
||||||
this.Text = "Создание поставки";
|
this.Text = "Создание поставки";
|
||||||
this.Load += new System.EventHandler(this.FormCreateSupply_Load);
|
this.Load += new System.EventHandler(this.FormCreateSupply_Load);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ComboBox comboBoxShop;
|
private ComboBox comboBoxShop;
|
||||||
private Label labelShop;
|
private Label labelShop;
|
||||||
private Label labelEngine;
|
private Label labelEngine;
|
||||||
private ComboBox comboBoxEngine;
|
private ComboBox comboBoxEngine;
|
||||||
private Label labelCount;
|
private Label labelCount;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,82 +12,82 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace MotorPlantView
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
public partial class FormCreateSupply : Form
|
public partial class FormCreateSupply : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IEngineLogic _logicP;
|
private readonly IEngineLogic _logicP;
|
||||||
private readonly IShopLogic _logicS;
|
private readonly IShopLogic _logicS;
|
||||||
private List<ShopViewModel> _shopList = new List<ShopViewModel>();
|
private List<ShopViewModel> _shopList = new List<ShopViewModel>();
|
||||||
private List<EngineViewModel> _EngineList = new List<EngineViewModel>();
|
private List<EngineViewModel> _EngineList = new List<EngineViewModel>();
|
||||||
public FormCreateSupply(ILogger<FormCreateSupply> logger, IEngineLogic logicP, IShopLogic logicS)
|
public FormCreateSupply(ILogger<FormCreateSupply> logger, IEngineLogic logicP, IShopLogic logicS)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicP = logicP;
|
_logicP = logicP;
|
||||||
_logicS = logicS;
|
_logicS = logicS;
|
||||||
}
|
}
|
||||||
private void FormCreateSupply_Load(object sender, EventArgs e)
|
private void FormCreateSupply_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_shopList = _logicS.ReadList(null);
|
_shopList = _logicS.ReadList(null);
|
||||||
_EngineList = _logicP.ReadList(null);
|
_EngineList = _logicP.ReadList(null);
|
||||||
if (_shopList != null)
|
if (_shopList != null)
|
||||||
{
|
{
|
||||||
comboBoxShop.DisplayMember = "ShopName";
|
comboBoxShop.DisplayMember = "ShopName";
|
||||||
comboBoxShop.ValueMember = "Id";
|
comboBoxShop.ValueMember = "Id";
|
||||||
comboBoxShop.DataSource = _shopList;
|
comboBoxShop.DataSource = _shopList;
|
||||||
comboBoxShop.SelectedItem = null;
|
comboBoxShop.SelectedItem = null;
|
||||||
_logger.LogInformation("Загрузка магазинов для поставок");
|
_logger.LogInformation("Загрузка магазинов для поставок");
|
||||||
}
|
}
|
||||||
if (_EngineList != null)
|
if (_EngineList != null)
|
||||||
{
|
{
|
||||||
comboBoxEngine.DisplayMember = "EngineName";
|
comboBoxEngine.DisplayMember = "EngineName";
|
||||||
comboBoxEngine.ValueMember = "Id";
|
comboBoxEngine.ValueMember = "Id";
|
||||||
comboBoxEngine.DataSource = _EngineList;
|
comboBoxEngine.DataSource = _EngineList;
|
||||||
comboBoxEngine.SelectedItem = null;
|
comboBoxEngine.SelectedItem = null;
|
||||||
_logger.LogInformation("Загрузка пиццы для поставок");
|
_logger.LogInformation("Загрузка двигателей для поставок");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (comboBoxShop.SelectedValue == null)
|
if (comboBoxShop.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxEngine.SelectedValue == null)
|
if (comboBoxEngine.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Создание поставки");
|
_logger.LogInformation("Создание поставки");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _logicS.MakeSupply(new SupplyBindingModel
|
var operationResult = _logicS.MakeSupply(new SupplyBindingModel
|
||||||
{
|
{
|
||||||
ShopId = Convert.ToInt32(comboBoxShop.SelectedValue),
|
ShopId = Convert.ToInt32(comboBoxShop.SelectedValue),
|
||||||
EngineId = Convert.ToInt32(comboBoxEngine.SelectedValue),
|
EngineId = Convert.ToInt32(comboBoxEngine.SelectedValue),
|
||||||
Count = Convert.ToInt32(textBoxCount.Text)
|
Count = Convert.ToInt32(textBoxCount.Text)
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка создания поставки");
|
_logger.LogError(ex, "Ошибка создания поставки");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.Cancel;
|
DialogResult = DialogResult.Cancel;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
401
MotorPlant/MotorPlantView/FormMain.Designer.cs
generated
401
MotorPlant/MotorPlantView/FormMain.Designer.cs
generated
@ -1,204 +1,213 @@
|
|||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
partial class FormMain
|
partial class FormMain
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
|
||||||
toolStrip1 = new ToolStrip();
|
toolStrip1 = new ToolStrip();
|
||||||
toolStripDropDownButton1 = new ToolStripDropDownButton();
|
toolStripDropDownButton1 = new ToolStripDropDownButton();
|
||||||
КомпонентыToolStripMenuItem = new ToolStripMenuItem();
|
КомпонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ДвигателиToolStripMenuItem = new ToolStripMenuItem();
|
ДвигателиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
buttonCreateOrder = new Button();
|
||||||
buttonCreateOrder = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonRef = new Button();
|
||||||
buttonRef = new Button();
|
dataGridView = new DataGridView();
|
||||||
dataGridView = new DataGridView();
|
operationToolStripMenuItem = new ToolStripMenuItem();
|
||||||
operationToolStripMenuItem = new ToolStripMenuItem();
|
transactionToolStripMenuItem = new ToolStripMenuItem();
|
||||||
transactionToolStripMenuItem = new ToolStripMenuItem();
|
продажаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
toolStrip1.SuspendLayout();
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
toolStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
//
|
SuspendLayout();
|
||||||
// toolStrip1
|
//
|
||||||
//
|
// toolStrip1
|
||||||
toolStrip1.ImageScalingSize = new Size(20, 20);
|
//
|
||||||
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, operationToolStripMenuItem });
|
toolStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
toolStrip1.Location = new Point(0, 0);
|
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, operationToolStripMenuItem });
|
||||||
toolStrip1.Name = "toolStrip1";
|
toolStrip1.Location = new Point(0, 0);
|
||||||
toolStrip1.Size = new Size(969, 25);
|
toolStrip1.Name = "toolStrip1";
|
||||||
toolStrip1.TabIndex = 0;
|
toolStrip1.Size = new Size(969, 25);
|
||||||
toolStrip1.Text = "toolStrip1";
|
toolStrip1.TabIndex = 0;
|
||||||
//
|
toolStrip1.Text = "toolStrip1";
|
||||||
// toolStripDropDownButton1
|
//
|
||||||
//
|
// toolStripDropDownButton1
|
||||||
toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
//
|
||||||
toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, ДвигателиToolStripMenuItem, магазиныToolStripMenuItem });
|
toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
||||||
toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image");
|
toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, ДвигателиToolStripMenuItem, магазиныToolStripMenuItem });
|
||||||
toolStripDropDownButton1.ImageTransparentColor = Color.Magenta;
|
toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image");
|
||||||
toolStripDropDownButton1.Name = "toolStripDropDownButton1";
|
toolStripDropDownButton1.ImageTransparentColor = Color.Magenta;
|
||||||
toolStripDropDownButton1.Size = new Size(88, 22);
|
toolStripDropDownButton1.Name = "toolStripDropDownButton1";
|
||||||
toolStripDropDownButton1.Text = "Справочник";
|
toolStripDropDownButton1.Size = new Size(88, 22);
|
||||||
//
|
toolStripDropDownButton1.Text = "Справочник";
|
||||||
// КомпонентыToolStripMenuItem
|
//
|
||||||
//
|
// КомпонентыToolStripMenuItem
|
||||||
КомпонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
//
|
||||||
КомпонентыToolStripMenuItem.Size = new Size(174, 22);
|
КомпонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||||
КомпонентыToolStripMenuItem.Text = "Компоненты";
|
КомпонентыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
//
|
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||||
// ДвигателиToolStripMenuItem
|
//
|
||||||
//
|
// ДвигателиToolStripMenuItem
|
||||||
ДвигателиToolStripMenuItem.Name = "ДвигателиToolStripMenuItem";
|
//
|
||||||
ДвигателиToolStripMenuItem.Size = new Size(174, 22);
|
ДвигателиToolStripMenuItem.Name = "ДвигателиToolStripMenuItem";
|
||||||
ДвигателиToolStripMenuItem.Text = "Двигатели";
|
ДвигателиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
ДвигателиToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
ДвигателиToolStripMenuItem.Text = "Двигатели";
|
||||||
//
|
ДвигателиToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||||
// магазиныToolStripMenuItem
|
//
|
||||||
//
|
// buttonCreateOrder
|
||||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
//
|
||||||
магазиныToolStripMenuItem.Size = new Size(180, 22);
|
buttonCreateOrder.Location = new Point(800, 56);
|
||||||
магазиныToolStripMenuItem.Text = "Магазины";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
магазиныToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
|
buttonCreateOrder.Size = new Size(141, 24);
|
||||||
//
|
buttonCreateOrder.TabIndex = 1;
|
||||||
// buttonCreateOrder
|
buttonCreateOrder.Text = "Создать заказ";
|
||||||
//
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
buttonCreateOrder.Location = new Point(800, 56);
|
buttonCreateOrder.Click += buttonCreateOrder_Click;
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
//
|
||||||
buttonCreateOrder.Size = new Size(141, 24);
|
// buttonTakeOrderInWork
|
||||||
buttonCreateOrder.TabIndex = 1;
|
//
|
||||||
buttonCreateOrder.Text = "Создать заказ";
|
buttonTakeOrderInWork.Location = new Point(800, 100);
|
||||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
buttonCreateOrder.Click += buttonCreateOrder_Click;
|
buttonTakeOrderInWork.Size = new Size(141, 24);
|
||||||
//
|
buttonTakeOrderInWork.TabIndex = 2;
|
||||||
// buttonTakeOrderInWork
|
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||||
//
|
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||||
buttonTakeOrderInWork.Location = new Point(800, 100);
|
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
|
||||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
//
|
||||||
buttonTakeOrderInWork.Size = new Size(141, 24);
|
// buttonOrderReady
|
||||||
buttonTakeOrderInWork.TabIndex = 2;
|
//
|
||||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
buttonOrderReady.Location = new Point(800, 142);
|
||||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
buttonOrderReady.Name = "buttonOrderReady";
|
||||||
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
|
buttonOrderReady.Size = new Size(141, 24);
|
||||||
//
|
buttonOrderReady.TabIndex = 3;
|
||||||
// buttonOrderReady
|
buttonOrderReady.Text = "Заказ готов";
|
||||||
//
|
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||||
buttonOrderReady.Location = new Point(800, 142);
|
buttonOrderReady.Click += buttonOrderReady_Click;
|
||||||
buttonOrderReady.Name = "buttonOrderReady";
|
//
|
||||||
buttonOrderReady.Size = new Size(141, 24);
|
// buttonIssuedOrder
|
||||||
buttonOrderReady.TabIndex = 3;
|
//
|
||||||
buttonOrderReady.Text = "Заказ готов";
|
buttonIssuedOrder.Location = new Point(800, 181);
|
||||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||||
buttonOrderReady.Click += buttonOrderReady_Click;
|
buttonIssuedOrder.Size = new Size(141, 24);
|
||||||
//
|
buttonIssuedOrder.TabIndex = 4;
|
||||||
// buttonIssuedOrder
|
buttonIssuedOrder.Text = "Заказ выдан";
|
||||||
//
|
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
buttonIssuedOrder.Location = new Point(800, 181);
|
buttonIssuedOrder.Click += buttonIssuedOrder_Click;
|
||||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
//
|
||||||
buttonIssuedOrder.Size = new Size(141, 24);
|
// buttonRef
|
||||||
buttonIssuedOrder.TabIndex = 4;
|
//
|
||||||
buttonIssuedOrder.Text = "Заказ выдан";
|
buttonRef.Location = new Point(800, 222);
|
||||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
buttonRef.Name = "buttonRef";
|
||||||
buttonIssuedOrder.Click += buttonIssuedOrder_Click;
|
buttonRef.Size = new Size(141, 24);
|
||||||
//
|
buttonRef.TabIndex = 5;
|
||||||
// buttonRef
|
buttonRef.Text = "Обновить список";
|
||||||
//
|
buttonRef.UseVisualStyleBackColor = true;
|
||||||
buttonRef.Location = new Point(800, 222);
|
buttonRef.Click += buttonRef_Click;
|
||||||
buttonRef.Name = "buttonRef";
|
//
|
||||||
buttonRef.Size = new Size(141, 24);
|
// dataGridView
|
||||||
buttonRef.TabIndex = 5;
|
//
|
||||||
buttonRef.Text = "Обновить список";
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
buttonRef.UseVisualStyleBackColor = true;
|
dataGridView.Location = new Point(0, 26);
|
||||||
buttonRef.Click += buttonRef_Click;
|
dataGridView.Name = "dataGridView";
|
||||||
//
|
dataGridView.ReadOnly = true;
|
||||||
// dataGridView
|
dataGridView.RowHeadersWidth = 51;
|
||||||
//
|
dataGridView.RowTemplate.Height = 24;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Location = new Point(0, 26);
|
dataGridView.Size = new Size(763, 435);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.TabIndex = 6;
|
||||||
dataGridView.ReadOnly = true;
|
//
|
||||||
dataGridView.RowHeadersWidth = 51;
|
// operationToolStripMenuItem
|
||||||
dataGridView.RowTemplate.Height = 24;
|
//
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transactionToolStripMenuItem, продажаToolStripMenuItem });
|
||||||
dataGridView.Size = new Size(763, 435);
|
operationToolStripMenuItem.Name = "operationToolStripMenuItem";
|
||||||
dataGridView.TabIndex = 6;
|
operationToolStripMenuItem.Size = new Size(75, 25);
|
||||||
//
|
operationToolStripMenuItem.Text = "Операции";
|
||||||
// operationToolStripMenuItem
|
//
|
||||||
//
|
// transactionToolStripMenuItem
|
||||||
operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transactionToolStripMenuItem });
|
//
|
||||||
operationToolStripMenuItem.Name = "operationToolStripMenuItem";
|
transactionToolStripMenuItem.Name = "transactionToolStripMenuItem";
|
||||||
operationToolStripMenuItem.Size = new Size(75, 25);
|
transactionToolStripMenuItem.Size = new Size(180, 22);
|
||||||
operationToolStripMenuItem.Text = "Операции";
|
transactionToolStripMenuItem.Text = "Поставка";
|
||||||
//
|
transactionToolStripMenuItem.Click += transactionToolStripMenuItem_Click;
|
||||||
// transactionToolStripMenuItem
|
//
|
||||||
//
|
// продажаToolStripMenuItem
|
||||||
transactionToolStripMenuItem.Name = "transactionToolStripMenuItem";
|
//
|
||||||
transactionToolStripMenuItem.Size = new Size(180, 22);
|
продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
|
||||||
transactionToolStripMenuItem.Text = "Поставка";
|
продажаToolStripMenuItem.Size = new Size(180, 22);
|
||||||
transactionToolStripMenuItem.Click += transactionToolStripMenuItem_Click;
|
продажаToolStripMenuItem.Text = "Продажа";
|
||||||
//
|
продажаToolStripMenuItem.Click += SellToolStripMenuItem_Click;
|
||||||
// FormMain
|
//
|
||||||
//
|
// магазиныToolStripMenuItem
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
//
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
ClientSize = new Size(969, 461);
|
магазиныToolStripMenuItem.Size = new Size(180, 22);
|
||||||
Controls.Add(dataGridView);
|
магазиныToolStripMenuItem.Text = "Магазины";
|
||||||
Controls.Add(buttonRef);
|
магазиныToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
|
||||||
Controls.Add(buttonIssuedOrder);
|
//
|
||||||
Controls.Add(buttonOrderReady);
|
// FormMain
|
||||||
Controls.Add(buttonTakeOrderInWork);
|
//
|
||||||
Controls.Add(buttonCreateOrder);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
Controls.Add(toolStrip1);
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
Name = "FormMain";
|
ClientSize = new Size(969, 461);
|
||||||
Text = "Моторный завод";
|
Controls.Add(dataGridView);
|
||||||
Load += FormMain_Load;
|
Controls.Add(buttonRef);
|
||||||
toolStrip1.ResumeLayout(false);
|
Controls.Add(buttonIssuedOrder);
|
||||||
toolStrip1.PerformLayout();
|
Controls.Add(buttonOrderReady);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
Controls.Add(buttonTakeOrderInWork);
|
||||||
ResumeLayout(false);
|
Controls.Add(buttonCreateOrder);
|
||||||
PerformLayout();
|
Controls.Add(toolStrip1);
|
||||||
}
|
Name = "FormMain";
|
||||||
|
Text = "Моторный завод";
|
||||||
|
Load += FormMain_Load;
|
||||||
|
toolStrip1.ResumeLayout(false);
|
||||||
|
toolStrip1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ToolStrip toolStrip1;
|
private ToolStrip toolStrip1;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
private Button buttonTakeOrderInWork;
|
private Button buttonTakeOrderInWork;
|
||||||
private Button buttonOrderReady;
|
private Button buttonOrderReady;
|
||||||
private Button buttonIssuedOrder;
|
private Button buttonIssuedOrder;
|
||||||
private Button buttonRef;
|
private Button buttonRef;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private ToolStripDropDownButton toolStripDropDownButton1;
|
private ToolStripDropDownButton toolStripDropDownButton1;
|
||||||
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
||||||
private ToolStripMenuItem ДвигателиToolStripMenuItem;
|
private ToolStripMenuItem ДвигателиToolStripMenuItem;
|
||||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
private ToolStripMenuItem operationToolStripMenuItem;
|
private ToolStripMenuItem operationToolStripMenuItem;
|
||||||
private ToolStripMenuItem transactionToolStripMenuItem;
|
private ToolStripMenuItem transactionToolStripMenuItem;
|
||||||
}
|
private ToolStripMenuItem продажаToolStripMenuItem;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,159 +4,167 @@ using MotorPlantContracts.BusinessLogicsContracts;
|
|||||||
|
|
||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
public partial class FormMain : Form
|
public partial class FormMain : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
}
|
}
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
var list = _orderLogic.ReadList(null);
|
||||||
|
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["EngineId"].Visible = false;
|
dataGridView.Columns["EngineId"].Visible = false;
|
||||||
dataGridView.Columns["EngineName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["EngineName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
if (service is FormComponents form)
|
if (service is FormComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormEngines));
|
var service = Program.ServiceProvider?.GetService(typeof(FormEngines));
|
||||||
|
|
||||||
if (service is FormEngines form)
|
if (service is FormEngines form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||||
if (service is FormCreateOrder form)
|
if (service is FormCreateOrder form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void buttonOrderReady_Click(object sender, EventArgs e)
|
private void buttonOrderReady_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id =
|
int id =
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void buttonIssuedOrder_Click(object sender, EventArgs e)
|
private void buttonIssuedOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id
|
Id = id
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
_logger.LogError(ex, "Ошибка отметки о выдачи заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void buttonRef_Click(object sender, EventArgs e)
|
private void buttonRef_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||||
if (service is FormShops form)
|
if (service is FormShops form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void transactionToolStripMenuItem_Click(object sender, EventArgs e)
|
private void transactionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
|
||||||
if (service is FormCreateSupply form)
|
if (service is FormCreateSupply form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
private void SellToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSellEngines));
|
||||||
|
if (service is FormSellEngines form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
@ -117,7 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
124
MotorPlant/MotorPlantView/FormSellEngines.Designer.cs
generated
Normal file
124
MotorPlant/MotorPlantView/FormSellEngines.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
namespace MotorPlantView.Forms
|
||||||
|
{
|
||||||
|
partial class FormSellEngines
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelEngine = new Label();
|
||||||
|
comboBoxEngine = new ComboBox();
|
||||||
|
labelCount = new Label();
|
||||||
|
textBoxCount = new TextBox();
|
||||||
|
buttonSell = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelEngine
|
||||||
|
//
|
||||||
|
labelEngine.AutoSize = true;
|
||||||
|
labelEngine.Location = new Point(10, 10);
|
||||||
|
labelEngine.Name = "labelEngine";
|
||||||
|
labelEngine.Size = new Size(69, 15);
|
||||||
|
labelEngine.TabIndex = 0;
|
||||||
|
labelEngine.Text = "Двигатель: ";
|
||||||
|
//
|
||||||
|
// comboBoxEngine
|
||||||
|
//
|
||||||
|
comboBoxEngine.FormattingEnabled = true;
|
||||||
|
comboBoxEngine.Location = new Point(101, 8);
|
||||||
|
comboBoxEngine.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
comboBoxEngine.Name = "comboBoxEngine";
|
||||||
|
comboBoxEngine.Size = new Size(210, 23);
|
||||||
|
comboBoxEngine.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
labelCount.AutoSize = true;
|
||||||
|
labelCount.Location = new Point(10, 41);
|
||||||
|
labelCount.Name = "labelCount";
|
||||||
|
labelCount.Size = new Size(78, 15);
|
||||||
|
labelCount.TabIndex = 2;
|
||||||
|
labelCount.Text = "Количество: ";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
textBoxCount.Location = new Point(101, 39);
|
||||||
|
textBoxCount.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
textBoxCount.Name = "textBoxCount";
|
||||||
|
textBoxCount.Size = new Size(210, 23);
|
||||||
|
textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonSell
|
||||||
|
//
|
||||||
|
buttonSell.Location = new Point(112, 74);
|
||||||
|
buttonSell.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonSell.Name = "buttonSell";
|
||||||
|
buttonSell.Size = new Size(82, 22);
|
||||||
|
buttonSell.TabIndex = 4;
|
||||||
|
buttonSell.Text = "Продать";
|
||||||
|
buttonSell.UseVisualStyleBackColor = true;
|
||||||
|
buttonSell.Click += ButtonSell_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(212, 74);
|
||||||
|
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(82, 22);
|
||||||
|
buttonCancel.TabIndex = 5;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormSellEngines
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(320, 105);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSell);
|
||||||
|
Controls.Add(textBoxCount);
|
||||||
|
Controls.Add(labelCount);
|
||||||
|
Controls.Add(comboBoxEngine);
|
||||||
|
Controls.Add(labelEngine);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormSellEngines";
|
||||||
|
Text = "Продажа двигателей";
|
||||||
|
Load += FormSellingEngine_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelEngine;
|
||||||
|
private ComboBox comboBoxEngine;
|
||||||
|
private Label labelCount;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Button buttonSell;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
82
MotorPlant/MotorPlantView/FormSellEngines.cs
Normal file
82
MotorPlant/MotorPlantView/FormSellEngines.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MotorPlantContracts.BusinessLogicsContracts;
|
||||||
|
using MotorPlantContracts.SearchModels;
|
||||||
|
using MotorPlantContracts.ViewModels;
|
||||||
|
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 MotorPlantView.Forms
|
||||||
|
{
|
||||||
|
public partial class FormSellEngines : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IEngineLogic _logicP;
|
||||||
|
private readonly IShopLogic _logicS;
|
||||||
|
private List<EngineViewModel> _EngineList = new List<EngineViewModel>();
|
||||||
|
public FormSellEngines(ILogger<FormSellEngines> logger, IEngineLogic logicP, IShopLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicS = logicS;
|
||||||
|
}
|
||||||
|
private void FormSellingEngine_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_EngineList = _logicP.ReadList(null);
|
||||||
|
if (_EngineList != null)
|
||||||
|
{
|
||||||
|
comboBoxEngine.DisplayMember = "EngineName";
|
||||||
|
comboBoxEngine.ValueMember = "Id";
|
||||||
|
comboBoxEngine.DataSource = _EngineList;
|
||||||
|
comboBoxEngine.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка двигателей для продажи");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonSell_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxEngine.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание покупки");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool resout = _logicS.Sale(new SupplySearchModel
|
||||||
|
{
|
||||||
|
EngineId = Convert.ToInt32(comboBoxEngine.SelectedValue),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text)
|
||||||
|
});
|
||||||
|
if (resout)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Проверка пройдена, продажа проведена");
|
||||||
|
MessageBox.Show("Продажа проведена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Проверка не пройдена");
|
||||||
|
MessageBox.Show("Продажа не может быть создана.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
MotorPlant/MotorPlantView/FormSellEngines.resx
Normal file
120
MotorPlant/MotorPlantView/FormSellEngines.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>
|
404
MotorPlant/MotorPlantView/FormShop.Designer.cs
generated
404
MotorPlant/MotorPlantView/FormShop.Designer.cs
generated
@ -1,196 +1,222 @@
|
|||||||
namespace MotorPlantView
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
partial class FormShop
|
partial class FormShop
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
labelName = new Label();
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
textBoxName = new TextBox();
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
textBoxAdress = new TextBox();
|
this.textBoxAdress = new System.Windows.Forms.TextBox();
|
||||||
labelAdress = new Label();
|
this.labelAdress = new System.Windows.Forms.Label();
|
||||||
buttonCancel = new Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
buttonSave = new Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
dataGridView = new DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
label1 = new Label();
|
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
dateTimeOpen = new DateTimePicker();
|
this.EngineName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
id = new DataGridViewTextBoxColumn();
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
EngineName = new DataGridViewTextBoxColumn();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
Count = new DataGridViewTextBoxColumn();
|
this.dateTimeOpen = new System.Windows.Forms.DateTimePicker();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
SuspendLayout();
|
this.numericUpEngineMaxCount = new System.Windows.Forms.NumericUpDown();
|
||||||
//
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
// labelName
|
((System.ComponentModel.ISupportInitialize)(this.numericUpEngineMaxCount)).BeginInit();
|
||||||
//
|
this.SuspendLayout();
|
||||||
labelName.AutoSize = true;
|
//
|
||||||
labelName.Location = new Point(10, 11);
|
// labelName
|
||||||
labelName.Name = "labelName";
|
//
|
||||||
labelName.Size = new Size(65, 15);
|
this.labelName.AutoSize = true;
|
||||||
labelName.TabIndex = 0;
|
this.labelName.Location = new System.Drawing.Point(11, 15);
|
||||||
labelName.Text = "Название: ";
|
this.labelName.Name = "labelName";
|
||||||
//
|
this.labelName.Size = new System.Drawing.Size(84, 20);
|
||||||
// textBoxName
|
this.labelName.TabIndex = 0;
|
||||||
//
|
this.labelName.Text = "Название: ";
|
||||||
textBoxName.Location = new Point(89, 9);
|
//
|
||||||
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
// textBoxName
|
||||||
textBoxName.Name = "textBoxName";
|
//
|
||||||
textBoxName.Size = new Size(242, 23);
|
this.textBoxName.Location = new System.Drawing.Point(102, 12);
|
||||||
textBoxName.TabIndex = 1;
|
this.textBoxName.Name = "textBoxName";
|
||||||
//
|
this.textBoxName.Size = new System.Drawing.Size(276, 27);
|
||||||
// textBoxAdress
|
this.textBoxName.TabIndex = 1;
|
||||||
//
|
//
|
||||||
textBoxAdress.Location = new Point(89, 44);
|
// textBoxAdress
|
||||||
textBoxAdress.Margin = new Padding(3, 2, 3, 2);
|
//
|
||||||
textBoxAdress.Name = "textBoxAdress";
|
this.textBoxAdress.Location = new System.Drawing.Point(102, 59);
|
||||||
textBoxAdress.Size = new Size(374, 23);
|
this.textBoxAdress.Name = "textBoxAdress";
|
||||||
textBoxAdress.TabIndex = 3;
|
this.textBoxAdress.Size = new System.Drawing.Size(427, 27);
|
||||||
//
|
this.textBoxAdress.TabIndex = 3;
|
||||||
// labelAdress
|
//
|
||||||
//
|
// labelAdress
|
||||||
labelAdress.AutoSize = true;
|
//
|
||||||
labelAdress.Location = new Point(10, 46);
|
this.labelAdress.AutoSize = true;
|
||||||
labelAdress.Name = "labelAdress";
|
this.labelAdress.Location = new System.Drawing.Point(11, 61);
|
||||||
labelAdress.Size = new Size(46, 15);
|
this.labelAdress.Name = "labelAdress";
|
||||||
labelAdress.TabIndex = 2;
|
this.labelAdress.Size = new System.Drawing.Size(58, 20);
|
||||||
labelAdress.Text = "Адрес: ";
|
this.labelAdress.TabIndex = 2;
|
||||||
//
|
this.labelAdress.Text = "Адрес: ";
|
||||||
// buttonCancel
|
//
|
||||||
//
|
// buttonCancel
|
||||||
buttonCancel.Location = new Point(395, 343);
|
//
|
||||||
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
this.buttonCancel.Location = new System.Drawing.Point(451, 457);
|
||||||
buttonCancel.Name = "buttonCancel";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(114, 33);
|
this.buttonCancel.Size = new System.Drawing.Size(130, 44);
|
||||||
buttonCancel.TabIndex = 5;
|
this.buttonCancel.TabIndex = 5;
|
||||||
buttonCancel.Text = "Отмена";
|
this.buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += buttonCancel_Click;
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(276, 343);
|
this.buttonSave.Location = new System.Drawing.Point(315, 457);
|
||||||
buttonSave.Margin = new Padding(3, 2, 3, 2);
|
this.buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Name = "buttonSave";
|
this.buttonSave.Size = new System.Drawing.Size(130, 44);
|
||||||
buttonSave.Size = new Size(114, 33);
|
this.buttonSave.TabIndex = 6;
|
||||||
buttonSave.TabIndex = 6;
|
this.buttonSave.Text = "Сохранить";
|
||||||
buttonSave.Text = "Сохранить";
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
buttonSave.Click += buttonSave_Click;
|
//
|
||||||
//
|
// dataGridView
|
||||||
// dataGridView
|
//
|
||||||
//
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView.AllowUserToAddRows = false;
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToDeleteRows = false;
|
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { id, EngineName, Count });
|
this.id,
|
||||||
dataGridView.Location = new Point(10, 108);
|
this.EngineName,
|
||||||
dataGridView.Margin = new Padding(3, 2, 3, 2);
|
this.Count});
|
||||||
dataGridView.Name = "dataGridView";
|
this.dataGridView.Location = new System.Drawing.Point(12, 185);
|
||||||
dataGridView.ReadOnly = true;
|
this.dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
|
this.dataGridView.ReadOnly = true;
|
||||||
dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
|
||||||
dataGridView.RowTemplate.Height = 29;
|
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||||
dataGridView.Size = new Size(498, 230);
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
dataGridView.TabIndex = 7;
|
this.dataGridView.Size = new System.Drawing.Size(569, 266);
|
||||||
//
|
this.dataGridView.TabIndex = 7;
|
||||||
// label1
|
//
|
||||||
//
|
// id
|
||||||
label1.AutoSize = true;
|
//
|
||||||
label1.Location = new Point(10, 77);
|
this.id.HeaderText = "id";
|
||||||
label1.Name = "label1";
|
this.id.MinimumWidth = 6;
|
||||||
label1.Size = new Size(87, 15);
|
this.id.Name = "id";
|
||||||
label1.TabIndex = 8;
|
this.id.ReadOnly = true;
|
||||||
label1.Text = "Дата открытия";
|
this.id.Visible = false;
|
||||||
//
|
//
|
||||||
// dateTimeOpen
|
// EngineName
|
||||||
//
|
//
|
||||||
dateTimeOpen.Location = new Point(112, 77);
|
this.EngineName.HeaderText = "Двигатель";
|
||||||
dateTimeOpen.Margin = new Padding(3, 2, 3, 2);
|
this.EngineName.MinimumWidth = 6;
|
||||||
dateTimeOpen.Name = "dateTimeOpen";
|
this.EngineName.Name = "EngineName";
|
||||||
dateTimeOpen.Size = new Size(351, 23);
|
this.EngineName.ReadOnly = true;
|
||||||
dateTimeOpen.TabIndex = 9;
|
//
|
||||||
//
|
// Count
|
||||||
// id
|
//
|
||||||
//
|
this.Count.HeaderText = "Количество";
|
||||||
id.HeaderText = "id";
|
this.Count.MinimumWidth = 6;
|
||||||
id.MinimumWidth = 6;
|
this.Count.Name = "Count";
|
||||||
id.Name = "id";
|
this.Count.ReadOnly = true;
|
||||||
id.ReadOnly = true;
|
//
|
||||||
id.Visible = false;
|
// label1
|
||||||
//
|
//
|
||||||
// EngineName
|
this.label1.AutoSize = true;
|
||||||
//
|
this.label1.Location = new System.Drawing.Point(12, 103);
|
||||||
EngineName.HeaderText = "Двигатель";
|
this.label1.Name = "label1";
|
||||||
EngineName.MinimumWidth = 6;
|
this.label1.Size = new System.Drawing.Size(110, 20);
|
||||||
EngineName.Name = "EngineName";
|
this.label1.TabIndex = 8;
|
||||||
EngineName.ReadOnly = true;
|
this.label1.Text = "Дата открытия";
|
||||||
//
|
//
|
||||||
// Count
|
// dateTimeOpen
|
||||||
//
|
//
|
||||||
Count.HeaderText = "Количество";
|
this.dateTimeOpen.Location = new System.Drawing.Point(128, 103);
|
||||||
Count.MinimumWidth = 6;
|
this.dateTimeOpen.Name = "dateTimeOpen";
|
||||||
Count.Name = "Count";
|
this.dateTimeOpen.Size = new System.Drawing.Size(401, 27);
|
||||||
Count.ReadOnly = true;
|
this.dateTimeOpen.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// FormShop
|
// label2
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
this.label2.AutoSize = true;
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
this.label2.Location = new System.Drawing.Point(12, 148);
|
||||||
ClientSize = new Size(519, 385);
|
this.label2.Name = "label2";
|
||||||
Controls.Add(dateTimeOpen);
|
this.label2.Size = new System.Drawing.Size(100, 20);
|
||||||
Controls.Add(label1);
|
this.label2.TabIndex = 10;
|
||||||
Controls.Add(dataGridView);
|
this.label2.Text = "Вместимость";
|
||||||
Controls.Add(buttonSave);
|
//
|
||||||
Controls.Add(buttonCancel);
|
// numericUpEngineMaxCount
|
||||||
Controls.Add(textBoxAdress);
|
//
|
||||||
Controls.Add(labelAdress);
|
this.numericUpEngineMaxCount.Location = new System.Drawing.Point(128, 146);
|
||||||
Controls.Add(textBoxName);
|
this.numericUpEngineMaxCount.Maximum = new decimal(new int[] {
|
||||||
Controls.Add(labelName);
|
10000,
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
0,
|
||||||
Name = "FormShop";
|
0,
|
||||||
Text = "Магазин";
|
0});
|
||||||
Load += FormShop_Load;
|
this.numericUpEngineMaxCount.Name = "numericUpEngineMaxCount";
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
this.numericUpEngineMaxCount.Size = new System.Drawing.Size(401, 27);
|
||||||
ResumeLayout(false);
|
this.numericUpEngineMaxCount.TabIndex = 11;
|
||||||
PerformLayout();
|
//
|
||||||
}
|
// FormShop
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(593, 513);
|
||||||
|
this.Controls.Add(this.numericUpEngineMaxCount);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.dateTimeOpen);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.textBoxAdress);
|
||||||
|
this.Controls.Add(this.labelAdress);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormShop";
|
||||||
|
this.Text = "Магазин";
|
||||||
|
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpEngineMaxCount)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
#endregion
|
}
|
||||||
|
|
||||||
private Label labelName;
|
#endregion
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxAdress;
|
private Label labelName;
|
||||||
private Label labelAdress;
|
private TextBox textBoxName;
|
||||||
private Button buttonCancel;
|
private TextBox textBoxAdress;
|
||||||
private Button buttonSave;
|
private Label labelAdress;
|
||||||
private DataGridView dataGridView;
|
private Button buttonCancel;
|
||||||
private Label label1;
|
private Button buttonSave;
|
||||||
private DateTimePicker dateTimeOpen;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewTextBoxColumn id;
|
private DataGridViewTextBoxColumn id;
|
||||||
private DataGridViewTextBoxColumn EngineName;
|
private DataGridViewTextBoxColumn EngineName;
|
||||||
private DataGridViewTextBoxColumn Count;
|
private DataGridViewTextBoxColumn Count;
|
||||||
}
|
private Label label1;
|
||||||
|
private DateTimePicker dateTimeOpen;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown numericUpEngineMaxCount;
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,111 +13,113 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace MotorPlantView
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
public partial class FormShop : Form
|
public partial class FormShop : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IShopLogic _logic;
|
private readonly IShopLogic _logic;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
private Dictionary<int, (IEngineModel, int)> _ShopEngines;
|
private Dictionary<int, (IEngineModel, int)> _ShopEngines;
|
||||||
private DateTime? _openingDate = null;
|
private DateTime? _openingDate = null;
|
||||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_ShopEngines = new Dictionary<int, (IEngineModel, int)>();
|
_ShopEngines = new Dictionary<int, (IEngineModel, int)>();
|
||||||
}
|
}
|
||||||
private void FormShop_Load(object sender, EventArgs e)
|
private void FormShop_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_id.HasValue)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка магазина");
|
_logger.LogInformation("Загрузка магазина");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var view = _logic.ReadElement(new ShopSearchModel
|
var view = _logic.ReadElement(new ShopSearchModel
|
||||||
{
|
{
|
||||||
Id = _id.Value
|
Id = _id.Value
|
||||||
});
|
});
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = view.ShopName;
|
textBoxName.Text = view.ShopName;
|
||||||
textBoxAdress.Text = view.Adress;
|
textBoxAdress.Text = view.Adress;
|
||||||
dateTimeOpen.Value = view.OpeningDate;
|
dateTimeOpen.Value = view.OpeningDate;
|
||||||
_ShopEngines = view.ShopEngines ?? new Dictionary<int, (IEngineModel, int)>();
|
numericUpEngineMaxCount.Value = view.EngineMaxCount;
|
||||||
LoadData();
|
_ShopEngines = view.ShopEngines ?? new Dictionary<int, (IEngineModel, int)>();
|
||||||
}
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||||
}
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadData()
|
}
|
||||||
{
|
private void LoadData()
|
||||||
_logger.LogInformation("Загрузка изделий в магазине");
|
{
|
||||||
try
|
_logger.LogInformation("Загрузка изделий в магазине");
|
||||||
{
|
try
|
||||||
if (_ShopEngines != null)
|
{
|
||||||
{
|
if (_ShopEngines != null)
|
||||||
dataGridView.Rows.Clear();
|
{
|
||||||
foreach (var sr in _ShopEngines)
|
dataGridView.Rows.Clear();
|
||||||
{
|
foreach (var sr in _ShopEngines)
|
||||||
dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.EngineName, sr.Value.Item2 });
|
{
|
||||||
}
|
dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.EngineName, sr.Value.Item2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||||
}
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
private void buttonSave_Click(object sender, EventArgs e)
|
}
|
||||||
{
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
{
|
||||||
{
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
{
|
||||||
return;
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
return;
|
||||||
if (string.IsNullOrEmpty(textBoxAdress.Text))
|
}
|
||||||
{
|
if (string.IsNullOrEmpty(textBoxAdress.Text))
|
||||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
{
|
||||||
return;
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
return;
|
||||||
_logger.LogInformation("Сохранение магазина");
|
}
|
||||||
try
|
_logger.LogInformation("Сохранение магазина");
|
||||||
{
|
try
|
||||||
var model = new ShopBindingModel
|
{
|
||||||
{
|
var model = new ShopBindingModel
|
||||||
Id = _id ?? 0,
|
{
|
||||||
ShopName = textBoxName.Text,
|
Id = _id ?? 0,
|
||||||
Adress = textBoxAdress.Text,
|
ShopName = textBoxName.Text,
|
||||||
OpeningDate = dateTimeOpen.Value
|
Adress = textBoxAdress.Text,
|
||||||
};
|
OpeningDate = dateTimeOpen.Value,
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
EngineMaxCount = (int)numericUpEngineMaxCount.Value
|
||||||
if (!operationResult)
|
};
|
||||||
{
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
if (!operationResult)
|
||||||
}
|
{
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
DialogResult = DialogResult.OK;
|
}
|
||||||
Close();
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
DialogResult = DialogResult.OK;
|
||||||
catch (Exception ex)
|
Close();
|
||||||
{
|
}
|
||||||
_logger.LogError(ex, "Ошибка сохранения магазина");
|
catch (Exception ex)
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
{
|
||||||
}
|
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||||
}
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
private void buttonCancel_Click(object sender, EventArgs e)
|
}
|
||||||
{
|
}
|
||||||
DialogResult = DialogResult.Cancel;
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
Close();
|
{
|
||||||
}
|
DialogResult = DialogResult.Cancel;
|
||||||
}
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
244
MotorPlant/MotorPlantView/FormShops.Designer.cs
generated
244
MotorPlant/MotorPlantView/FormShops.Designer.cs
generated
@ -1,130 +1,130 @@
|
|||||||
namespace MotorPlantView
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
partial class FormShops
|
partial class FormShops
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.ToolsPanel.SuspendLayout();
|
this.ToolsPanel.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ToolsPanel
|
// ToolsPanel
|
||||||
//
|
//
|
||||||
this.ToolsPanel.Controls.Add(this.buttonRef);
|
this.ToolsPanel.Controls.Add(this.buttonRef);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonDel);
|
this.ToolsPanel.Controls.Add(this.buttonDel);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||||
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
||||||
this.ToolsPanel.Name = "ToolsPanel";
|
this.ToolsPanel.Name = "ToolsPanel";
|
||||||
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
||||||
this.ToolsPanel.TabIndex = 3;
|
this.ToolsPanel.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
||||||
this.buttonRef.Name = "buttonRef";
|
this.buttonRef.Name = "buttonRef";
|
||||||
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonRef.TabIndex = 3;
|
this.buttonRef.TabIndex = 3;
|
||||||
this.buttonRef.Text = "Обновить";
|
this.buttonRef.Text = "Обновить";
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
//
|
//
|
||||||
// buttonDel
|
// buttonDel
|
||||||
//
|
//
|
||||||
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
||||||
this.buttonDel.Name = "buttonDel";
|
this.buttonDel.Name = "buttonDel";
|
||||||
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonDel.TabIndex = 2;
|
this.buttonDel.TabIndex = 2;
|
||||||
this.buttonDel.Text = "Удалить";
|
this.buttonDel.Text = "Удалить";
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
//
|
//
|
||||||
// buttonUpd
|
// buttonUpd
|
||||||
//
|
//
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonUpd.TabIndex = 1;
|
this.buttonUpd.TabIndex = 1;
|
||||||
this.buttonUpd.Text = "Изменить";
|
this.buttonUpd.Text = "Изменить";
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonAdd.TabIndex = 0;
|
this.buttonAdd.TabIndex = 0;
|
||||||
this.buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.ReadOnly = true;
|
this.dataGridView.ReadOnly = true;
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(590, 426);
|
this.dataGridView.Size = new System.Drawing.Size(590, 426);
|
||||||
this.dataGridView.TabIndex = 2;
|
this.dataGridView.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// FormShops
|
// FormShops
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
this.Controls.Add(this.ToolsPanel);
|
this.Controls.Add(this.ToolsPanel);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Name = "FormShops";
|
this.Name = "FormShops";
|
||||||
this.Text = "Магазины";
|
this.Text = "Магазины";
|
||||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||||
this.ToolsPanel.ResumeLayout(false);
|
this.ToolsPanel.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Panel ToolsPanel;
|
private Panel ToolsPanel;
|
||||||
private Button buttonRef;
|
private Button buttonRef;
|
||||||
private Button buttonDel;
|
private Button buttonDel;
|
||||||
private Button buttonUpd;
|
private Button buttonUpd;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,99 +11,99 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace MotorPlantView
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
public partial class FormShops : Form
|
public partial class FormShops : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IShopLogic _logic;
|
private readonly IShopLogic _logic;
|
||||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
private void FormShops_Load(object sender, EventArgs e)
|
private void FormShops_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
var list = _logic.ReadList(null);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
dataGridView.Columns["ShopEngines"].Visible = false;
|
dataGridView.Columns["ShopEngines"].Visible = false;
|
||||||
dataGridView.Columns["ShopName"].AutoSizeMode =
|
dataGridView.Columns["ShopName"].AutoSizeMode =
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка магазинов");
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
if (service is FormShop form)
|
if (service is FormShop form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
if (service is FormShop form)
|
if (service is FormShop form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Удаление магазина");
|
_logger.LogInformation("Удаление магазина");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new ShopBindingModel
|
if (!_logic.Delete(new ShopBindingModel
|
||||||
{
|
{
|
||||||
Id = id
|
Id = id
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MotorPlantBusinessLogic\MotorPlantBusinessLogic.csproj" />
|
<ProjectReference Include="..\MotorPlantBusinessLogic\MotorPlantBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
<ProjectReference Include="..\MotorPlantContracts\MotorPlantContracts.csproj" />
|
||||||
<ProjectReference Include="..\MotorPlantFileImplement\MotorPlantFileImplement.csproj" />
|
<ProjectReference Include="..\MotorPlantFileImplement\MotorPlantFileImplement.csproj" />
|
||||||
<ProjectReference Include="..\MotorPlantListImplement\MotorPlantListImplement.csproj" />
|
<ProjectReference Include="..\MotorPlantListImplement\MotorPlantListImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -49,11 +49,12 @@ namespace MotorPlantView.Forms
|
|||||||
services.AddTransient<FormEngine>();
|
services.AddTransient<FormEngine>();
|
||||||
services.AddTransient<FormEngineComponent>();
|
services.AddTransient<FormEngineComponent>();
|
||||||
services.AddTransient<FormEngines>();
|
services.AddTransient<FormEngines>();
|
||||||
services.AddTransient<IShopStorage, ShopStorage>();
|
services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
services.AddTransient<IShopLogic, ShopLogic>();
|
services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
services.AddTransient<FormShop>();
|
services.AddTransient<FormShop>();
|
||||||
services.AddTransient<FormShops>();
|
services.AddTransient<FormShops>();
|
||||||
services.AddTransient<FormCreateSupply>();
|
services.AddTransient<FormCreateSupply>();
|
||||||
}
|
services.AddTransient<FormSellEngines>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user