PIbd-22_Kurbanova_A.A._LabWork.2H #H2 #10

Closed
ALINA_KURBANOVA wants to merge 1 commits from LabWork02_Hard into LabWork01_Hard
36 changed files with 1610 additions and 519 deletions
Showing only changes of commit b4a45a20de - Show all commits

View File

@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyBusinessLogic", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyDataModels", "TypographyDataModels\TypographyDataModels.csproj", "{75576C57-02E9-4D1D-9A02-D39C1EBE992D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypographyFileImplement", "TypographyFileImplement\TypographyFileImplement.csproj", "{C6E23C8E-9FCD-40B9-B21E-F64D8BDDA9C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -39,6 +41,10 @@ Global
{75576C57-02E9-4D1D-9A02-D39C1EBE992D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75576C57-02E9-4D1D-9A02-D39C1EBE992D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75576C57-02E9-4D1D-9A02-D39C1EBE992D}.Release|Any CPU.Build.0 = Release|Any CPU
{C6E23C8E-9FCD-40B9-B21E-F64D8BDDA9C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6E23C8E-9FCD-40B9-B21E-F64D8BDDA9C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6E23C8E-9FCD-40B9-B21E-F64D8BDDA9C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6E23C8E-9FCD-40B9-B21E-F64D8BDDA9C1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,10 +1,10 @@
using TypographyContracts.BindingModels;
using TypographyDataModels.Enums;
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using Microsoft.Extensions.Logging;
using TypographyDataModels.Enums;
namespace TypographyBusinessLogic.BusinessLogics
{
@ -12,11 +12,18 @@ namespace TypographyBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
private readonly IPrintedStorage _printedStorage;
private readonly IShopStorage _shopStorage;
private readonly IShopLogic _shopLogic;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IPrintedStorage printedStorage,
IShopStorage shopStorage, IShopLogic shopLogic)
{
_logger = logger;
_orderStorage = orderStorage;
_printedStorage = printedStorage;
_shopStorage = shopStorage;
_shopLogic = shopLogic;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
@ -97,6 +104,21 @@ namespace TypographyBusinessLogic.BusinessLogics
return false;
}
if (newStatus == OrderStatus.Готов)
{
var supplyPrinted = _printedStorage.GetElement(new PrintedSearchModel { Id = orderView.PrintedId });
if (supplyPrinted == null)
{
_logger.LogWarning("Printed not found in order");
return false;
}
if(!SypplyFromOrder(supplyPrinted, orderView.Count))
{
_logger.LogWarning("Supply of printeds to shops failed");
return false;
}
}
model.Status = newStatus;
if (newStatus == OrderStatus.Выдан)
{
@ -110,5 +132,50 @@ namespace TypographyBusinessLogic.BusinessLogics
}
return true;
}
private bool SypplyFromOrder (PrintedViewModel model, int amount)
{
if(_shopStorage.GetFullList()
.Sum(x => x.MaxNumberPrinteds - x.ShopPrinteds.Sum(y => y.Value.Item2) < 0 ? 0 : x.MaxNumberPrinteds - x.ShopPrinteds.Sum(y => y.Value.Item2)) < amount)
//Тернарное выражение не учитывает переполненные обычными поставками магазины (т. к. это не отражается на других)
{
_logger.LogWarning("Insufficient capacity to accept an order");
return false;
}
foreach (var shop in _shopStorage.GetFullList())
{
int freeSpace = shop.MaxNumberPrinteds - shop.ShopPrinteds.Sum(x => x.Value.Item2);
if (freeSpace < 0)
{
continue;
}
if (freeSpace > amount)
{
if(!_shopLogic.SupplyPrinteds(new ShopSearchModel { Id = shop.Id}, model, amount))
{
_logger.LogWarning("Shop partial fill failed");
return false;
}
amount = 0;
}
if (freeSpace < amount)
{
if (!_shopLogic.SupplyPrinteds(new ShopSearchModel { Id = shop.Id }, model, freeSpace))
{
_logger.LogWarning("Shop max fill failed");
return false;
}
amount -= freeSpace;
}
if (amount <= 0)
{
return true;
}
}
return true;
}
}
}
}

View File

@ -9,6 +9,7 @@ using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
namespace TypographyBusinessLogic.BusinessLogics
{
@ -87,8 +88,8 @@ namespace TypographyBusinessLogic.BusinessLogics
return true;
}
public bool SupplyPrinteds(ShopSearchModel shop, PrintedBindingModel printed, int amount)
{
public bool SupplyPrinteds(ShopSearchModel shop, IPrintedModel printed, int amount)
{
if (shop == null)
{
throw new ArgumentNullException(nameof(shop));
@ -125,7 +126,8 @@ namespace TypographyBusinessLogic.BusinessLogics
ShopName = shopView.ShopName,
Address = shopView.Address,
OpeningDate = shopView.OpeningDate,
ShopPrinteds = shopView.ShopPrinteds
MaxNumberPrinteds = shopView.MaxNumberPrinteds,
ShopPrinteds = shopView.ShopPrinteds
}) == null)
{
_logger.LogWarning("SupplyPrinteds. Update operation failed");
@ -133,8 +135,12 @@ namespace TypographyBusinessLogic.BusinessLogics
}
return true;
}
public bool SellPrinteds(PrintedBindingModel model, int amount)
{
return _shopStorage.SellPrinteds(model, amount);
}
private void CheckModel(ShopBindingModel model, bool withParams = true)
private void CheckModel(ShopBindingModel model, bool withParams = true)
{
if (model == null)
{

View File

@ -16,7 +16,8 @@ namespace TypographyContracts.BindingModels
public string Address { get; set; } = string.Empty;
public DateTime OpeningDate { get; set; } = DateTime.Now;
public int MaxNumberPrinteds { get; set; }
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
}
}

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
namespace TypographyContracts.BusinessLogicsContracts
{
@ -16,6 +17,7 @@ namespace TypographyContracts.BusinessLogicsContracts
bool Create(ShopBindingModel model);
bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model);
bool SupplyPrinteds(ShopSearchModel shop, PrintedBindingModel printed, int amount);
}
bool SupplyPrinteds(ShopSearchModel shop, IPrintedModel printed, int amount);
bool SellPrinteds(PrintedBindingModel model, int amount);
}
}

