SecondWork Hard

This commit is contained in:
Алишер Бустонов 2023-04-20 23:12:22 +04:00
parent 5ba88811e6
commit 411f52a5ce
34 changed files with 1283 additions and 163 deletions

View File

@ -3,27 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248 VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
<<<<<<< Updated upstream Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryView", "FishFactoryView\FishFactoryView.csproj", "{493271EC-376B-4F9E-A22B-433080D12559}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDataModels", "FishFactoryDataModels\FishFactoryDataModels.csproj", "{D3365297-DF47-4830-BF3C-A24EE3E62B15}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryView", "FishFactoryView\FishFactoryView.csproj", "{2304F79F-E763-44E3-8CF6-50CFC3BDC288}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDataModels", "FishFactoryDataModels\FishFactoryDataModels.csproj", "{F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryContracts", "FishFactoryContracts\FishFactoryContracts.csproj", "{78DE3D5B-DA83-4266-B91F-5601C5603450}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryContracts", "FishFactoryContracts\FishFactoryContracts.csproj", "{B038384B-AEAB-4709-BFC6-84E8A485A810}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryBusinessLogic", "FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj", "{AC755273-7FEE-42B5-9BA1-5D17FF559C37}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryBusinessLogic", "FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj", "{A5DC30A0-6199-4FC9-BC3F-4F71CB8908E7}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryListImplement", "FishFactoryListImplement\FishFactoryListImplement.csproj", "{923C2993-D4F1-4480-B31C-B80F16575603}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryListImplement", "FishFactoryListImplement\FishFactoryListImplement.csproj", "{726F9326-8BDA-4A88-BD87-AD5F88CE3779}"
=======
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDataModels", "FishFactoryDataModels\FishFactoryDataModels.csproj", "{ABEC1828-156D-4B7F-927B-2495A2D8B660}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryContracts", "FishFactoryContracts\FishFactoryContracts.csproj", "{2CA5AB11-8934-4ACD-B600-FE4E3C6A0C5E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FishFactoryFileImplement", "FishFactoryFileImplement\FishFactoryFileImplement.csproj", "{DE30E611-C52D-4BDB-8CD1-2331EC5D24F8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryBusinessLogic", "FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj", "{C2D0F702-2D82-4446-A6C4-DC296D915076}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryListImplement", "FishFactoryListImplement\FishFactoryListImplement.csproj", "{877A969D-0983-4044-8AB5-42EE3D7B22DF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryView", "FishFactoryView\FishFactoryView.csproj", "{B25E8CDF-D3CC-4476-A213-2FC35EDFF4AC}"
>>>>>>> Stashed changes
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -31,54 +21,35 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
<<<<<<< Updated upstream {493271EC-376B-4F9E-A22B-433080D12559}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3365297-DF47-4830-BF3C-A24EE3E62B15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {493271EC-376B-4F9E-A22B-433080D12559}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3365297-DF47-4830-BF3C-A24EE3E62B15}.Debug|Any CPU.Build.0 = Debug|Any CPU {493271EC-376B-4F9E-A22B-433080D12559}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3365297-DF47-4830-BF3C-A24EE3E62B15}.Release|Any CPU.ActiveCfg = Release|Any CPU {493271EC-376B-4F9E-A22B-433080D12559}.Release|Any CPU.Build.0 = Release|Any CPU
{D3365297-DF47-4830-BF3C-A24EE3E62B15}.Release|Any CPU.Build.0 = Release|Any CPU {F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2304F79F-E763-44E3-8CF6-50CFC3BDC288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2304F79F-E763-44E3-8CF6-50CFC3BDC288}.Debug|Any CPU.Build.0 = Debug|Any CPU {F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2304F79F-E763-44E3-8CF6-50CFC3BDC288}.Release|Any CPU.ActiveCfg = Release|Any CPU {F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}.Release|Any CPU.Build.0 = Release|Any CPU
{2304F79F-E763-44E3-8CF6-50CFC3BDC288}.Release|Any CPU.Build.0 = Release|Any CPU {B038384B-AEAB-4709-BFC6-84E8A485A810}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78DE3D5B-DA83-4266-B91F-5601C5603450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B038384B-AEAB-4709-BFC6-84E8A485A810}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78DE3D5B-DA83-4266-B91F-5601C5603450}.Debug|Any CPU.Build.0 = Debug|Any CPU {B038384B-AEAB-4709-BFC6-84E8A485A810}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78DE3D5B-DA83-4266-B91F-5601C5603450}.Release|Any CPU.ActiveCfg = Release|Any CPU {B038384B-AEAB-4709-BFC6-84E8A485A810}.Release|Any CPU.Build.0 = Release|Any CPU
{78DE3D5B-DA83-4266-B91F-5601C5603450}.Release|Any CPU.Build.0 = Release|Any CPU {A5DC30A0-6199-4FC9-BC3F-4F71CB8908E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC755273-7FEE-42B5-9BA1-5D17FF559C37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A5DC30A0-6199-4FC9-BC3F-4F71CB8908E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC755273-7FEE-42B5-9BA1-5D17FF559C37}.Debug|Any CPU.Build.0 = Debug|Any CPU {A5DC30A0-6199-4FC9-BC3F-4F71CB8908E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC755273-7FEE-42B5-9BA1-5D17FF559C37}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5DC30A0-6199-4FC9-BC3F-4F71CB8908E7}.Release|Any CPU.Build.0 = Release|Any CPU
{AC755273-7FEE-42B5-9BA1-5D17FF559C37}.Release|Any CPU.Build.0 = Release|Any CPU {726F9326-8BDA-4A88-BD87-AD5F88CE3779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{923C2993-D4F1-4480-B31C-B80F16575603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {726F9326-8BDA-4A88-BD87-AD5F88CE3779}.Debug|Any CPU.Build.0 = Debug|Any CPU
{923C2993-D4F1-4480-B31C-B80F16575603}.Debug|Any CPU.Build.0 = Debug|Any CPU {726F9326-8BDA-4A88-BD87-AD5F88CE3779}.Release|Any CPU.ActiveCfg = Release|Any CPU
{923C2993-D4F1-4480-B31C-B80F16575603}.Release|Any CPU.ActiveCfg = Release|Any CPU {726F9326-8BDA-4A88-BD87-AD5F88CE3779}.Release|Any CPU.Build.0 = Release|Any CPU
{923C2993-D4F1-4480-B31C-B80F16575603}.Release|Any CPU.Build.0 = Release|Any CPU {DE30E611-C52D-4BDB-8CD1-2331EC5D24F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
======= {DE30E611-C52D-4BDB-8CD1-2331EC5D24F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABEC1828-156D-4B7F-927B-2495A2D8B660}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE30E611-C52D-4BDB-8CD1-2331EC5D24F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABEC1828-156D-4B7F-927B-2495A2D8B660}.Debug|Any CPU.Build.0 = Debug|Any CPU {DE30E611-C52D-4BDB-8CD1-2331EC5D24F8}.Release|Any CPU.Build.0 = Release|Any CPU
{ABEC1828-156D-4B7F-927B-2495A2D8B660}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABEC1828-156D-4B7F-927B-2495A2D8B660}.Release|Any CPU.Build.0 = Release|Any CPU
{2CA5AB11-8934-4ACD-B600-FE4E3C6A0C5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CA5AB11-8934-4ACD-B600-FE4E3C6A0C5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CA5AB11-8934-4ACD-B600-FE4E3C6A0C5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CA5AB11-8934-4ACD-B600-FE4E3C6A0C5E}.Release|Any CPU.Build.0 = Release|Any CPU
{C2D0F702-2D82-4446-A6C4-DC296D915076}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2D0F702-2D82-4446-A6C4-DC296D915076}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2D0F702-2D82-4446-A6C4-DC296D915076}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2D0F702-2D82-4446-A6C4-DC296D915076}.Release|Any CPU.Build.0 = Release|Any CPU
{877A969D-0983-4044-8AB5-42EE3D7B22DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{877A969D-0983-4044-8AB5-42EE3D7B22DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{877A969D-0983-4044-8AB5-42EE3D7B22DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{877A969D-0983-4044-8AB5-42EE3D7B22DF}.Release|Any CPU.Build.0 = Release|Any CPU
{B25E8CDF-D3CC-4476-A213-2FC35EDFF4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B25E8CDF-D3CC-4476-A213-2FC35EDFF4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B25E8CDF-D3CC-4476-A213-2FC35EDFF4AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B25E8CDF-D3CC-4476-A213-2FC35EDFF4AC}.Release|Any CPU.Build.0 = Release|Any CPU
>>>>>>> Stashed changes
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0E9B62C7-0966-47D1-BDF0-F8F88E91166D} SolutionGuid = {AAD48BBC-4981-49E9-8CAC-601A95705C8D}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -12,11 +12,15 @@ namespace FishFactoryBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly IShopLogic _shopLogic;
private readonly ICannedStorage _cannedStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage) public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, ICannedStorage cannedStorage)
{ {
_logger = logger; _logger = logger;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_shopLogic = shopLogic;
_cannedStorage = cannedStorage;
} }
public bool CreateOrder(OrderBindingModel model) public bool CreateOrder(OrderBindingModel model)
@ -39,14 +43,35 @@ namespace FishFactoryBusinessLogic.BusinessLogics
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
{ {
CheckModel(model); var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (model.Status + 1 != newStatus) if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != newStatus)
{ {
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
return false; return false;
} }
model.Status = newStatus; model.Status = newStatus;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; if (model.Status == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
var canned = _cannedStorage.GetElement(new() { Id = viewModel.CannedId });
if (canned == null)
{
throw new ArgumentNullException(nameof(canned));
}
if (!_shopLogic.AddCanned(canned, viewModel.Count))
{
throw new Exception($"AddCanned operation failed. Shop is full.");
}
}
else
{
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model, false);
if (_orderStorage.Update(model) == null) if (_orderStorage.Update(model) == null)
{ {
model.Status--; model.Status--;

View File

@ -93,6 +93,12 @@ namespace CannedBusinessLogic
{ {
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName)); throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
} }
if (model.MaxCountCanned < 0)
{
throw new ArgumentException(
"Максимальное количество консервы в магазине не может быть меньше нуля",
nameof(model.MaxCountCanned));
}
_logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}", _logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}",
model.ShopName, model.Address, model.Id); model.ShopName, model.Address, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel var element = _shopStorage.GetElement(new ShopSearchModel
@ -105,7 +111,7 @@ namespace CannedBusinessLogic
} }
} }
public bool AddCannedInShop(ShopSearchModel model, ICannedModel Canned, int count) public bool AddCannedInShop(ShopSearchModel model, ICannedModel canned, int count)
{ {
if (model == null) if (model == null)
{ {
@ -123,30 +129,88 @@ namespace CannedBusinessLogic
_logger.LogWarning("AddCannedInShop element not found"); _logger.LogWarning("AddCannedInShop element not found");
return false; return false;
} }
if (element.MaxCountCanned -
element.ListCanned.Select(x => x.Value.Item2).Sum() < count)
{
throw new ArgumentNullException("Магазин переполнен", nameof(count));
}
_logger.LogInformation("AddCannedInShop find. Id:{Id}", element.Id); _logger.LogInformation("AddCannedInShop find. Id:{Id}", element.Id);
if (element.ListCanned.TryGetValue(Canned.Id, out var pair)) if (element.ListCanned.TryGetValue(canned.Id, out var pair))
{ {
element.ListCanned[Canned.Id] = (Canned, count + pair.Item2); element.ListCanned[canned.Id] = (canned, count + pair.Item2);
_logger.LogInformation( _logger.LogInformation(
"AddCannedInShop. Added {count} {Canned} to '{ShopName}' shop", "AddCannedInShop. Added {count} {Canned} to '{ShopName}' shop",
count, Canned.CannedName, element.ShopName); count, canned.CannedName, element.ShopName);
} }
else else
{ {
element.ListCanned[Canned.Id] = (Canned, count); element.ListCanned[canned.Id] = (canned, count);
_logger.LogInformation( _logger.LogInformation(
"AddCannedInShop. Added {count} new Canned {Canned} to '{ShopName}' shop", "AddCannedInShop. Added {count} new Canned {Canned} to '{ShopName}' shop",
count, Canned.CannedName, element.ShopName); count, canned.CannedName, element.ShopName);
} }
_shopStorage.Update(new() { _shopStorage.Update(new() {
Id = element.Id, Id = element.Id,
Address = element.Address, Address = element.Address,
ShopName = element.ShopName, ShopName = element.ShopName,
DateOpening = element.DateOpening, DateOpening = element.DateOpening,
MaxCountCanned = element.MaxCountCanned,
ListCanned = element.ListCanned ListCanned = element.ListCanned
}); });
return true; return true;
} }
public bool AddCanned(ICannedModel model, int count)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (count <= 0)
{
throw new ArgumentException("Количество консерв должно быть больше 0", nameof(count));
}
var freeCount = _shopStorage.GetFullList()
.Select(x => x.MaxCountCanned - x.ListCanned
.Select(p => p.Value.Item2).Sum()).Sum() - count;
if (freeCount < 0)
{
_logger.LogInformation("AddCanned. Не удалось добавить изделия в магазины, они переполнены.");
return false;
}
foreach (var shop in _shopStorage.GetFullList())
{
int countFree = shop.MaxCountCanned - shop.ListCanned.Select(x => x.Value.Item2).Sum();
if (countFree < count)
{
if (!AddCannedInShop(new() { Id = shop.Id }, model, countFree))
{
_logger.LogWarning("AddCannedInShop operation failed.");
return false;
}
count -= countFree;
}
else
{
if (!AddCannedInShop(new() { Id = shop.Id }, model, count))
{
_logger.LogWarning("AddCannedInShop operation failed.");
return false;
}
count = 0;
}
if (count == 0)
{
return true;
}
}
return false;
}
public bool SellCanned(ICannedModel model, int count)
{
return _shopStorage.SellCanned(model, count);
}
} }
} }

