This commit is contained in:
m1aksim1 2023-04-03 18:01:26 +04:00
commit dd52116f62
31 changed files with 1482 additions and 301 deletions

View File

@ -0,0 +1,60 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models;
using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models
{
public class Component : IComponentModel
{
public int Id { get; private set; }
public string ComponentName { get; private set; } = string.Empty;
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel model)
{
if (model == null)
{
return null;
}
return new Component()
{
Id = model.Id,
ComponentName = model.ComponentName,
Cost = model.Cost
};
}
public static Component? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Component()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ComponentName = element.Element("ComponentName")!.Value,
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
};
}
public void Update(ComponentBindingModel model)
{
if (model == null)
{
return;
}
ComponentName = model.ComponentName;
Cost = model.Cost;
}
public ComponentViewModel GetViewModel => new()
{
Id = Id,
ComponentName = ComponentName,
Cost = Cost
};
public XElement GetXElement => new("Component",
new XAttribute("Id", Id),
new XElement("ComponentName", ComponentName),
new XElement("Cost", Cost.ToString()));
}
}

View File

@ -0,0 +1,79 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.SearchModels;
using SoftwareInstallationContracts.StoragesContracts;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationFileImplement.Models;
namespace SoftwareInstallationFileImplement.Implements
{
public class ComponentStorage : IComponentStorage
{
private readonly DataFileSingleton _source;
public ComponentStorage()
{
_source = DataFileSingleton.GetInstance();
}
public List<ComponentViewModel> GetFullList()
{
return _source.Components
.Select(x => x.GetViewModel)
.ToList();
}
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName))
{
return new();
}
return _source.Components
.Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel)
.ToList();
}
public ComponentViewModel? GetElement(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
{
return null;
}
return _source.Components.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.ComponentName) &&
x.ComponentName == model.ComponentName) ||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public ComponentViewModel? Insert(ComponentBindingModel model)
{
model.Id = _source.Components.Count > 0 ? _source.Components.Max(x => x.Id) + 1 : 1;
var newComponent = Component.Create(model);
if (newComponent == null)
{
return null;
}
_source.Components.Add(newComponent);
_source.SaveComponents();
return newComponent.GetViewModel;
}
public ComponentViewModel? Update(ComponentBindingModel model)
{
var component = _source.Components.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
_source.SaveComponents();
return component.GetViewModel;
}
public ComponentViewModel? Delete(ComponentBindingModel model)
{
var element = _source.Components.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
_source.Components.Remove(element);
_source.SaveComponents();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,54 @@
using SoftwareInstallationFileImplement.Models;
using System.Xml.Linq;
namespace SoftwareInstallationFileImplement
{
public class DataFileSingleton
{
private static DataFileSingleton? instance;
private readonly string ComponentFileName = "Component.xml";
private readonly string OrderFileName = "Order.xml";
private readonly string PackageFileName = "Package.xml";
private readonly string ShopFileName = "Shop.xml";
public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; }
public List<Package> Packages { get; private set; }
public List<Shop> Shops { get; private set; }
public static DataFileSingleton GetInstance()
{
if (instance == null)
{
instance = new DataFileSingleton();
}
return instance;
}
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
public void SavePackages() => SaveData(Packages, PackageFileName, "Packages", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
private DataFileSingleton()
{
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Packages = LoadData(PackageFileName, "Package", x => Package.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,96 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Enums;
using SoftwareInstallationDataModels.Models;
using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int PackageId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; }
public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
PackageId = model.PackageId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
Id = model.Id,
};
}
public static Order? Create(XElement element)
{
if (element == null)
{
return null;
}
var dateImplement = element.Element("DateImplement")!.Value;
return new()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value),
PackageId = Convert.ToInt32(element.Element("PackageId")!.Value),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
DateImplement = string.IsNullOrEmpty(dateImplement) ? null : Convert.ToDateTime(dateImplement),
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
PackageId = model.PackageId;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement;
Id = model.Id;
}
public OrderViewModel GetViewModel => new()
{
PackageName = DataFileSingleton.GetInstance().Packages.FirstOrDefault(x => x.Id == PackageId)?.PackageName ?? string.Empty,
PackageId = PackageId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
Id = Id,
};
public XElement GetXElement => new("Order",
new XAttribute("Id", Id),
new XElement("PackageId", PackageId),
new XElement("Count", Count),
new XElement("Sum", Sum.ToString()),
new XElement("Status", (int)Status),
new XElement("DateCreate", DateCreate),
new XElement("DateImplement", DateImplement)
);
}
}

View File

@ -0,0 +1,76 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.SearchModels;
using SoftwareInstallationContracts.StoragesContracts;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationFileImplement.Models;
namespace SoftwareInstallationFileImplement
{
public class OrderStorage : IOrderStorage
{
private readonly DataFileSingleton _source;
public OrderStorage()
{
_source = DataFileSingleton.GetInstance();
}
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 element.GetViewModel;
}
return null;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
return _source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = GetElement(model);
return result != null ? new() { result } : new();
}
public List<OrderViewModel> GetFullList()
{
return _source.Orders
.Select(x => x.GetViewModel)
.ToList();
}
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 newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
var order = _source.Orders.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
_source.SaveOrders();
return order.GetViewModel;
}
}
}

View File

