2 усложненная лабораторная
This commit is contained in:
parent
cabab17454
commit
8ead770c88
@ -14,10 +14,16 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IWorkStorage _workStorage;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage, IWorkStorage workStorage, IShopLogic shopLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
_workStorage = workStorage;
|
||||
_shopLogic = shopLogic;
|
||||
}
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
@ -75,11 +81,21 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("Change status operation failed");
|
||||
return false;
|
||||
}
|
||||
if (newStatus == OrderStatus.Выдан)
|
||||
{
|
||||
var work = _workStorage.GetElement(new WorkSearchModel() { Id = viewModel.WorkId});
|
||||
if (work == null)
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed.Work not found");
|
||||
return false;
|
||||
}
|
||||
if (!_shopLogic.CheckAndSupply(work, viewModel.Count))
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed. Works delivery operation failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
model.Status = newStatus;
|
||||
model.WorkId = viewModel.WorkId;
|
||||
model.Count = viewModel.Count;
|
||||
model.Sum = viewModel.Sum;
|
||||
model.DateCreate = viewModel.DateCreate;
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
|
@ -5,6 +5,12 @@ using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -101,9 +107,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
var element = _shopStorage.GetElement(shopModel);
|
||||
if (element == null)
|
||||
{
|
||||
throw new InvalidOperationException("StoreReplenishment. Element not found");
|
||||
throw new InvalidOperationException("Ошибка. Элемент не найден");
|
||||
}
|
||||
if(element.maxCountWorks - element.ShopWorks.Sum(x => x.Value.Item2) < count)
|
||||
{
|
||||
throw new InvalidOperationException("Ошибка. Нет места в магазине");
|
||||
}
|
||||
|
||||
if(element.ShopWorks.ContainsKey(workModel.Id))
|
||||
{
|
||||
var oldWorks = element.ShopWorks[workModel.Id];
|
||||
@ -122,7 +131,8 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
ShopName = element.ShopName,
|
||||
Address = element.Address,
|
||||
DateOpening = element.DateOpening,
|
||||
ShopWorks= element.ShopWorks
|
||||
maxCountWorks = element.maxCountWorks,
|
||||
ShopWorks= element.ShopWorks,
|
||||
}) == null)
|
||||
{
|
||||
_logger.LogInformation("StoreReplenishment. Update operation failed");
|
||||
@ -132,6 +142,54 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
|
||||
}
|
||||
|
||||
public bool CheckAndSupply(IWorkModel model, int count)
|
||||
{
|
||||
if (count<0)
|
||||
{
|
||||
_logger.LogWarning("Checksupply operation error. Works count < 0.");
|
||||
return false;
|
||||
}
|
||||
var shopList = _shopStorage.GetFullList();
|
||||
int shopsCapacity = shopList.Sum(x => x.maxCountWorks);
|
||||
int currentWorks = shopList.Select(x => x.ShopWorks.Sum(x => x.Value.Item2)).Sum();
|
||||
int freespace = shopsCapacity - currentWorks;
|
||||
if ( freespace < count)
|
||||
{
|
||||
_logger.LogWarning("Checksupply operation error. No space for a new work.");
|
||||
return false;
|
||||
}
|
||||
foreach (var shop in shopList)
|
||||
{
|
||||
int freePlaces = shop.maxCountWorks - shop.ShopWorks.Select(x => x.Value.Item2).Sum();
|
||||
if (freePlaces == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( freePlaces - count >= 0)
|
||||
{
|
||||
if (StoreReplenishment(new() { Id = shop.Id }, model, count))
|
||||
count = 0;
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Supply error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (freePlaces - count < 0)
|
||||
{
|
||||
if (StoreReplenishment(new() { Id = shop.Id }, model, freePlaces))
|
||||
count-= freePlaces;
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Supply error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (count == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
@ -150,7 +208,10 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет адреса магазина", nameof(model.ShopName));
|
||||
}
|
||||
|
||||
if (model.maxCountWorks < 0)
|
||||
{
|
||||
throw new InvalidOperationException("Максимальное количество работ магазина отрицательно");
|
||||
}
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{Address}. Id:{Id}", model.ShopName, model.Address, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
@ -161,5 +222,9 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool SellWork(IWorkModel model, int count)
|
||||
{
|
||||
return _shopStorage.SellWork(model, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlumbingRepairContracts.BindingModels
|
||||
{
|
||||
@ -10,6 +16,8 @@ namespace PlumbingRepairContracts.BindingModels
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public int maxCountWorks { get; set; }
|
||||
|
||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; set; } = new();
|
||||
|
@ -2,6 +2,11 @@
|
||||
using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||
{
|
||||
@ -18,5 +23,8 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||
bool Delete(ShopBindingModel model);
|
||||
|
||||
bool StoreReplenishment(ShopSearchModel shopModel, IWorkModel workModel, int count);
|
||||
|
||||
bool SellWork(IWorkModel workModel, int count);
|
||||
bool CheckAndSupply(IWorkModel workModel, int count);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
namespace PlumbingRepairContracts.SearchModels
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlumbingRepairContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
|
||||
namespace PlumbingRepairContracts.StoragesContracts
|
||||
{
|
||||
@ -17,5 +18,8 @@ namespace PlumbingRepairContracts.StoragesContracts
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
|
||||
bool SellWork(IWorkModel workModel, int count);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ namespace PlumbingRepairContracts.ViewModels
|
||||
|
||||
[DisplayName("Адрес")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Максимальное количество работ")]
|
||||
public int maxCountWorks { get; set; }
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpening { get; set; }
|
||||
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; set; } = new();
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
DateTime DateOpening { get; }
|
||||
|
||||
int maxCountWorks { get; }
|
||||
|
||||
Dictionary<int, (IWorkModel, int)> ShopWorks { get; }
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,14 @@ namespace PlumbingRepairFileImplement
|
||||
|
||||
private readonly string WorkFileName = "Work.xml";
|
||||
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
|
||||
public List<Order> Orders { get; private set; }
|
||||
|
||||
public List<Work> Works { get; private set; }
|
||||
public List<Shop> Shops { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -33,12 +36,14 @@ namespace PlumbingRepairFileImplement
|
||||
public void SaveWorks() => SaveData(Works, WorkFileName, "Works", 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)!)!;
|
||||
Works = LoadData(WorkFileName, "Work", x => Work.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)
|
||||
|
@ -0,0 +1,134 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairFileImplement.Models;
|
||||
|
||||
namespace PlumbingRepairFileImplement.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 component = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
source.SaveShops();
|
||||
return component.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 SellWork(IWorkModel model, int count)
|
||||
{
|
||||
var work = source.Works.FirstOrDefault(x => x.Id == model.Id);
|
||||
int countInShops = source.Shops
|
||||
.SelectMany(x => x.ShopWorks)
|
||||
.Sum(y => y.Key == model.Id ? y.Value.Item2 : 0);
|
||||
|
||||
if (work == null || countInShops < count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in source.Shops)
|
||||
{
|
||||
var shopWorks = shop.ShopWorks.Where(x => x.Key == model.Id);
|
||||
if (shopWorks.Any())
|
||||
{
|
||||
var shopWork = shopWorks.First();
|
||||
int min = Math.Min(shopWork.Value.Item2, count);
|
||||
if (min == shopWork.Value.Item2)
|
||||
{
|
||||
shop.ShopWorks.Remove(shopWork.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.ShopWorks[shopWork.Key] = (shopWork.Value.Item1, shopWork.Value.Item2 - min);
|
||||
}
|
||||
shop.Update(new ShopBindingModel
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpening = shop.DateOpening,
|
||||
ShopWorks = shop.ShopWorks,
|
||||
maxCountWorks = shop.maxCountWorks
|
||||
});
|
||||
count -= min;
|
||||
if (count <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
107
PlumbingRepair/PlumbingRepairFileImplement/Models/Shop.cs
Normal file
107
PlumbingRepair/PlumbingRepairFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpening { get; private set; }
|
||||
|
||||
public Dictionary<int, int> Works { get; private set; } = new();
|
||||
|
||||
private Dictionary<int, (IWorkModel, int)>? _shopWorks = null;
|
||||
public Dictionary<int, (IWorkModel, int)> ShopWorks
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopWorks == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_shopWorks = Works.ToDictionary(x => x.Key,
|
||||
y => ((source.Works.FirstOrDefault(z => z.Id == y.Key) as IWorkModel)!, y.Value));
|
||||
}
|
||||
return _shopWorks;
|
||||
}
|
||||
}
|
||||
|
||||
public int maxCountWorks { get; private set; }
|
||||
|
||||
|
||||
public static Shop? Create(ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpening = model.DateOpening,
|
||||
Works = model.ShopWorks.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
maxCountWorks= model.maxCountWorks,
|
||||
};
|
||||
}
|
||||
|
||||
public static Shop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
|
||||
maxCountWorks = Convert.ToInt32(element.Element("maxCountWorks")!.Value),
|
||||
Works = element.Element("ShopWorks")!.Elements("ShopWork")
|
||||
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpening = model.DateOpening;
|
||||
Works = model.ShopWorks.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
maxCountWorks = model.maxCountWorks;
|
||||
_shopWorks = null;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpening = DateOpening,
|
||||
ShopWorks = ShopWorks,
|
||||
maxCountWorks = maxCountWorks,
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("DateOpening", DateOpening.ToString()),
|
||||
new XElement("maxCountWorks", maxCountWorks.ToString()),
|
||||
new XElement("ShopWorks",
|
||||
Works.Select(x => new XElement("ShopWork",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))).ToArray()));
|
||||
}
|
||||
}
|
@ -11,8 +11,4 @@
|
||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Implements\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -2,6 +2,7 @@
|
||||
using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -104,5 +105,9 @@ namespace PlumbingRepairListImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool SellWork(IWorkModel model, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ namespace PlumbingRepairListImplement.Models
|
||||
|
||||
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; private set; } = new Dictionary<int, (IWorkModel, int)>();
|
||||
|
||||
public int maxCountWorks { get; private set; }
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -27,7 +29,8 @@ namespace PlumbingRepairListImplement.Models
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpening = model.DateOpening,
|
||||
ShopWorks = model.ShopWorks
|
||||
ShopWorks = model.ShopWorks,
|
||||
maxCountWorks = model.maxCountWorks
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,6 +43,8 @@ namespace PlumbingRepairListImplement.Models
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpening= model.DateOpening;
|
||||
ShopWorks= model.ShopWorks;
|
||||
maxCountWorks= model.maxCountWorks;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
@ -48,7 +53,8 @@ namespace PlumbingRepairListImplement.Models
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpening = DateOpening,
|
||||
ShopWorks = ShopWorks
|
||||
ShopWorks = ShopWorks,
|
||||
maxCountWorks = maxCountWorks
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
this.РаботыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.пToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.продажаРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -141,7 +142,8 @@
|
||||
this.компонентыToolStripMenuItem,
|
||||
this.РаботыToolStripMenuItem,
|
||||
this.магазиныToolStripMenuItem,
|
||||
this.пToolStripMenuItem});
|
||||
this.пToolStripMenuItem,
|
||||
this.продажаРаботToolStripMenuItem});
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29);
|
||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -149,14 +151,14 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
//
|
||||
// РаботыToolStripMenuItem
|
||||
//
|
||||
this.РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem";
|
||||
this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
|
||||
this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
this.РаботыToolStripMenuItem.Text = "Работы";
|
||||
this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click);
|
||||
//
|
||||
@ -174,6 +176,13 @@
|
||||
this.пToolStripMenuItem.Text = "Пополнение магазина";
|
||||
this.пToolStripMenuItem.Click += new System.EventHandler(this.пополнениеToolStripMenuItem_Click);
|
||||
//
|
||||
// продажаРаботToolStripMenuItem
|
||||
//
|
||||
this.продажаРаботToolStripMenuItem.Name = "продажаРаботToolStripMenuItem";
|
||||
this.продажаРаботToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
this.продажаРаботToolStripMenuItem.Text = "Продажа работ";
|
||||
this.продажаРаботToolStripMenuItem.Click += new System.EventHandler(this.продажаРаботToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
@ -212,5 +221,6 @@
|
||||
private ToolStripMenuItem РаботыToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem пToolStripMenuItem;
|
||||
private ToolStripMenuItem продажаРаботToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -159,5 +159,14 @@ namespace PlumbingRepairView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void продажаРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellWorks));
|
||||
if (service is FormSellWorks form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
PlumbingRepair/PlumbingRepairView/FormSellWorks.Designer.cs
generated
Normal file
126
PlumbingRepair/PlumbingRepairView/FormSellWorks.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
||||
namespace PlumbingRepairView
|
||||
{
|
||||
partial class FormSellWorks
|
||||
{
|
||||
/// <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.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSell = new System.Windows.Forms.Button();
|
||||
this.comboBoxWork = new System.Windows.Forms.ComboBox();
|
||||
this.labelWork = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(137, 103);
|
||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(183, 31);
|
||||
this.textBoxCount.TabIndex = 13;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(14, 103);
|
||||
this.labelCount.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(111, 25);
|
||||
this.labelCount.TabIndex = 12;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(361, 156);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(126, 45);
|
||||
this.buttonCancel.TabIndex = 15;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
this.buttonSell.Location = new System.Drawing.Point(225, 156);
|
||||
this.buttonSell.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonSell.Name = "buttonSell";
|
||||
this.buttonSell.Size = new System.Drawing.Size(126, 45);
|
||||
this.buttonSell.TabIndex = 14;
|
||||
this.buttonSell.Text = "Продать";
|
||||
this.buttonSell.UseVisualStyleBackColor = true;
|
||||
this.buttonSell.Click += new System.EventHandler(this.ButtonSale_Click);
|
||||
//
|
||||
// comboBoxWork
|
||||
//
|
||||
this.comboBoxWork.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxWork.FormattingEnabled = true;
|
||||
this.comboBoxWork.Location = new System.Drawing.Point(137, 33);
|
||||
this.comboBoxWork.Name = "comboBoxWork";
|
||||
this.comboBoxWork.Size = new System.Drawing.Size(317, 33);
|
||||
this.comboBoxWork.TabIndex = 16;
|
||||
//
|
||||
// labelWork
|
||||
//
|
||||
this.labelWork.AutoSize = true;
|
||||
this.labelWork.Location = new System.Drawing.Point(14, 36);
|
||||
this.labelWork.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.labelWork.Name = "labelWork";
|
||||
this.labelWork.Size = new System.Drawing.Size(72, 25);
|
||||
this.labelWork.TabIndex = 17;
|
||||
this.labelWork.Text = "Работа:";
|
||||
//
|
||||
// FormSellWorks
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(493, 207);
|
||||
this.Controls.Add(this.labelWork);
|
||||
this.Controls.Add(this.comboBoxWork);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSell);
|
||||
this.Name = "FormSellWorks";
|
||||
this.Text = "Продажа работ";
|
||||
this.Load += new System.EventHandler(this.FormSellWorks_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxCount;
|
||||
private Label labelCount;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSell;
|
||||
private ComboBox comboBoxWork;
|
||||
private Label labelWork;
|
||||
}
|
||||
}
|
87
PlumbingRepair/PlumbingRepairView/FormSellWorks.cs
Normal file
87
PlumbingRepair/PlumbingRepairView/FormSellWorks.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
|
||||
namespace PlumbingRepairView
|
||||
{
|
||||
public partial class FormSellWorks : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IWorkLogic _workLogic;
|
||||
|
||||
private readonly IShopLogic _logicShop;
|
||||
|
||||
public FormSellWorks(ILogger<FormStoreReplenishment> logger, IWorkLogic workLogic, IShopLogic logicShop)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_workLogic = workLogic;
|
||||
_logicShop = logicShop;
|
||||
}
|
||||
|
||||
private void FormSellWorks_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Ice creams loading");
|
||||
try
|
||||
{
|
||||
var list = _workLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxWork.DisplayMember = "WorkName";
|
||||
comboBoxWork.ValueMember = "Id";
|
||||
comboBoxWork.DataSource = list;
|
||||
comboBoxWork.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Works loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSale_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxWork.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите работу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("work sale");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicShop.SellWork(
|
||||
new WorkBindingModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxWork.SelectedValue)
|
||||
},
|
||||
Convert.ToInt32(textBoxCount.Text)
|
||||
);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при продаже.");
|
||||
}
|
||||
MessageBox.Show("Продажа прошла успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Work sale error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
PlumbingRepair/PlumbingRepairView/FormSellWorks.resx
Normal file
60
PlumbingRepair/PlumbingRepairView/FormSellWorks.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -41,13 +41,15 @@
|
||||
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.labelDateOpening = new System.Windows.Forms.Label();
|
||||
this.textBoxMaxCount = new System.Windows.Forms.TextBox();
|
||||
this.labelMaxCount = new System.Windows.Forms.Label();
|
||||
this.groupBoxComponents.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(152, 75);
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(310, 49);
|
||||
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(183, 31);
|
||||
@ -56,7 +58,7 @@
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(8, 78);
|
||||
this.labelAddress.Location = new System.Drawing.Point(8, 52);
|
||||
this.labelAddress.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(66, 25);
|
||||
@ -87,7 +89,7 @@
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(152, 27);
|
||||
this.textBoxName.Location = new System.Drawing.Point(310, 1);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(358, 31);
|
||||
@ -96,7 +98,7 @@
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(8, 30);
|
||||
this.labelName.Location = new System.Drawing.Point(8, 7);
|
||||
this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(94, 25);
|
||||
@ -105,7 +107,7 @@
|
||||
//
|
||||
// dateTimePickerOpening
|
||||
//
|
||||
this.dateTimePickerOpening.Location = new System.Drawing.Point(152, 118);
|
||||
this.dateTimePickerOpening.Location = new System.Drawing.Point(152, 133);
|
||||
this.dateTimePickerOpening.Name = "dateTimePickerOpening";
|
||||
this.dateTimePickerOpening.Size = new System.Drawing.Size(300, 31);
|
||||
this.dateTimePickerOpening.TabIndex = 18;
|
||||
@ -115,7 +117,7 @@
|
||||
this.groupBoxComponents.Controls.Add(this.dataGridView);
|
||||
this.groupBoxComponents.Controls.Add(this.buttonSave);
|
||||
this.groupBoxComponents.Controls.Add(this.buttonCancel);
|
||||
this.groupBoxComponents.Location = new System.Drawing.Point(8, 151);
|
||||
this.groupBoxComponents.Location = new System.Drawing.Point(8, 183);
|
||||
this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.groupBoxComponents.Name = "groupBoxComponents";
|
||||
this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
@ -174,18 +176,38 @@
|
||||
// labelDateOpening
|
||||
//
|
||||
this.labelDateOpening.AutoSize = true;
|
||||
this.labelDateOpening.Location = new System.Drawing.Point(8, 118);
|
||||
this.labelDateOpening.Location = new System.Drawing.Point(8, 133);
|
||||
this.labelDateOpening.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.labelDateOpening.Name = "labelDateOpening";
|
||||
this.labelDateOpening.Size = new System.Drawing.Size(135, 25);
|
||||
this.labelDateOpening.TabIndex = 20;
|
||||
this.labelDateOpening.Text = "Дата открытия:";
|
||||
//
|
||||
// textBoxMaxCount
|
||||
//
|
||||
this.textBoxMaxCount.Location = new System.Drawing.Point(310, 94);
|
||||
this.textBoxMaxCount.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.textBoxMaxCount.Name = "textBoxMaxCount";
|
||||
this.textBoxMaxCount.Size = new System.Drawing.Size(183, 31);
|
||||
this.textBoxMaxCount.TabIndex = 22;
|
||||
//
|
||||
// labelMaxCount
|
||||
//
|
||||
this.labelMaxCount.AutoSize = true;
|
||||
this.labelMaxCount.Location = new System.Drawing.Point(8, 93);
|
||||
this.labelMaxCount.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.labelMaxCount.Name = "labelMaxCount";
|
||||
this.labelMaxCount.Size = new System.Drawing.Size(290, 25);
|
||||
this.labelMaxCount.TabIndex = 21;
|
||||
this.labelMaxCount.Text = "Максимальное количество работ:";
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(812, 543);
|
||||
this.ClientSize = new System.Drawing.Size(812, 564);
|
||||
this.Controls.Add(this.textBoxMaxCount);
|
||||
this.Controls.Add(this.labelMaxCount);
|
||||
this.Controls.Add(this.labelDateOpening);
|
||||
this.Controls.Add(this.groupBoxComponents);
|
||||
this.Controls.Add(this.dateTimePickerOpening);
|
||||
@ -218,5 +240,7 @@
|
||||
private DataGridViewTextBoxColumn ColumnName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private Label labelDateOpening;
|
||||
private TextBox textBoxMaxCount;
|
||||
private Label labelMaxCount;
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ namespace PlumbingRepairView
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
textBoxMaxCount.Text = view.maxCountWorks.ToString();
|
||||
dateTimePickerOpening.Value = view.DateOpening;
|
||||
_shopWorks = view.ShopWorks ?? new Dictionary<int, (IWorkModel, int)>();
|
||||
LoadData();
|
||||
@ -67,7 +68,7 @@ namespace PlumbingRepairView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
_logger.LogError(ex, "Ошибка загрузки работ магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -83,6 +84,11 @@ namespace PlumbingRepairView
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxMaxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните максимальное количество работ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(dateTimePickerOpening.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
@ -97,6 +103,7 @@ namespace PlumbingRepairView
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening= dateTimePickerOpening.Value,
|
||||
maxCountWorks = Convert.ToInt32(textBoxMaxCount.Text),
|
||||
ShopWorks = _shopWorks
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
@ -132,7 +132,7 @@
|
||||
this.Controls.Add(this.labelWorkName);
|
||||
this.Controls.Add(this.labelShopName);
|
||||
this.Name = "FormStoreReplenishment";
|
||||
this.Text = "FormStoreReplenishment";
|
||||
this.Text = "Пополнение магазина";
|
||||
this.Load += new System.EventHandler(this.FormStoreReplenishment_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
@ -55,6 +55,7 @@ namespace PlumbingRepairView
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormWorkComponent>();
|
||||
services.AddTransient<FormStoreReplenishment>();
|
||||
services.AddTransient<FormSellWorks>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user