View File

@ -16,5 +16,7 @@ namespace FishFactoryContracts.BindingModels
get; get;
set; set;
} = new(); } = new();
public int MaxCountCanned { get; set; }
} }
} }

View File

@ -12,6 +12,8 @@ namespace FishFactoryContracts.BusinessLogicsContracts
bool Create(ShopBindingModel model); bool Create(ShopBindingModel model);
bool Update(ShopBindingModel model); bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model); bool Delete(ShopBindingModel model);
bool AddCannedInShop(ShopSearchModel model, ICannedModel canned, int count); bool AddCannedInShop(ShopSearchModel model, ICannedModel canned, int count);
bool AddCanned(ICannedModel canned, int count);
bool SellCanned(ICannedModel canned, int count);
} }
} }

View File

@ -1,6 +1,7 @@
using FishFactoryContracts.BindingModels; using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels; using FishFactoryContracts.SearchModels;
using FishFactoryContracts.ViewModels; using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
namespace FishFactoryContracts.StoragesContracts namespace FishFactoryContracts.StoragesContracts
{ {
@ -12,5 +13,6 @@ namespace FishFactoryContracts.StoragesContracts
ShopViewModel? Insert(ShopBindingModel model); ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model); ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model); ShopViewModel? Delete(ShopBindingModel model);
bool SellCanned(ICannedModel model, int count);
} }
} }