@ -0,0 +1,86 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models;
using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models
{
public class Package : IPackageModel
{
public int Id { get; private set; }
public string PackageName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _PackageComponents = null;
public Dictionary<int, (IComponentModel, int)> PackageComponents
{
get
{
if (_PackageComponents == null)
{
var source = DataFileSingleton.GetInstance();
_PackageComponents = Components.ToDictionary(x => x.Key, y =>
((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!,
y.Value));
}
return _PackageComponents;
}
}
public static Package? Create(PackageBindingModel model)
{
if (model == null)
{
return null;
}
return new Package()
{
Id = model.Id,
PackageName = model.PackageName,
Price = model.Price,
Components = model.PackageComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Package? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Package()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
PackageName = element.Element("PackageName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value),
Components = element.Element("PackageComponents")!.Elements("PackageComponent").ToDictionary(x =>
Convert.ToInt32(x.Element("Key")?.Value), x =>
Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(PackageBindingModel model)
{
if (model == null)
{
return;
}
PackageName = model.PackageName;
Price = model.Price;
Components = model.PackageComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
_PackageComponents = null;
}
public PackageViewModel GetViewModel => new()
{
Id = Id,
PackageName = PackageName,
Price = Price,
PackageComponents = PackageComponents
};
public XElement GetXElement => new("Package",
new XAttribute("Id", Id),
new XElement("PackageName", PackageName),
new XElement("Price", Price.ToString()),
new XElement("PackageComponents", Components.Select(x =>
new XElement("PackageComponent",
new XElement("Key", x.Key),
new XElement("Value", x.Value))).ToArray()));
}
}

View File

@ -0,0 +1,85 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.SearchModels;
using SoftwareInstallationContracts.StoragesContracts;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationFileImplement.Models;
namespace SoftwareInstallationFileImplement
{
public class PackageStorage : IPackageStorage
{
private readonly DataFileSingleton _source;
public PackageStorage()
{
_source = DataFileSingleton.GetInstance();
}
public PackageViewModel? Delete(PackageBindingModel model)
{
var element = _source.Packages.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
_source.Packages.Remove(element);
_source.SavePackages();
return element.GetViewModel;
}
return null;
}
public PackageViewModel? GetElement(PackageSearchModel model)
{
if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue)
{
return null;
}
return _source.Packages.FirstOrDefault
(x => (!string.IsNullOrEmpty(model.PackageName) && x.PackageName == model.PackageName) ||
(model.Id.HasValue && x.Id == model.Id)
)?.GetViewModel;
}
public List<PackageViewModel> GetFilteredList(PackageSearchModel model)
{
if (string.IsNullOrEmpty(model.PackageName))
{
return new();
}
return _source.Packages
.Select(x => x.GetViewModel)
.Where(x => x.PackageName.Contains(model.PackageName))
.ToList();
}
public List<PackageViewModel> GetFullList()
{
return _source.Packages
.Select(x => x.GetViewModel)
.ToList();
}
public PackageViewModel? Insert(PackageBindingModel model)
{
model.Id = _source.Packages.Count > 0 ? _source.Packages.Max(x => x.Id) + 1 : 1;
var newPackage = Package.Create(model);
if (newPackage == null)
{
return null;
}
_source.Packages.Add(newPackage);
_source.SavePackages();
return newPackage.GetViewModel;
}
public PackageViewModel? Update(PackageBindingModel model)
{
var package = _source.Packages.FirstOrDefault(x => x.Id == model.Id);
if (package == null)
{
return null;
}
package.Update(model);
_source.SavePackages();
return package.GetViewModel;
}
}
}

View File

@ -0,0 +1,109 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels;
using SoftwareInstallationDataModels.Models;
using System.Xml.Linq;
namespace SoftwareInstallationFileImplement
{
public class Shop : IShopModel
{
public string Name { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public int MaxCountPackages { get; private set; }
public DateTime DateOpening { get; private set; }
public Dictionary<int, int> CountPackages { get; private set; } = new();
private Dictionary<int, (IPackageModel, int)>? _cachedPackages = null;
public Dictionary<int, (IPackageModel, int)> Packages
{
get
{
if (_cachedPackages == null)
{
var source = DataFileSingleton.GetInstance();
_cachedPackages = CountPackages
.ToDictionary(x => x.Key, x => (source.Packages
.FirstOrDefault(y => y.Id == x.Key)! as IPackageModel, x.Value));
}
return _cachedPackages;
}
}
public int Id { get; private set; }
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
Name = model.Name,
Address = model.Address,
DateOpening = model.DateOpening,
MaxCountPackages = model.MaxCountPackages,
CountPackages = new()
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
Name = element.Element("Name")!.Value,
Address = element.Element("Address")!.Value,
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
MaxCountPackages = Convert.ToInt32(element.Element("MaxCountPackages")!.Value),
CountPackages = element.Element("CountPackages")!.Elements("CountPackage")
.ToDictionary(
x => Convert.ToInt32(x.Element("Key")?.Value),
x => Convert.ToInt32(x.Element("Value")?.Value)
)
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
Name = model.Name;
Address = model.Address;
DateOpening = model.DateOpening;
CountPackages = model.Packages.ToDictionary(x => x.Key, x => x.Value.Item2);
_cachedPackages = null;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Address = Address,
Packages = Packages,
DateOpening = DateOpening,
MaxCountPackages = MaxCountPackages,
};
public XElement GetXElement => new("Shop",
new XAttribute("Id", Id),
new XElement("Name", Name),
new XElement("Address", Address),
new XElement("DateOpening", DateOpening),
new XElement("MaxCountPackages", MaxCountPackages),
new XElement("CountPackages", CountPackages
.Select(x => new XElement("CountPackage",
new XElement("Key", x.Key),
new XElement("Value", x.Value))
))
);
}
}

View File

@ -0,0 +1,110 @@
using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.SearchModels;
using SoftwareInstallationContracts.StoragesContracts;
using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels;
using SoftwareInstallationDataModels.Models;
namespace SoftwareInstallationFileImplement
{
public class ShopStorage : IShopStorage
{
private readonly DataFileSingleton _source;
public ShopStorage()
{
_source = DataFileSingleton.GetInstance();
}
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 ShopViewModel? GetElement(ShopSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
return _source.Shops.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
return _source.Shops
.Select(x => x.GetViewModel)
.Where(x => x.Name.Contains(model.Name ?? string.Empty))
.ToList();
}
public List<ShopViewModel> GetFullList()
{
return _source.Shops
.Select(shop => shop.GetViewModel)
.ToList();
}
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 bool SellPackages(IPackageModel package, int needCount)
{
var resultCount = _source.Shops
.Select(shop => shop.Packages
.FirstOrDefault(x => x.Key == package.Id).Value.Item2)
.Sum();
if (resultCount >= needCount)
{
return false;
}
foreach (var shop in _source.Shops.Where(shop => shop.Packages.ContainsKey(package.Id)))
{
var tuple = shop.Packages[package.Id];
var diff = Math.Min(tuple.Item2, needCount);
shop.Packages[package.Id] = (tuple.Item1, tuple.Item2 - diff);
needCount -= diff;
if (needCount <= 0)
{
return true;
}
}
return true;
}
}
}

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="..\SoftwareInstallationContracts\SoftwareInstallationContracts.csproj" />
<ProjectReference Include="..\SoftwareInstallationDataModels\SoftwareInstallationDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationListImp
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationView", "SoftwareInstallationView\SoftwareInstallationView.csproj", "{564F09E4-FA75-4090-BBC8-656F23FC8F3E}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationView", "SoftwareInstallationView\SoftwareInstallationView.csproj", "{564F09E4-FA75-4090-BBC8-656F23FC8F3E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftWareInstallationFileImplement", "SoftWareInstallationFileImplement\SoftWareInstallationFileImplement.csproj", "{B2816D6F-A74D-4533-8F37-3217FB028243}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -39,6 +41,10 @@ Global
{564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Release|Any CPU.Build.0 = Release|Any CPU {564F09E4-FA75-4090-BBC8-656F23FC8F3E}.Release|Any CPU.Build.0 = Release|Any CPU
{B2816D6F-A74D-4533-8F37-3217FB028243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2816D6F-A74D-4533-8F37-3217FB028243}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2816D6F-A74D-4533-8F37-3217FB028243}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2816D6F-A74D-4533-8F37-3217FB028243}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -12,10 +12,14 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly IPackageStorage _packageStorage;
private readonly IShopLogic _shopLogic;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage) public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IPackageStorage packageStorage, IShopLogic shopLogic)
{ {
_logger = logger; _logger = logger;
_shopLogic = shopLogic;
_packageStorage = packageStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
} }
public bool CreateOrder(OrderBindingModel model) public bool CreateOrder(OrderBindingModel model)
@ -101,6 +105,15 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
$"Доступный статус: {(OrderStatus)((int)viewModel.Status + 1)}", $"Доступный статус: {(OrderStatus)((int)viewModel.Status + 1)}",
nameof(viewModel)); nameof(viewModel));
} }
if (orderStatus == OrderStatus.Готов)
{
var vpackage = _packageStorage.GetElement(new() { Id = viewModel.PackageId });
if (vpackage == null || !_shopLogic.AddPackagesInShops(vpackage, viewModel.Count))
{
throw new Exception($"Не удалось заполнить магазины изделием '{vpackage?.PackageName ?? string.Empty}' из заказа {viewModel.Id}");
}
}
if (model.DateImplement == null) model.DateImplement = viewModel.DateImplement; if (model.DateImplement == null) model.DateImplement = viewModel.DateImplement;
model.Status = orderStatus; model.Status = orderStatus;
model.Sum = viewModel.Sum; model.Sum = viewModel.Sum;

