Compare commits
No commits in common. "c44b2183fb5418b4235fadd6b33d44349dac7a60" and "c43b7d883166b2e5d88d00ae44ed5eb48857be6a" have entirely different histories.
c44b2183fb
...
c43b7d8831
@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GarmentFactoryDataModels",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GarmentFactoryListImplement", "GarmentFactoryListImplement\GarmentFactoryListImplement.csproj", "{AA691567-80A9-45EF-9916-C55FA3B53C47}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GarmentFactoryFileImplement", "GarmentFactoryFileImplement\GarmentFactoryFileImplement.csproj", "{281A8DE2-A45A-4B4B-B4A6-DC13ECC0144E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -41,10 +39,6 @@ Global
|
||||
{AA691567-80A9-45EF-9916-C55FA3B53C47}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AA691567-80A9-45EF-9916-C55FA3B53C47}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AA691567-80A9-45EF-9916-C55FA3B53C47}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{281A8DE2-A45A-4B4B-B4A6-DC13ECC0144E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{281A8DE2-A45A-4B4B-B4A6-DC13ECC0144E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{281A8DE2-A45A-4B4B-B4A6-DC13ECC0144E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{281A8DE2-A45A-4B4B-B4A6-DC13ECC0144E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -18,17 +18,12 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
private readonly ITextileStorage _textileStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, ITextileStorage textileStorage)
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopLogic = shopLogic;
|
||||
_textileStorage = textileStorage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
@ -116,21 +111,11 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
newStatus, order.Status);
|
||||
return false;
|
||||
}
|
||||
if (newStatus == OrderStatus.Выдан)
|
||||
{
|
||||
var textile = _textileStorage.GetElement(new() { Id = order.TextileId });
|
||||
if (textile == null)
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed. Textile not found");
|
||||
return false;
|
||||
}
|
||||
if (!_shopLogic.DeliverTextiles(textile, order.Count))
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed. Textiles delivery operation failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
model.Status = newStatus;
|
||||
model.TextileId = order.TextileId;
|
||||
model.Count = order.Count;
|
||||
model.Sum = order.Sum;
|
||||
model.DateCreate = order.DateCreate;
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
|
@ -106,12 +106,7 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("MakeDelivery(GetElement). Element not found");
|
||||
return false;
|
||||
}
|
||||
if (shop.TextilesMaximum - shop.ShopTextiles.Sum(x => x.Value.Item2) < count)
|
||||
{
|
||||
_logger.LogWarning("MakeShipment error. No space for new textiles");
|
||||
return false;
|
||||
}
|
||||
if (shop.ShopTextiles.ContainsKey(textile.Id))
|
||||
if (shop.ShopTextiles.ContainsKey(textile.Id))
|
||||
{
|
||||
var shopT = shop.ShopTextiles[textile.Id];
|
||||
shopT.Item2 += count;
|
||||
@ -131,8 +126,7 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpening = shop.DateOpening,
|
||||
TextilesMaximum = shop.TextilesMaximum,
|
||||
ShopTextiles = shop.ShopTextiles,
|
||||
ShopTextiles = shop.ShopTextiles,
|
||||
}) == null)
|
||||
{
|
||||
_logger.LogWarning("MakeDelivery. Update operation failed");
|
||||
@ -140,11 +134,8 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool MakeSale(ITextileModel model, int count)
|
||||
{
|
||||
return _shopStorage.MakeSale(model, count);
|
||||
}
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -172,62 +163,5 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool DeliverTextiles(ITextileModel textile, int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
_logger.LogWarning("Textiles delivery operation failed. Textile count <= 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
var shopList = _shopStorage.GetFullList();
|
||||
int shopsCapacity = shopList.Sum(x => x.TextilesMaximum);
|
||||
int currentTextiles = shopList.Select(x => x.ShopTextiles.Sum(y => y.Value.Item2)).Sum();
|
||||
int freePlaces = shopsCapacity - currentTextiles;
|
||||
|
||||
if (freePlaces < count)
|
||||
{
|
||||
_logger.LogWarning("Textiles delivery operation failed. No space for new textiles");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in shopList)
|
||||
{
|
||||
freePlaces = shop.TextilesMaximum - shop.ShopTextiles.Sum(x => x.Value.Item2);
|
||||
if (freePlaces == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (freePlaces >= count)
|
||||
{
|
||||
if (MakeDelivery(new() { Id = shop.Id }, textile, count))
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Textiles delivery operation failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MakeDelivery(new() { Id = shop.Id }, textile, freePlaces))
|
||||
{
|
||||
count -= freePlaces;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Textiles delivery operation failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,5 @@ namespace GarmentFactoryContracts.BindingModels
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
public int TextilesMaximum { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,5 @@ namespace GarmentFactoryContracts.BusinessLogicsContracts
|
||||
bool Delete(ShopBindingModel model);
|
||||
|
||||
bool MakeDelivery(ShopSearchModel shopModel, ITextileModel textile, int count);
|
||||
bool MakeSale(ITextileModel model, int count);
|
||||
bool DeliverTextiles(ITextileModel model, int count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
|
||||
namespace GarmentFactoryContracts.StoragesContracts
|
||||
{
|
||||
@ -23,6 +22,5 @@ namespace GarmentFactoryContracts.StoragesContracts
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
bool MakeSale(ITextileModel model, int count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,5 @@ namespace GarmentFactoryContracts.ViewModels
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
[DisplayName("Максимальное количество изделий")]
|
||||
public int TextilesMaximum { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,5 @@ namespace GarmentFactoryDataModels.Models
|
||||
DateTime DateOpening { get; }
|
||||
|
||||
Dictionary<int, (ITextileModel, int)> ShopTextiles { get; }
|
||||
int TextilesMaximum { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GarmentFactoryFileImplement.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GarmentFactoryFileImplement
|
||||
{
|
||||
internal class DataFileSingleton
|
||||
{
|
||||
private static DataFileSingleton? instance;
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string TextileFileName = "Textile.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Textile> Textiles { get; private set; }
|
||||
public List<Shop> Shops { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new DataFileSingleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveTextiles() => SaveData(Textiles, TextileFileName, "Textiles", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Textiles = LoadData(TextileFileName, "Textile", x => Textile.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)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
return
|
||||
XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
||||
}
|
||||
return new List<T>();
|
||||
}
|
||||
private static void SaveData<T>(List<T> data, string filename, string
|
||||
xmlNodeName, Func<T, XElement> selectFunction)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GarmentFactoryContracts\GarmentFactoryContracts.csproj" />
|
||||
<ProjectReference Include="..\GarmentFactoryDataModels\GarmentFactoryDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,84 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Implements
|
||||
{
|
||||
public class ComponentStorage : IComponentStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ComponentStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
return source.Components
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
|
||||
model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Components
|
||||
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Components
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||
{
|
||||
model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1;
|
||||
var newComponent = Component.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Components.Add(newComponent);
|
||||
source.SaveComponents();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
source.SaveComponents();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Components.Remove(element);
|
||||
source.SaveComponents();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public OrderStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders
|
||||
.Select(x => AddTextileName(x.GetViewModel))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => AddTextileName(x.GetViewModel))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return AddTextileName(order.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return AddTextileName(newOrder.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return AddTextileName(order.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Orders.Remove(element);
|
||||
source.SaveOrders();
|
||||
return AddTextileName(element.GetViewModel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private OrderViewModel AddTextileName(OrderViewModel model)
|
||||
{
|
||||
var selectedTextile = source.Textiles.FirstOrDefault(x => x.Id == model.TextileId);
|
||||
model.TextileName = selectedTextile?.TextileName;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryFileImplement.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(ITextileModel model, int count)
|
||||
{
|
||||
var textile = source.Textiles.FirstOrDefault(x => x.Id == model.Id);
|
||||
int countInShops = source.Shops.SelectMany(x => x.ShopTextiles).Sum(y => y.Key == model.Id ? y.Value.Item2 : 0);
|
||||
|
||||
if (textile == null || countInShops < count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in source.Shops)
|
||||
{
|
||||
var shopTextiles = shop.ShopTextiles.Where(x => x.Key == model.Id);
|
||||
if (shopTextiles.Any())
|
||||
{
|
||||
var shopTextile = shopTextiles.First();
|
||||
int min = Math.Min(shopTextile.Value.Item2, count);
|
||||
if (min == shopTextile.Value.Item2)
|
||||
{
|
||||
shop.ShopTextiles.Remove(shopTextile.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.ShopTextiles[shopTextile.Key] = (shopTextile.Value.Item1, shopTextile.Value.Item2 - min);
|
||||
}
|
||||
shop.Update(new ShopBindingModel
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpening = shop.DateOpening,
|
||||
ShopTextiles = shop.ShopTextiles,
|
||||
TextilesMaximum = shop.TextilesMaximum
|
||||
});
|
||||
count -= min;
|
||||
if (count <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Implements
|
||||
{
|
||||
public class TextileStorage : ITextileStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public TextileStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<TextileViewModel> GetFullList()
|
||||
{
|
||||
return source.Textiles
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<TextileViewModel> GetFilteredList(TextileSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.TextileName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Textiles
|
||||
.Where(x => x.TextileName.Contains(model.TextileName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public TextileViewModel? GetElement(TextileSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.TextileName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Textiles
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.TextileName) && x.TextileName == model.TextileName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public TextileViewModel? Insert(TextileBindingModel model)
|
||||
{
|
||||
model.Id = source.Textiles.Count > 0 ? source.Textiles.Max(x => x.Id) + 1 : 1;
|
||||
var newTextile = Textile.Create(model);
|
||||
if (newTextile == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Textiles.Add(newTextile);
|
||||
source.SaveTextiles();
|
||||
return newTextile.GetViewModel;
|
||||
}
|
||||
|
||||
public TextileViewModel? Update(TextileBindingModel model)
|
||||
{
|
||||
var textile = source.Textiles.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (textile == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
textile.Update(model);
|
||||
source.SaveTextiles();
|
||||
return textile.GetViewModel;
|
||||
}
|
||||
|
||||
public TextileViewModel? Delete(TextileBindingModel model)
|
||||
{
|
||||
var element = source.Textiles.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Textiles.Remove(element);
|
||||
source.SaveTextiles();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public static Component? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ComponentName = element.Element("ComponentName")!.Value,
|
||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
||||
};
|
||||
}
|
||||
public void Update(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
};
|
||||
public XElement GetXElement => new("Component",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ComponentName", ComponentName),
|
||||
new XElement("Cost", Cost.ToString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,97 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Enums;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int TextileId { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
public DateTime DateCreate { get; private set; }
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
TextileId = model.TextileId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
}
|
||||
|
||||
public static Order? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
TextileId = Convert.ToInt32(element.Element("TextileId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null
|
||||
: Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
TextileId = TextileId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("TextileId", TextileId),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Status", Status.ToString()),
|
||||
new XElement("DateCreate", DateCreate.ToString()),
|
||||
new XElement("DateImplement", DateImplement.ToString()));
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GarmentFactoryFileImplement.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> Textiles { get; private set; } = new();
|
||||
|
||||
private Dictionary<int, (ITextileModel, int)>? _shopTextiles = null;
|
||||
|
||||
public Dictionary<int, (ITextileModel, int)> ShopTextiles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopTextiles == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_shopTextiles = Textiles.ToDictionary(x => x.Key,
|
||||
y => ((source.Textiles.FirstOrDefault(z => z.Id == y.Key) as ITextileModel)!, y.Value));
|
||||
}
|
||||
return _shopTextiles;
|
||||
}
|
||||
}
|
||||
|
||||
public int TextilesMaximum { 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,
|
||||
Textiles = model.ShopTextiles.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
TextilesMaximum = model.TextilesMaximum
|
||||
};
|
||||
}
|
||||
|
||||
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),
|
||||
TextilesMaximum = Convert.ToInt32(element.Element("TextilesMaximum")!.Value),
|
||||
Textiles = element.Element("ShopTextiles")!.Elements("ShopTextile")
|
||||
.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;
|
||||
TextilesMaximum = model.TextilesMaximum;
|
||||
Textiles = model.ShopTextiles.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_shopTextiles = null;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpening = DateOpening,
|
||||
ShopTextiles = ShopTextiles,
|
||||
TextilesMaximum = TextilesMaximum
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("DateOpening", DateOpening.ToString()),
|
||||
new XElement("TextilesMaximum", TextilesMaximum.ToString()),
|
||||
new XElement("ShopTextiles",
|
||||
Textiles.Select(x => new XElement("ShopTextile",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))).ToArray()));
|
||||
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Models
|
||||
{
|
||||
public class Textile : ITextileModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string TextileName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, int> Components { get; private set; } = new();
|
||||
private Dictionary<int, (IComponentModel, int)>? _textileComponents =
|
||||
null;
|
||||
public Dictionary<int, (IComponentModel, int)> TextileComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_textileComponents == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_textileComponents = Components.ToDictionary(x => x.Key, y =>
|
||||
((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!,
|
||||
y.Value));
|
||||
}
|
||||
return _textileComponents;
|
||||
}
|
||||
}
|
||||
public static Textile? Create(TextileBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Textile()
|
||||
{
|
||||
Id = model.Id,
|
||||
TextileName = model.TextileName,
|
||||
Price = model.Price,
|
||||
Components = model.TextileComponents.ToDictionary(x => x.Key, x
|
||||
=> x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static Textile? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Textile()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
TextileName = element.Element("TextileName")!.Value,
|
||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
||||
Components =
|
||||
element.Element("TextileComponents")!.Elements("TextileComponent")
|
||||
.ToDictionary(x =>
|
||||
Convert.ToInt32(x.Element("Key")?.Value), x =>
|
||||
Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
public void Update(TextileBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TextileName = model.TextileName;
|
||||
Price = model.Price;
|
||||
Components = model.TextileComponents.ToDictionary(x => x.Key, x =>
|
||||
x.Value.Item2);
|
||||
_textileComponents = null;
|
||||
}
|
||||
public TextileViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
TextileName = TextileName,
|
||||
Price = Price,
|
||||
TextileComponents = TextileComponents
|
||||
};
|
||||
public XElement GetXElement => new("Textile",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("TextileName", TextileName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("TextileComponents", Components.Select(x =>
|
||||
new XElement("TextileComponent",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))).ToArray()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using GarmentFactoryListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -111,10 +110,5 @@ namespace GarmentFactoryListImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool MakeSale(ITextileModel model, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,5 @@ namespace GarmentFactoryListImplement.Models
|
||||
DateOpening = DateOpening,
|
||||
ShopTextiles = ShopTextiles
|
||||
};
|
||||
|
||||
public int TextilesMaximum { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
331
GarmentFactory/GarmentFactoryView/FormMain.Designer.cs
generated
331
GarmentFactory/GarmentFactoryView/FormMain.Designer.cs
generated
@ -20,177 +20,169 @@
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
#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()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
изделиеToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазинToolStripMenuItem = new ToolStripMenuItem();
|
||||
пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonUpd = new Button();
|
||||
продажаИзделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, пополнениеМагазинаToolStripMenuItem, продажаИзделияToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1178, 28);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, магазинToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// изделиеToolStripMenuItem
|
||||
//
|
||||
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
|
||||
изделиеToolStripMenuItem.Size = new Size(224, 26);
|
||||
изделиеToolStripMenuItem.Text = "Изделие";
|
||||
изделиеToolStripMenuItem.Click += ИзделиеToolStripMenuItem_Click;
|
||||
//
|
||||
// магазинToolStripMenuItem
|
||||
//
|
||||
магазинToolStripMenuItem.Name = "магазинToolStripMenuItem";
|
||||
магазинToolStripMenuItem.Size = new Size(224, 26);
|
||||
магазинToolStripMenuItem.Text = "Магазины";
|
||||
магазинToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
|
||||
//
|
||||
// пополнениеМагазинаToolStripMenuItem
|
||||
//
|
||||
пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
|
||||
пополнениеМагазинаToolStripMenuItem.Size = new Size(182, 24);
|
||||
пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
|
||||
пополнениеМагазинаToolStripMenuItem.Click += ПополнениеМагазинаToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 37);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(944, 427);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(965, 77);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(199, 36);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(965, 149);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(199, 36);
|
||||
buttonTakeOrderInWork.TabIndex = 3;
|
||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(963, 222);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(199, 36);
|
||||
buttonOrderReady.TabIndex = 4;
|
||||
buttonOrderReady.Text = "Заказ готов";
|
||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
buttonOrderReady.Click += ButtonOrderReady_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(965, 305);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(199, 36);
|
||||
buttonIssuedOrder.TabIndex = 5;
|
||||
buttonIssuedOrder.Text = "Заказ выдан";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(965, 384);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(197, 36);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Обновить список";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += ButtonUpd_Click;
|
||||
//
|
||||
// продажаИзделияToolStripMenuItem
|
||||
//
|
||||
продажаИзделияToolStripMenuItem.Name = "продажаИзделияToolStripMenuItem";
|
||||
продажаИзделияToolStripMenuItem.Size = new Size(148, 24);
|
||||
продажаИзделияToolStripMenuItem.Text = "Продажа изделия";
|
||||
продажаИзделияToolStripMenuItem.Click += продажаИзделияToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1178, 463);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonOrderReady);
|
||||
Controls.Add(buttonTakeOrderInWork);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Текстильная фабрика";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
изделиеToolStripMenuItem = new ToolStripMenuItem();
|
||||
пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonUpd = new Button();
|
||||
магазинToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, пополнениеМагазинаToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1178, 28);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, магазинToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// изделиеToolStripMenuItem
|
||||
//
|
||||
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
|
||||
изделиеToolStripMenuItem.Size = new Size(224, 26);
|
||||
изделиеToolStripMenuItem.Text = "Изделие";
|
||||
изделиеToolStripMenuItem.Click += ИзделиеToolStripMenuItem_Click;
|
||||
//
|
||||
// пополнениеМагазинаToolStripMenuItem
|
||||
//
|
||||
пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
|
||||
пополнениеМагазинаToolStripMenuItem.Size = new Size(182, 24);
|
||||
пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
|
||||
пополнениеМагазинаToolStripMenuItem.Click += ПополнениеМагазинаToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 37);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(944, 427);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(965, 77);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(199, 36);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(965, 149);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(199, 36);
|
||||
buttonTakeOrderInWork.TabIndex = 3;
|
||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(963, 222);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(199, 36);
|
||||
buttonOrderReady.TabIndex = 4;
|
||||
buttonOrderReady.Text = "Заказ готов";
|
||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
buttonOrderReady.Click += ButtonOrderReady_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(965, 305);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(199, 36);
|
||||
buttonIssuedOrder.TabIndex = 5;
|
||||
buttonIssuedOrder.Text = "Заказ выдан";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(965, 384);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(197, 36);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Обновить список";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += ButtonUpd_Click;
|
||||
//
|
||||
// магазинToolStripMenuItem
|
||||
//
|
||||
магазинToolStripMenuItem.Name = "магазинToolStripMenuItem";
|
||||
магазинToolStripMenuItem.Size = new Size(224, 26);
|
||||
магазинToolStripMenuItem.Text = "Магазины";
|
||||
магазинToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1178, 463);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonOrderReady);
|
||||
Controls.Add(buttonTakeOrderInWork);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Текстильная фабрика";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem изделиеToolStripMenuItem;
|
||||
@ -202,6 +194,5 @@
|
||||
private Button buttonUpd;
|
||||
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||
private ToolStripMenuItem магазинToolStripMenuItem;
|
||||
private ToolStripMenuItem продажаИзделияToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
}
|
@ -13,174 +13,165 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
}
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["TextileId"].Visible = false;
|
||||
dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["TextileId"].Visible = false;
|
||||
dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ИзделиеToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTextiles));
|
||||
if (service is FormTextiles form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ИзделиеToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTextiles));
|
||||
if (service is FormTextiles form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new
|
||||
OrderBindingModel
|
||||
{ Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new
|
||||
OrderBindingModel
|
||||
{ Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ПополнениеМагазинаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMakeDelivery));
|
||||
if (service is FormMakeDelivery form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ПополнениеМагазинаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMakeDelivery));
|
||||
if (service is FormMakeDelivery form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void продажаИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTextileSale));
|
||||
if (service is FormTextileSale form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,120 +20,119 @@
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
#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()
|
||||
{
|
||||
labelShop = new Label();
|
||||
labelProduct = new Label();
|
||||
labelCount = new Label();
|
||||
comboBoxShop = new ComboBox();
|
||||
comboBoxTextile = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
labelShop.AutoSize = true;
|
||||
labelShop.Location = new Point(21, 9);
|
||||
labelShop.Name = "labelShop";
|
||||
labelShop.Size = new Size(76, 20);
|
||||
labelShop.TabIndex = 0;
|
||||
labelShop.Text = "Магазин :";
|
||||
//
|
||||
// labelProduct
|
||||
//
|
||||
labelProduct.AutoSize = true;
|
||||
labelProduct.Location = new Point(21, 55);
|
||||
labelProduct.Name = "labelProduct";
|
||||
labelProduct.Size = new Size(73, 20);
|
||||
labelProduct.TabIndex = 1;
|
||||
labelProduct.Text = "Продукт :";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(21, 99);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(97, 20);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Количество :";
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxShop.FormattingEnabled = true;
|
||||
comboBoxShop.Location = new Point(124, 6);
|
||||
comboBoxShop.Name = "comboBoxShop";
|
||||
comboBoxShop.Size = new Size(276, 28);
|
||||
comboBoxShop.TabIndex = 3;
|
||||
//
|
||||
// comboBoxTextile
|
||||
//
|
||||
comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTextile.FormattingEnabled = true;
|
||||
comboBoxTextile.Location = new Point(124, 52);
|
||||
comboBoxTextile.Name = "comboBoxTextile";
|
||||
comboBoxTextile.Size = new Size(276, 28);
|
||||
comboBoxTextile.TabIndex = 4;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(124, 99);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(276, 27);
|
||||
textBoxCount.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(183, 148);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(101, 36);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(290, 148);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(101, 36);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormMakeDelivery
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(426, 196);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxTextile);
|
||||
Controls.Add(comboBoxShop);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelProduct);
|
||||
Controls.Add(labelShop);
|
||||
Name = "FormMakeDelivery";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Пополнение магазина";
|
||||
Load += FormMakeDelivery_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelShop = new Label();
|
||||
labelProduct = new Label();
|
||||
labelCount = new Label();
|
||||
comboBoxShop = new ComboBox();
|
||||
comboBoxTextile = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
labelShop.AutoSize = true;
|
||||
labelShop.Location = new Point(21, 9);
|
||||
labelShop.Name = "labelShop";
|
||||
labelShop.Size = new Size(76, 20);
|
||||
labelShop.TabIndex = 0;
|
||||
labelShop.Text = "Магазин :";
|
||||
//
|
||||
// labelProduct
|
||||
//
|
||||
labelProduct.AutoSize = true;
|
||||
labelProduct.Location = new Point(21, 55);
|
||||
labelProduct.Name = "labelProduct";
|
||||
labelProduct.Size = new Size(73, 20);
|
||||
labelProduct.TabIndex = 1;
|
||||
labelProduct.Text = "Продукт :";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(21, 99);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(97, 20);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Количество :";
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxShop.FormattingEnabled = true;
|
||||
comboBoxShop.Location = new Point(124, 6);
|
||||
comboBoxShop.Name = "comboBoxShop";
|
||||
comboBoxShop.Size = new Size(276, 28);
|
||||
comboBoxShop.TabIndex = 3;
|
||||
//
|
||||
// comboBoxTextile
|
||||
//
|
||||
comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTextile.FormattingEnabled = true;
|
||||
comboBoxTextile.Location = new Point(124, 52);
|
||||
comboBoxTextile.Name = "comboBoxTextile";
|
||||
comboBoxTextile.Size = new Size(276, 28);
|
||||
comboBoxTextile.TabIndex = 4;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(124, 99);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(276, 27);
|
||||
textBoxCount.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(183, 148);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(101, 36);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(290, 148);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(101, 36);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormMakeDelivery
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(426, 196);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxTextile);
|
||||
Controls.Add(comboBoxShop);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelProduct);
|
||||
Controls.Add(labelShop);
|
||||
Name = "FormMakeDelivery";
|
||||
Text = "Пополнение магазина";
|
||||
Load += FormMakeDelivery_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private Label labelShop;
|
||||
private Label labelShop;
|
||||
private Label labelProduct;
|
||||
private Label labelCount;
|
||||
private ComboBox comboBoxShop;
|
||||
|
388
GarmentFactory/GarmentFactoryView/FormShop.Designer.cs
generated
388
GarmentFactory/GarmentFactoryView/FormShop.Designer.cs
generated
@ -20,211 +20,191 @@
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelName = new Label();
|
||||
textBoxName = new TextBox();
|
||||
labelAddress = new Label();
|
||||
textBoxAddress = new TextBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
labelOpeningDate = new Label();
|
||||
groupBoxTextiles = new GroupBox();
|
||||
dataGridView = new DataGridView();
|
||||
ColumnId = new DataGridViewTextBoxColumn();
|
||||
ColumnName = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelMaxTextile = new Label();
|
||||
textBoxMaximum = new TextBox();
|
||||
groupBoxTextiles.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(16, 13);
|
||||
labelName.Margin = new Padding(5, 0, 5, 0);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(84, 20);
|
||||
labelName.TabIndex = 1;
|
||||
labelName.Text = "Название :";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(105, 9);
|
||||
textBoxName.Margin = new Padding(5, 4, 5, 4);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(287, 27);
|
||||
textBoxName.TabIndex = 2;
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(16, 53);
|
||||
labelAddress.Margin = new Padding(5, 0, 5, 0);
|
||||
labelAddress.Name = "labelAddress";
|
||||
labelAddress.Size = new Size(58, 20);
|
||||
labelAddress.TabIndex = 3;
|
||||
labelAddress.Text = "Адрес :";
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
textBoxAddress.Location = new Point(105, 49);
|
||||
textBoxAddress.Margin = new Padding(5, 4, 5, 4);
|
||||
textBoxAddress.Name = "textBoxAddress";
|
||||
textBoxAddress.Size = new Size(287, 27);
|
||||
textBoxAddress.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(144, 88);
|
||||
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(249, 27);
|
||||
dateTimePicker.TabIndex = 5;
|
||||
//
|
||||
// labelOpeningDate
|
||||
//
|
||||
labelOpeningDate.AutoSize = true;
|
||||
labelOpeningDate.Location = new Point(16, 92);
|
||||
labelOpeningDate.Margin = new Padding(5, 0, 5, 0);
|
||||
labelOpeningDate.Name = "labelOpeningDate";
|
||||
labelOpeningDate.Size = new Size(117, 20);
|
||||
labelOpeningDate.TabIndex = 6;
|
||||
labelOpeningDate.Text = "Дата открытия :";
|
||||
//
|
||||
// groupBoxTextiles
|
||||
//
|
||||
groupBoxTextiles.Controls.Add(dataGridView);
|
||||
groupBoxTextiles.Location = new Point(5, 168);
|
||||
groupBoxTextiles.Margin = new Padding(5, 4, 5, 4);
|
||||
groupBoxTextiles.Name = "groupBoxTextiles";
|
||||
groupBoxTextiles.Padding = new Padding(5, 4, 5, 4);
|
||||
groupBoxTextiles.Size = new Size(536, 397);
|
||||
groupBoxTextiles.TabIndex = 7;
|
||||
groupBoxTextiles.TabStop = false;
|
||||
groupBoxTextiles.Text = "Мороженое";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnCount });
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(5, 24);
|
||||
dataGridView.Margin = new Padding(5, 4, 5, 4);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(522, 369);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ColumnId
|
||||
//
|
||||
ColumnId.HeaderText = "Id";
|
||||
ColumnId.MinimumWidth = 6;
|
||||
ColumnId.Name = "ColumnId";
|
||||
ColumnId.ReadOnly = true;
|
||||
ColumnId.Visible = false;
|
||||
ColumnId.Width = 125;
|
||||
//
|
||||
// ColumnName
|
||||
//
|
||||
ColumnName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
ColumnName.HeaderText = "Название продукта";
|
||||
ColumnName.MinimumWidth = 6;
|
||||
ColumnName.Name = "ColumnName";
|
||||
ColumnName.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
ColumnCount.Width = 125;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(301, 592);
|
||||
buttonSave.Margin = new Padding(5, 4, 5, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(101, 36);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(421, 592);
|
||||
buttonCancel.Margin = new Padding(5, 4, 5, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(101, 36);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// labelMaxTextile
|
||||
//
|
||||
labelMaxTextile.AutoSize = true;
|
||||
labelMaxTextile.Location = new Point(16, 137);
|
||||
labelMaxTextile.Name = "labelMaxTextile";
|
||||
labelMaxTextile.Size = new Size(150, 20);
|
||||
labelMaxTextile.TabIndex = 10;
|
||||
labelMaxTextile.Text = "Максимум изделия :";
|
||||
//
|
||||
// textBoxMaximum
|
||||
//
|
||||
textBoxMaximum.Location = new Point(173, 134);
|
||||
textBoxMaximum.Name = "textBoxMaximum";
|
||||
textBoxMaximum.Size = new Size(219, 27);
|
||||
textBoxMaximum.TabIndex = 11;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(546, 641);
|
||||
Controls.Add(textBoxMaximum);
|
||||
Controls.Add(labelMaxTextile);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(groupBoxTextiles);
|
||||
Controls.Add(labelOpeningDate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelName);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormShop";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
groupBoxTextiles.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelName = new Label();
|
||||
textBoxName = new TextBox();
|
||||
labelAddress = new Label();
|
||||
textBoxAddress = new TextBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
labelOpeningDate = new Label();
|
||||
groupBoxTextiles = new GroupBox();
|
||||
dataGridView = new DataGridView();
|
||||
ColumnId = new DataGridViewTextBoxColumn();
|
||||
ColumnName = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxTextiles.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(16, 13);
|
||||
labelName.Margin = new Padding(5, 0, 5, 0);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(84, 20);
|
||||
labelName.TabIndex = 1;
|
||||
labelName.Text = "Название :";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(105, 9);
|
||||
textBoxName.Margin = new Padding(5, 4, 5, 4);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(287, 27);
|
||||
textBoxName.TabIndex = 2;
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(16, 53);
|
||||
labelAddress.Margin = new Padding(5, 0, 5, 0);
|
||||
labelAddress.Name = "labelAddress";
|
||||
labelAddress.Size = new Size(58, 20);
|
||||
labelAddress.TabIndex = 3;
|
||||
labelAddress.Text = "Адрес :";
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
textBoxAddress.Location = new Point(105, 49);
|
||||
textBoxAddress.Margin = new Padding(5, 4, 5, 4);
|
||||
textBoxAddress.Name = "textBoxAddress";
|
||||
textBoxAddress.Size = new Size(287, 27);
|
||||
textBoxAddress.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(144, 88);
|
||||
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(249, 27);
|
||||
dateTimePicker.TabIndex = 5;
|
||||
//
|
||||
// labelOpeningDate
|
||||
//
|
||||
labelOpeningDate.AutoSize = true;
|
||||
labelOpeningDate.Location = new Point(16, 92);
|
||||
labelOpeningDate.Margin = new Padding(5, 0, 5, 0);
|
||||
labelOpeningDate.Name = "labelOpeningDate";
|
||||
labelOpeningDate.Size = new Size(117, 20);
|
||||
labelOpeningDate.TabIndex = 6;
|
||||
labelOpeningDate.Text = "Дата открытия :";
|
||||
//
|
||||
// groupBoxTextiles
|
||||
//
|
||||
groupBoxTextiles.Controls.Add(dataGridView);
|
||||
groupBoxTextiles.Location = new Point(5, 133);
|
||||
groupBoxTextiles.Margin = new Padding(5, 4, 5, 4);
|
||||
groupBoxTextiles.Name = "groupBoxTextiles";
|
||||
groupBoxTextiles.Padding = new Padding(5, 4, 5, 4);
|
||||
groupBoxTextiles.Size = new Size(536, 384);
|
||||
groupBoxTextiles.TabIndex = 7;
|
||||
groupBoxTextiles.TabStop = false;
|
||||
groupBoxTextiles.Text = "Мороженое";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnCount });
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(5, 24);
|
||||
dataGridView.Margin = new Padding(5, 4, 5, 4);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(522, 356);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ColumnId
|
||||
//
|
||||
ColumnId.HeaderText = "Id";
|
||||
ColumnId.MinimumWidth = 6;
|
||||
ColumnId.Name = "ColumnId";
|
||||
ColumnId.ReadOnly = true;
|
||||
ColumnId.Visible = false;
|
||||
ColumnId.Width = 125;
|
||||
//
|
||||
// ColumnName
|
||||
//
|
||||
ColumnName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
ColumnName.HeaderText = "Название продукта";
|
||||
ColumnName.MinimumWidth = 6;
|
||||
ColumnName.Name = "ColumnName";
|
||||
ColumnName.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
ColumnCount.Width = 125;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(291, 525);
|
||||
buttonSave.Margin = new Padding(5, 4, 5, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(101, 36);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(410, 525);
|
||||
buttonCancel.Margin = new Padding(5, 4, 5, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(101, 36);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(546, 576);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(groupBoxTextiles);
|
||||
Controls.Add(labelOpeningDate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelName);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormShop";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
groupBoxTextiles.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelName;
|
||||
private TextBox textBoxName;
|
||||
private Label labelAddress;
|
||||
private TextBox textBoxAddress;
|
||||
@ -237,7 +217,5 @@
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
private DataGridViewTextBoxColumn ColumnName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private Label labelMaxTextile;
|
||||
private TextBox textBoxMaximum;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,128 +6,120 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopLogic _logic;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
private int? _id;
|
||||
|
||||
private Dictionary<int, (ITextileModel, int)> _shopTextiles;
|
||||
private Dictionary<int, (ITextileModel, int)> _shopTextiles;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopTextiles = new Dictionary<int, (ITextileModel, int)>();
|
||||
}
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopTextiles = new Dictionary<int, (ITextileModel, int)>();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Shop loading");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
dateTimePicker.Value = view.DateOpening;
|
||||
textBoxMaximum.Text = view.TextilesMaximum.ToString();
|
||||
_shopTextiles = view.ShopTextiles ?? new Dictionary<int, (ITextileModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Shop loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Shop loading");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
dateTimePicker.Value = view.DateOpening;
|
||||
_shopTextiles = view.ShopTextiles ?? new Dictionary<int, (ITextileModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Shop loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Shop textiles loading");
|
||||
try
|
||||
{
|
||||
if (_shopTextiles != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var textile in _shopTextiles)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { textile.Key, textile.Value.Item1.TextileName, textile.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Shop textiles loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Shop textiles loading");
|
||||
try
|
||||
{
|
||||
if (_shopTextiles != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var textile in _shopTextiles)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { textile.Key, textile.Value.Item1.TextileName, textile.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Shop textiles loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(dateTimePicker.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxMaximum.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните максимальное количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Shop saving");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening = dateTimePicker.Value,
|
||||
TextilesMaximum = Convert.ToInt32(textBoxMaximum.Text),
|
||||
ShopTextiles = _shopTextiles
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Shop saving error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(dateTimePicker.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Shop saving");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening = dateTimePicker.Value,
|
||||
ShopTextiles = _shopTextiles
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Shop saving error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,121 +0,0 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
partial class FormTextileSale
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelTextile = new Label();
|
||||
labelCount = new Label();
|
||||
buttonSale = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxTextile = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelTextile
|
||||
//
|
||||
labelTextile.AutoSize = true;
|
||||
labelTextile.Location = new Point(25, 33);
|
||||
labelTextile.Name = "labelTextile";
|
||||
labelTextile.Size = new Size(75, 20);
|
||||
labelTextile.TabIndex = 0;
|
||||
labelTextile.Text = "Изделие :";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(25, 81);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(97, 20);
|
||||
labelCount.TabIndex = 1;
|
||||
labelCount.Text = "Количество :";
|
||||
//
|
||||
// buttonSale
|
||||
//
|
||||
buttonSale.Location = new Point(212, 124);
|
||||
buttonSale.Name = "buttonSale";
|
||||
buttonSale.Size = new Size(101, 36);
|
||||
buttonSale.TabIndex = 2;
|
||||
buttonSale.Text = "Продать";
|
||||
buttonSale.UseVisualStyleBackColor = true;
|
||||
buttonSale.Click += ButtonSale_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(328, 124);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(101, 36);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// comboBoxTextile
|
||||
//
|
||||
comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTextile.FormattingEnabled = true;
|
||||
comboBoxTextile.Location = new Point(132, 30);
|
||||
comboBoxTextile.Name = "comboBoxTextile";
|
||||
comboBoxTextile.Size = new Size(297, 28);
|
||||
comboBoxTextile.TabIndex = 4;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(132, 78);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(297, 27);
|
||||
textBoxCount.TabIndex = 5;
|
||||
//
|
||||
// FormTextileSale
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(464, 176);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxTextile);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSale);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelTextile);
|
||||
Name = "FormTextileSale";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Продажа изделий";
|
||||
Load += FormTextileSale_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelTextile;
|
||||
private Label labelCount;
|
||||
private Button buttonSale;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxTextile;
|
||||
private TextBox textBoxCount;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormTextileSale : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ITextileLogic _logicTextile;
|
||||
|
||||
private readonly IShopLogic _logicShop;
|
||||
public FormTextileSale(ILogger<FormMakeDelivery> logger, ITextileLogic logicTextile, IShopLogic logicShop)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicTextile = logicTextile;
|
||||
_logicShop = logicShop;
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonSale_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxTextile.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Textile sale");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicShop.MakeSale(
|
||||
new TextileBindingModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxTextile.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, "Textile sale error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FormTextileSale_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Textiles loading");
|
||||
try
|
||||
{
|
||||
var list = _logicTextile.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxTextile.DisplayMember = "TextileName";
|
||||
comboBoxTextile.ValueMember = "Id";
|
||||
comboBoxTextile.DataSource = list;
|
||||
comboBoxTextile.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Textiles loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
@ -17,7 +17,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GarmentFactoryBusinessLogic\GarmentFactoryBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\GarmentFactoryContracts\GarmentFactoryContracts.csproj" />
|
||||
<ProjectReference Include="..\GarmentFactoryFileImplement\GarmentFactoryFileImplement.csproj" />
|
||||
<ProjectReference Include="..\GarmentFactoryListImplement\GarmentFactoryListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
using GarmentFactoryBusinessLogic.BusinessLogics;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryListImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using GarmentFactoryFileImplement.Implements;
|
||||
using System.Drawing;
|
||||
|
||||
namespace GarmentFactoryView
|
||||
@ -33,7 +33,6 @@ namespace GarmentFactoryView
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ITextileStorage, TextileStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ITextileLogic, TextileLogic>();
|
||||
@ -49,8 +48,7 @@ namespace GarmentFactoryView
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormMakeDelivery>();
|
||||
services.AddTransient<FormTextileSale>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user