View File

@ -15,6 +15,9 @@ namespace FishFactoryContracts.ViewModels
[DisplayName("Дата открытия")] [DisplayName("Дата открытия")]
public DateTime DateOpening { get; set; } = DateTime.Now; public DateTime DateOpening { get; set; } = DateTime.Now;
[DisplayName("Максимальное количество консерв")]
public int MaxCountCanned { get; set; }
public Dictionary<int, (ICannedModel, int)> ListCanned public Dictionary<int, (ICannedModel, int)> ListCanned
{ {
get; get;

View File

@ -6,5 +6,6 @@
string Address { get; } string Address { get; }
DateTime DateOpening { get; } DateTime DateOpening { get; }
Dictionary<int, (ICannedModel, int)> ListCanned { get; } Dictionary<int, (ICannedModel, int)> ListCanned { get; }
int MaxCountCanned { get; }
} }
} }

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,63 @@
using FishFactoryFileImplement.Models;
using System.Xml.Linq;
namespace FishFactoryFileImplement
{
public class DataFileSingleton
{
private static DataFileSingleton? instance;
private readonly string IngredientFileName = "Ingredient.xml";
private readonly string OrderFileName = "Order.xml";
private readonly string CannedFileName = "Canned.xml";
private readonly string ShopFileName = "Shop.xml";
public List<Ingredient> Ingredients { get; private set; }
public List<Order> Orders { get; private set; }
public List<Canned> ListCanned { get; private set; }
public List<Shop> Shops { get; private set; }
public static DataFileSingleton GetInstance()
{
if (instance == null)
{
instance = new DataFileSingleton();
}
return instance;
}
public void SaveIngredients() => SaveData(Ingredients, IngredientFileName,
"Ingredients", x => x.GetXElement);
public void SaveListCanned() => SaveData(ListCanned, CannedFileName,
"ListCanned", 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()
{
Ingredients = LoadData(IngredientFileName, "Ingredient", x => Ingredient.Create(x)!)!;
ListCanned = LoadData(CannedFileName, "Canned", x => Canned.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);
}
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\FishFactoryContracts\FishFactoryContracts.csproj" />
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,80 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryFileImplement.Models;
namespace FishFactoryFileImplement.Implements
{
public class CannedStorage : ICannedStorage
{
private readonly DataFileSingleton source;
public CannedStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<CannedViewModel> GetFullList()
{
return source.ListCanned.Select(x => x.GetViewModel).ToList();
}
public List<CannedViewModel> GetFilteredList(CannedSearchModel model)
{
if (string.IsNullOrEmpty(model.CannedName))
{
return new();
}
return source.ListCanned.Where(x =>
x.CannedName.Contains(model.CannedName)).Select(x => x.GetViewModel).ToList();
}
public CannedViewModel? GetElement(CannedSearchModel model)
{
if (string.IsNullOrEmpty(model.CannedName) && !model.Id.HasValue)
{
return null;
}
return source.ListCanned.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.CannedName) && x.CannedName ==
model.CannedName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public CannedViewModel? Insert(CannedBindingModel model)
{
model.Id = source.ListCanned.Count > 0 ? source.ListCanned.Max(x => x.Id) + 1 : 1;
var newCanned = Canned.Create(model);
if (newCanned == null)
{
return null;
}
source.ListCanned.Add(newCanned);
source.SaveListCanned();
return newCanned.GetViewModel;
}
public CannedViewModel? Update(CannedBindingModel model)
{
var canned = source.ListCanned.FirstOrDefault(x => x.Id == model.Id);
if (canned == null)
{
return null;
}
canned.Update(model);
source.SaveListCanned();
return canned.GetViewModel;
}
public CannedViewModel? Delete(CannedBindingModel model)
{
var element = source.ListCanned.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.ListCanned.Remove(element);
source.SaveListCanned();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,74 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryFileImplement.Models;
namespace FishFactoryFileImplement.Implements
{
public class IngredientStorage : IIngredientStorage
{
private readonly DataFileSingleton source;
public IngredientStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<IngredientViewModel> GetFullList()
{
return source.Ingredients.Select(x => x.GetViewModel).ToList();
}
public List<IngredientViewModel> GetFilteredList(IngredientSearchModel model)
{
if (string.IsNullOrEmpty(model.IngredientName))
{
return new();
}
return source.Ingredients.Where(x =>
x.IngredientName.Contains(model.IngredientName)).Select(x => x.GetViewModel).ToList();
}
public IngredientViewModel? GetElement(IngredientSearchModel model)
{
if (string.IsNullOrEmpty(model.IngredientName) && !model.Id.HasValue)
{
return null;
}
return source.Ingredients.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.IngredientName) && x.IngredientName ==
model.IngredientName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public IngredientViewModel? Insert(IngredientBindingModel model)
{
model.Id = source.Ingredients.Count > 0 ? source.Ingredients.Max(x => x.Id) + 1 : 1;
var newIngredient = Ingredient.Create(model);
if (newIngredient == null)
{
return null;
}
source.Ingredients.Add(newIngredient);
source.SaveIngredients();
return newIngredient.GetViewModel;
}
public IngredientViewModel? Update(IngredientBindingModel model)
{
var ingredient = source.Ingredients.FirstOrDefault(x => x.Id == model.Id);
if (ingredient == null)
{
return null;
}
ingredient.Update(model);
source.SaveIngredients();
return ingredient.GetViewModel;
}
public IngredientViewModel? Delete(IngredientBindingModel model)
{
var element = source.Ingredients.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Ingredients.Remove(element);
source.SaveIngredients();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,91 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryFileImplement.Models;
namespace FishFactoryFileImplement.Implements
{
public class OrderStorage :IOrderStorage
{
private readonly DataFileSingleton source;
public OrderStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<OrderViewModel> GetFullList()
{
return source.Orders.Select(x => GetViewModel(x)).ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
return source.Orders.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var canned in source.ListCanned)
{
if (canned.Id == order.CannedId)
{
viewModel.CannedName = canned.CannedName;
break;
}
}
return viewModel;
}
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 GetViewModel(newOrder);
}
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 GetViewModel(order);
}
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 GetViewModel(element);
}
return null;
}
}
}

View File

@ -0,0 +1,102 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using FishFactoryFileImplement.Models;
namespace FishFactoryFileImplement.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 SellCanned(ICannedModel model, int count)
{
if (source.Shops.Select(x => x.ListCanned.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum() < count)
{
return false;
}
foreach (var shop in source.Shops.Where(x => x.ListCanned.ContainsKey(model.Id)))
{
int countInCurrentShop = shop.ListCanned[model.Id].Item2;
if (countInCurrentShop <= count)
{
shop.ListCanned.Remove(model.Id);
count -= countInCurrentShop;
}
else
{
shop.ListCanned[model.Id] = (shop.ListCanned[model.Id].Item1, countInCurrentShop - count);
count = 0;
}
if (count == 0)
{
return true;
}
}
return false;
}
}
}

View File

@ -0,0 +1,86 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using System.Xml.Linq;
namespace FishFactoryFileImplement.Models
{
public class Canned : ICannedModel
{
public int Id { get; private set; }
public string CannedName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, int> Ingredients { get; private set; } = new();
private Dictionary<int, (IIngredientModel, int)>? _productIngredients = null;
public Dictionary<int, (IIngredientModel, int)> CannedIngredients
{
get
{
if(_productIngredients == null)
{
var source = DataFileSingleton.GetInstance();
_productIngredients = Ingredients.ToDictionary(x => x.Key, y => ((source.Ingredients.FirstOrDefault(z => z.Id == y.Key) as IIngredientModel)!, y.Value));
}
return _productIngredients;
}
}
public static Canned? Create(CannedBindingModel model)
{
if (model == null)
{
return null;
}
return new Canned()
{
Id = model.Id,
CannedName = model.CannedName,
Price = model.Price,
Ingredients = model.CannedIngredients.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Canned? Create(XElement element)
{
if(element == null)
{
return null;
}
return new Canned()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
CannedName = element.Element("CannedName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value),
Ingredients = element.Element("CannedIngredients")!.Elements("CannedIngredient").ToDictionary(x =>
Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(CannedBindingModel model)
{
if(model == null)
{
return;
}
CannedName = model.CannedName;
Price = model.Price;
Ingredients = model.CannedIngredients.ToDictionary(x => x.Key, x => x.Value.Item2);
_productIngredients = null;
}
public CannedViewModel GetViewModel => new()
{
Id = Id,
CannedName = CannedName,
Price = Price,
CannedIngredients = CannedIngredients,
};
public XElement GetXElement => new("Canned",
new XAttribute("Id", Id),
new XElement("CannedName", CannedName),
new XElement("Price", Price.ToString()),
new XElement("CannedIngredients", Ingredients.Select(x => new XElement("CannedIngredient",
new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()));
}
}

View File

@ -0,0 +1,59 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using System.Xml.Linq;
namespace FishFactoryFileImplement.Models
{
public class Ingredient : IIngredientModel
{
public int Id { get; private set; }
public string IngredientName { get; private set; } = string.Empty;
public double Cost { get; set; }
public static Ingredient? Create(IngredientBindingModel model)
{
if (model == null)
{
return null;
}
return new Ingredient()
{
Id = model.Id,
IngredientName = model.IngredientName,
Cost = model.Cost
};
}
public static Ingredient? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Ingredient()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
IngredientName = element.Element("IngredientName")!.Value,
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
};
}
public void Update(IngredientBindingModel model)
{
if (model == null)
{
return;
}
IngredientName = model.IngredientName;
Cost = model.Cost;
}
public IngredientViewModel GetViewModel => new()
{
Id = Id,
IngredientName = IngredientName,
Cost = Cost
};
public XElement GetXElement => new("Ingredient",
new XAttribute("Id", Id),
new XElement("IngredientName", IngredientName),
new XElement("Cost", Cost.ToString()));
}
}

View File

@ -0,0 +1,85 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using FishFactoryDataModels.Enums;
using System.Xml.Linq;
namespace FishFactoryFileImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int CannedId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
CannedId = model.CannedId,
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),
CannedId = Convert.ToInt32(element.Element("CannedId")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.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()
{
CannedId = CannedId,
Count = Count,
Sum = Sum,
DateCreate = DateCreate,
DateImplement = DateImplement,
Id = Id,
Status = Status,
};
public XElement GetXElement => new("Order",
new XAttribute("Id", Id),
new XElement("CannedId", CannedId),
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()));
}
}

View File

@ -0,0 +1,106 @@

using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using System.Xml.Linq;
namespace FishFactoryFileImplement.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 int MaxCountCanned { get; private set; }
public Dictionary<int, int> CountCanned
{
get;
private set;
} = new();
private Dictionary<int, (ICannedModel, int)>? _shopCanned = null;
public Dictionary<int, (ICannedModel, int)> ListCanned
{
get
{
if (_shopCanned == null)
{
var source = DataFileSingleton.GetInstance();
_shopCanned =
CountCanned.ToDictionary(x => x.Key,
y => ((source.ListCanned.FirstOrDefault(z => z.Id == y.Key) as ICannedModel)!, y.Value));
}
return _shopCanned;
}
}
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
MaxCountCanned = model.MaxCountCanned,
DateOpening = model.DateOpening,
CountCanned = model.ListCanned.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value,
Address = element.Element("Address")!.Value,
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
MaxCountCanned = Convert.ToInt32(element.Element("MaxCountCanned")!.Value),
CountCanned = element.Element("ListCanned")!.Elements("Canned").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;
MaxCountCanned = model.MaxCountCanned;
CountCanned = model.ListCanned.ToDictionary(x => x.Key, x => x.Value.Item2);
_shopCanned = null;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
ListCanned = ListCanned,
DateOpening = DateOpening,
MaxCountCanned = MaxCountCanned,
};
public XElement GetXElement => new("Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Address", Address),
new XElement("DateOpening", DateOpening),
new XElement("MaxCountCanned", MaxCountCanned),
new XElement("ListCanned", CountCanned
.Select(x => new XElement("Canned",
new XElement("Key", x.Key),
new XElement("Value", x.Value))
).ToArray()));
}
}

View File

@ -2,6 +2,7 @@
using FishFactoryContracts.SearchModels; using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels; using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using FishFactoryListImplement.Models; using FishFactoryListImplement.Models;
namespace FishFactoryListImplement.Implements namespace FishFactoryListImplement.Implements
@ -97,6 +98,11 @@ namespace FishFactoryListImplement.Implements
} }
} }
return null; return null;
}
public bool SellCanned(ICannedModel model, int count)
{
throw new NotImplementedException();
} }
} }
} }