View File

@ -101,6 +101,12 @@ namespace SoftwareInstallationBusinessLogic
throw new ArgumentNullException("Нет названия магазина", throw new ArgumentNullException("Нет названия магазина",
nameof(model.Name)); nameof(model.Name));
} }
if (model.MaxCountPackages < 0)
{
throw new ArgumentException(
"Максимальное количество изделий в магазине не должно быть отрицательным",
nameof(model.MaxCountPackages));
}
_logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}", _logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}",
model.Name, model.Address, model.Id); model.Name, model.Address, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel var element = _shopStorage.GetElement(new ShopSearchModel
@ -123,13 +129,22 @@ namespace SoftwareInstallationBusinessLogic
{ {
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(count)); throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(count));
} }
_logger.LogInformation("AddPackageInShop. ShopName:{ShopName}.Id:{ Id}", model.Name, model.Id);
_logger.LogInformation("AddPackageInShop. ShopName:{ShopName}.Id:{ Id}",
model.Name, model.Id);
var element = _shopStorage.GetElement(model); var element = _shopStorage.GetElement(model);
int currCount = element.Packages.Values.First().Item2;
if (element == null) if (element == null)
{ {
_logger.LogWarning("AddPackageInShop element not found"); _logger.LogWarning("AddPackageInShop element not found");
return false; return false;
} }
if (count + currCount > element.MaxCountPackages)
{
throw new ArgumentException("Количество изделий не должно быть больше максимального количества изделий");
return false;
}
_logger.LogInformation("AddPackageInShop find. Id:{Id}", element.Id); _logger.LogInformation("AddPackageInShop find. Id:{Id}", element.Id);
var prevCount = element.Packages.GetValueOrDefault(package.Id, (package, 0)).Item2; var prevCount = element.Packages.GetValueOrDefault(package.Id, (package, 0)).Item2;
@ -148,5 +163,53 @@ namespace SoftwareInstallationBusinessLogic
}); });
return true; return true;
} }
public int GetFreePlacesWithPackagesInShops(int countPackages)
{
// Сумма разностей между максимальный кол-вом изделий и суммой всех изделий в магазине
return _shopStorage.GetFullList()
.Select(x => x.MaxCountPackages - x.Packages
.Select(p => p.Value.Item2).Sum())
.Sum() - countPackages;
}
public bool AddPackagesInShops(IPackageModel package, int count)
{
if (count <= 0)
{
_logger.LogWarning("AddPackagesInShops. Количество добавляемых изделий должно быть больше 0. Количество - {count}", count);
return false;
}
var freePlaces = GetFreePlacesWithPackagesInShops(count);
if (freePlaces < 0)
{
_logger.LogInformation("AddPackagesInShops. Не удалось добавить изделия в магазины, поскольку они переполнены." +
"Освободите магазины на {places} изделий", -freePlaces);
return false;
}
foreach (var shop in _shopStorage.GetFullList())
{
var cnt = Math.Min(count, shop.MaxCountPackages - shop.Packages.Select(x => x.Value.Item2).Sum());
if (cnt <= 0)
{
continue;
}
if (!AddPackage(new() { Id = shop.Id }, package, cnt))
{
_logger.LogWarning("При добавления изделий во все магазины произошла ошибка");
return false;
}
count -= cnt;
if (count == 0)
{
return true;
}
}
return true;
}
public bool SellPackages(IPackageModel package, int needCount)
{
return _shopStorage.SellPackages(package, needCount);
}
} }
} }