View File

@ -12,5 +12,7 @@ namespace TypographyContracts.StoragesContracts
ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model);
}
bool SellPrinteds(PrintedBindingModel model, int amount);
}
}

View File

@ -21,6 +21,9 @@ namespace TypographyContracts.ViewModels
[DisplayName("Дата открытия")]
public DateTime OpeningDate { get; set; } = DateTime.Now;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
[DisplayName("Вместимость")]
public int MaxNumberPrinteds { get; set; }
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
}
}

View File

@ -11,6 +11,7 @@ namespace TypographyDataModels.Models
string ShopName { get; }
string Address { get; }
DateTime OpeningDate { get; }
Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; }
int MaxNumberPrinteds { get; }
Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; }
}
}

View File

@ -0,0 +1,62 @@
using TypographyFileImplement.Models;
using System.Xml.Linq;
namespace TypographyFileImplement
{
public class DataFileSingleton
{
private static DataFileSingleton? instance;
private readonly string ComponentFileName = "Component.xml";
private readonly string OrderFileName = "Order.xml";
private readonly string PrintedFileName = "Printed.xml";
private readonly string ShopFileName = "Shop.xml";
public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; }
public List<Printed> Printeds { 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 SavePrinteds() => SaveData(Printeds, PrintedFileName, "Printeds", 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)!)!;
Printeds = LoadData(PrintedFileName, "Product", x => Printed.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,85 @@
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyFileImplement.Models;
namespace TypographyFileImplement.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,94 @@
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyFileImplement.Models;
namespace TypographyFileImplement.Implements
{
public class OrderStorage : IOrderStorage
{
private readonly DataFileSingleton source;
public OrderStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<OrderViewModel> GetFullList()
{
return source.Orders
.Select(x => DefinePrintedName(x.GetViewModel))
.ToList();
}
private OrderViewModel DefinePrintedName(OrderViewModel model)
{
string? printedName = source.Printeds.FirstOrDefault(x => model.PrintedId == x.Id)?.PrintedName;
if (printedName != null)
{
model.PrintedName = printedName;
}
return model;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (model.Id == null)
{
return new();
}
return source.Orders
.Where(x => x.Id == model.Id)
.Select(x => DefinePrintedName(x.GetViewModel))
.ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
return DefinePrintedName(source.Orders
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel);
}
public OrderViewModel? Insert(OrderBindingModel model)
{
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
var newOrder = Order.Create(model);
if (newOrder == null)
{
return null;
}
source.Orders.Add(newOrder);
source.SaveOrders();
return DefinePrintedName(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 DefinePrintedName(order.GetViewModel);
}
public OrderViewModel? Delete(OrderBindingModel model)
{
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Orders.Remove(element);
source.SaveOrders();
return DefinePrintedName(element.GetViewModel);
}
return null;
}
}
}

View File

@ -0,0 +1,85 @@
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyFileImplement.Models;
namespace TypographyFileImplement.Implements
{
public class PrintedStorage : IPrintedStorage
{
private readonly DataFileSingleton source;
public PrintedStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<PrintedViewModel> GetFullList()
{
return source.Printeds
.Select(x => x.GetViewModel)
.ToList();
}
public List<PrintedViewModel> GetFilteredList(PrintedSearchModel model)
{
if (string.IsNullOrEmpty(model.PrintedName))
{
return new();
}
return source.Printeds
.Where(x => x.PrintedName.Contains(model.PrintedName))
.Select(x => x.GetViewModel)
.ToList();
}
public PrintedViewModel? GetElement(PrintedSearchModel model)
{
if (string.IsNullOrEmpty(model.PrintedName) && !model.Id.HasValue)
{
return null;
}
return source.Printeds
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.PrintedName) && x.PrintedName == model.PrintedName) ||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public PrintedViewModel? Insert(PrintedBindingModel model)
{
model.Id = source.Printeds.Count > 0 ? source.Printeds.Max(x => x.Id) + 1 : 1;
var newPrinted = Printed.Create(model);
if (newPrinted == null)
{
return null;
}
source.Printeds.Add(newPrinted);
source.SavePrinteds();
return newPrinted.GetViewModel;
}
public PrintedViewModel? Update(PrintedBindingModel model)
{
var printed = source.Printeds.FirstOrDefault(x => x.Id == model.Id);
if (printed == null)
{
return null;
}
printed.Update(model);
source.SavePrinteds();
return printed.GetViewModel;
}
public PrintedViewModel? Delete(PrintedBindingModel model)
{
var element = source.Printeds.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Printeds.Remove(element);
source.SavePrinteds();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,134 @@
using System.Linq;
using System.Net;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyFileImplement.Models;
namespace TypographyFileImplement.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 SellPrinteds(PrintedBindingModel model, int amount)
{
var sellPrinted = source.Printeds.FirstOrDefault(x => x.Id == model.Id);
if (sellPrinted == null)
{
return false;
}
if (source.Shops.SelectMany(x => x.ShopPrinteds.Where(y => y.Key == sellPrinted.Id)).Sum(x => x.Value.Item2) < amount)
{
return false;
}
foreach(var shop in source.Shops)
{
var shopPrinteds = shop.ShopPrinteds;
foreach(var printed in shopPrinteds.Where(x => x.Key == sellPrinted.Id))
{
int minAmount = amount > printed.Value.Item2 ? printed.Value.Item2 : amount;
shopPrinteds[printed.Value.Item1.Id] = (printed.Value.Item1, printed.Value.Item2 - minAmount);
amount -= minAmount;
if (amount == 0)
{
break;
}
}
Update(new ShopBindingModel
{
Id = shop.Id,
ShopName = shop.ShopName,
Address = shop.Address,
OpeningDate = shop.OpeningDate,
MaxNumberPrinteds = shop.MaxNumberPrinteds,
ShopPrinteds = shopPrinteds
});
if (amount == 0)
{
break;
}
}
return true;
}
}
}

View File

@ -0,0 +1,64 @@
using TypographyContracts.BindingModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
using System.Xml.Linq;
namespace TypographyFileImplement.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,86 @@
using TypographyContracts.BindingModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
using System.Xml.Linq;
using TypographyDataModels.Enums;
namespace TypographyFileImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int PrintedId { 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,
PrintedId = model.PrintedId,
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),
PrintedId = Convert.ToInt32(element.Element("PrintedId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
DateImplement = String.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null :
Convert.ToDateTime(element.Element("DateImplement")!.Value)
};
}
public void Update(OrderBindingModel model)
{
if (model == null)
{
return;
}
Status = model.Status;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
PrintedId = PrintedId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
public XElement GetXElement => new("Order",
new XAttribute("Id", Id),
new XElement("PrintedId", PrintedId),
new XElement("Count", Count),
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,93 @@
using TypographyContracts.BindingModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
using System.Xml.Linq;
namespace TypographyFileImplement.Models
{
public class Printed : IPrintedModel
{
public int Id { get; private set; }
public string PrintedName { 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)>? _productComponents = null;
public Dictionary<int, (IComponentModel, int)> PrintedComponents
{
get
{
if (_productComponents == null)
{
var source = DataFileSingleton.GetInstance();
_productComponents = Components.ToDictionary(x => x.Key, y =>
((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!,y.Value));
}
return _productComponents;
}
}
public static Printed? Create(PrintedBindingModel model)
{
if (model == null)
{
return null;
}
return new Printed()
{
Id = model.Id,
PrintedName = model.PrintedName,
Price = model.Price,
Components = model.PrintedComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Printed? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Printed()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
PrintedName = element.Element("ProductName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value),
Components = element.Element("ProductComponents")!.Elements("ProductComponent").ToDictionary(x =>
Convert.ToInt32(x.Element("Key")?.Value), x =>
Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(PrintedBindingModel model)
{
if (model == null)
{
return;
}
PrintedName = model.PrintedName;
Price = model.Price;
Components = model.PrintedComponents.ToDictionary(x => x.Key, x =>x.Value.Item2);
_productComponents = null;
}
public PrintedViewModel GetViewModel => new()
{
Id = Id,
PrintedName = PrintedName,
Price = Price,
PrintedComponents = PrintedComponents
};
public XElement GetXElement => new("Product",
new XAttribute("Id", Id),
new XElement("ProductName", PrintedName),
new XElement("Price", Price.ToString()),
new XElement("ProductComponents", Components.Select(x =>
new XElement("ProductComponent",
new XElement("Key", x.Key),
new XElement("Value", x.Value)))
.ToArray()));
}
}

View File

@ -0,0 +1,111 @@
using TypographyContracts.BindingModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
using System.Xml.Linq;
using System.Diagnostics;
namespace TypographyFileImplement.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 OpeningDate { get; private set; } = DateTime.Now;
public int MaxNumberPrinteds { get; private set; }
public Dictionary<int, int> Printeds { get; private set; } = new();
private Dictionary<int, (IPrintedModel, int)>? _shopPrinteds = null;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds
{
get
{
if (_shopPrinteds == null)
{
var source = DataFileSingleton.GetInstance();
_shopPrinteds = Printeds.ToDictionary(x => x.Key, y =>
((source.Printeds.FirstOrDefault(z => z.Id == y.Key) as IPrintedModel)!, y.Value));
}
return _shopPrinteds;
}
}
public static Shop? Create(ShopBindingModel model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
OpeningDate = model.OpeningDate,
MaxNumberPrinteds = model.MaxNumberPrinteds,
Printeds = model.ShopPrinteds.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Shop()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value,
Address = element.Element("Address")!.Value,
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
MaxNumberPrinteds = Convert.ToInt32(element.Element("MaxNumberPrinteds")!.Value),
Printeds = element.Element("ShopPrinteds")!.Elements("ShopPrinted").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;
OpeningDate = model.OpeningDate;
MaxNumberPrinteds = model.MaxNumberPrinteds;
Printeds = model.ShopPrinteds.ToDictionary(x => x.Key, x => x.Value.Item2);
_shopPrinteds = null;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
OpeningDate = OpeningDate,
MaxNumberPrinteds = MaxNumberPrinteds,
ShopPrinteds = ShopPrinteds
};
public XElement GetXElement => new("Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Address", Address),
new XElement("OpeningDate", OpeningDate.ToString()),
new XElement("MaxNumberPrinteds", MaxNumberPrinteds),
new XElement("ShopPrinteds", Printeds.Select(x =>
new XElement("ShopPrinted",
new XElement("Key", x.Key),
new XElement("Value", x.Value)))
.ToArray()));
}
}

View File

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

View File

@ -105,5 +105,9 @@ namespace TypographyListImplement.Implements
}
return null;
}
}
public bool SellPrinteds(PrintedBindingModel model, int amount)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
@ -15,7 +16,9 @@ namespace TypographyListImplement.Models
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; } = DateTime.Now;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; private set; } = new();
public int MaxNumberPrinteds { get; private set; }
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; private set; } = new();
public static Shop? Create(ShopBindingModel? model)
{
@ -29,7 +32,8 @@ namespace TypographyListImplement.Models
ShopName = model.ShopName,
Address = model.Address,
OpeningDate = model.OpeningDate,
ShopPrinteds = new()
MaxNumberPrinteds = model.MaxNumberPrinteds,
ShopPrinteds = new()
};
}
public void Update(ShopBindingModel? model)
@ -41,7 +45,8 @@ namespace TypographyListImplement.Models
ShopName = model.ShopName;
Address = model.Address;
OpeningDate = model.OpeningDate;
ShopPrinteds = model.ShopPrinteds;
MaxNumberPrinteds = model.MaxNumberPrinteds;
ShopPrinteds = model.ShopPrinteds;
}
public ShopViewModel GetViewModel => new()
{
@ -49,6 +54,7 @@ namespace TypographyListImplement.Models
ShopName = ShopName,
Address = Address,
OpeningDate = OpeningDate,
MaxNumberPrinteds = MaxNumberPrinteds,
ShopPrinteds = ShopPrinteds
};
}

