laba2coml mb done no test
This commit is contained in:
parent
10e694172f
commit
5c4d7d410e
@ -4,6 +4,7 @@ using AutomobilePlantContracts.SearchModels;
|
|||||||
using AutomobilePlantContracts.StoragesContracts;
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
using AutomobilePlantContracts.ViewModels;
|
using AutomobilePlantContracts.ViewModels;
|
||||||
using AutomobilePlantDataModels.Enums;
|
using AutomobilePlantDataModels.Enums;
|
||||||
|
using AutomobilePlantDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -17,11 +18,17 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
private readonly IShopLogic _shopLogic;
|
||||||
|
private readonly ICarStorage _carStorage;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, ICarStorage carStorage, IShopStorage shopStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
|
_carStorage = carStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
@ -40,16 +47,80 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (model.Status != OrderStatus.Неизвестен) return false;
|
if (model.Status != OrderStatus.Неизвестен)
|
||||||
|
return false;
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
if (_orderStorage.Insert(model) == null)
|
if (_orderStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
|
model.Status = OrderStatus.Неизвестен;
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CheckThenSupplyMany(ICarModel car, int count)
|
||||||
|
{
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Check then supply operation error. Car count < 0.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int freeSpace = 0;
|
||||||
|
foreach (var shop in _shopStorage.GetFullList())
|
||||||
|
{
|
||||||
|
freeSpace += shop.MaxCountCars;
|
||||||
|
foreach (var c in shop.ShopCars)
|
||||||
|
{
|
||||||
|
freeSpace -= c.Value.Item2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freeSpace < count)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Check then supply operation error. There's no place for new cars in shops.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shop in _shopStorage.GetFullList())
|
||||||
|
{
|
||||||
|
freeSpace = shop.MaxCountCars;
|
||||||
|
|
||||||
|
foreach (var c in shop.ShopCars)
|
||||||
|
freeSpace -= c.Value.Item2;
|
||||||
|
|
||||||
|
if (freeSpace <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (freeSpace >= count)
|
||||||
|
{
|
||||||
|
if (_shopLogic.SupplyCars(new ShopSearchModel() { Id = shop.Id }, car, count))
|
||||||
|
count = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Supply error");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (freeSpace < count)
|
||||||
|
{
|
||||||
|
if (_shopLogic.SupplyCars(new ShopSearchModel() { Id = shop.Id }, car, freeSpace))
|
||||||
|
count -= freeSpace;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Supply error");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
@ -64,6 +135,23 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Status change operation failed");
|
_logger.LogWarning("Status change operation failed");
|
||||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status == OrderStatus.Готов)
|
||||||
|
{
|
||||||
|
var car = _carStorage.GetElement(new CarSearchModel() { Id = model.CarId });
|
||||||
|
if (car == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status change operation failed. Car not found.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CheckThenSupplyMany(car, model.Count))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status change operation failed. Shop supply error.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OrderStatus oldStatus = model.Status;
|
OrderStatus oldStatus = model.Status;
|
||||||
model.Status = status;
|
model.Status = status;
|
||||||
if (model.Status == OrderStatus.Выдан)
|
if (model.Status == OrderStatus.Выдан)
|
||||||
|
@ -88,6 +88,17 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
_logger.LogInformation("Shop element found. ID: {0}, Name: {1}", shopElement.Id, shopElement.Name);
|
_logger.LogInformation("Shop element found. ID: {0}, Name: {1}", shopElement.Id, shopElement.Name);
|
||||||
|
|
||||||
|
int countCars = 0;
|
||||||
|
foreach (var c in shopElement.ShopCars)
|
||||||
|
countCars += c.Value.Item2;
|
||||||
|
|
||||||
|
if (countCars > shopElement.MaxCountCars - countCars)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Required shop will be overflowed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (shopElement.ShopCars.TryGetValue(car.Id, out var sameCar))
|
if (shopElement.ShopCars.TryGetValue(car.Id, out var sameCar))
|
||||||
{
|
{
|
||||||
shopElement.ShopCars[car.Id] = (car, sameCar.Item2 + count);
|
shopElement.ShopCars[car.Id] = (car, sameCar.Item2 + count);
|
||||||
@ -107,6 +118,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
OpeningDate = shopElement.OpeningDate,
|
OpeningDate = shopElement.OpeningDate,
|
||||||
ShopCars = shopElement.ShopCars
|
ShopCars = shopElement.ShopCars
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -167,6 +179,11 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
throw new ArgumentNullException("Нет названия магазина!", nameof(model.Name));
|
throw new ArgumentNullException("Нет названия магазина!", nameof(model.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.MaxCountCars < 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Отрицательное максимальное количество авто!");
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Shop. Name: {0}, Address: {1}, ID: {2}", model.Name, model.Address, model.Id);
|
_logger.LogInformation("Shop. Name: {0}, Address: {1}, ID: {2}", model.Name, model.Address, model.Id);
|
||||||
|
|
||||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
@ -179,5 +196,10 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|||||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SellCar(ICarModel car, int count)
|
||||||
|
{
|
||||||
|
return _shopStorage.SellCar(car, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ namespace AutomobilePlantContracts.BindingModels
|
|||||||
|
|
||||||
public string Address { get; set; } = string.Empty;
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int MaxCountCars { get; set; }
|
||||||
|
|
||||||
public DateTime OpeningDate { get; set; }
|
public DateTime OpeningDate { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (ICarModel, int)> ShopCars
|
public Dictionary<int, (ICarModel, int)> ShopCars
|
||||||
|
@ -18,5 +18,6 @@ namespace AutomobilePlantContracts.BusinessLogicsContracts
|
|||||||
bool Update(ShopBindingModel model);
|
bool Update(ShopBindingModel model);
|
||||||
bool Delete(ShopBindingModel model);
|
bool Delete(ShopBindingModel model);
|
||||||
bool SupplyCars(ShopSearchModel model, ICarModel car, int count);
|
bool SupplyCars(ShopSearchModel model, ICarModel car, int count);
|
||||||
|
bool SellCar(ICarModel car, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.SearchModels;
|
using AutomobilePlantContracts.SearchModels;
|
||||||
using AutomobilePlantContracts.ViewModels;
|
using AutomobilePlantContracts.ViewModels;
|
||||||
|
using AutomobilePlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,5 +18,6 @@ namespace AutomobilePlantContracts.StoragesContracts
|
|||||||
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 SellCar(ICarModel model, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,19 @@ namespace AutomobilePlantContracts.ViewModels
|
|||||||
public class ShopViewModel : IShopModel
|
public class ShopViewModel : IShopModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Shop's name")]
|
[DisplayName("Shop's name")]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Address")]
|
[DisplayName("Address")]
|
||||||
public string Address { get; set; } = string.Empty;
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Maximum cars' count in shop")]
|
||||||
|
public int MaxCountCars { get; set; }
|
||||||
|
|
||||||
[DisplayName("Opening date")]
|
[DisplayName("Opening date")]
|
||||||
public DateTime OpeningDate { get; set; }
|
public DateTime OpeningDate { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } = new();
|
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace AutomobilePlantDataModels.Models
|
|||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
string Address { get; }
|
string Address { get; }
|
||||||
|
int MaxCountCars { get; }
|
||||||
DateTime OpeningDate { get; }
|
DateTime OpeningDate { get; }
|
||||||
Dictionary<int, (ICarModel, int)> ShopCars { get; }
|
Dictionary<int, (ICarModel, int)> ShopCars { get; }
|
||||||
}
|
}
|
||||||
|
@ -90,26 +90,16 @@ namespace AutomobilePlantFileImplement.Implements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var countStore = count;
|
|
||||||
|
|
||||||
var shopCars = source.Shops.SelectMany(shop => shop.ShopCars.Where(c => c.Value.Item1.Id == car.Id));
|
var shopCars = source.Shops.SelectMany(shop => shop.ShopCars.Where(c => c.Value.Item1.Id == car.Id));
|
||||||
|
|
||||||
foreach (var c in shopCars)
|
int countStore = 0;
|
||||||
{
|
|
||||||
count -= c.Value.Item2;
|
|
||||||
|
|
||||||
if (count <= 0)
|
foreach (var it in shopCars)
|
||||||
{
|
countStore += it.Value.Item2;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > 0)
|
if (count > countStore)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
count = countStore;
|
|
||||||
|
|
||||||
foreach (var shop in source.Shops)
|
foreach (var shop in source.Shops)
|
||||||
{
|
{
|
||||||
@ -117,15 +107,13 @@ namespace AutomobilePlantFileImplement.Implements
|
|||||||
|
|
||||||
foreach (var c in cars.Where(x => x.Value.Item1.Id == car.Id))
|
foreach (var c in cars.Where(x => x.Value.Item1.Id == car.Id))
|
||||||
{
|
{
|
||||||
var min = Math.Min(c.Value.Item2, count);
|
int min = Math.Min(c.Value.Item2, count);
|
||||||
cars[c.Value.Item1.Id] = (c.Value.Item1, c.Value.Item2 - min);
|
cars[c.Value.Item1.Id] = (c.Value.Item1, c.Value.Item2 - min);
|
||||||
count -= min;
|
count -= min;
|
||||||
|
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
shop.Update(new ShopBindingModel
|
shop.Update(new ShopBindingModel
|
||||||
{
|
{
|
||||||
@ -138,10 +126,11 @@ namespace AutomobilePlantFileImplement.Implements
|
|||||||
|
|
||||||
source.SaveShops();
|
source.SaveShops();
|
||||||
|
|
||||||
if (count <= 0) break;
|
if (count <= 0)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count <= 0;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ namespace AutomobilePlantFileImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
public string Address { get; private set; } = string.Empty;
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
public int MaxCountCars { get; private set; }
|
||||||
public DateTime OpeningDate { get; private set; }
|
public DateTime OpeningDate { get; private set; }
|
||||||
public Dictionary<int, int> Cars { get; private set; } = new();
|
public Dictionary<int, int> Cars { get; private set; } = new();
|
||||||
private Dictionary<int, (ICarModel, int)>? _shopCars = null;
|
private Dictionary<int, (ICarModel, int)>? _shopCars = null;
|
||||||
@ -46,6 +47,7 @@ namespace AutomobilePlantFileImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Address = model.Address,
|
Address = model.Address,
|
||||||
|
MaxCountCars = model.MaxCountCars,
|
||||||
OpeningDate = model.OpeningDate,
|
OpeningDate = model.OpeningDate,
|
||||||
Cars = model.ShopCars.ToDictionary(x => x.Key, x => x.Value.Item2)
|
Cars = model.ShopCars.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||||
};
|
};
|
||||||
@ -62,6 +64,7 @@ namespace AutomobilePlantFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
Name = element.Element("Name")!.Value,
|
Name = element.Element("Name")!.Value,
|
||||||
Address = element.Element("Address")!.Value,
|
Address = element.Element("Address")!.Value,
|
||||||
|
MaxCountCars = Convert.ToInt32(element.Element("MaxCountCars")!.Value),
|
||||||
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
||||||
Cars = element.Element("ShopCars")!.Elements("ShopCar").ToDictionary(
|
Cars = element.Element("ShopCars")!.Elements("ShopCar").ToDictionary(
|
||||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||||
@ -79,6 +82,7 @@ namespace AutomobilePlantFileImplement.Models
|
|||||||
}
|
}
|
||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
Address = model.Address;
|
Address = model.Address;
|
||||||
|
MaxCountCars = model.MaxCountCars;
|
||||||
OpeningDate = model.OpeningDate;
|
OpeningDate = model.OpeningDate;
|
||||||
if (model.ShopCars.Count > 0)
|
if (model.ShopCars.Count > 0)
|
||||||
{
|
{
|
||||||
@ -91,6 +95,7 @@ namespace AutomobilePlantFileImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Address = Address,
|
Address = Address,
|
||||||
|
MaxCountCars = MaxCountCars,
|
||||||
OpeningDate = OpeningDate,
|
OpeningDate = OpeningDate,
|
||||||
ShopCars = ShopCars,
|
ShopCars = ShopCars,
|
||||||
};
|
};
|
||||||
@ -100,6 +105,7 @@ namespace AutomobilePlantFileImplement.Models
|
|||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("Name", Name),
|
new XElement("Name", Name),
|
||||||
new XElement("Address", Address),
|
new XElement("Address", Address),
|
||||||
|
new XElement("MaxCountCars", MaxCountCars),
|
||||||
new XElement("OpeningDate", OpeningDate.ToString()),
|
new XElement("OpeningDate", OpeningDate.ToString()),
|
||||||
new XElement("ShopCars", Cars.Select(x =>
|
new XElement("ShopCars", Cars.Select(x =>
|
||||||
new XElement("ShopCar",
|
new XElement("ShopCar",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using AutomobilePlantContracts.SearchModels;
|
using AutomobilePlantContracts.SearchModels;
|
||||||
using AutomobilePlantContracts.StoragesContracts;
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
using AutomobilePlantContracts.ViewModels;
|
using AutomobilePlantContracts.ViewModels;
|
||||||
|
using AutomobilePlantDataModels.Models;
|
||||||
using AutomobilePlantListImplement.Models;
|
using AutomobilePlantListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -13,6 +14,10 @@ namespace AutomobilePlantListImplement.Implements
|
|||||||
{
|
{
|
||||||
public class ShopStorage : IShopStorage
|
public class ShopStorage : IShopStorage
|
||||||
{
|
{
|
||||||
|
public bool SellCar(ICarModel car, int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
private readonly DataListSingleton _source;
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
public ShopStorage()
|
public ShopStorage()
|
||||||
|
@ -14,6 +14,7 @@ namespace AutomobilePlantListImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
public string Address { get; private set; } = string.Empty;
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
public int MaxCountCars { get; private set; }
|
||||||
public DateTime OpeningDate { get; private set; }
|
public DateTime OpeningDate { get; private set; }
|
||||||
public Dictionary<int, (ICarModel, int)> ShopCars { get; private set; } = new();
|
public Dictionary<int, (ICarModel, int)> ShopCars { get; private set; } = new();
|
||||||
|
|
||||||
|
@ -32,14 +32,15 @@
|
|||||||
toolStripMenuItemCatalogs = new ToolStripMenuItem();
|
toolStripMenuItemCatalogs = new ToolStripMenuItem();
|
||||||
toolStripMenuItemComponents = new ToolStripMenuItem();
|
toolStripMenuItemComponents = new ToolStripMenuItem();
|
||||||
toolStripMenuItemCars = new ToolStripMenuItem();
|
toolStripMenuItemCars = new ToolStripMenuItem();
|
||||||
|
shopsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
shopsSupplyToolStripMenuItem = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
shopsToolStripMenuItem = new ToolStripMenuItem();
|
sellCarsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
shopsSupplyToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -55,7 +56,7 @@
|
|||||||
//
|
//
|
||||||
// toolStripMenuItemCatalogs
|
// toolStripMenuItemCatalogs
|
||||||
//
|
//
|
||||||
toolStripMenuItemCatalogs.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemComponents, toolStripMenuItemCars, shopsToolStripMenuItem, shopsSupplyToolStripMenuItem });
|
toolStripMenuItemCatalogs.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemComponents, toolStripMenuItemCars, shopsToolStripMenuItem, shopsSupplyToolStripMenuItem, sellCarsToolStripMenuItem });
|
||||||
toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs";
|
toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs";
|
||||||
toolStripMenuItemCatalogs.Size = new Size(65, 20);
|
toolStripMenuItemCatalogs.Size = new Size(65, 20);
|
||||||
toolStripMenuItemCatalogs.Text = "Catalogs";
|
toolStripMenuItemCatalogs.Text = "Catalogs";
|
||||||
@ -74,6 +75,20 @@
|
|||||||
toolStripMenuItemCars.Text = "Cars";
|
toolStripMenuItemCars.Text = "Cars";
|
||||||
toolStripMenuItemCars.Click += CarsToolStripMenuItem_Click;
|
toolStripMenuItemCars.Click += CarsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// shopsToolStripMenuItem
|
||||||
|
//
|
||||||
|
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
|
||||||
|
shopsToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
shopsToolStripMenuItem.Text = "Shops";
|
||||||
|
shopsToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// shopsSupplyToolStripMenuItem
|
||||||
|
//
|
||||||
|
shopsSupplyToolStripMenuItem.Name = "shopsSupplyToolStripMenuItem";
|
||||||
|
shopsSupplyToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
shopsSupplyToolStripMenuItem.Text = "Shop's supply";
|
||||||
|
shopsSupplyToolStripMenuItem.Click += shopsSupplyToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
@ -133,19 +148,12 @@
|
|||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += ButtonRef_Click;
|
buttonRefresh.Click += ButtonRef_Click;
|
||||||
//
|
//
|
||||||
// shopsToolStripMenuItem
|
// sellCarsToolStripMenuItem
|
||||||
//
|
//
|
||||||
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
|
sellCarsToolStripMenuItem.Name = "sellCarsToolStripMenuItem";
|
||||||
shopsToolStripMenuItem.Size = new Size(180, 22);
|
sellCarsToolStripMenuItem.Size = new Size(180, 22);
|
||||||
shopsToolStripMenuItem.Text = "Shops";
|
sellCarsToolStripMenuItem.Text = "Sell Cars";
|
||||||
shopsToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
|
sellCarsToolStripMenuItem.Click += sellCarsToolStripMenuItem_Click;
|
||||||
//
|
|
||||||
// shopsSupplyToolStripMenuItem
|
|
||||||
//
|
|
||||||
shopsSupplyToolStripMenuItem.Name = "shopsSupplyToolStripMenuItem";
|
|
||||||
shopsSupplyToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
shopsSupplyToolStripMenuItem.Text = "Shop's supply";
|
|
||||||
shopsSupplyToolStripMenuItem.Click += shopsSupplyToolStripMenuItem_Click;
|
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -183,5 +191,6 @@
|
|||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
private ToolStripMenuItem shopsToolStripMenuItem;
|
private ToolStripMenuItem shopsToolStripMenuItem;
|
||||||
private ToolStripMenuItem shopsSupplyToolStripMenuItem;
|
private ToolStripMenuItem shopsSupplyToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem sellCarsToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,7 +38,6 @@ namespace AutomobilePlantView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["CarId"].Visible = false;
|
dataGridView.Columns["CarId"].Visible = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
@ -48,6 +47,8 @@ namespace AutomobilePlantView
|
|||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// управление менюшкой
|
||||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
@ -64,6 +65,32 @@ namespace AutomobilePlantView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||||
|
if (service is FormShops form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void shopsSupplyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
|
||||||
|
if (service is FormShopSupply form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void sellCarsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShopSell));
|
||||||
|
if (service is FormShopSell form)
|
||||||
|
{
|
||||||
|
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));
|
||||||
@ -158,23 +185,6 @@ namespace AutomobilePlantView
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
|
||||||
if (service is FormShops form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void shopsSupplyToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
|
|
||||||
if (service is FormShopSupply form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,26 +40,28 @@
|
|||||||
IdCol = new DataGridViewTextBoxColumn();
|
IdCol = new DataGridViewTextBoxColumn();
|
||||||
CarCol = new DataGridViewTextBoxColumn();
|
CarCol = new DataGridViewTextBoxColumn();
|
||||||
CountCol = new DataGridViewTextBoxColumn();
|
CountCol = new DataGridViewTextBoxColumn();
|
||||||
|
textBoxMaxCountCars = new TextBox();
|
||||||
|
labelMaxCountCars = new Label();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
textBoxName.Location = new Point(100, 6);
|
textBoxName.Location = new Point(60, 6);
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(378, 23);
|
textBoxName.Size = new Size(418, 23);
|
||||||
textBoxName.TabIndex = 0;
|
textBoxName.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// textBoxAddress
|
// textBoxAddress
|
||||||
//
|
//
|
||||||
textBoxAddress.Location = new Point(100, 35);
|
textBoxAddress.Location = new Point(60, 35);
|
||||||
textBoxAddress.Name = "textBoxAddress";
|
textBoxAddress.Name = "textBoxAddress";
|
||||||
textBoxAddress.Size = new Size(378, 23);
|
textBoxAddress.Size = new Size(418, 23);
|
||||||
textBoxAddress.TabIndex = 1;
|
textBoxAddress.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// openingDateTimePicker
|
// openingDateTimePicker
|
||||||
//
|
//
|
||||||
openingDateTimePicker.Location = new Point(100, 64);
|
openingDateTimePicker.Location = new Point(100, 93);
|
||||||
openingDateTimePicker.Name = "openingDateTimePicker";
|
openingDateTimePicker.Name = "openingDateTimePicker";
|
||||||
openingDateTimePicker.Size = new Size(378, 23);
|
openingDateTimePicker.Size = new Size(378, 23);
|
||||||
openingDateTimePicker.TabIndex = 3;
|
openingDateTimePicker.TabIndex = 3;
|
||||||
@ -85,7 +87,7 @@
|
|||||||
// labelOpeningDate
|
// labelOpeningDate
|
||||||
//
|
//
|
||||||
labelOpeningDate.AutoSize = true;
|
labelOpeningDate.AutoSize = true;
|
||||||
labelOpeningDate.Location = new Point(12, 70);
|
labelOpeningDate.Location = new Point(12, 99);
|
||||||
labelOpeningDate.Name = "labelOpeningDate";
|
labelOpeningDate.Name = "labelOpeningDate";
|
||||||
labelOpeningDate.Size = new Size(82, 15);
|
labelOpeningDate.Size = new Size(82, 15);
|
||||||
labelOpeningDate.TabIndex = 6;
|
labelOpeningDate.TabIndex = 6;
|
||||||
@ -93,7 +95,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(322, 334);
|
buttonSave.Location = new Point(322, 363);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 7;
|
buttonSave.TabIndex = 7;
|
||||||
@ -103,7 +105,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(403, 334);
|
buttonCancel.Location = new Point(403, 363);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 8;
|
buttonCancel.TabIndex = 8;
|
||||||
@ -119,7 +121,7 @@
|
|||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { IdCol, CarCol, CountCol });
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { IdCol, CarCol, CountCol });
|
||||||
dataGridView.Location = new Point(12, 93);
|
dataGridView.Location = new Point(12, 122);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
dataGridView.Size = new Size(466, 235);
|
dataGridView.Size = new Size(466, 235);
|
||||||
@ -142,11 +144,29 @@
|
|||||||
CountCol.HeaderText = "Count";
|
CountCol.HeaderText = "Count";
|
||||||
CountCol.Name = "CountCol";
|
CountCol.Name = "CountCol";
|
||||||
//
|
//
|
||||||
|
// textBoxMaxCountCars
|
||||||
|
//
|
||||||
|
textBoxMaxCountCars.Location = new Point(144, 64);
|
||||||
|
textBoxMaxCountCars.Name = "textBoxMaxCountCars";
|
||||||
|
textBoxMaxCountCars.Size = new Size(334, 23);
|
||||||
|
textBoxMaxCountCars.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// labelMaxCountCars
|
||||||
|
//
|
||||||
|
labelMaxCountCars.AutoSize = true;
|
||||||
|
labelMaxCountCars.Location = new Point(12, 67);
|
||||||
|
labelMaxCountCars.Name = "labelMaxCountCars";
|
||||||
|
labelMaxCountCars.Size = new Size(126, 15);
|
||||||
|
labelMaxCountCars.TabIndex = 11;
|
||||||
|
labelMaxCountCars.Text = "Maximum cars' count:";
|
||||||
|
//
|
||||||
// FormShop
|
// FormShop
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(490, 369);
|
ClientSize = new Size(490, 396);
|
||||||
|
Controls.Add(labelMaxCountCars);
|
||||||
|
Controls.Add(textBoxMaxCountCars);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
@ -157,7 +177,7 @@
|
|||||||
Controls.Add(textBoxAddress);
|
Controls.Add(textBoxAddress);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
Name = "FormShop";
|
Name = "FormShop";
|
||||||
Text = "FormShop";
|
Text = "Shop";
|
||||||
Load += FormShop_Load;
|
Load += FormShop_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
@ -178,5 +198,7 @@
|
|||||||
private DataGridViewTextBoxColumn IdCol;
|
private DataGridViewTextBoxColumn IdCol;
|
||||||
private DataGridViewTextBoxColumn CarCol;
|
private DataGridViewTextBoxColumn CarCol;
|
||||||
private DataGridViewTextBoxColumn CountCol;
|
private DataGridViewTextBoxColumn CountCol;
|
||||||
|
private TextBox textBoxMaxCountCars;
|
||||||
|
private Label labelMaxCountCars;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,6 +45,7 @@ namespace AutomobilePlantView
|
|||||||
{
|
{
|
||||||
textBoxName.Text = view.Name;
|
textBoxName.Text = view.Name;
|
||||||
textBoxAddress.Text = view.Address;
|
textBoxAddress.Text = view.Address;
|
||||||
|
textBoxMaxCountCars.Text = view.MaxCountCars.ToString();
|
||||||
openingDateTimePicker.Value = view.OpeningDate;
|
openingDateTimePicker.Value = view.OpeningDate;
|
||||||
_shopCars = view.ShopCars ?? new Dictionary<int, (ICarModel, int)>();
|
_shopCars = view.ShopCars ?? new Dictionary<int, (ICarModel, int)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -94,6 +95,12 @@ namespace AutomobilePlantView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(textBoxMaxCountCars.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните макс. количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Сохранение магазина");
|
_logger.LogInformation("Сохранение магазина");
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -103,6 +110,7 @@ namespace AutomobilePlantView
|
|||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
Name = textBoxName.Text,
|
Name = textBoxName.Text,
|
||||||
Address = textBoxAddress.Text,
|
Address = textBoxAddress.Text,
|
||||||
|
MaxCountCars = Convert.ToInt32(textBoxMaxCountCars.Text),
|
||||||
OpeningDate = openingDateTimePicker.Value.Date,
|
OpeningDate = openingDateTimePicker.Value.Date,
|
||||||
ShopCars = _shopCars
|
ShopCars = _shopCars
|
||||||
};
|
};
|
||||||
|
@ -126,13 +126,4 @@
|
|||||||
<metadata name="CountCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="CountCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="IdCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="CarCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="CountCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
119
AutomobilePlant/AutomobilePlantView/FormShopSell.Designer.cs
generated
Normal file
119
AutomobilePlant/AutomobilePlantView/FormShopSell.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
namespace AutomobilePlantView
|
||||||
|
{
|
||||||
|
partial class FormShopSell
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelCar = new Label();
|
||||||
|
labelCount = new Label();
|
||||||
|
comboBoxCar = new ComboBox();
|
||||||
|
textBoxCount = new TextBox();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSell = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelCar
|
||||||
|
//
|
||||||
|
labelCar.AutoSize = true;
|
||||||
|
labelCar.Location = new Point(12, 9);
|
||||||
|
labelCar.Name = "labelCar";
|
||||||
|
labelCar.Size = new Size(28, 15);
|
||||||
|
labelCar.TabIndex = 0;
|
||||||
|
labelCar.Text = "Car:";
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
labelCount.AutoSize = true;
|
||||||
|
labelCount.Location = new Point(12, 38);
|
||||||
|
labelCount.Name = "labelCount";
|
||||||
|
labelCount.Size = new Size(43, 15);
|
||||||
|
labelCount.TabIndex = 1;
|
||||||
|
labelCount.Text = "Count:";
|
||||||
|
//
|
||||||
|
// comboBoxCar
|
||||||
|
//
|
||||||
|
comboBoxCar.FormattingEnabled = true;
|
||||||
|
comboBoxCar.Location = new Point(61, 6);
|
||||||
|
comboBoxCar.Name = "comboBoxCar";
|
||||||
|
comboBoxCar.Size = new Size(324, 23);
|
||||||
|
comboBoxCar.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
textBoxCount.Location = new Point(61, 35);
|
||||||
|
textBoxCount.Name = "textBoxCount";
|
||||||
|
textBoxCount.Size = new Size(324, 23);
|
||||||
|
textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(229, 64);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 4;
|
||||||
|
buttonCancel.Text = "Cancel";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSell
|
||||||
|
//
|
||||||
|
buttonSell.Location = new Point(310, 64);
|
||||||
|
buttonSell.Name = "buttonSell";
|
||||||
|
buttonSell.Size = new Size(75, 23);
|
||||||
|
buttonSell.TabIndex = 5;
|
||||||
|
buttonSell.Text = "Sell";
|
||||||
|
buttonSell.UseVisualStyleBackColor = true;
|
||||||
|
buttonSell.Click += buttonSell_Click;
|
||||||
|
//
|
||||||
|
// FormShopSell
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(397, 93);
|
||||||
|
Controls.Add(buttonSell);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(textBoxCount);
|
||||||
|
Controls.Add(comboBoxCar);
|
||||||
|
Controls.Add(labelCount);
|
||||||
|
Controls.Add(labelCar);
|
||||||
|
Name = "FormShopSell";
|
||||||
|
Text = "Sell";
|
||||||
|
Load += FormShopSell_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelCar;
|
||||||
|
private Label labelCount;
|
||||||
|
private ComboBox comboBoxCar;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSell;
|
||||||
|
}
|
||||||
|
}
|
95
AutomobilePlant/AutomobilePlantView/FormShopSell.cs
Normal file
95
AutomobilePlant/AutomobilePlantView/FormShopSell.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using AutomobilePlantContracts.BindingModels;
|
||||||
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AutomobilePlantView
|
||||||
|
{
|
||||||
|
public partial class FormShopSell : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ICarLogic _logicCar;
|
||||||
|
private readonly IShopLogic _logicShop;
|
||||||
|
|
||||||
|
public FormShopSell(ILogger<FormShopSell> logger, ICarLogic logicCar, IShopLogic logicShop)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicCar = logicCar;
|
||||||
|
_logicShop = logicShop;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormShopSell_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка авто для продажи");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicCar.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxCar.DisplayMember = "CarName";
|
||||||
|
comboBoxCar.ValueMember = "Id";
|
||||||
|
comboBoxCar.DataSource = list;
|
||||||
|
comboBoxCar.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка авто");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSell_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxCar.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите авто", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание продажи");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicShop.SellCar(
|
||||||
|
new CarBindingModel
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(comboBoxCar.SelectedValue)
|
||||||
|
},
|
||||||
|
Convert.ToInt32(textBoxCount.Text)
|
||||||
|
);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при создании продажи. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания продажи");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
AutomobilePlant/AutomobilePlantView/FormShopSell.resx
Normal file
120
AutomobilePlant/AutomobilePlantView/FormShopSell.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>
|
@ -52,6 +52,7 @@ namespace AutomobilePlantView
|
|||||||
services.AddTransient<FormShop>();
|
services.AddTransient<FormShop>();
|
||||||
services.AddTransient<FormShops>();
|
services.AddTransient<FormShops>();
|
||||||
services.AddTransient<FormShopSupply>();
|
services.AddTransient<FormShopSupply>();
|
||||||
|
services.AddTransient<FormShopSell>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user