View File

@ -9,6 +9,8 @@ namespace SoftwareInstallationContracts.BindingModels
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
public int MaxCountPackages { get; set; }
public DateTime DateOpening { get; set; } = DateTime.Now; public DateTime DateOpening { get; set; } = DateTime.Now;
public Dictionary<int, (IPackageModel, int)> Packages public Dictionary<int, (IPackageModel, int)> Packages
@ -19,4 +21,4 @@ namespace SoftwareInstallationContracts.BindingModels
public int Id { get; set; } public int Id { get; set; }
} }
} }

View File

@ -13,5 +13,8 @@ namespace SoftwareInstallationContracts.BusinessLogicsContracts
bool Update(ShopBindingModel model); bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model); bool Delete(ShopBindingModel model);
bool AddPackage(ShopSearchModel model, IPackageModel package, int count); bool AddPackage(ShopSearchModel model, IPackageModel package, int count);
int GetFreePlacesWithPackagesInShops(int countPackages);
bool AddPackagesInShops(IPackageModel package, int count);
public bool SellPackages(IPackageModel package, int needCount);
} }
} }

View File

@ -1,6 +1,7 @@
using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BindingModels;
using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.SearchModels;
using SoftwareInstallationContracts.ViewModels; using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models;
namespace SoftwareInstallationContracts.StoragesContracts namespace SoftwareInstallationContracts.StoragesContracts
{ {
@ -12,5 +13,7 @@ namespace SoftwareInstallationContracts.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);
public bool SellPackages(IPackageModel package, int needCount);
} }
} }

View File

@ -12,6 +12,9 @@ namespace SoftwareInstallationContracts.ViewModels
[DisplayName("Адрес магазина")] [DisplayName("Адрес магазина")]
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
[DisplayName("Максимальное количество изделий в магазине")]
public int MaxCountPackages { get; set; }
[DisplayName("Время открытия")] [DisplayName("Время открытия")]
public DateTime DateOpening { get; set; } = DateTime.Now; public DateTime DateOpening { get; set; } = DateTime.Now;
@ -23,4 +26,4 @@ namespace SoftwareInstallationContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
} }
} }

View File

@ -6,6 +6,7 @@ namespace SoftwareInstallationDataModels
{ {
string Name { get; } string Name { get; }
string Address { get; } string Address { get; }
int MaxCountPackages { get; }
DateTime DateOpening { get; } DateTime DateOpening { get; }
Dictionary<int, (IPackageModel, int)> Packages { get; } Dictionary<int, (IPackageModel, int)> Packages { get; }
} }

View File

@ -11,6 +11,8 @@ namespace SoftwareInstallationListImplement
public string Address { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty;
public int MaxCountPackages { get; private set; }
public DateTime DateOpening { get; private set; } public DateTime DateOpening { get; private set; }
public Dictionary<int, (IPackageModel, int)> Packages public Dictionary<int, (IPackageModel, int)> Packages
@ -33,6 +35,7 @@ namespace SoftwareInstallationListImplement
Name = model.Name, Name = model.Name,
Address = model.Address, Address = model.Address,
DateOpening = model.DateOpening, DateOpening = model.DateOpening,
MaxCountPackages = model.MaxCountPackages,
Packages = new() Packages = new()
}; };
} }
@ -45,6 +48,7 @@ namespace SoftwareInstallationListImplement
Name = model.Name; Name = model.Name;
Address = model.Address; Address = model.Address;
DateOpening = model.DateOpening; DateOpening = model.DateOpening;
MaxCountPackages = model.MaxCountPackages;
Packages = model.Packages; Packages = model.Packages;
} }
public ShopViewModel GetViewModel => new() public ShopViewModel GetViewModel => new()
@ -54,6 +58,7 @@ namespace SoftwareInstallationListImplement
Address = Address, Address = Address,
Packages = Packages, Packages = Packages,
DateOpening = DateOpening, DateOpening = DateOpening,
MaxCountPackages = MaxCountPackages,
}; };
} }
} }

View File

@ -2,6 +2,7 @@
using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.SearchModels;
using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.StoragesContracts;
using SoftwareInstallationContracts.ViewModels; using SoftwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models;
namespace SoftwareInstallationListImplement namespace SoftwareInstallationListImplement
{ {
@ -72,6 +73,11 @@ namespace SoftwareInstallationListImplement
return result; return result;
} }
public bool HasNeedPackages(IPackageModel package, int needCount)
{
throw new NotImplementedException();
}
public ShopViewModel? Insert(ShopBindingModel model) public ShopViewModel? Insert(ShopBindingModel model)
{ {
model.Id = 1; model.Id = 1;
@ -91,6 +97,11 @@ namespace SoftwareInstallationListImplement
return newShop.GetViewModel; return newShop.GetViewModel;
} }
public bool SellPackages(IPackageModel package, int needCount)
{
throw new NotImplementedException();
}
public ShopViewModel? Update(ShopBindingModel model) public ShopViewModel? Update(ShopBindingModel model)
{ {
foreach (var shop in _source.Shops) foreach (var shop in _source.Shops)

View File

@ -39,11 +39,11 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// comboBoxShop // textBoxShop
// //
this.textBoxShop.FormattingEnabled = true; this.textBoxShop.FormattingEnabled = true;
this.textBoxShop.Location = new System.Drawing.Point(214, 17); this.textBoxShop.Location = new System.Drawing.Point(214, 17);
this.textBoxShop.Name = "comboBoxShop"; this.textBoxShop.Name = "textBoxShop";
this.textBoxShop.Size = new System.Drawing.Size(222, 23); this.textBoxShop.Size = new System.Drawing.Size(222, 23);
this.textBoxShop.TabIndex = 3; this.textBoxShop.TabIndex = 3;
// //

View File

@ -41,10 +41,10 @@ namespace SoftwareInstallationView
_listPackages = packageLogic.ReadList(null); _listPackages = packageLogic.ReadList(null);
if (_listPackages != null) if (_listPackages != null)
{ {
textBoxPackage.DisplayMember = "PackageName"; comboBoxPackage.DisplayMember = "PackageName";
textBoxPackage.ValueMember= "Id"; comboBoxPackage.ValueMember= "Id";
textBoxPackage.DataSource = _listPackages; comboBoxPackage.DataSource = _listPackages;
textBoxPackage.SelectedItem = null; comboBoxPackage.SelectedItem = null;
} }
} }

