лаба
This commit is contained in:
parent
ad0398f687
commit
a023f3b24a
@ -16,24 +16,21 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
public class OrderLogic : IOrderLogic
|
public class OrderLogic : IOrderLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
|
||||||
|
private readonly IReinforcedStorage _reinforcedStorage;
|
||||||
|
|
||||||
|
private readonly IShopLogic _shopLogic;
|
||||||
|
|
||||||
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IReinforcedStorage reinforcedStorage, IShopLogic shopLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_reinforcedStorage = reinforcedStorage;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
}
|
}
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
@ -50,54 +47,35 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. OrderId: {Id}.", model?.Id);
|
||||||
|
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||||
if (_orderStorage.GetElement(new OrderSearchModel { Id = model.Id })?.Status != OrderStatus.Принят)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Invalid order status");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Выполняется;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
return ChangeStatus(model, OrderStatus.Готов);
|
||||||
if (_orderStorage.GetElement(new OrderSearchModel { Id = model.Id })?.Status != OrderStatus.Выполняется)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Invalid order status");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Готов;
|
|
||||||
model.DateImplement = DateTime.Now;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
return ChangeStatus(model, OrderStatus.Выдан);
|
||||||
var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
|
||||||
if (order?.Status != OrderStatus.Готов)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Invalid order status");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Выдан;
|
|
||||||
model.DateImplement = order.DateImplement;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -108,16 +86,67 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (model.ReinforcedId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.ReinforcedId));
|
||||||
|
}
|
||||||
|
if (model.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("В заказе должно быть хотя бы одно изделие", nameof(model.Count));
|
||||||
|
}
|
||||||
if (model.Sum <= 0)
|
if (model.Sum <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Стоимость должна быть больше 0", nameof(model.Sum));
|
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(model.Sum));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Order. Id: {Id}. Sum: {Sum}. ReinforcedId: {ReinforcedId}", model.Id, model.Sum, model.ReinforcedId);
|
_logger.LogInformation("Order. Id: {Id}. Sum: {Sum}. ReinforcedId: {ReinforcedId}. ReinforcedCount: {Count}", model.Id, model.Sum,
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
model.ReinforcedId, model.Count);
|
||||||
if (element != null && element.Id == model.Id)
|
}
|
||||||
|
|
||||||
|
private bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Заказ с таким номером уже есть");
|
CheckModel(model, false);
|
||||||
|
var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Change status operation failed. Order not found");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
if (order.Status + 1 != newStatus)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Change status operation failed. Incorrect new status: {newStatus}. Current status: {currStatus}",
|
||||||
|
newStatus, order.Status);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//наверное тут вопрос 3 тип если изделий нема то и выдать нечего
|
||||||
|
if (newStatus == OrderStatus.Выдан)
|
||||||
|
{
|
||||||
|
var reinforced = _reinforcedStorage.GetElement(new ReinforcedSearchModel() { Id = order.ReinforcedId });
|
||||||
|
if (reinforced == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Change status operation failed. Reinforced not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!_shopLogic.DeliverReinforceds(reinforced, order.Count))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Change status operation failed. Reinforceds delivery operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.Status = newStatus;
|
||||||
|
if (model.Status == OrderStatus.Готов)
|
||||||
|
{
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.DateImplement = order.DateImplement;
|
||||||
|
}
|
||||||
|
if (_orderStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Change status operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -88,8 +88,8 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//логика пополнения магазина
|
|
||||||
public bool RefillShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count)
|
public bool ReplenishShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count)
|
||||||
{
|
{
|
||||||
if (shopModel == null)
|
if (shopModel == null)
|
||||||
{
|
{
|
||||||
@ -103,27 +103,30 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("В магазине должен быть хотя бы один товар", nameof(count));
|
throw new ArgumentException("В магазине должен быть хотя бы один товар", nameof(count));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("RefillShop(GetElement). ShopName: {ShopName}. Id: {Id}", shopModel.ShopName, shopModel.Id);
|
_logger.LogInformation("ReplenishShop(GetElement). ShopName: {ShopName}. Id: {Id}", shopModel.ShopName, shopModel.Id);
|
||||||
|
|
||||||
var shop = _shopStorage.GetElement(shopModel);
|
var shop = _shopStorage.GetElement(shopModel);
|
||||||
|
|
||||||
if (shop == null)
|
if (shop == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("RefillShop(GetElement). Element not found");
|
_logger.LogWarning("ReplenishShop(GetElement). Element not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (shop.ShopReinforceds.ContainsKey(reinforced.Id))//если есть товар то плюс
|
if (shop.ReinforcedsMax - shop.ShopReinforceds.Sum(x => x.Value.Item2) < count)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReplenishShop error. No space for new reinforceds");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (shop.ShopReinforceds.ContainsKey(reinforced.Id))
|
||||||
{
|
{
|
||||||
var shopR = shop.ShopReinforceds[reinforced.Id];
|
var shopR = shop.ShopReinforceds[reinforced.Id];
|
||||||
shopR.Item2 += count;
|
shopR.Item2 += count;
|
||||||
shop.ShopReinforceds[reinforced.Id] = shopR;
|
shop.ShopReinforceds[reinforced.Id] = shopR;
|
||||||
_logger.LogInformation("RefillShop. Added {count} '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
_logger.LogInformation("ReplenishShop. Added {count} '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
||||||
shop.ShopName);
|
shop.ShopName);
|
||||||
}
|
}
|
||||||
else//если нет то просто добавляем
|
else
|
||||||
{
|
{
|
||||||
shop.ShopReinforceds.Add(reinforced.Id, (reinforced, count));
|
shop.ShopReinforceds.Add(reinforced.Id, (reinforced, count));
|
||||||
_logger.LogInformation("RefillShop. Added {count} new '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
_logger.LogInformation("ReplenishShop. Added {count} new '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
||||||
shop.ShopName);
|
shop.ShopName);
|
||||||
}
|
}
|
||||||
if (_shopStorage.Update(new ShopBindingModel()
|
if (_shopStorage.Update(new ShopBindingModel()
|
||||||
@ -132,15 +135,78 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
ShopName = shop.ShopName,
|
ShopName = shop.ShopName,
|
||||||
Address = shop.Address,
|
Address = shop.Address,
|
||||||
DateOpening = shop.DateOpening,
|
DateOpening = shop.DateOpening,
|
||||||
|
ReinforcedsMax = shop.ReinforcedsMax,
|
||||||
ShopReinforceds = shop.ShopReinforceds,
|
ShopReinforceds = shop.ShopReinforceds,
|
||||||
}) == null)
|
}) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("RefillShop. Update operation failed");
|
_logger.LogWarning("ReplenishShop. Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MakeSale(IReinforcedModel model, int count)
|
||||||
|
{
|
||||||
|
return _shopStorage.MakeSale(model, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeliverReinforceds(IReinforcedModel reinforced, int count)
|
||||||
|
{
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Reinforceds delivery operation failed. Reinforced count <= 0");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var shopList = _shopStorage.GetFullList();
|
||||||
|
int shopsCapacity = shopList.Sum(x => x.ReinforcedsMax);
|
||||||
|
int currentReinforceds = shopList.Select(x => x.ShopReinforceds.Sum(y => y.Value.Item2)).Sum();
|
||||||
|
int freePlaces = shopsCapacity - currentReinforceds;
|
||||||
|
|
||||||
|
if (freePlaces < count)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Reinforceds delivery operation failed. No space for new кeinforceds");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in shopList)
|
||||||
|
{
|
||||||
|
freePlaces = shop.ReinforcedsMax - shop.ShopReinforceds.Sum(x => x.Value.Item2);
|
||||||
|
if (freePlaces == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (freePlaces >= count)
|
||||||
|
{
|
||||||
|
if (ReplenishShop(new() { Id = shop.Id }, reinforced, count))
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Reinforceds delivery operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ReplenishShop(new() { Id = shop.Id }, reinforced, freePlaces))
|
||||||
|
{
|
||||||
|
count -= freePlaces;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Reinforceds delivery operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -22,5 +22,6 @@ namespace PrecastConcretePlantContracts.BindingModels
|
|||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
} = new();
|
} = new();
|
||||||
|
public int ReinforcedsMax { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,10 @@ namespace PrecastConcretePlantContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
bool Delete(ShopBindingModel model);
|
bool Delete(ShopBindingModel model);
|
||||||
|
|
||||||
bool RefillShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count);
|
bool ReplenishShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count);
|
||||||
|
|
||||||
|
bool MakeSale(IReinforcedModel model, int count);
|
||||||
|
|
||||||
|
bool DeliverReinforceds(IReinforcedModel model, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using PrecastConcretePlantContracts.BindingModels;
|
using PrecastConcretePlantContracts.BindingModels;
|
||||||
using PrecastConcretePlantContracts.SearchModels;
|
using PrecastConcretePlantContracts.SearchModels;
|
||||||
using PrecastConcretePlantContracts.ViewModels;
|
using PrecastConcretePlantContracts.ViewModels;
|
||||||
|
using PrecastConcretePlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -22,5 +23,7 @@ namespace PrecastConcretePlantContracts.StoragesContracts
|
|||||||
ShopViewModel? Update(ShopBindingModel model);
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
|
|
||||||
ShopViewModel? Delete(ShopBindingModel model);
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool MakeSale(IReinforcedModel model, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,8 @@ namespace PrecastConcretePlantContracts.ViewModels
|
|||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
} = new();
|
} = new();
|
||||||
|
|
||||||
|
[DisplayName("Максимальное количество изделий")]
|
||||||
|
public int ReinforcedsMax { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,6 @@ namespace PrecastConcretePlantDataModels.Models
|
|||||||
DateTime DateOpening { get; }
|
DateTime DateOpening { get; }
|
||||||
|
|
||||||
Dictionary<int, (IReinforcedModel, int)> ShopReinforceds { get; }
|
Dictionary<int, (IReinforcedModel, int)> ShopReinforceds { get; }
|
||||||
|
int ReinforcedsMax { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
using PrecastConcretePlantFileImplement.Models;
|
using System.Xml.Linq;
|
||||||
using System;
|
using PrecastConcretePlantFileImplement.Models;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PrecastConcretePlantFileImplement
|
namespace PrecastConcretePlantFileImplement
|
||||||
{
|
{
|
||||||
public class DataFileSingleton
|
internal class DataFileSingleton
|
||||||
{
|
{
|
||||||
private static DataFileSingleton? instance;
|
private static DataFileSingleton? instance;
|
||||||
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 ReinforcedFileName = "Reinforced.xml";
|
private readonly string ReinforcedFileName = "Reinforced.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<Reinforced> Reinforceds { get; private set; }
|
public List<Reinforced> Reinforceds { get; private set; }
|
||||||
|
public List<Shop> Shops { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -28,18 +25,19 @@ namespace PrecastConcretePlantFileImplement
|
|||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||||
public void SaveReinforceds() => SaveData(Reinforceds, ReinforcedFileName, "Reinforceds", x => x.GetXElement);
|
public void SaveReinforceds() => SaveData(Reinforceds, ReinforcedFileName, "Reinforceds", 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)!)!;
|
||||||
Reinforceds = LoadData(ReinforcedFileName, "Reinforced", x => Reinforced.Create(x)!)!;
|
Reinforceds = LoadData(ReinforcedFileName, "Reinforced", x => Reinforced.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)
|
||||||
{
|
{
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
{
|
{
|
||||||
return
|
return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
||||||
XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
|
||||||
}
|
}
|
||||||
return new List<T>();
|
return new List<T>();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,138 @@
|
|||||||
|
using PrecastConcretePlantContracts.BindingModels;
|
||||||
|
using PrecastConcretePlantContracts.SearchModels;
|
||||||
|
using PrecastConcretePlantContracts.StoragesContracts;
|
||||||
|
using PrecastConcretePlantContracts.ViewModels;
|
||||||
|
using PrecastConcretePlantDataModels.Models;
|
||||||
|
using PrecastConcretePlantFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PrecastConcretePlantFileImplement.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 element = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Shops.Remove(element);
|
||||||
|
source.SaveShops();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//логика продажи изделий с магазинов
|
||||||
|
public bool MakeSale(IReinforcedModel model, int count)
|
||||||
|
{
|
||||||
|
var reinforced = source.Reinforceds.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
int countInShops = source.Shops.SelectMany(x => x.ShopReinforceds).Sum(y => y.Key == model.Id ? y.Value.Item2 : 0);
|
||||||
|
|
||||||
|
if (reinforced == null || countInShops < count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in source.Shops)
|
||||||
|
{
|
||||||
|
var shopReinforceds = shop.ShopReinforceds.Where(x => x.Key == model.Id);
|
||||||
|
if (shopReinforceds.Any())
|
||||||
|
{
|
||||||
|
var shopReinforced = shopReinforceds.First();
|
||||||
|
int min = Math.Min(shopReinforced.Value.Item2, count);
|
||||||
|
if (min == shopReinforced.Value.Item2)
|
||||||
|
{
|
||||||
|
shop.ShopReinforceds.Remove(shopReinforced.Key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.ShopReinforceds[shopReinforced.Key] = (shopReinforced.Value.Item1, shopReinforced.Value.Item2 - min);
|
||||||
|
}
|
||||||
|
shop.Update(new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = shop.Id,
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Address = shop.Address,
|
||||||
|
DateOpening = shop.DateOpening,
|
||||||
|
ShopReinforceds = shop.ShopReinforceds,
|
||||||
|
ReinforcedsMax = shop.ReinforcedsMax
|
||||||
|
});
|
||||||
|
count -= min;
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source.SaveShops();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
using PrecastConcretePlantContracts.BindingModels;
|
||||||
|
using PrecastConcretePlantContracts.ViewModels;
|
||||||
|
using PrecastConcretePlantDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace PrecastConcretePlantFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string ShopName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateOpening { get; private set; }
|
||||||
|
|
||||||
|
public Dictionary<int, int> Reinforceds { get; private set; } = new();
|
||||||
|
|
||||||
|
private Dictionary<int, (IReinforcedModel, int)>? _shopReinforceds = null;
|
||||||
|
|
||||||
|
public Dictionary<int, (IReinforcedModel, int)> ShopReinforceds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopReinforceds == null)
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
_shopReinforceds = Reinforceds.ToDictionary(x => x.Key,
|
||||||
|
y => ((source.Reinforceds.FirstOrDefault(z => z.Id == y.Key) as IReinforcedModel)!, y.Value));
|
||||||
|
}
|
||||||
|
return _shopReinforceds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReinforcedsMax { get; private set; }
|
||||||
|
|
||||||
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Address = model.Address,
|
||||||
|
DateOpening = model.DateOpening,
|
||||||
|
Reinforceds = model.ShopReinforceds.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||||
|
ReinforcedsMax = model.ReinforcedsMax
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Shop? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ShopName = element.Element("ShopName")!.Value,
|
||||||
|
Address = element.Element("Address")!.Value,
|
||||||
|
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
|
||||||
|
ReinforcedsMax = Convert.ToInt32(element.Element("ReinforcedsMax")!.Value),
|
||||||
|
Reinforceds = element.Element("ShopReinforceds")!.Elements("ShopReinforced")
|
||||||
|
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Address = model.Address;
|
||||||
|
DateOpening = model.DateOpening;
|
||||||
|
ReinforcedsMax = model.ReinforcedsMax;
|
||||||
|
Reinforceds = model.ShopReinforceds.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||||
|
_shopReinforceds = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Address = Address,
|
||||||
|
DateOpening = DateOpening,
|
||||||
|
ShopReinforceds = ShopReinforceds,
|
||||||
|
ReinforcedsMax = ReinforcedsMax
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Shop",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ShopName", ShopName),
|
||||||
|
new XElement("Address", Address),
|
||||||
|
new XElement("DateOpening", DateOpening.ToString()),
|
||||||
|
new XElement("ReinforcedsMax", ReinforcedsMax.ToString()),
|
||||||
|
new XElement("ShopReinforceds",
|
||||||
|
Reinforceds.Select(x => new XElement("ShopReinforced",
|
||||||
|
new XElement("Key", x.Key),
|
||||||
|
new XElement("Value", x.Value))).ToArray()));
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,4 @@
|
|||||||
using PrecastConcretePlantListImplement.Models;
|
using PrecastConcretePlantListImplement.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PrecastConcretePlantListImplement
|
namespace PrecastConcretePlantListImplement
|
||||||
{
|
{
|
||||||
@ -29,6 +24,5 @@ namespace PrecastConcretePlantListImplement
|
|||||||
}
|
}
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using PrecastConcretePlantContracts.SearchModels;
|
using PrecastConcretePlantContracts.SearchModels;
|
||||||
using PrecastConcretePlantContracts.StoragesContracts;
|
using PrecastConcretePlantContracts.StoragesContracts;
|
||||||
using PrecastConcretePlantContracts.ViewModels;
|
using PrecastConcretePlantContracts.ViewModels;
|
||||||
|
using PrecastConcretePlantDataModels.Models;
|
||||||
using PrecastConcretePlantListImplement.Models;
|
using PrecastConcretePlantListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -110,5 +111,9 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public bool MakeSale(IReinforcedModel model, int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace PrecastConcretePlantListImplement.Models
|
|||||||
|
|
||||||
public DateTime DateOpening { get; private set; }
|
public DateTime DateOpening { get; private set; }
|
||||||
|
|
||||||
|
public int ReinforcedsMax { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IReinforcedModel, int)> ShopReinforceds
|
public Dictionary<int, (IReinforcedModel, int)> ShopReinforceds
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PrecastConcretePlantContracts.BindingModels;
|
using PrecastConcretePlantContracts.BindingModels;
|
||||||
using PrecastConcretePlantContracts.BusinessLogicsContracts;
|
using PrecastConcretePlantContracts.BusinessLogicsContracts;
|
||||||
using System;
|
using System;
|
||||||
@ -36,26 +36,27 @@ namespace PrecastConcretePlantView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["ReinforcedId"].Visible = false;
|
dataGridView.Columns["ReinforcedId"].Visible = false;
|
||||||
dataGridView.Columns["ReinforcedName"].AutoSizeMode =
|
dataGridView.Columns["reinforcedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
_logger.LogInformation("青沭箸赅 玎赅珙<E8B585>");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Îøèáêà çàãðóçêè çàêàçîâ");
|
_logger.LogError(ex, "硒栳赅 玎沭箸觇 玎赅珙<E8B585>");
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 如溴腓<EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedS));
|
var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedS));
|
||||||
if (service is FormReinforcedS form)
|
if (service is FormReinforcedS form)
|
||||||
@ -63,7 +64,7 @@ namespace PrecastConcretePlantView
|
|||||||
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(FormShops));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||||
if (service is FormShops form)
|
if (service is FormShops form)
|
||||||
@ -71,17 +72,26 @@ namespace PrecastConcretePlantView
|
|||||||
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(FormShopRefill));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShopReplenishment));
|
||||||
if (service is FormShopRefill form)
|
if (service is FormShopReplenishment form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void 橡钿噫嗳玟咫栝ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedSale));
|
||||||
|
if (service is FormReinforcedSale 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();
|
||||||
@ -92,24 +102,23 @@ namespace PrecastConcretePlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id =
|
||||||
_logger.LogInformation("Çàêàç No{id}. Ìåíÿåòñÿ ñòàòóñ íà 'Â ðàáîòå'", id);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("青赅<E99D92> 箋id}. 体<><E4BD93>弪<EFBFBD><E5BCAA> 耱囹篑 磬 '<27> 疣犷蝈'", 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("硒栳赅 镳<> 耦躔囗屙梃.念镱腠栩咫<E6A0A9><E592AB><EFBFBD> 桧纛痨圉<E797A8><E59C89> <20> 腩汔<E885A9>.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Îøèáêà ïåðåäà÷è çàêàçà â ðàáîòó");
|
_logger.LogError(ex, "硒栳赅 镥疱溧麒 玎赅玎 <20> 疣犷蝮");
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,24 +126,25 @@ namespace PrecastConcretePlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id =
|
||||||
_logger.LogInformation("Çàêàç No{id}. Ìåíÿåòñÿ ñòàòóñ íà 'Ãîòîâ'", id);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("青赅<E99D92> 箋id}. 体<><E4BD93>弪<EFBFBD><E5BCAA> 耱囹篑 磬 '妙蝾<E5A699>'",
|
||||||
|
id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
var operationResult = _orderLogic.FinishOrder(new
|
||||||
{
|
OrderBindingModel
|
||||||
Id = id
|
{ Id = id });
|
||||||
});
|
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Îøèáêà ïðè ñîõðàíåíèè. Äîïîëíèòåëüíàÿ èíôîðìàöèÿ â ëîãàõ.");
|
throw new Exception("硒栳赅 镳<> 耦躔囗屙梃. 念镱腠栩咫<E6A0A9><E592AB><EFBFBD> 桧纛痨圉<E797A8><E59C89> <20> 腩汔<E885A9>.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Îøèáêà îòìåòêè î ãîòîâíîñòè çàêàçà");
|
_logger.LogError(ex, "硒栳赅 铗戾蜿<E688BE> <20> 泐蝾忭铖蜩 玎赅玎");
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "硒栳赅", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,29 +152,28 @@ namespace PrecastConcretePlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id =
|
||||||
_logger.LogInformation("Çàêàç No{id}. Ìåíÿåòñÿ ñòàòóñ íà 'Âûäàí'", id);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("青赅<E99D92> 箋id}. 体<><E4BD93>弪<EFBFBD><E5BCAA> 耱囹篑 磬 '蔓溧<E89493>'", 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("Çàêàç No{id} âûäàí", id);
|
_logger.LogInformation("青赅<E99D92> 箋id} 恹溧<E681B9>", id);
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Îøèáêà îòìåòêè î âûäà÷è çàêàçà");
|
_logger.LogError(ex, "硒栳赅 铗戾蜿<E688BE> <20> 恹溧麒 玎赅玎");
|
||||||
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 ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user