View File

@ -20,173 +20,181 @@
base.Dispose(disposing);
}
#region Windows Form Designer generated code
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
buttonIssuedOrder = new Button();
dataGridViewOrders = new DataGridView();
buttonRef = new Button();
buttonOrderReady = new Button();
menuStrip = new MenuStrip();
directoriesToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem();
printedsToolStripMenuItem = new ToolStripMenuItem();
shopsToolStripMenuItem = new ToolStripMenuItem();
supplyToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// buttonCreateOrder
//
buttonCreateOrder.Location = new Point(1224, 70);
buttonCreateOrder.Margin = new Padding(5, 5, 5, 5);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(330, 46);
buttonCreateOrder.TabIndex = 0;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += ButtonCreateOrder_Click;
//
// buttonTakeOrderInWork
//
buttonTakeOrderInWork.Location = new Point(1224, 162);
buttonTakeOrderInWork.Margin = new Padding(5, 5, 5, 5);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(330, 46);
buttonTakeOrderInWork.TabIndex = 1;
buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
//
// buttonIssuedOrder
//
buttonIssuedOrder.Location = new Point(1224, 379);
buttonIssuedOrder.Margin = new Padding(5, 5, 5, 5);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(330, 46);
buttonIssuedOrder.TabIndex = 2;
buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
//
// dataGridViewOrders
//
dataGridViewOrders.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Location = new Point(0, 50);
dataGridViewOrders.Margin = new Padding(5, 5, 5, 5);
dataGridViewOrders.Name = "dataGridViewOrders";
dataGridViewOrders.RowHeadersVisible = false;
dataGridViewOrders.RowHeadersWidth = 51;
dataGridViewOrders.RowTemplate.Height = 29;
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewOrders.Size = new Size(1156, 506);
dataGridViewOrders.TabIndex = 3;
//
// buttonRef
//
buttonRef.Location = new Point(1224, 487);
buttonRef.Margin = new Padding(5, 5, 5, 5);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(330, 46);
buttonRef.TabIndex = 4;
buttonRef.Text = "Обновить список";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// buttonOrderReady
//
buttonOrderReady.Location = new Point(1224, 265);
buttonOrderReady.Margin = new Padding(5, 5, 5, 5);
buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.Size = new Size(330, 46);
buttonOrderReady.TabIndex = 5;
buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.UseVisualStyleBackColor = true;
buttonOrderReady.Click += ButtonOrderReady_Click;
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { directoriesToolStripMenuItem, supplyToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(10, 3, 0, 3);
menuStrip.Size = new Size(1580, 42);
menuStrip.TabIndex = 6;
menuStrip.Text = "menuStrip1";
//
// directoriesToolStripMenuItem
//
directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, printedsToolStripMenuItem, shopsToolStripMenuItem });
directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem";
directoriesToolStripMenuItem.Size = new Size(184, 36);
directoriesToolStripMenuItem.Text = "Справочники";
//
// componentsToolStripMenuItem
//
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
componentsToolStripMenuItem.Size = new Size(377, 44);
componentsToolStripMenuItem.Text = "Компоненты";
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
// printedsToolStripMenuItem
//
printedsToolStripMenuItem.Name = "printedsToolStripMenuItem";
printedsToolStripMenuItem.Size = new Size(377, 44);
printedsToolStripMenuItem.Text = "Печатная продукция";
printedsToolStripMenuItem.Click += PrintedsToolStripMenuItem_Click;
//
// shopsToolStripMenuItem
//
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
shopsToolStripMenuItem.Size = new Size(377, 44);
shopsToolStripMenuItem.Text = "Магазины";
shopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
//
// supplyToolStripMenuItem
//
supplyToolStripMenuItem.Name = "supplyToolStripMenuItem";
supplyToolStripMenuItem.Size = new Size(282, 36);
supplyToolStripMenuItem.Text = "Пополнение магазина";
supplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1580, 605);
Controls.Add(buttonOrderReady);
Controls.Add(buttonRef);
Controls.Add(dataGridViewOrders);
Controls.Add(buttonIssuedOrder);
Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Margin = new Padding(5, 5, 5, 5);
Name = "FormMain";
StartPosition = FormStartPosition.CenterScreen;
Text = "Типография";
Load += FormMain_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
buttonIssuedOrder = new Button();
dataGridViewOrders = new DataGridView();
buttonRef = new Button();
buttonOrderReady = new Button();
menuStrip = new MenuStrip();
directoriesToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem();
printedsToolStripMenuItem = new ToolStripMenuItem();
shopsToolStripMenuItem = new ToolStripMenuItem();
магазиныToolStripMenuItem = new ToolStripMenuItem();
supplyToolStripMenuItem = new ToolStripMenuItem();
saleToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// buttonCreateOrder
//
buttonCreateOrder.Location = new Point(1100, 31);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(203, 29);
buttonCreateOrder.TabIndex = 0;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += ButtonCreateOrder_Click;
//
// buttonTakeOrderInWork
//
buttonTakeOrderInWork.Location = new Point(1100, 66);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(203, 29);
buttonTakeOrderInWork.TabIndex = 1;
buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
//
// buttonIssuedOrder
//
buttonIssuedOrder.Location = new Point(1100, 136);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(203, 29);
buttonIssuedOrder.TabIndex = 2;
buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
//
// dataGridViewOrders
//
dataGridViewOrders.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Location = new Point(0, 31);
dataGridViewOrders.Name = "dataGridViewOrders";
dataGridViewOrders.RowHeadersVisible = false;
dataGridViewOrders.RowHeadersWidth = 51;
dataGridViewOrders.RowTemplate.Height = 29;
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewOrders.Size = new Size(1078, 402);
dataGridViewOrders.TabIndex = 3;
//
// buttonRef
//
buttonRef.Location = new Point(1100, 171);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(203, 29);
buttonRef.TabIndex = 4;
buttonRef.Text = "Обновить список";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// buttonOrderReady
//
buttonOrderReady.Location = new Point(1100, 101);
buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.Size = new Size(203, 29);
buttonOrderReady.TabIndex = 5;
buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.UseVisualStyleBackColor = true;
buttonOrderReady.Click += ButtonOrderReady_Click;
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { directoriesToolStripMenuItem, магазиныToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1315, 28);
menuStrip.TabIndex = 6;
menuStrip.Text = "menuStrip1";
//
// directoriesToolStripMenuItem
//
directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, printedsToolStripMenuItem, shopsToolStripMenuItem });
directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem";
directoriesToolStripMenuItem.Size = new Size(117, 24);
directoriesToolStripMenuItem.Text = "Справочники";
//
// componentsToolStripMenuItem
//
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
componentsToolStripMenuItem.Size = new Size(237, 26);
componentsToolStripMenuItem.Text = "Компоненты";
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
// printedsToolStripMenuItem
//
printedsToolStripMenuItem.Name = "printedsToolStripMenuItem";
printedsToolStripMenuItem.Size = new Size(237, 26);
printedsToolStripMenuItem.Text = "Печатная продукция";
printedsToolStripMenuItem.Click += PrintedsToolStripMenuItem_Click;
//
// shopsToolStripMenuItem
//
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
shopsToolStripMenuItem.Size = new Size(237, 26);
shopsToolStripMenuItem.Text = "Магазины";
shopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
//
// магазиныToolStripMenuItem
//
магазиныToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { supplyToolStripMenuItem, saleToolStripMenuItem });
магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
магазиныToolStripMenuItem.Size = new Size(94, 24);
магазиныToolStripMenuItem.Text = "Магазины";
//
// supplyToolStripMenuItem
//
supplyToolStripMenuItem.Name = "supplyToolStripMenuItem";
supplyToolStripMenuItem.Size = new Size(224, 26);
supplyToolStripMenuItem.Text = "Пополнение";
supplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click;
//
// saleToolStripMenuItem
//
saleToolStripMenuItem.Name = "saleToolStripMenuItem";
saleToolStripMenuItem.Size = new Size(224, 26);
saleToolStripMenuItem.Text = "Продажа";
saleToolStripMenuItem.Click += SaleToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1315, 433);
Controls.Add(buttonOrderReady);
Controls.Add(buttonRef);
Controls.Add(dataGridViewOrders);
Controls.Add(buttonIssuedOrder);
Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
StartPosition = FormStartPosition.CenterScreen;
Text = "Типография";
Load += FormMain_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
#endregion
private Button buttonCreateOrder;
private Button buttonCreateOrder;
private Button buttonTakeOrderInWork;
private Button buttonIssuedOrder;
private DataGridView dataGridViewOrders;
@ -197,6 +205,8 @@
private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem printedsToolStripMenuItem;
private ToolStripMenuItem shopsToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem supplyToolStripMenuItem;
private ToolStripMenuItem saleToolStripMenuItem;
}
}