View File

@ -28,162 +28,176 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.packageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.packageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ButtonRef = new System.Windows.Forms.Button(); this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ButtonIssuedOrder = new System.Windows.Forms.Button(); this.ButtonRef = new System.Windows.Forms.Button();
this.ButtonOrderReady = new System.Windows.Forms.Button(); this.ButtonIssuedOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); this.ButtonOrderReady = new System.Windows.Forms.Button();
this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonAddPackageInShop = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonAddPackageInShop = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout(); this.buttonSellPackage = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
// this.SuspendLayout();
// menuStrip1 //
// // menuStrip1
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { //
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem}); this.справочникиToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1125, 24); this.menuStrip1.Size = new System.Drawing.Size(1125, 24);
this.menuStrip1.TabIndex = 1; this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.packageToolStripMenuItem, this.packageToolStripMenuItem,
this.componentToolStripMenuItem, this.componentToolStripMenuItem,
this.магазиныToolStripMenuItem}); this.магазиныToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
this.справочникиToolStripMenuItem.Text = "Справочники"; this.справочникиToolStripMenuItem.Text = "Справочники";
// //
// packageToolStripMenuItem // packageToolStripMenuItem
// //
this.packageToolStripMenuItem.Name = "packageToolStripMenuItem"; this.packageToolStripMenuItem.Name = "packageToolStripMenuItem";
this.packageToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.packageToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
this.packageToolStripMenuItem.Text = "Изделия"; this.packageToolStripMenuItem.Text = "Изделия";
this.packageToolStripMenuItem.Click += new System.EventHandler(this.PackagesToolStripMenuItem_Click); this.packageToolStripMenuItem.Click += new System.EventHandler(this.PackagesToolStripMenuItem_Click);
// //
// componentToolStripMenuItem // componentToolStripMenuItem
// //
this.componentToolStripMenuItem.Name = "componentToolStripMenuItem"; this.componentToolStripMenuItem.Name = "componentToolStripMenuItem";
this.componentToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.componentToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
this.componentToolStripMenuItem.Text = "Компоненты"; this.componentToolStripMenuItem.Text = "Компоненты";
this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
// //
// ButtonRef // магазиныToolStripMenuItem
// //
this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
this.ButtonRef.Location = new System.Drawing.Point(966, 313); this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
this.ButtonRef.Name = "ButtonRef"; this.магазиныToolStripMenuItem.Text = "Магазины";
this.ButtonRef.Size = new System.Drawing.Size(147, 55); this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
this.ButtonRef.TabIndex = 12; //
this.ButtonRef.Text = "Обновить список"; // ButtonRef
this.ButtonRef.UseVisualStyleBackColor = true; //
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
// this.ButtonRef.Location = new System.Drawing.Point(966, 232);
// ButtonIssuedOrder this.ButtonRef.Name = "ButtonRef";
// this.ButtonRef.Size = new System.Drawing.Size(147, 42);
this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.ButtonRef.TabIndex = 12;
this.ButtonIssuedOrder.Location = new System.Drawing.Point(966, 210); this.ButtonRef.Text = "Обновить список";
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; this.ButtonRef.UseVisualStyleBackColor = true;
this.ButtonIssuedOrder.Size = new System.Drawing.Size(147, 55); this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
this.ButtonIssuedOrder.TabIndex = 11; //
this.ButtonIssuedOrder.Text = "Заказ выдан"; // ButtonIssuedOrder
this.ButtonIssuedOrder.UseVisualStyleBackColor = true; //
this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
// this.ButtonIssuedOrder.Location = new System.Drawing.Point(966, 184);
// ButtonOrderReady this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
// this.ButtonIssuedOrder.Size = new System.Drawing.Size(147, 42);
this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.ButtonIssuedOrder.TabIndex = 11;
this.ButtonOrderReady.Location = new System.Drawing.Point(966, 149); this.ButtonIssuedOrder.Text = "Заказ выдан";
this.ButtonOrderReady.Name = "ButtonOrderReady"; this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
this.ButtonOrderReady.Size = new System.Drawing.Size(147, 55); this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
this.ButtonOrderReady.TabIndex = 10; //
this.ButtonOrderReady.Text = "Заказ готов"; // ButtonOrderReady
this.ButtonOrderReady.UseVisualStyleBackColor = true; //
this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
// this.ButtonOrderReady.Location = new System.Drawing.Point(966, 136);
// buttonTakeOrderInWork this.ButtonOrderReady.Name = "ButtonOrderReady";
// this.ButtonOrderReady.Size = new System.Drawing.Size(147, 42);
this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.ButtonOrderReady.TabIndex = 10;
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(966, 88); this.ButtonOrderReady.Text = "Заказ готов";
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; this.ButtonOrderReady.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 55); this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
this.buttonTakeOrderInWork.TabIndex = 9; //
this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; // buttonTakeOrderInWork
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; //
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
// this.buttonTakeOrderInWork.Location = new System.Drawing.Point(966, 88);
// buttonCreateOrder this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
// this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 42);
this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonTakeOrderInWork.TabIndex = 9;
this.buttonCreateOrder.Location = new System.Drawing.Point(966, 27); this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Size = new System.Drawing.Size(147, 55); this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
this.buttonCreateOrder.TabIndex = 8; //
this.buttonCreateOrder.Text = "Создать заказ"; // buttonCreateOrder
this.buttonCreateOrder.UseVisualStyleBackColor = true; //
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
// this.buttonCreateOrder.Location = new System.Drawing.Point(966, 40);
// dataGridView this.buttonCreateOrder.Name = "buttonCreateOrder";
// this.buttonCreateOrder.Size = new System.Drawing.Size(147, 42);
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.buttonCreateOrder.TabIndex = 8;
this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
//
// dataGridView
//
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 27); this.dataGridView.Location = new System.Drawing.Point(12, 27);
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25; this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(948, 402); this.dataGridView.Size = new System.Drawing.Size(948, 402);
this.dataGridView.TabIndex = 7; this.dataGridView.TabIndex = 7;
// //
// buttonAddPackageInShop // buttonAddPackageInShop
// //
this.buttonAddPackageInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonAddPackageInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonAddPackageInShop.Location = new System.Drawing.Point(966, 374); this.buttonAddPackageInShop.Location = new System.Drawing.Point(966, 387);
this.buttonAddPackageInShop.Name = "buttonAddPackageInShop"; this.buttonAddPackageInShop.Name = "buttonAddPackageInShop";
this.buttonAddPackageInShop.Size = new System.Drawing.Size(147, 55); this.buttonAddPackageInShop.Size = new System.Drawing.Size(147, 42);
this.buttonAddPackageInShop.TabIndex = 13; this.buttonAddPackageInShop.TabIndex = 13;
this.buttonAddPackageInShop.Text = "Пополнение магазина"; this.buttonAddPackageInShop.Text = "Пополнение магазина";
this.buttonAddPackageInShop.UseVisualStyleBackColor = true; this.buttonAddPackageInShop.UseVisualStyleBackColor = true;
this.buttonAddPackageInShop.Click += new System.EventHandler(this.ButtonAddPackageInShop_Click); this.buttonAddPackageInShop.Click += new System.EventHandler(this.ButtonAddPackageInShop_Click);
// //
// магазиныToolStripMenuItem // buttonSellPackage
// //
this.магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem"; this.buttonSellPackage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.buttonSellPackage.Location = new System.Drawing.Point(966, 339);
this.магазиныToolStripMenuItem.Text = "Магазины"; this.buttonSellPackage.Name = "buttonSellPackage";
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click); this.buttonSellPackage.Size = new System.Drawing.Size(147, 42);
// this.buttonSellPackage.TabIndex = 14;
// FormMain this.buttonSellPackage.Text = "Продать изделие";
// this.buttonSellPackage.UseVisualStyleBackColor = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.buttonSellPackage.Click += new System.EventHandler(this.ButtonSellPackage_Click);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; //
this.ClientSize = new System.Drawing.Size(1125, 441); // FormMain
this.Controls.Add(this.buttonAddPackageInShop); //
this.Controls.Add(this.ButtonRef); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.Controls.Add(this.ButtonIssuedOrder); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.ButtonOrderReady); this.ClientSize = new System.Drawing.Size(1125, 441);
this.Controls.Add(this.buttonTakeOrderInWork); this.Controls.Add(this.buttonSellPackage);
this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.buttonAddPackageInShop);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.ButtonRef);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.ButtonIssuedOrder);
this.Name = "FormMain"; this.Controls.Add(this.ButtonOrderReady);
this.Text = "Установка ПО"; this.Controls.Add(this.buttonTakeOrderInWork);
this.menuStrip1.ResumeLayout(false); this.Controls.Add(this.buttonCreateOrder);
this.menuStrip1.PerformLayout(); this.Controls.Add(this.dataGridView);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.Controls.Add(this.menuStrip1);
this.ResumeLayout(false); this.Name = "FormMain";
this.PerformLayout(); this.Text = "Установка ПО";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
} }
@ -201,5 +215,6 @@
private DataGridView dataGridView; private DataGridView dataGridView;
private ToolStripMenuItem магазиныToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem;
private Button buttonAddPackageInShop; private Button buttonAddPackageInShop;
private Button buttonSellPackage;
} }
} }