View File

@ -49,5 +49,7 @@ namespace FishFactoryListImplement.Models
ListCanned = ListCanned, ListCanned = ListCanned,
DateOpening = DateOpening, DateOpening = DateOpening,
}; };
public int MaxCountCanned => throw new NotImplementedException();
} }
} }

View File

@ -16,6 +16,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj" /> <ProjectReference Include="..\FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj" />
<ProjectReference Include="..\FishFactoryFileImplement\FishFactoryFileImplement.csproj" />
<ProjectReference Include="..\FishFactoryListImplement\FishFactoryListImplement.csproj" /> <ProjectReference Include="..\FishFactoryListImplement\FishFactoryListImplement.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -104,7 +104,7 @@
this.Controls.Add(this.buttonEdit); this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd); this.Controls.Add(this.buttonAdd);
this.Name = "FormListCanned"; this.Name = "FormListCanned";
this.Text = "Список консерв"; this.Text = "Список консервы";
this.Load += new System.EventHandler(this.FormDocuments_Load); this.Load += new System.EventHandler(this.FormDocuments_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -32,16 +32,14 @@
this.reference_booksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reference_booksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ingredientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ingredientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cannedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cannedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
<<<<<<< Updated upstream this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
=======
this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
>>>>>>> Stashed changes
this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonSetToFinish = new System.Windows.Forms.Button(); this.buttonSetToFinish = new System.Windows.Forms.Button();
this.buttonSetToDone = new System.Windows.Forms.Button(); this.buttonSetToDone = new System.Windows.Forms.Button();
this.buttonSetToWork = new System.Windows.Forms.Button(); this.buttonSetToWork = new System.Windows.Forms.Button();
this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonAddCannedInShop = new System.Windows.Forms.Button(); this.buttonAddCannedInShop = new System.Windows.Forms.Button();
this.buttonSellCanned = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.menuStrip.SuspendLayout(); this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
@ -67,7 +65,7 @@
this.reference_booksToolStripMenuItem.Size = new System.Drawing.Size(94, 20); this.reference_booksToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
this.reference_booksToolStripMenuItem.Text = "Справочники"; this.reference_booksToolStripMenuItem.Text = "Справочники";
// //
// ingredientsингредиентыToolStripMenuItem // ingredientsToolStripMenuItem
// //
this.ingredientsToolStripMenuItem.Name = "ingredientsToolStripMenuItem"; this.ingredientsToolStripMenuItem.Name = "ingredientsToolStripMenuItem";
this.ingredientsToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.ingredientsToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
@ -81,22 +79,19 @@
this.cannedToolStripMenuItem.Text = "Консервы"; this.cannedToolStripMenuItem.Text = "Консервы";
this.cannedToolStripMenuItem.Click += new System.EventHandler(this.CannedToolStripMenuItem_Click); this.cannedToolStripMenuItem.Click += new System.EventHandler(this.CannedToolStripMenuItem_Click);
// //
<<<<<<< Updated upstream
=======
// shopsToolStripMenuItem // shopsToolStripMenuItem
// //
this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem"; this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
this.shopsToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.shopsToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.shopsToolStripMenuItem.Text = "Магазины"; this.shopsToolStripMenuItem.Text = "Магазины";
this.shopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click); this.shopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
// //
>>>>>>> Stashed changes
// buttonUpdate // buttonUpdate
// //
this.buttonUpdate.Location = new System.Drawing.Point(781, 299); this.buttonUpdate.Location = new System.Drawing.Point(781, 212);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate"; this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(170, 58); this.buttonUpdate.Size = new System.Drawing.Size(170, 32);
this.buttonUpdate.TabIndex = 12; this.buttonUpdate.TabIndex = 12;
this.buttonUpdate.Text = "Обновить"; this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.UseVisualStyleBackColor = true;
@ -104,10 +99,10 @@
// //
// buttonSetToFinish // buttonSetToFinish
// //
this.buttonSetToFinish.Location = new System.Drawing.Point(781, 237); this.buttonSetToFinish.Location = new System.Drawing.Point(781, 176);
this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSetToFinish.Name = "buttonSetToFinish"; this.buttonSetToFinish.Name = "buttonSetToFinish";
this.buttonSetToFinish.Size = new System.Drawing.Size(170, 58); this.buttonSetToFinish.Size = new System.Drawing.Size(170, 32);
this.buttonSetToFinish.TabIndex = 11; this.buttonSetToFinish.TabIndex = 11;
this.buttonSetToFinish.Text = "Заказ выдан"; this.buttonSetToFinish.Text = "Заказ выдан";
this.buttonSetToFinish.UseVisualStyleBackColor = true; this.buttonSetToFinish.UseVisualStyleBackColor = true;
@ -115,10 +110,10 @@
// //
// buttonSetToDone // buttonSetToDone
// //
this.buttonSetToDone.Location = new System.Drawing.Point(781, 175); this.buttonSetToDone.Location = new System.Drawing.Point(781, 140);
this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSetToDone.Name = "buttonSetToDone"; this.buttonSetToDone.Name = "buttonSetToDone";
this.buttonSetToDone.Size = new System.Drawing.Size(170, 58); this.buttonSetToDone.Size = new System.Drawing.Size(170, 32);
this.buttonSetToDone.TabIndex = 10; this.buttonSetToDone.TabIndex = 10;
this.buttonSetToDone.Text = "Заказ готов"; this.buttonSetToDone.Text = "Заказ готов";
this.buttonSetToDone.UseVisualStyleBackColor = true; this.buttonSetToDone.UseVisualStyleBackColor = true;
@ -126,10 +121,10 @@
// //
// buttonSetToWork // buttonSetToWork
// //
this.buttonSetToWork.Location = new System.Drawing.Point(781, 113); this.buttonSetToWork.Location = new System.Drawing.Point(781, 104);
this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSetToWork.Name = "buttonSetToWork"; this.buttonSetToWork.Name = "buttonSetToWork";
this.buttonSetToWork.Size = new System.Drawing.Size(170, 58); this.buttonSetToWork.Size = new System.Drawing.Size(170, 32);
this.buttonSetToWork.TabIndex = 9; this.buttonSetToWork.TabIndex = 9;
this.buttonSetToWork.Text = "Отдать на выполнение"; this.buttonSetToWork.Text = "Отдать на выполнение";
this.buttonSetToWork.UseVisualStyleBackColor = true; this.buttonSetToWork.UseVisualStyleBackColor = true;
@ -137,15 +132,37 @@
// //
// buttonCreateOrder // buttonCreateOrder
// //
this.buttonCreateOrder.Location = new System.Drawing.Point(781, 51); this.buttonCreateOrder.Location = new System.Drawing.Point(781, 68);
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(170, 58); this.buttonCreateOrder.Size = new System.Drawing.Size(170, 32);
this.buttonCreateOrder.TabIndex = 8; this.buttonCreateOrder.TabIndex = 8;
this.buttonCreateOrder.Text = "Создать заказ"; this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true; this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
// //
// buttonAddCannedInShop
//
this.buttonAddCannedInShop.Location = new System.Drawing.Point(781, 248);
this.buttonAddCannedInShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAddCannedInShop.Name = "buttonAddCannedInShop";
this.buttonAddCannedInShop.Size = new System.Drawing.Size(170, 43);
this.buttonAddCannedInShop.TabIndex = 13;
this.buttonAddCannedInShop.Text = "Добавить консерву в магазин";
this.buttonAddCannedInShop.UseVisualStyleBackColor = true;
this.buttonAddCannedInShop.Click += new System.EventHandler(this.ButtonAddCannedInShop_Click);
//
// buttonSellCanned
//
this.buttonSellCanned.Location = new System.Drawing.Point(781, 295);
this.buttonSellCanned.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSellCanned.Name = "buttonSellCanned";
this.buttonSellCanned.Size = new System.Drawing.Size(170, 32);
this.buttonSellCanned.TabIndex = 14;
this.buttonSellCanned.Text = "Продать консерву";
this.buttonSellCanned.UseVisualStyleBackColor = true;
this.buttonSellCanned.Click += new System.EventHandler(this.ButtonSellCanned_Click);
//
// dataGridView // dataGridView
// //
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@ -158,17 +175,6 @@
this.dataGridView.Size = new System.Drawing.Size(755, 426); this.dataGridView.Size = new System.Drawing.Size(755, 426);
this.dataGridView.TabIndex = 7; this.dataGridView.TabIndex = 7;
// //
// buttonAddCannedInShop
//
this.buttonAddCannedInShop.Location = new System.Drawing.Point(781, 361);
this.buttonAddCannedInShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAddCannedInShop.Name = "buttonAddCannedInShop";
this.buttonAddCannedInShop.Size = new System.Drawing.Size(170, 58);
this.buttonAddCannedInShop.TabIndex = 13;
this.buttonAddCannedInShop.Text = "Добавить консерву в магазин";
this.buttonAddCannedInShop.UseVisualStyleBackColor = true;
this.buttonAddCannedInShop.Click += new System.EventHandler(this.ButtonAddCannedInShop_Click);
//
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -180,6 +186,7 @@
this.Controls.Add(this.buttonSetToWork); this.Controls.Add(this.buttonSetToWork);
this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.buttonAddCannedInShop); this.Controls.Add(this.buttonAddCannedInShop);
this.Controls.Add(this.buttonSellCanned);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip); this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip; this.MainMenuStrip = this.menuStrip;
@ -207,6 +214,7 @@
private Button buttonSetToWork; private Button buttonSetToWork;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonAddCannedInShop; private Button buttonAddCannedInShop;
private Button buttonSellCanned;
private DataGridView dataGridView; private DataGridView dataGridView;
} }
} }