View File

@ -78,6 +78,15 @@ namespace TypographyView
}
}
private void SaleToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSale));
if (service is FormSale form)
{
form.ShowDialog();
}
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -0,0 +1,120 @@
namespace TypographyView
{
partial class FormSale
{
/// <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()
{
buttonSave = new Button();
buttonCancel = new Button();
comboBoxPrinted = new ComboBox();
textBoxAmount = new TextBox();
labelAmount = new Label();
labelPrinted = new Label();
SuspendLayout();
//
// buttonSave
//
buttonSave.Location = new Point(205, 80);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(102, 29);
buttonSave.TabIndex = 0;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(313, 80);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(102, 29);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// comboBoxPrinted
//
comboBoxPrinted.FormattingEnabled = true;
comboBoxPrinted.Location = new Point(172, 12);
comboBoxPrinted.Name = "comboBoxPrinted";
comboBoxPrinted.Size = new Size(243, 28);
comboBoxPrinted.TabIndex = 2;
//
// textBoxAmount
//
textBoxAmount.Location = new Point(172, 46);
textBoxAmount.Name = "textBoxAmount";
textBoxAmount.Size = new Size(243, 27);
textBoxAmount.TabIndex = 3;
//
// labelAmount
//
labelAmount.AutoSize = true;
labelAmount.Location = new Point(12, 49);
labelAmount.Name = "labelAmount";
labelAmount.Size = new Size(90, 20);
labelAmount.TabIndex = 4;
labelAmount.Text = "Количество";
//
// labelPrinted
//
labelPrinted.AutoSize = true;
labelPrinted.Location = new Point(12, 15);
labelPrinted.Name = "labelPrinted";
labelPrinted.Size = new Size(154, 20);
labelPrinted.TabIndex = 5;
labelPrinted.Text = "Печатная продукция";
//
// FormSale
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(427, 118);
Controls.Add(labelPrinted);
Controls.Add(labelAmount);
Controls.Add(textBoxAmount);
Controls.Add(comboBoxPrinted);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Name = "FormSale";
StartPosition = FormStartPosition.CenterParent;
Text = "Продажа";
Load += FormSale_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonSave;
private Button buttonCancel;
private ComboBox comboBoxPrinted;
private TextBox textBoxAmount;
private Label labelAmount;
private Label labelPrinted;
}
}

View File

@ -0,0 +1,79 @@
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
namespace TypographyView
{
public partial class FormSale : Form
{
private readonly ILogger _logger;
private readonly IPrintedLogic _logicP;
private readonly IShopLogic _logicS;
public FormSale(ILogger<FormSale> logger, IPrintedLogic logicP, IShopLogic logicS)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicS = logicS;
}
private void FormSale_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка печатной продукции для поставки");
var _listP = _logicP.ReadList(null);
if (_listP != null)
{
comboBoxPrinted.DisplayMember = "PrintedName";
comboBoxPrinted.ValueMember = "Id";
comboBoxPrinted.DataSource = _listP;
comboBoxPrinted.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxPrinted.SelectedValue == null)
{
MessageBox.Show("Выберите печатную продукцию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxAmount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание продажи");
try
{
var operationResult = _logicS.SellPrinteds(
new PrintedBindingModel()
{
Id = Convert.ToInt32(comboBoxPrinted.SelectedValue),
PrintedName = comboBoxPrinted.Text
},
Convert.ToInt32(textBoxAmount.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

@ -20,198 +20,206 @@
base.Dispose(disposing);
}
#region Windows Form Designer generated code
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCancel = new Button();
buttonSave = new Button();
groupBoxPrinteds = new GroupBox();
dataGridViewPrinteds = new DataGridView();
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
ColumnPrintedName = new DataGridViewTextBoxColumn();
ColumnAmount = new DataGridViewTextBoxColumn();
buttonRef = new Button();
labelName = new Label();
labelAddress = new Label();
textBoxAddress = new TextBox();
textBoxName = new TextBox();
labelDate = new Label();
dateTimePickerOpening = new DateTimePicker();
groupBoxPrinteds.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(1086, 885);
buttonCancel.Margin = new Padding(5, 5, 5, 5);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(166, 46);
buttonCancel.TabIndex = 0;
buttonCancel.Text = "Закрыть";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(910, 885);
buttonSave.Margin = new Padding(5, 5, 5, 5);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(166, 46);
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// groupBoxPrinteds
//
groupBoxPrinteds.Controls.Add(dataGridViewPrinteds);
groupBoxPrinteds.Controls.Add(buttonRef);
groupBoxPrinteds.Location = new Point(20, 178);
groupBoxPrinteds.Margin = new Padding(5, 5, 5, 5);
groupBoxPrinteds.Name = "groupBoxPrinteds";
groupBoxPrinteds.Padding = new Padding(5, 5, 5, 5);
groupBoxPrinteds.Size = new Size(1232, 698);
groupBoxPrinteds.TabIndex = 2;
groupBoxPrinteds.TabStop = false;
groupBoxPrinteds.Text = "Печатная продукция";
//
// dataGridViewPrinteds
//
dataGridViewPrinteds.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewPrinteds.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewPrinteds.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, ColumnPrintedName, ColumnAmount });
dataGridViewPrinteds.GridColor = SystemColors.ControlLightLight;
dataGridViewPrinteds.Location = new Point(10, 42);
dataGridViewPrinteds.Margin = new Padding(5, 5, 5, 5);
dataGridViewPrinteds.Name = "dataGridViewPrinteds";
dataGridViewPrinteds.RowHeadersVisible = false;
dataGridViewPrinteds.RowHeadersWidth = 51;
dataGridViewPrinteds.RowTemplate.Height = 29;
dataGridViewPrinteds.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewPrinteds.Size = new Size(1037, 640);
dataGridViewPrinteds.TabIndex = 4;
//
// dataGridViewTextBoxColumn1
//
dataGridViewTextBoxColumn1.HeaderText = "Id";
dataGridViewTextBoxColumn1.MinimumWidth = 6;
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
dataGridViewTextBoxColumn1.Visible = false;
dataGridViewTextBoxColumn1.Width = 125;
//
// ColumnPrintedName
//
ColumnPrintedName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnPrintedName.HeaderText = "Печатное изделие";
ColumnPrintedName.MinimumWidth = 6;
ColumnPrintedName.Name = "ColumnPrintedName";
//
// ColumnAmount
//
ColumnAmount.HeaderText = "Количество";
ColumnAmount.MinimumWidth = 6;
ColumnAmount.Name = "ColumnAmount";
ColumnAmount.Width = 125;
//
// buttonRef
//
buttonRef.Location = new Point(1056, 42);
buttonRef.Margin = new Padding(5, 5, 5, 5);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(166, 46);
buttonRef.TabIndex = 3;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(20, 24);
labelName.Margin = new Padding(5, 0, 5, 0);
labelName.Name = "labelName";
labelName.Size = new Size(120, 32);
labelName.TabIndex = 0;
labelName.Text = "Название";
//
// labelAddress
//
labelAddress.AutoSize = true;
labelAddress.Location = new Point(20, 77);
labelAddress.Margin = new Padding(5, 0, 5, 0);
labelAddress.Name = "labelAddress";
labelAddress.Size = new Size(80, 32);
labelAddress.TabIndex = 1;
labelAddress.Text = "Адрес";
//
// textBoxAddress
//
textBoxAddress.Location = new Point(208, 72);
textBoxAddress.Margin = new Padding(5, 5, 5, 5);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(336, 39);
textBoxAddress.TabIndex = 3;
//
// textBoxName
//
textBoxName.Location = new Point(208, 24);
textBoxName.Margin = new Padding(5, 5, 5, 5);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(336, 39);
textBoxName.TabIndex = 4;
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(20, 133);
labelDate.Margin = new Padding(5, 0, 5, 0);
labelDate.Name = "labelDate";
labelDate.Size = new Size(175, 32);
labelDate.TabIndex = 5;
labelDate.Text = "Дата открытия";
//
// dateTimePickerOpening
//
dateTimePickerOpening.Location = new Point(208, 125);
dateTimePickerOpening.Margin = new Padding(5, 5, 5, 5);
dateTimePickerOpening.Name = "dateTimePickerOpening";
dateTimePickerOpening.Size = new Size(336, 39);
dateTimePickerOpening.TabIndex = 6;
//
// FormShop
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1271, 949);
Controls.Add(dateTimePickerOpening);
Controls.Add(labelDate);
Controls.Add(labelName);
Controls.Add(labelAddress);
Controls.Add(textBoxName);
Controls.Add(textBoxAddress);
Controls.Add(groupBoxPrinteds);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Margin = new Padding(5, 5, 5, 5);
Name = "FormShop";
StartPosition = FormStartPosition.CenterParent;
Text = "Магазин";
Load += FormShop_Load;
groupBoxPrinteds.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).EndInit();
ResumeLayout(false);
PerformLayout();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCancel = new Button();
buttonSave = new Button();
groupBoxPrinteds = new GroupBox();
dataGridViewPrinteds = new DataGridView();
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
ColumnPrintedName = new DataGridViewTextBoxColumn();
ColumnAmount = new DataGridViewTextBoxColumn();
buttonRef = new Button();
labelName = new Label();
labelAddress = new Label();
textBoxAddress = new TextBox();
textBoxName = new TextBox();
#endregion
labelDate = new Label();
textBoxMaxNumber = new TextBox();
labelMaxNumber = new Label();
dateTimePickerOpening = new DateTimePicker();
groupBoxPrinteds.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(668, 586);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(102, 29);
buttonCancel.TabIndex = 0;
buttonCancel.Text = "Закрыть";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(560, 586);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(102, 29);
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// groupBoxPrinteds
//
groupBoxPrinteds.Controls.Add(dataGridViewPrinteds);
groupBoxPrinteds.Controls.Add(buttonRef);
groupBoxPrinteds.Location = new Point(12, 144);
groupBoxPrinteds.Name = "groupBoxPrinteds";
groupBoxPrinteds.Size = new Size(758, 436);
groupBoxPrinteds.TabIndex = 2;
groupBoxPrinteds.TabStop = false;
groupBoxPrinteds.Text = "Печатная продукция";
//
// dataGridViewPrinteds
//
dataGridViewPrinteds.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewPrinteds.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewPrinteds.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, ColumnPrintedName, ColumnAmount });
dataGridViewPrinteds.GridColor = SystemColors.ControlLightLight;
dataGridViewPrinteds.Location = new Point(6, 26);
dataGridViewPrinteds.Name = "dataGridViewPrinteds";
dataGridViewPrinteds.RowHeadersVisible = false;
dataGridViewPrinteds.RowHeadersWidth = 51;
dataGridViewPrinteds.RowTemplate.Height = 29;
dataGridViewPrinteds.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewPrinteds.Size = new Size(638, 400);
dataGridViewPrinteds.TabIndex = 4;
//
// dataGridViewTextBoxColumn1
//
dataGridViewTextBoxColumn1.HeaderText = "Id";
dataGridViewTextBoxColumn1.MinimumWidth = 6;
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
dataGridViewTextBoxColumn1.Visible = false;
dataGridViewTextBoxColumn1.Width = 125;
//
// ColumnPrintedName
//
ColumnPrintedName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnPrintedName.HeaderText = "Печатное изделие";
ColumnPrintedName.MinimumWidth = 6;
ColumnPrintedName.Name = "ColumnPrintedName";
//
// ColumnAmount
//
ColumnAmount.HeaderText = "Количество";
ColumnAmount.MinimumWidth = 6;
ColumnAmount.Name = "ColumnAmount";
ColumnAmount.Width = 125;
//
// buttonRef
//
buttonRef.Location = new Point(650, 26);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(102, 29);
buttonRef.TabIndex = 3;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(12, 15);
labelName.Name = "labelName";
labelName.Size = new Size(77, 20);
labelName.TabIndex = 0;
labelName.Text = "Название";
//
// labelAddress
//
labelAddress.AutoSize = true;
labelAddress.Location = new Point(12, 48);
labelAddress.Name = "labelAddress";
labelAddress.Size = new Size(51, 20);
labelAddress.TabIndex = 1;
labelAddress.Text = "Адрес";
//
// textBoxAddress
//
textBoxAddress.Location = new Point(128, 45);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(208, 27);
textBoxAddress.TabIndex = 3;
//
// textBoxName
//
textBoxName.Location = new Point(128, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(208, 27);
textBoxName.TabIndex = 4;
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(12, 81);
labelDate.Name = "labelDate";
labelDate.Size = new Size(110, 20);
labelDate.TabIndex = 5;
labelDate.Text = "Дата открытия";
//
// textBoxMaxNumber
//
textBoxMaxNumber.Location = new Point(128, 111);
textBoxMaxNumber.Name = "textBoxMaxNumber";
textBoxMaxNumber.Size = new Size(104, 27);
textBoxMaxNumber.TabIndex = 6;
//
// labelMaxNumber
//
labelMaxNumber.AutoSize = true;
labelMaxNumber.Location = new Point(12, 114);
labelMaxNumber.Name = "labelMaxNumber";
labelMaxNumber.Size = new Size(100, 20);
labelMaxNumber.TabIndex = 7;
labelMaxNumber.Text = "Вместимость";
//
// dateTimePickerOpening
//
dateTimePickerOpening.Location = new Point(128, 78);
dateTimePickerOpening.Name = "dateTimePickerOpening";
dateTimePickerOpening.Size = new Size(208, 27);
dateTimePickerOpening.TabIndex = 8;
//
// FormShop
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(782, 628);
Controls.Add(dateTimePickerOpening);
Controls.Add(labelMaxNumber);
Controls.Add(textBoxMaxNumber);
Controls.Add(labelDate);
Controls.Add(labelName);
Controls.Add(labelAddress);
Controls.Add(textBoxName);
Controls.Add(textBoxAddress);
Controls.Add(groupBoxPrinteds);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Name = "FormShop";
StartPosition = FormStartPosition.CenterParent;
Text = "Магазин";
Load += FormShop_Load;
groupBoxPrinteds.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).EndInit();
ResumeLayout(false);
PerformLayout();
}
private Button buttonCancel;
#endregion
private Button buttonCancel;
private Button buttonSave;
private GroupBox groupBoxPrinteds;
private Label labelName;
@ -224,6 +232,8 @@
private DataGridViewTextBoxColumn ColumnPrintedName;
private DataGridViewTextBoxColumn ColumnAmount;
private Label labelDate;
private TextBox textBoxMaxNumber;
private Label labelMaxNumber;
private DateTimePicker dateTimePickerOpening;
}
}