View File

@ -151,5 +151,13 @@ namespace SoftwareInstallationView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ButtonSellPackage_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSellPackage));
if (service is FormSellPackage form)
{
form.ShowDialog();
}
}
} }
} }

View File

@ -0,0 +1,133 @@
namespace SoftwareInstallationView
{
partial class FormSellPackage
{
/// <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.comboBoxPackage = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
this.buttonSell = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
this.SuspendLayout();
//
// comboBoxPackage
//
this.comboBoxPackage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxPackage.FormattingEnabled = true;
this.comboBoxPackage.Location = new System.Drawing.Point(141, 12);
this.comboBoxPackage.Name = "comboBoxPackage";
this.comboBoxPackage.Size = new System.Drawing.Size(121, 23);
this.comboBoxPackage.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(123, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Изделие на продажу:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(60, 46);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15);
this.label2.TabIndex = 2;
this.label2.Text = "Количество:";
//
// numericUpDownCount
//
this.numericUpDownCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDownCount.Location = new System.Drawing.Point(142, 46);
this.numericUpDownCount.Maximum = new decimal(new int[] {
10000000,
0,
0,
0});
this.numericUpDownCount.Name = "numericUpDownCount";
this.numericUpDownCount.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.numericUpDownCount.Size = new System.Drawing.Size(120, 23);
this.numericUpDownCount.TabIndex = 3;
//
// buttonSell
//
this.buttonSell.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSell.Location = new System.Drawing.Point(12, 90);
this.buttonSell.Name = "buttonSell";
this.buttonSell.Size = new System.Drawing.Size(123, 23);
this.buttonSell.TabIndex = 4;
this.buttonSell.Text = "Продать";
this.buttonSell.UseVisualStyleBackColor = true;
this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(142, 90);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(123, 23);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormSellPackage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(277, 122);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSell);
this.Controls.Add(this.numericUpDownCount);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBoxPackage);
this.Name = "FormSellPackage";
this.Text = "Продажа изделия";
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBoxPackage;
private Label label1;
private Label label2;
private NumericUpDown numericUpDownCount;
private Button buttonSell;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,54 @@
using SoftwareInstallationContracts.BusinessLogicsContracts;
namespace SoftwareInstallationView
{
public partial class FormSellPackage : Form
{
private readonly IShopLogic _shopLogic;
private readonly IPackageLogic _packageLogic;
public FormSellPackage(IPackageLogic logic, IShopLogic shopLogic)
{
InitializeComponent();
_packageLogic = logic;
_shopLogic = shopLogic;
var list = logic.ReadList(null);
if (list != null)
{
comboBoxPackage.DisplayMember = "PackageName";
comboBoxPackage.ValueMember = "Id";
comboBoxPackage.DataSource = list;
comboBoxPackage.SelectedItem = null;
}
}
private void ButtonSell_Click(object sender, EventArgs e)
{
if (comboBoxPackage.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка",MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (numericUpDownCount.Value <= 0)
{
MessageBox.Show("Количество должно быть больше нуля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var count = (int)numericUpDownCount.Value;
var package = _packageLogic.ReadElement(new() { Id = (int)comboBoxPackage.SelectedValue });
if (package == null || !_shopLogic.SellPackages(package, count))
{
MessageBox.Show("Не удалось продать изделия. Информацию смотрите в логах", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
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

@ -28,144 +28,171 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.PackageName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.PackageName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.textBoxAddress = new System.Windows.Forms.TextBox(); this.textBoxAddress = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button();
this.textBoxShop = new System.Windows.Forms.TextBox(); this.numericUpDownMaxPackage = new System.Windows.Forms.NumericUpDown();
this.textBoxDateOpening = new System.Windows.Forms.DateTimePicker(); this.label4 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.textBoxDateOpening = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout(); this.textBoxShop = new System.Windows.Forms.TextBox();
// ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
// label1 ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxPackage)).BeginInit();
// this.SuspendLayout();
this.label1.AutoSize = true; //
this.label1.Location = new System.Drawing.Point(12, 9); // label1
this.label1.Name = "label1"; //
this.label1.Size = new System.Drawing.Size(116, 15); this.label1.AutoSize = true;
this.label1.TabIndex = 0; this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Text = "Название магазина:"; this.label1.Name = "label1";
// this.label1.Size = new System.Drawing.Size(116, 15);
// dataGridView this.label1.TabIndex = 0;
// this.label1.Text = "Название магазина:";
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) //
// dataGridView
//
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.PackageName, this.PackageName,
this.Price, this.Price,
this.Count}); this.Count});
this.dataGridView.Location = new System.Drawing.Point(12, 64); this.dataGridView.Location = new System.Drawing.Point(12, 64);
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25; this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(583, 213); this.dataGridView.Size = new System.Drawing.Size(583, 213);
this.dataGridView.TabIndex = 2; this.dataGridView.TabIndex = 2;
// //
// PackageName // PackageName
// //
this.PackageName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.PackageName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.PackageName.HeaderText = "Имя изделия"; this.PackageName.HeaderText = "Имя изделия";
this.PackageName.Name = "PackageName"; this.PackageName.Name = "PackageName";
// //
// Price // Price
// //
this.Price.HeaderText = "Цена"; this.Price.HeaderText = "Цена";
this.Price.Name = "Price"; this.Price.Name = "Price";
// //
// Count // Count
// //
this.Count.HeaderText = "Количество"; this.Count.HeaderText = "Количество";
this.Count.Name = "Count"; this.Count.Name = "Count";
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(159, 9); this.label2.Location = new System.Drawing.Point(159, 9);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(97, 15); this.label2.Size = new System.Drawing.Size(97, 15);
this.label2.TabIndex = 3; this.label2.TabIndex = 3;
this.label2.Text = "Адрес магазина:"; this.label2.Text = "Адрес магазина:";
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(386, 9); this.label3.Location = new System.Drawing.Point(340, 9);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(87, 15); this.label3.Size = new System.Drawing.Size(100, 15);
this.label3.TabIndex = 4; this.label3.TabIndex = 4;
this.label3.Text = "Дата открытия"; this.label3.Text = "Время открытия:";
// //
// textBoxAddress // textBoxAddress
// //
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(175, 23);
this.textBoxAddress.TabIndex = 5; this.textBoxAddress.TabIndex = 5;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(492, 283); this.buttonCancel.Location = new System.Drawing.Point(492, 283);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(103, 23); this.buttonCancel.Size = new System.Drawing.Size(103, 23);
this.buttonCancel.TabIndex = 7; this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Отмена"; this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
// //
// buttonSave // buttonSave
// //
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSave.Location = new System.Drawing.Point(366, 284); this.buttonSave.Location = new System.Drawing.Point(366, 284);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(120, 22); this.buttonSave.Size = new System.Drawing.Size(120, 22);
this.buttonSave.TabIndex = 8; this.buttonSave.TabIndex = 8;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
// //
// textBoxShop // numericUpDownMaxPackage
// //
this.textBoxShop.Location = new System.Drawing.Point(13, 27); this.numericUpDownMaxPackage.Location = new System.Drawing.Point(462, 27);
this.textBoxShop.Name = "textBoxShop"; this.numericUpDownMaxPackage.Maximum = new decimal(new int[] {
this.textBoxShop.Size = new System.Drawing.Size(140, 23); 10000000,
this.textBoxShop.TabIndex = 9; 0,
// 0,
// textBoxDateOpening 0});
// this.numericUpDownMaxPackage.Name = "numericUpDownMaxPackage";
this.textBoxDateOpening.Location = new System.Drawing.Point(386, 27); this.numericUpDownMaxPackage.Size = new System.Drawing.Size(133, 23);
this.textBoxDateOpening.Name = "textBoxDateOpening"; this.numericUpDownMaxPackage.TabIndex = 11;
this.textBoxDateOpening.Size = new System.Drawing.Size(200, 23); //
this.textBoxDateOpening.TabIndex = 10; // label4
// //
// FormShop this.label4.AutoSize = true;
// this.label4.Location = new System.Drawing.Point(462, 9);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.label4.Name = "label4";
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.label4.Size = new System.Drawing.Size(118, 15);
this.ClientSize = new System.Drawing.Size(607, 317); this.label4.TabIndex = 12;
this.Controls.Add(this.textBoxDateOpening); this.label4.Text = "Максимум изделий:";
this.Controls.Add(this.textBoxShop); //
this.Controls.Add(this.buttonSave); // textBoxDateOpening
this.Controls.Add(this.buttonCancel); //
this.Controls.Add(this.textBoxAddress); this.textBoxDateOpening.Location = new System.Drawing.Point(340, 27);
this.Controls.Add(this.label3); this.textBoxDateOpening.Name = "textBoxDateOpening";
this.Controls.Add(this.label2); this.textBoxDateOpening.Size = new System.Drawing.Size(116, 23);
this.Controls.Add(this.dataGridView); this.textBoxDateOpening.TabIndex = 13;
this.Controls.Add(this.label1); //
this.Name = "FormShop"; // textBoxShop
this.Text = "Просмотр изделий магазина"; //
this.Load += new System.EventHandler(this.FormShop_Load); this.textBoxShop.Location = new System.Drawing.Point(12, 26);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.textBoxShop.Name = "textBoxShop";
this.ResumeLayout(false); this.textBoxShop.Size = new System.Drawing.Size(141, 23);
this.PerformLayout(); this.textBoxShop.TabIndex = 14;
//
// FormShop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(607, 317);
this.Controls.Add(this.textBoxShop);
this.Controls.Add(this.textBoxDateOpening);
this.Controls.Add(this.label4);
this.Controls.Add(this.numericUpDownMaxPackage);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.textBoxAddress);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.label1);
this.Name = "FormShop";
this.Text = "Просмотр изделий магазина";
this.Load += new System.EventHandler(this.FormShop_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxPackage)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
} }
@ -181,7 +208,9 @@
private DataGridViewTextBoxColumn PackageName; private DataGridViewTextBoxColumn PackageName;
private DataGridViewTextBoxColumn Price; private DataGridViewTextBoxColumn Price;
private DataGridViewTextBoxColumn Count; private DataGridViewTextBoxColumn Count;
private TextBox textBoxShop; private NumericUpDown numericUpDownMaxPackage;
private Label label4;
private DateTimePicker textBoxDateOpening; private DateTimePicker textBoxDateOpening;
private TextBox textBoxShop;
} }
} }

