эх, если бы я не забыл написать тест...
This commit is contained in:
parent
6a39f77db1
commit
d5a0edc89b
171
Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs
Normal file
171
Confectionery/ConfectioneryBusinessLogic/ShopLogic.cs
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BussinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContracts;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryBusinessLogic
|
||||||
|
{
|
||||||
|
public class ShopLogic : IShopLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
|
||||||
|
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ShopName: {ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||||
|
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ShopName: {ShopName}. Id: {Id}", model.ShopName, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_shopStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_shopStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_shopStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Supply(ShopSearchModel shopModel, IPastryModel Pastry, int count)
|
||||||
|
{
|
||||||
|
if (shopModel == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(shopModel));
|
||||||
|
}
|
||||||
|
if (Pastry == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(Pastry));
|
||||||
|
}
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Количество товаров(выпечки) в магазине должно быть больше нуля", nameof(count));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Supply(GetElement). ShopName: {ShopName}. Id: {Id}", shopModel.ShopName, shopModel.Id);
|
||||||
|
var shop = _shopStorage.GetElement(shopModel);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Supply(GetElement). Element not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (shop.ShopPastries.ContainsKey(Pastry.Id))
|
||||||
|
{
|
||||||
|
var shopP = shop.ShopPastries[Pastry.Id];
|
||||||
|
shopP.Item2 += count;
|
||||||
|
shop.ShopPastries[Pastry.Id] = shopP;
|
||||||
|
_logger.LogInformation("Supply. Added {count} '{Pastry}' to '{ShopName}' shop", count, Pastry.PastryName,
|
||||||
|
shop.ShopName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.ShopPastries.Add(Pastry.Id, (Pastry, count));
|
||||||
|
_logger.LogInformation("Supply. Added {count} new '{Pastry}' to '{ShopName}' shop", count, Pastry.PastryName,
|
||||||
|
shop.ShopName);
|
||||||
|
}
|
||||||
|
if (_shopStorage.Update(new ShopBindingModel()
|
||||||
|
{
|
||||||
|
Id = shop.Id,
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Address = shop.Address,
|
||||||
|
DateOpening = shop.DateOpening,
|
||||||
|
ShopPastries = shop.ShopPastries,
|
||||||
|
}) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Supply. Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Address))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет адреса магазина", nameof(model.Address));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shop. ShopName: {ShopName}. Address: {Address}. Id: {Id}", model.ShopName, model.Address, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using ConfectioneryDataModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ShopBindingModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public Dictionary<int, (IPastryModel, int)> ShopPastries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryContracts.BussinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IShopLogic
|
||||||
|
{
|
||||||
|
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||||
|
|
||||||
|
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool Update(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool Delete(ShopBindingModel model);
|
||||||
|
|
||||||
|
bool Supply(ShopSearchModel shopModel, IPastryModel pastry, int count);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ShopSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
public string? ShopName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IShopStorage
|
||||||
|
{
|
||||||
|
List<ShopViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||||
|
|
||||||
|
ShopViewModel? GetElement(ShopSearchModel model);
|
||||||
|
|
||||||
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
|
|
||||||
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
|
|
||||||
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
using ConfectioneryDataModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ShopViewModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название магазина")]
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Адрес")]
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата открытия")]
|
||||||
|
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public Dictionary<int, (IPastryModel, int)> ShopPastries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
}
|
20
Confectionery/ConfectioneryDataModels/IShopModel.cs
Normal file
20
Confectionery/ConfectioneryDataModels/IShopModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryDataModels
|
||||||
|
{
|
||||||
|
public interface IShopModel : IId
|
||||||
|
{
|
||||||
|
string ShopName { get; }
|
||||||
|
|
||||||
|
string Address { get; }
|
||||||
|
|
||||||
|
DateTime DateOpening { get; }
|
||||||
|
|
||||||
|
Dictionary<int, (IPastryModel, int)> ShopPastries { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -13,12 +13,14 @@ namespace ConfectioneryListImplement
|
|||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Pastry> Pastries { get; set; }
|
public List<Pastry> Pastries { get; set; }
|
||||||
|
public List<Shop> Shops { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Pastries = new List<Pastry>();
|
Pastries = new List<Pastry>();
|
||||||
|
Shops = new List<Shop>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryContracts.StoragesContracts;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.ShopName.Contains(model.ShopName))
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.ShopName) &&
|
||||||
|
shop.ShopName == model.ShopName) ||
|
||||||
|
(model.Id.HasValue && shop.Id == model.Id))
|
||||||
|
{
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (model.Id <= shop.Id)
|
||||||
|
{
|
||||||
|
model.Id = shop.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Shops.Add(newShop);
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.Id == model.Id)
|
||||||
|
{
|
||||||
|
shop.Update(model);
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Shops[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Shops[i];
|
||||||
|
_source.Shops.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
Confectionery/ConfectioneryListImplement/Models/Shop.cs
Normal file
66
Confectionery/ConfectioneryListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConfectioneryListImplement.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, (IPastryModel, int)> ShopPastries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = new Dictionary<int, (IPastryModel, int)>();
|
||||||
|
|
||||||
|
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,
|
||||||
|
ShopPastries = model.ShopPastries
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Address = model.Address;
|
||||||
|
DateOpening = model.DateOpening;
|
||||||
|
ShopPastries = model.ShopPastries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Address = Address,
|
||||||
|
DateOpening = DateOpening,
|
||||||
|
ShopPastries = ShopPastries
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -9,12 +9,14 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ConfectioneryBusinessLogic\ConfectioneryBusinessLogic.csproj" />
|
<ProjectReference Include="..\ConfectioneryBusinessLogic\ConfectioneryBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\ConfectioneryContracts\ConfectioneryContracts.csproj" />
|
||||||
<ProjectReference Include="..\ConfectioneryListImplement\ConfectioneryListImplement.csproj" />
|
<ProjectReference Include="..\ConfectioneryListImplement\ConfectioneryListImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
216
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
216
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
@ -28,135 +28,157 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
menuStrip = new MenuStrip();
|
||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
КомпонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.КондитерскиеИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
КондитерскиеИзделияToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
dataGridView = new DataGridView();
|
||||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
buttonCreateOrder = new Button();
|
||||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
buttonOrderReady = new Button();
|
||||||
this.menuStrip.SuspendLayout();
|
buttonIssuedOrder = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
buttonUpd = new Button();
|
||||||
this.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
this.справочникиToolStripMenuItem});
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, пополнениеМагазинаToolStripMenuItem });
|
||||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
this.menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
this.menuStrip.Size = new System.Drawing.Size(1009, 24);
|
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||||
this.menuStrip.TabIndex = 0;
|
menuStrip.Size = new Size(1153, 30);
|
||||||
this.menuStrip.Text = "menuStrip1";
|
menuStrip.TabIndex = 0;
|
||||||
|
menuStrip.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, КондитерскиеИзделияToolStripMenuItem, магазиныToolStripMenuItem });
|
||||||
this.КомпонентыToolStripMenuItem,
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
this.КондитерскиеИзделияToolStripMenuItem});
|
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
|
||||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
//
|
||||||
// КомпонентыToolStripMenuItem
|
// КомпонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||||
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(198, 22);
|
КомпонентыToolStripMenuItem.Size = new Size(251, 26);
|
||||||
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// КондитерскиеИзделияToolStripMenuItem
|
// КондитерскиеИзделияToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.КондитерскиеИзделияToolStripMenuItem.Name = "КондитерскиеИзделияToolStripMenuItem";
|
КондитерскиеИзделияToolStripMenuItem.Name = "КондитерскиеИзделияToolStripMenuItem";
|
||||||
this.КондитерскиеИзделияToolStripMenuItem.Size = new System.Drawing.Size(198, 22);
|
КондитерскиеИзделияToolStripMenuItem.Size = new Size(251, 26);
|
||||||
this.КондитерскиеИзделияToolStripMenuItem.Text = "Кондитерские изделия";
|
КондитерскиеИзделияToolStripMenuItem.Text = "Кондитерские изделия";
|
||||||
this.КондитерскиеИзделияToolStripMenuItem.Click += new System.EventHandler(this.КондитерскиеИзделияToolStripMenuItem_Click);
|
КондитерскиеИзделияToolStripMenuItem.Click += КондитерскиеИзделияToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// магазиныToolStripMenuItem
|
||||||
|
//
|
||||||
|
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
|
магазиныToolStripMenuItem.Size = new Size(251, 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
|
||||||
//
|
//
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 27);
|
dataGridView.Location = new Point(0, 36);
|
||||||
this.dataGridView.Name = "dataGridView";
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.Size = new System.Drawing.Size(757, 306);
|
dataGridView.RowHeadersWidth = 51;
|
||||||
this.dataGridView.TabIndex = 1;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
|
dataGridView.Size = new Size(865, 408);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(806, 51);
|
buttonCreateOrder.Location = new Point(921, 68);
|
||||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Margin = new Padding(3, 4, 3, 4);
|
||||||
this.buttonCreateOrder.Size = new System.Drawing.Size(182, 27);
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
this.buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.Size = new Size(208, 36);
|
||||||
this.buttonCreateOrder.Text = "Создать заказ";
|
buttonCreateOrder.TabIndex = 2;
|
||||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonCreateOrder.Text = "Создать заказ";
|
||||||
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateOrder.Click += buttonCreateOrder_Click;
|
||||||
//
|
//
|
||||||
// buttonTakeOrderInWork
|
// buttonTakeOrderInWork
|
||||||
//
|
//
|
||||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(806, 112);
|
buttonTakeOrderInWork.Location = new Point(921, 149);
|
||||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4);
|
||||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(184, 26);
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
buttonTakeOrderInWork.Size = new Size(210, 35);
|
||||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
buttonTakeOrderInWork.TabIndex = 3;
|
||||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click);
|
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||||
|
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
|
||||||
//
|
//
|
||||||
// buttonOrderReady
|
// buttonOrderReady
|
||||||
//
|
//
|
||||||
this.buttonOrderReady.Location = new System.Drawing.Point(806, 169);
|
buttonOrderReady.Location = new Point(921, 225);
|
||||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
buttonOrderReady.Margin = new Padding(3, 4, 3, 4);
|
||||||
this.buttonOrderReady.Size = new System.Drawing.Size(182, 28);
|
buttonOrderReady.Name = "buttonOrderReady";
|
||||||
this.buttonOrderReady.TabIndex = 4;
|
buttonOrderReady.Size = new Size(208, 37);
|
||||||
this.buttonOrderReady.Text = "Заказ готов";
|
buttonOrderReady.TabIndex = 4;
|
||||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
buttonOrderReady.Text = "Заказ готов";
|
||||||
this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click);
|
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||||
|
buttonOrderReady.Click += buttonOrderReady_Click;
|
||||||
//
|
//
|
||||||
// buttonIssuedOrder
|
// buttonIssuedOrder
|
||||||
//
|
//
|
||||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(806, 227);
|
buttonIssuedOrder.Location = new Point(921, 303);
|
||||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4);
|
||||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(182, 27);
|
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||||
this.buttonIssuedOrder.TabIndex = 5;
|
buttonIssuedOrder.Size = new Size(208, 36);
|
||||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
buttonIssuedOrder.TabIndex = 5;
|
||||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
buttonIssuedOrder.Text = "Заказ выдан";
|
||||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click);
|
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
|
buttonIssuedOrder.Click += buttonIssuedOrder_Click;
|
||||||
//
|
//
|
||||||
// buttonUpd
|
// buttonUpd
|
||||||
//
|
//
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(806, 281);
|
buttonUpd.Location = new Point(921, 375);
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(182, 29);
|
buttonUpd.Name = "buttonUpd";
|
||||||
this.buttonUpd.TabIndex = 6;
|
buttonUpd.Size = new Size(208, 39);
|
||||||
this.buttonUpd.Text = "Обновить список";
|
buttonUpd.TabIndex = 6;
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
buttonUpd.Text = "Обновить список";
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1009, 332);
|
ClientSize = new Size(1153, 443);
|
||||||
this.Controls.Add(this.buttonUpd);
|
Controls.Add(buttonUpd);
|
||||||
this.Controls.Add(this.buttonIssuedOrder);
|
Controls.Add(buttonIssuedOrder);
|
||||||
this.Controls.Add(this.buttonOrderReady);
|
Controls.Add(buttonOrderReady);
|
||||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
Controls.Add(buttonTakeOrderInWork);
|
||||||
this.Controls.Add(this.buttonCreateOrder);
|
Controls.Add(buttonCreateOrder);
|
||||||
this.Controls.Add(this.dataGridView);
|
Controls.Add(dataGridView);
|
||||||
this.Controls.Add(this.menuStrip);
|
Controls.Add(menuStrip);
|
||||||
this.MainMenuStrip = this.menuStrip;
|
MainMenuStrip = menuStrip;
|
||||||
this.Name = "FormMain";
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
this.Text = "Кондитерская";
|
Name = "FormMain";
|
||||||
this.menuStrip.ResumeLayout(false);
|
Text = "Кондитерская";
|
||||||
this.menuStrip.PerformLayout();
|
menuStrip.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
menuStrip.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
this.PerformLayout();
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -171,5 +193,7 @@
|
|||||||
private Button buttonOrderReady;
|
private Button buttonOrderReady;
|
||||||
private Button buttonIssuedOrder;
|
private Button buttonIssuedOrder;
|
||||||
private Button buttonUpd;
|
private Button buttonUpd;
|
||||||
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -150,5 +150,23 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(FormSupply));
|
||||||
|
if (service is FormSupply form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,64 @@
|
|||||||
<root>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
223
Confectionery/ConfectioneryView/FormShop.Designer.cs
generated
Normal file
223
Confectionery/ConfectioneryView/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormShop
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.labelOpeningDate = new System.Windows.Forms.Label();
|
||||||
|
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelAddress = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.groupBoxPastries = new System.Windows.Forms.GroupBox();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.groupBoxPastries.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelOpeningDate
|
||||||
|
//
|
||||||
|
this.labelOpeningDate.AutoSize = true;
|
||||||
|
this.labelOpeningDate.Location = new System.Drawing.Point(31, 102);
|
||||||
|
this.labelOpeningDate.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
this.labelOpeningDate.Name = "labelOpeningDate";
|
||||||
|
this.labelOpeningDate.Size = new System.Drawing.Size(113, 20);
|
||||||
|
this.labelOpeningDate.TabIndex = 12;
|
||||||
|
this.labelOpeningDate.Text = "Дата открытия:";
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
this.dateTimePicker.Location = new System.Drawing.Point(159, 98);
|
||||||
|
this.dateTimePicker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.dateTimePicker.Name = "dateTimePicker";
|
||||||
|
this.dateTimePicker.Size = new System.Drawing.Size(249, 27);
|
||||||
|
this.dateTimePicker.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// textBoxAddress
|
||||||
|
//
|
||||||
|
this.textBoxAddress.Location = new System.Drawing.Point(120, 59);
|
||||||
|
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.textBoxAddress.Name = "textBoxAddress";
|
||||||
|
this.textBoxAddress.Size = new System.Drawing.Size(287, 27);
|
||||||
|
this.textBoxAddress.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// labelAddress
|
||||||
|
//
|
||||||
|
this.labelAddress.AutoSize = true;
|
||||||
|
this.labelAddress.Location = new System.Drawing.Point(31, 63);
|
||||||
|
this.labelAddress.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
this.labelAddress.Name = "labelAddress";
|
||||||
|
this.labelAddress.Size = new System.Drawing.Size(54, 20);
|
||||||
|
this.labelAddress.TabIndex = 9;
|
||||||
|
this.labelAddress.Text = "Адрес:";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(120, 19);
|
||||||
|
this.textBoxName.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(287, 27);
|
||||||
|
this.textBoxName.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(31, 23);
|
||||||
|
this.labelName.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.labelName.TabIndex = 7;
|
||||||
|
this.labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// groupBoxPastries
|
||||||
|
//
|
||||||
|
this.groupBoxPastries.Controls.Add(this.dataGridView);
|
||||||
|
this.groupBoxPastries.Location = new System.Drawing.Point(31, 133);
|
||||||
|
this.groupBoxPastries.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.groupBoxPastries.Name = "groupBoxPastries";
|
||||||
|
this.groupBoxPastries.Padding = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.groupBoxPastries.Size = new System.Drawing.Size(536, 384);
|
||||||
|
this.groupBoxPastries.TabIndex = 13;
|
||||||
|
this.groupBoxPastries.TabStop = false;
|
||||||
|
this.groupBoxPastries.Text = "Выпечка";
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ActiveBorder;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.ColumnId,
|
||||||
|
this.ColumnName,
|
||||||
|
this.ColumnCount});
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(5, 24);
|
||||||
|
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.dataGridView.MultiSelect = false;
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersVisible = false;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(522, 356);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnId
|
||||||
|
//
|
||||||
|
this.ColumnId.HeaderText = "Id";
|
||||||
|
this.ColumnId.MinimumWidth = 6;
|
||||||
|
this.ColumnId.Name = "ColumnId";
|
||||||
|
this.ColumnId.ReadOnly = true;
|
||||||
|
this.ColumnId.Visible = false;
|
||||||
|
this.ColumnId.Width = 125;
|
||||||
|
//
|
||||||
|
// ColumnName
|
||||||
|
//
|
||||||
|
this.ColumnName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.ColumnName.HeaderText = "Название выпечки";
|
||||||
|
this.ColumnName.MinimumWidth = 6;
|
||||||
|
this.ColumnName.Name = "ColumnName";
|
||||||
|
this.ColumnName.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
this.ColumnCount.HeaderText = "Количество";
|
||||||
|
this.ColumnCount.MinimumWidth = 6;
|
||||||
|
this.ColumnCount.Name = "ColumnCount";
|
||||||
|
this.ColumnCount.ReadOnly = true;
|
||||||
|
this.ColumnCount.Width = 125;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(449, 529);
|
||||||
|
this.buttonCancel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonCancel.TabIndex = 15;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(330, 529);
|
||||||
|
this.buttonSave.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonSave.TabIndex = 14;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// FormShop
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(603, 578);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.groupBoxPastries);
|
||||||
|
this.Controls.Add(this.labelOpeningDate);
|
||||||
|
this.Controls.Add(this.dateTimePicker);
|
||||||
|
this.Controls.Add(this.textBoxAddress);
|
||||||
|
this.Controls.Add(this.labelAddress);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormShop";
|
||||||
|
this.Text = "Магазин";
|
||||||
|
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||||
|
this.groupBoxPastries.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelOpeningDate;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private TextBox textBoxAddress;
|
||||||
|
private Label labelAddress;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelName;
|
||||||
|
private GroupBox groupBoxPastries;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private DataGridViewTextBoxColumn ColumnId;
|
||||||
|
private DataGridViewTextBoxColumn ColumnName;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
}
|
||||||
|
}
|
133
Confectionery/ConfectioneryView/FormShop.cs
Normal file
133
Confectionery/ConfectioneryView/FormShop.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
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;
|
||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BussinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormShop : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
|
||||||
|
private Dictionary<int, (IPastryModel, int)> _shopPastries;
|
||||||
|
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_shopPastries = new Dictionary<int, (IPastryModel, 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;
|
||||||
|
_shopPastries = view.ShopPastries ?? new Dictionary<int, (IPastryModel, 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 pastries loading");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_shopPastries != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var pastry in _shopPastries)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { pastry.Key, pastry.Value.Item1.PastryName, pastry.Value.Item2 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Shop pastries 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;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shop saving");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ShopName = textBoxName.Text,
|
||||||
|
Address = textBoxAddress.Text,
|
||||||
|
DateOpening = dateTimePicker.Value,
|
||||||
|
ShopPastries = _shopPastries
|
||||||
|
};
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Confectionery/ConfectioneryView/FormShop.resx
Normal file
60
Confectionery/ConfectioneryView/FormShop.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
127
Confectionery/ConfectioneryView/FormShops.Designer.cs
generated
Normal file
127
Confectionery/ConfectioneryView/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormShops
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonEdit = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(511, 221);
|
||||||
|
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonUpd.TabIndex = 16;
|
||||||
|
this.buttonUpd.Text = "Обновить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(511, 158);
|
||||||
|
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonDel.TabIndex = 15;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// buttonEdit
|
||||||
|
//
|
||||||
|
this.buttonEdit.Location = new System.Drawing.Point(511, 95);
|
||||||
|
this.buttonEdit.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
|
this.buttonEdit.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonEdit.TabIndex = 14;
|
||||||
|
this.buttonEdit.Text = "Изменить";
|
||||||
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(511, 37);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonAdd.TabIndex = 13;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ActiveBorder;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.dataGridView.MultiSelect = false;
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersVisible = false;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(466, 538);
|
||||||
|
this.dataGridView.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// FormShops
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(650, 538);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonEdit);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Name = "FormShops";
|
||||||
|
this.Text = "Магазины";
|
||||||
|
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonEdit;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
111
Confectionery/ConfectioneryView/FormShops.cs
Normal file
111
Confectionery/ConfectioneryView/FormShops.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
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;
|
||||||
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BussinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormShops : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormShops_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ShopPastries"].Visible = false;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shops loading");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Shops loading error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
|
if (service is FormShop form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonEdit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
|
if (service is FormShop form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("Deletion of shop");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ShopBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Shop deletion error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Confectionery/ConfectioneryView/FormShops.resx
Normal file
60
Confectionery/ConfectioneryView/FormShops.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
153
Confectionery/ConfectioneryView/FormSupply.Designer.cs
generated
Normal file
153
Confectionery/ConfectioneryView/FormSupply.Designer.cs
generated
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
partial class FormSupply
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxPastry = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelPastry = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelShop = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(312, 170);
|
||||||
|
this.buttonCancel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonCancel.TabIndex = 19;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(205, 170);
|
||||||
|
this.buttonSave.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(101, 36);
|
||||||
|
this.buttonSave.TabIndex = 18;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(139, 128);
|
||||||
|
this.textBoxCount.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(287, 27);
|
||||||
|
this.textBoxCount.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(38, 132);
|
||||||
|
this.labelCount.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
||||||
|
this.labelCount.TabIndex = 16;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// comboBoxPastry
|
||||||
|
//
|
||||||
|
this.comboBoxPastry.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxPastry.FormattingEnabled = true;
|
||||||
|
this.comboBoxPastry.Location = new System.Drawing.Point(139, 80);
|
||||||
|
this.comboBoxPastry.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.comboBoxPastry.Name = "comboBoxPastry";
|
||||||
|
this.comboBoxPastry.Size = new System.Drawing.Size(287, 28);
|
||||||
|
this.comboBoxPastry.TabIndex = 15;
|
||||||
|
//
|
||||||
|
// labelPastry
|
||||||
|
//
|
||||||
|
this.labelPastry.AutoSize = true;
|
||||||
|
this.labelPastry.Location = new System.Drawing.Point(38, 85);
|
||||||
|
this.labelPastry.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
this.labelPastry.Name = "labelPastry";
|
||||||
|
this.labelPastry.Size = new System.Drawing.Size(72, 20);
|
||||||
|
this.labelPastry.TabIndex = 14;
|
||||||
|
this.labelPastry.Text = "Выпечка:";
|
||||||
|
//
|
||||||
|
// comboBoxShop
|
||||||
|
//
|
||||||
|
this.comboBoxShop.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxShop.FormattingEnabled = true;
|
||||||
|
this.comboBoxShop.Location = new System.Drawing.Point(139, 34);
|
||||||
|
this.comboBoxShop.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||||
|
this.comboBoxShop.Name = "comboBoxShop";
|
||||||
|
this.comboBoxShop.Size = new System.Drawing.Size(287, 28);
|
||||||
|
this.comboBoxShop.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// labelShop
|
||||||
|
//
|
||||||
|
this.labelShop.AutoSize = true;
|
||||||
|
this.labelShop.Location = new System.Drawing.Point(38, 38);
|
||||||
|
this.labelShop.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
this.labelShop.Name = "labelShop";
|
||||||
|
this.labelShop.Size = new System.Drawing.Size(72, 20);
|
||||||
|
this.labelShop.TabIndex = 12;
|
||||||
|
this.labelShop.Text = "Магазин:";
|
||||||
|
//
|
||||||
|
// FormSupply
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(464, 233);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.comboBoxPastry);
|
||||||
|
this.Controls.Add(this.labelPastry);
|
||||||
|
this.Controls.Add(this.comboBoxShop);
|
||||||
|
this.Controls.Add(this.labelShop);
|
||||||
|
this.Name = "FormSupply";
|
||||||
|
this.Text = "Пополнение магазина";
|
||||||
|
this.Load += new System.EventHandler(this.FormSupply_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Label labelCount;
|
||||||
|
private ComboBox comboBoxPastry;
|
||||||
|
private Label labelPastry;
|
||||||
|
private ComboBox comboBoxShop;
|
||||||
|
private Label labelShop;
|
||||||
|
}
|
||||||
|
}
|
124
Confectionery/ConfectioneryView/FormSupply.cs
Normal file
124
Confectionery/ConfectioneryView/FormSupply.cs
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
using ConfectioneryContracts.BussinessLogicsContracts;
|
||||||
|
using ConfectioneryContracts.SearchModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ConfectioneryView
|
||||||
|
{
|
||||||
|
public partial class FormSupply : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IPastryLogic _logicPastry;
|
||||||
|
|
||||||
|
private readonly IShopLogic _logicShop;
|
||||||
|
public FormSupply(ILogger<FormSupply> logger, IPastryLogic logicPastry, IShopLogic logicShop)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicPastry = logicPastry;
|
||||||
|
_logicShop = logicShop;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormSupply_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Pastries loading");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicPastry.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxPastry.DisplayMember = "PastryName";
|
||||||
|
comboBoxPastry.ValueMember = "Id";
|
||||||
|
comboBoxPastry.DataSource = list;
|
||||||
|
comboBoxPastry.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Pastries loading error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shops loading");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logicShop.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxShop.DisplayMember = "ShopName";
|
||||||
|
comboBoxShop.ValueMember = "Id";
|
||||||
|
comboBoxShop.DataSource = list;
|
||||||
|
comboBoxShop.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Shops loading error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxShop.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxPastry.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите выпечку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shop replenishment");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pastry = _logicPastry.ReadElement(new PastrySearchModel
|
||||||
|
{ Id = Convert.ToInt32(comboBoxPastry.SelectedValue) });
|
||||||
|
if (pastry == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Выпечка не найдена.");
|
||||||
|
}
|
||||||
|
var operationResult = _logicShop.Supply(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(comboBoxShop.SelectedValue)
|
||||||
|
},
|
||||||
|
pastry,
|
||||||
|
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, "Shop replenishment error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Confectionery/ConfectioneryView/FormSupply.resx
Normal file
60
Confectionery/ConfectioneryView/FormSupply.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -36,10 +36,12 @@ namespace ConfectioneryView
|
|||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<IPastryStorage, PastryStorage>();
|
services.AddTransient<IPastryStorage, PastryStorage>();
|
||||||
|
services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IPastryLogic, PastryLogic>();
|
services.AddTransient<IPastryLogic, PastryLogic>();
|
||||||
|
services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
@ -48,6 +50,9 @@ namespace ConfectioneryView
|
|||||||
services.AddTransient<FormPastry>();
|
services.AddTransient<FormPastry>();
|
||||||
services.AddTransient<FormPastryComponent>();
|
services.AddTransient<FormPastryComponent>();
|
||||||
services.AddTransient<FormPastries>();
|
services.AddTransient<FormPastries>();
|
||||||
|
services.AddTransient<FormShop>();
|
||||||
|
services.AddTransient<FormShops>();
|
||||||
|
services.AddTransient<FormSupply>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user