View File

@ -36,6 +36,7 @@ namespace TypographyView
textBoxName.Text = view.ShopName;
textBoxAddress.Text = view.Address;
dateTimePickerOpening.Value = view.OpeningDate;
textBoxMaxNumber.Text = view.MaxNumberPrinteds.ToString();
_shopPrinteds = view.ShopPrinteds ?? new Dictionary<int, (IPrintedModel, int)>();
LoadData();
}
@ -87,6 +88,11 @@ namespace TypographyView
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxMaxNumber.Text))
{
MessageBox.Show("Заполните вместимость", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение магазина");
try
{
@ -96,6 +102,7 @@ namespace TypographyView
ShopName = textBoxName.Text,
Address = textBoxAddress.Text,
OpeningDate = dateTimePickerOpening.Value.Date,
MaxNumberPrinteds = Convert.ToInt32(textBoxMaxNumber.Text),
ShopPrinteds = _shopPrinteds
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">
@ -126,13 +66,4 @@
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnPrintedName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -1,17 +1,15 @@
using TypographyBusinessLogic.BusinessLogics;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.StoragesContracts;
using TypographyListImplement.Implements;
using TypographyFileImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
namespace TypographyView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
@ -29,6 +27,7 @@ namespace TypographyView
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
@ -41,21 +40,22 @@ namespace TypographyView
services.AddTransient<IPrintedStorage, PrintedStorage>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPrintedLogic, PrintedLogic>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormPrinted>();
services.AddTransient<FormPrinteds>();
services.AddTransient<FormPrintedComponent>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormSupplies>();
}
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormSupplies>();
services.AddTransient<FormSale>();
}
}
}

View File

@ -12,12 +12,6 @@
<None Remove="nlog.config" />
</ItemGroup>
<ItemGroup>
<Content Include="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
@ -26,8 +20,14 @@
<ItemGroup>
<ProjectReference Include="..\TypographyBusinessLogic\TypographyBusinessLogic.csproj" />
<ProjectReference Include="..\TypographyContracts\TypographyContracts.csproj" />
<ProjectReference Include="..\TypographyListImplement\TypographyListImplement.csproj" />
<ProjectReference Include="..\TypographyFileImplement\TypographyFileImplement.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>