View File

@ -50,7 +50,7 @@ namespace SoftwareInstallationView
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_listShops = logic.ReadList(null); _listShops = logic.ReadList(null);
_logic = logic; _logic = logic;
} }
private void LoadData(bool extendDate = true) private void LoadData(bool extendDate = true)
@ -59,7 +59,8 @@ namespace SoftwareInstallationView
{ {
var model = GetShop(extendDate ? Id : Convert.ToInt32(null)); var model = GetShop(extendDate ? Id : Convert.ToInt32(null));
if (model != null) if (model != null)
{ {
numericUpDownMaxPackage.Value = model.MaxCountPackages;
textBoxShop.Text = model.Name; textBoxShop.Text = model.Name;
textBoxAddress.Text = model.Address; textBoxAddress.Text = model.Address;
textBoxDateOpening.Text = Convert.ToString(model.DateOpening); textBoxDateOpening.Text = Convert.ToString(model.DateOpening);
@ -101,7 +102,8 @@ namespace SoftwareInstallationView
{ {
Name = textBoxShop.Text, Name = textBoxShop.Text,
Address = textBoxAddress.Text, Address = textBoxAddress.Text,
DateOpening = dateTime DateOpening = dateTime,
MaxCountPackages = (int)numericUpDownMaxPackage.Value,
}; };
var vmodel = GetShop(Id); var vmodel = GetShop(Id);
bool operationResult = false; bool operationResult = false;

View File

@ -1,14 +1,13 @@
using SoftwareInstallationBusinessLogic.BusinessLogics; using SoftwareInstallationBusinessLogic.BusinessLogics;
using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.BusinessLogicsContracts;
using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.StoragesContracts;
using SoftwareInstallationListImplement.Implements; using SoftwareInstallationFileImplement;
using SoftwareInstallationListImplement; using SoftwareInstallationFileImplement.Implements;
using SoftwareInstallationBusinessLogic; using SoftwareInstallationBusinessLogic;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
namespace SoftwareInstallationView namespace SoftwareInstallationView
{ {
internal static class Program internal static class Program
@ -54,6 +53,7 @@ namespace SoftwareInstallationView
services.AddTransient<FormAddPackageInShop>(); services.AddTransient<FormAddPackageInShop>();
services.AddTransient<FormViewShops>(); services.AddTransient<FormViewShops>();
services.AddTransient<FormShop>(); services.AddTransient<FormShop>();
services.AddTransient<FormSellPackage>();
} }
} }
} }

View File

@ -18,6 +18,7 @@
<ProjectReference Include="..\SoftwareInstallationBusinessLogic\SoftwareInstallationBusinessLogic.csproj" /> <ProjectReference Include="..\SoftwareInstallationBusinessLogic\SoftwareInstallationBusinessLogic.csproj" />
<ProjectReference Include="..\SoftwareInstallationContracts\SoftwareInstallationContracts.csproj" /> <ProjectReference Include="..\SoftwareInstallationContracts\SoftwareInstallationContracts.csproj" />
<ProjectReference Include="..\SoftwareInstallationDataModels\SoftwareInstallationDataModels.csproj" /> <ProjectReference Include="..\SoftwareInstallationDataModels\SoftwareInstallationDataModels.csproj" />
<ProjectReference Include="..\SoftWareInstallationFileImplement\SoftWareInstallationFileImplement.csproj" />
<ProjectReference Include="..\SoftwareInstallationListImplement\SoftwareInstallationListImplement.csproj" /> <ProjectReference Include="..\SoftwareInstallationListImplement\SoftwareInstallationListImplement.csproj" />
</ItemGroup> </ItemGroup>