View File

@ -69,6 +69,15 @@ namespace FishFactoryView
{ {
form.ShowDialog(); form.ShowDialog();
} }
}
private void ButtonSellCanned_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSellCanned));
if (service is FormSellCanned form)
{
form.ShowDialog();
LoadData();
}
} }
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void ButtonCreateOrder_Click(object sender, EventArgs e)
{ {
@ -89,13 +98,7 @@ namespace FishFactoryView
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{ {
Id = id, Id = id
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString(),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
}); });
if (!operationResult) if (!operationResult)
{ {
@ -120,13 +123,7 @@ namespace FishFactoryView
{ {
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{ {
Id = id, Id = id
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString(),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
}); });
if (!operationResult) if (!operationResult)
{ {
@ -151,13 +148,7 @@ namespace FishFactoryView
{ {
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
{ {
Id = id, Id = id
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString(),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
}); });
if (!operationResult) if (!operationResult)
{ {

View File

@ -0,0 +1,126 @@
namespace FishFactoryView
{
partial class FormSellCanned
{
/// <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.labelCanned = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.comboBoxCanned = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelCanned
//
this.labelCanned.AutoSize = true;
this.labelCanned.Location = new System.Drawing.Point(9, 11);
this.labelCanned.Name = "labelCanned";
this.labelCanned.Size = new System.Drawing.Size(39, 15);
this.labelCanned.TabIndex = 0;
this.labelCanned.Text = "Консерва";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(11, 51);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(72, 15);
this.labelCount.TabIndex = 1;
this.labelCount.Text = "Количество";
//
// comboBoxCanned
//
this.comboBoxCanned.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCanned.FormattingEnabled = true;
this.comboBoxCanned.Location = new System.Drawing.Point(100, 11);
this.comboBoxCanned.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxCanned.Name = "comboBoxCanned";
this.comboBoxCanned.Size = new System.Drawing.Size(230, 23);
this.comboBoxCanned.TabIndex = 3;
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(100, 51);
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(230, 23);
this.textBoxCount.TabIndex = 4;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(160, 78);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 6;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(248, 78);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormSellCanned
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(349, 119);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.comboBoxCanned);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelCanned);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormSellCanned";
this.Text = "Продажа консерв";
this.Load += new System.EventHandler(this.FormSellCanned_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelCanned;
private Label labelCount;
private ComboBox comboBoxCanned;
private TextBox textBoxCount;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,81 @@
using Microsoft.Extensions.Logging;
using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.SearchModels;
namespace FishFactoryView
{
public partial class FormSellCanned : Form
{
private readonly ILogger _logger;
private readonly ICannedLogic _logicCanned;
private readonly IShopLogic _logicShop;
public FormSellCanned(ILogger<FormSellCanned> logger, ICannedLogic logicCanned, IShopLogic logicShop)
{
InitializeComponent();
_logger = logger;
_logicCanned = logicCanned;
_logicShop = logicShop;
}
private void FormSellCanned_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка списка консервы для продажи");
try
{
var list = _logicCanned.ReadList(null);
if (list != null)
{
comboBoxCanned.DisplayMember = "CannedName";
comboBoxCanned.ValueMember = "Id";
comboBoxCanned.DataSource = list;
comboBoxCanned.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка консерв");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле 'Количество'", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxCanned.SelectedValue == null)
{
MessageBox.Show("Выберите консерву", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Продажа консерв");
try
{
var operationResult = _logicShop.SellCanned(_logicCanned.ReadElement(new CannedSearchModel()
{
Id = Convert.ToInt32(comboBoxCanned.SelectedValue)
})!, Convert.ToInt32(textBoxCount.Text));
if (!operationResult)
{
throw new Exception("Ошибка при продаже консервы. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка продажи консервы");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -34,13 +34,16 @@
this.labelTime = new System.Windows.Forms.Label(); this.labelTime = new System.Windows.Forms.Label();
this.labelAddress = new System.Windows.Forms.Label(); this.labelAddress = new System.Windows.Forms.Label();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.labelShop = new System.Windows.Forms.Label();
this.textBoxShop = new System.Windows.Forms.TextBox();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCannedName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCannedName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.labelShop = new System.Windows.Forms.Label();
this.textBoxShop = new System.Windows.Forms.TextBox();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.labelCount = new System.Windows.Forms.Label();
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonSave // buttonSave
@ -69,7 +72,7 @@
// //
this.textBoxAddress.Location = new System.Drawing.Point(159, 27); this.textBoxAddress.Location = new System.Drawing.Point(159, 27);
this.textBoxAddress.Name = "textBoxAddress"; this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(221, 23); this.textBoxAddress.Size = new System.Drawing.Size(141, 23);
this.textBoxAddress.TabIndex = 14; this.textBoxAddress.TabIndex = 14;
// //
// labelTime // labelTime
@ -106,6 +109,23 @@
this.dataGridView.Size = new System.Drawing.Size(581, 240); this.dataGridView.Size = new System.Drawing.Size(581, 240);
this.dataGridView.TabIndex = 11; this.dataGridView.TabIndex = 11;
// //
// ColumnID
//
this.ColumnID.HeaderText = "ID";
this.ColumnID.Name = "ColumnID";
this.ColumnID.Visible = false;
//
// ColumnCannedName
//
this.ColumnCannedName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ColumnCannedName.HeaderText = "Консерва";
this.ColumnCannedName.Name = "ColumnCannedName";
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount";
//
// labelShop // labelShop
// //
this.labelShop.AutoSize = true; this.labelShop.AutoSize = true;
@ -124,33 +144,34 @@
// //
// dateTimePicker // dateTimePicker
// //
this.dateTimePicker.Location = new System.Drawing.Point(386, 27); this.dateTimePicker.Location = new System.Drawing.Point(306, 27);
this.dateTimePicker.Name = "dateTimePicker"; this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(207, 23); this.dateTimePicker.Size = new System.Drawing.Size(141, 23);
this.dateTimePicker.TabIndex = 19; this.dateTimePicker.TabIndex = 19;
// //
// ColumnID // labelCount
// //
this.ColumnID.HeaderText = "ID"; this.labelCount.AutoSize = true;
this.ColumnID.Name = "ColumnID"; this.labelCount.Location = new System.Drawing.Point(453, 9);
this.ColumnID.Visible = false; this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(134, 15);
this.labelCount.TabIndex = 20;
this.labelCount.Text = "Вместимость магазина";
// //
// ColumnCannedName // numericUpDownCount
// //
this.ColumnCannedName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.numericUpDownCount.Location = new System.Drawing.Point(453, 27);
this.ColumnCannedName.HeaderText = "Консерва"; this.numericUpDownCount.Name = "numericUpDownCount";
this.ColumnCannedName.Name = "ColumnCannedName"; this.numericUpDownCount.Size = new System.Drawing.Size(140, 23);
// this.numericUpDownCount.TabIndex = 21;
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount";
// //
// FormShop // FormShop
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(605, 337); this.ClientSize = new System.Drawing.Size(605, 337);
this.Controls.Add(this.numericUpDownCount);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.dateTimePicker); this.Controls.Add(this.dateTimePicker);
this.Controls.Add(this.textBoxShop); this.Controls.Add(this.textBoxShop);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
@ -165,6 +186,7 @@
this.Load += new System.EventHandler(this.FormShop_Load); this.Load += new System.EventHandler(this.FormShop_Load);
this.Click += new System.EventHandler(this.FormShop_Load); this.Click += new System.EventHandler(this.FormShop_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -184,5 +206,7 @@
private DataGridViewTextBoxColumn ColumnID; private DataGridViewTextBoxColumn ColumnID;
private DataGridViewTextBoxColumn ColumnCannedName; private DataGridViewTextBoxColumn ColumnCannedName;
private DataGridViewTextBoxColumn ColumnCount; private DataGridViewTextBoxColumn ColumnCount;
private Label labelCount;
private NumericUpDown numericUpDownCount;
} }
} }

View File

@ -39,6 +39,7 @@ namespace FishFactoryView
textBoxShop.Text = view.ShopName; textBoxShop.Text = view.ShopName;
textBoxAddress.Text = view.Address; textBoxAddress.Text = view.Address;
dateTimePicker.Text = view.DateOpening.ToString(); dateTimePicker.Text = view.DateOpening.ToString();
numericUpDownCount.Value = view.MaxCountCanned;
_shopListCanned = view.ListCanned ?? new Dictionary<int, (ICannedModel, int)>(); _shopListCanned = view.ListCanned ?? new Dictionary<int, (ICannedModel, int)>();
LoadData(); LoadData();
} }
@ -54,7 +55,7 @@ namespace FishFactoryView
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка консервы магазина"); _logger.LogInformation("Загрузка консерв магазина");
try try
{ {
if (_shopListCanned != null) if (_shopListCanned != null)
@ -94,7 +95,8 @@ namespace FishFactoryView
ShopName = textBoxShop.Text, ShopName = textBoxShop.Text,
Address = textBoxAddress.Text, Address = textBoxAddress.Text,
DateOpening = dateTimePicker.Value.Date, DateOpening = dateTimePicker.Value.Date,
ListCanned = _shopListCanned MaxCountCanned = (int)numericUpDownCount.Value,
ListCanned = _shopListCanned
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult) if (!operationResult)

View File

@ -60,9 +60,6 @@
<metadata name="ColumnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="ColumnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="ColumnSushiName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>

View File

@ -130,7 +130,7 @@
this.Controls.Add(this.comboBoxShop); this.Controls.Add(this.comboBoxShop);
this.Controls.Add(this.labelShop); this.Controls.Add(this.labelShop);
this.Name = "FormShopCanned"; this.Name = "FormShopCanned";
this.Text = "Поступление консервы в рыбный завод"; this.Text = "Поступление консервы в рыбный завод";
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging; using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace FishFactoryView namespace FishFactoryView
{ {

View File

@ -4,12 +4,8 @@ using NLog.Extensions.Logging;
using FishFactoryBusinessLogic.BusinessLogics; using FishFactoryBusinessLogic.BusinessLogics;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.StoragesContracts;
using FishFactoryListImplement.Implements; using FishFactoryFileImplement.Implements;
<<<<<<< Updated upstream
using FishFactoryView;
=======
using CannedBusinessLogic; using CannedBusinessLogic;
>>>>>>> Stashed changes
namespace FishFactoryView namespace FishFactoryView
{ {
@ -48,10 +44,7 @@ namespace FishFactoryView
services.AddTransient<IIngredientLogic, IngredientLogic>(); services.AddTransient<IIngredientLogic, IngredientLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ICannedLogic, CannedLogic>(); services.AddTransient<ICannedLogic, CannedLogic>();
<<<<<<< Updated upstream
=======
services.AddTransient<IShopLogic, ShopLogic>(); services.AddTransient<IShopLogic, ShopLogic>();
>>>>>>> Stashed changes
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormIngredient>(); services.AddTransient<FormIngredient>();
services.AddTransient<FormIngredients>(); services.AddTransient<FormIngredients>();
@ -59,12 +52,10 @@ namespace FishFactoryView
services.AddTransient<FormCanned>(); services.AddTransient<FormCanned>();
services.AddTransient<FormCannedIngredients>(); services.AddTransient<FormCannedIngredients>();
services.AddTransient<FormListCanned>(); services.AddTransient<FormListCanned>();
<<<<<<< Updated upstream
=======
services.AddTransient<FormShopCanned>(); services.AddTransient<FormShopCanned>();
services.AddTransient<FormShops>(); services.AddTransient<FormShops>();
services.AddTransient<FormShop>(); services.AddTransient<FormShop>();
>>>>>>> Stashed changes services.AddTransient<FormSellCanned>();
} }
} }
} }