Compare commits
No commits in common. "lab_3_hard" and "main" have entirely different histories.
lab_3_hard
...
main
@ -3,19 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.4.33110.190
|
VisualStudioVersion = 17.4.33110.190
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairView", "PlumbingRepairView\PlumbingRepairView.csproj", "{C267FC29-91DC-4543-9EF8-678A3A5556E7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairView", "PlumbingRepairView\PlumbingRepairView.csproj", "{C267FC29-91DC-4543-9EF8-678A3A5556E7}"
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairBusinessLogic", "PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj", "{7C2FE920-E8CA-4F50-9EEC-B6EDBAE47480}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairContracts", "PlumbingRepairContracts\PlumbingRepairContracts.csproj", "{9D62913E-8AC0-48E6-B131-B7E744E4B48A}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairDataModels", "PlumbingRepairDataModels\PlumbingRepairDataModels.csproj", "{1889C02D-BF89-47E5-BF8B-897DBFF8D726}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairListImplement", "PlumbingRepairListImplement\PlumbingRepairListImplement.csproj", "{A5D22B59-19BC-4DB6-A234-24AEA47605C2}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairFileImplement", "PlumbingRepairFileImplement\PlumbingRepairFileImplement.csproj", "{102B6C63-8EB6-4786-BFEA-88B7DB0DB3F0}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairDatabaseImplement", "PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj", "{6DDC0CCD-97E0-4CB7-8024-C27DB9AEF97B}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -27,30 +15,6 @@ Global
|
|||||||
{C267FC29-91DC-4543-9EF8-678A3A5556E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C267FC29-91DC-4543-9EF8-678A3A5556E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C267FC29-91DC-4543-9EF8-678A3A5556E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C267FC29-91DC-4543-9EF8-678A3A5556E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C267FC29-91DC-4543-9EF8-678A3A5556E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C267FC29-91DC-4543-9EF8-678A3A5556E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7C2FE920-E8CA-4F50-9EEC-B6EDBAE47480}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{7C2FE920-E8CA-4F50-9EEC-B6EDBAE47480}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{7C2FE920-E8CA-4F50-9EEC-B6EDBAE47480}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{7C2FE920-E8CA-4F50-9EEC-B6EDBAE47480}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{9D62913E-8AC0-48E6-B131-B7E744E4B48A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{9D62913E-8AC0-48E6-B131-B7E744E4B48A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{9D62913E-8AC0-48E6-B131-B7E744E4B48A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{9D62913E-8AC0-48E6-B131-B7E744E4B48A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{1889C02D-BF89-47E5-BF8B-897DBFF8D726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1889C02D-BF89-47E5-BF8B-897DBFF8D726}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1889C02D-BF89-47E5-BF8B-897DBFF8D726}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1889C02D-BF89-47E5-BF8B-897DBFF8D726}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{A5D22B59-19BC-4DB6-A234-24AEA47605C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{A5D22B59-19BC-4DB6-A234-24AEA47605C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{A5D22B59-19BC-4DB6-A234-24AEA47605C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{A5D22B59-19BC-4DB6-A234-24AEA47605C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{102B6C63-8EB6-4786-BFEA-88B7DB0DB3F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{102B6C63-8EB6-4786-BFEA-88B7DB0DB3F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{102B6C63-8EB6-4786-BFEA-88B7DB0DB3F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{102B6C63-8EB6-4786-BFEA-88B7DB0DB3F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{6DDC0CCD-97E0-4CB7-8024-C27DB9AEF97B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{6DDC0CCD-97E0-4CB7-8024-C27DB9AEF97B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6DDC0CCD-97E0-4CB7-8024-C27DB9AEF97B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{6DDC0CCD-97E0-4CB7-8024-C27DB9AEF97B}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ComponentLogic : IComponentLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
|
|
||||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.ComponentName, model?.Id);
|
|
||||||
var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{Id}", model.ComponentName, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_componentStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(ComponentBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
|
|
||||||
}
|
|
||||||
if (model.Cost <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{Cost}. Id:{Id}", model.ComponentName, model.Cost, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
ComponentName = model.ComponentName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class OrderLogic : IOrderLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly 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)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Invalid order status");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
if (_orderStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return ChangeStatus(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return ChangeStatus(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
|
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
|
|
||||||
{
|
|
||||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
|
||||||
if (viewModel == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (viewModel.Status + 1 != newStatus)
|
|
||||||
{
|
|
||||||
_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;
|
|
||||||
if (model.Status == OrderStatus.Готов)
|
|
||||||
{
|
|
||||||
model.DateImplement = DateTime.Now;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
model.DateImplement = viewModel.DateImplement;
|
|
||||||
}
|
|
||||||
CheckModel(model, false);
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Change status operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.WorkId < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Некорректный идентификатор работы", nameof(model.WorkId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Количество работ в заказе должно быть больше 0", nameof(model.Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (model.Sum <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Order. OrderId:{Id}. Sum:{Sum}. WorkId: {WorkId}", model.Id, model.Sum, model.WorkId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,230 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
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
|
|
||||||
{
|
|
||||||
public class ShopLogic :IShopLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IShopStorage _shopStorage;
|
|
||||||
|
|
||||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_shopStorage = shopStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ShopName:{ShopName}. Id:{Id}", model?.ShopName, model?.Id);
|
|
||||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
|
||||||
var element = _shopStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_shopStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_shopStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_shopStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool StoreReplenishment(ShopSearchModel shopModel, IWorkModel workModel, int count)
|
|
||||||
{
|
|
||||||
if (shopModel == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(shopModel));
|
|
||||||
}
|
|
||||||
if (workModel == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(workModel));
|
|
||||||
}
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Количество товаров должно быть больше 0", nameof(count));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("StoreReplenishment. ShopName:{ShopName}. Id:{Id}", shopModel.ShopName, shopModel.Id);
|
|
||||||
var element = _shopStorage.GetElement(shopModel);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
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];
|
|
||||||
oldWorks.Item2 += count;
|
|
||||||
element.ShopWorks[workModel.Id] = oldWorks;
|
|
||||||
_logger.LogInformation("StoreReplenishment. Added {count} '{work}' to '{ShopName}' shop", count, workModel.WorkName,shopModel.ShopName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
element.ShopWorks.Add(workModel.Id,(workModel, count));
|
|
||||||
_logger.LogInformation("StoreReplenishment. Added {count} new '{work}' to '{ShopName}' shop", count, workModel.WorkName, shopModel.ShopName);
|
|
||||||
}
|
|
||||||
if(_shopStorage.Update(new ShopBindingModel()
|
|
||||||
{
|
|
||||||
Id = element.Id,
|
|
||||||
ShopName = element.ShopName,
|
|
||||||
Address = element.Address,
|
|
||||||
DateOpening = element.DateOpening,
|
|
||||||
maxCountWorks = element.maxCountWorks,
|
|
||||||
ShopWorks= element.ShopWorks,
|
|
||||||
}) == null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("StoreReplenishment. Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ShopName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Address))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет адреса магазина", nameof(model.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
|
|
||||||
{
|
|
||||||
ShopName = model.ShopName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool SellWork(IWorkModel model, int count)
|
|
||||||
{
|
|
||||||
return _shopStorage.SellWork(model, count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class WorkLogic : IWorkLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IWorkStorage _workStorage;
|
|
||||||
public WorkLogic(ILogger<ComponentLogic> logger, IWorkStorage workStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_workStorage = workStorage;
|
|
||||||
}
|
|
||||||
public bool Create(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_workStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_workStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_workStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? ReadElement(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. WorkName:{WorkName}. Id:{Id}", model.WorkName, model.Id);
|
|
||||||
var element = _workStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel>? ReadList(WorkSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. WorkName:{WorkName}. Id:{Id}", model?.WorkName, model?.Id);
|
|
||||||
var list = model == null ? _workStorage.GetFullList() : _workStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(WorkBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия работы", nameof(model.WorkName));
|
|
||||||
}
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Стоимость работы должна быть больше 0", nameof(model.Price));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Component. WorkName:{WorkName}. Price:{Price}. Id:{Id}", model.WorkName, model.Price, model.Id);
|
|
||||||
var element = _workStorage.GetElement(new WorkSearchModel
|
|
||||||
{
|
|
||||||
WorkName = model.WorkName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Работа с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ComponentBindingModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class OrderBindingModel : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public int WorkId { get; set; }
|
|
||||||
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
public double Sum { get; set; }
|
|
||||||
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
|
||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
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
|
|
||||||
{
|
|
||||||
public class ShopBindingModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string ShopName { get; set; } =string.Empty;
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class WorkBindingModel : IWorkModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string WorkName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public double Price { get; set; }
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IComponentLogic
|
|
||||||
{
|
|
||||||
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
|
||||||
|
|
||||||
ComponentViewModel? ReadElement(ComponentSearchModel model);
|
|
||||||
|
|
||||||
bool Create(ComponentBindingModel model);
|
|
||||||
|
|
||||||
bool Update(ComponentBindingModel model);
|
|
||||||
|
|
||||||
bool Delete(ComponentBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IOrderLogic
|
|
||||||
{
|
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
|
||||||
|
|
||||||
bool CreateOrder(OrderBindingModel model);
|
|
||||||
|
|
||||||
bool TakeOrderInWork(OrderBindingModel model);
|
|
||||||
|
|
||||||
bool FinishOrder(OrderBindingModel model);
|
|
||||||
|
|
||||||
bool DeliveryOrder(OrderBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
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
|
|
||||||
{
|
|
||||||
public interface IShopLogic
|
|
||||||
{
|
|
||||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
|
||||||
|
|
||||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
|
||||||
|
|
||||||
bool Create(ShopBindingModel model);
|
|
||||||
|
|
||||||
bool Update(ShopBindingModel model);
|
|
||||||
|
|
||||||
bool Delete(ShopBindingModel model);
|
|
||||||
|
|
||||||
bool StoreReplenishment(ShopSearchModel shopModel, IWorkModel workModel, int count);
|
|
||||||
|
|
||||||
bool SellWork(IWorkModel workModel, int count);
|
|
||||||
bool CheckAndSupply(IWorkModel workModel, int count);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IWorkLogic
|
|
||||||
{
|
|
||||||
List<WorkViewModel>? ReadList(WorkSearchModel? model);
|
|
||||||
|
|
||||||
WorkViewModel? ReadElement(WorkSearchModel model);
|
|
||||||
|
|
||||||
bool Create(WorkBindingModel model);
|
|
||||||
|
|
||||||
bool Update(WorkBindingModel model);
|
|
||||||
|
|
||||||
bool Delete(WorkBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace PlumbingRepairContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class ComponentSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
public string? ComponentName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace PlumbingRepairContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class OrderSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class ShopSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
public string? ShopName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace PlumbingRepairContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class WorkSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
|
|
||||||
public string? WorkName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IComponentStorage
|
|
||||||
{
|
|
||||||
List<ComponentViewModel> GetFullList();
|
|
||||||
|
|
||||||
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
|
||||||
|
|
||||||
ComponentViewModel? GetElement(ComponentSearchModel model);
|
|
||||||
|
|
||||||
ComponentViewModel? Insert(ComponentBindingModel model);
|
|
||||||
|
|
||||||
ComponentViewModel? Update(ComponentBindingModel model);
|
|
||||||
|
|
||||||
ComponentViewModel? Delete(ComponentBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IOrderStorage
|
|
||||||
{
|
|
||||||
List<OrderViewModel> GetFullList();
|
|
||||||
|
|
||||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
|
||||||
|
|
||||||
OrderViewModel? GetElement(OrderSearchModel model);
|
|
||||||
|
|
||||||
OrderViewModel? Insert(OrderBindingModel model);
|
|
||||||
|
|
||||||
OrderViewModel? Update(OrderBindingModel model);
|
|
||||||
|
|
||||||
OrderViewModel? Delete(OrderBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IShopStorage
|
|
||||||
{
|
|
||||||
List<ShopViewModel> GetFullList();
|
|
||||||
|
|
||||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
|
||||||
|
|
||||||
ShopViewModel? GetElement(ShopSearchModel model);
|
|
||||||
|
|
||||||
ShopViewModel? Insert(ShopBindingModel model);
|
|
||||||
|
|
||||||
ShopViewModel? Update(ShopBindingModel model);
|
|
||||||
|
|
||||||
ShopViewModel? Delete(ShopBindingModel model);
|
|
||||||
|
|
||||||
bool SellWork(IWorkModel workModel, int count);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IWorkStorage
|
|
||||||
{
|
|
||||||
List<WorkViewModel> GetFullList();
|
|
||||||
|
|
||||||
List<WorkViewModel> GetFilteredList(WorkSearchModel model);
|
|
||||||
|
|
||||||
WorkViewModel? GetElement(WorkSearchModel model);
|
|
||||||
|
|
||||||
WorkViewModel? Insert(WorkBindingModel model);
|
|
||||||
|
|
||||||
WorkViewModel? Update(WorkBindingModel model);
|
|
||||||
|
|
||||||
WorkViewModel? Delete(WorkBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ComponentViewModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Название компонента")]
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class OrderViewModel : IOrderModel
|
|
||||||
{
|
|
||||||
[DisplayName("Номер")]
|
|
||||||
public int Id { get; set; }
|
|
||||||
[DisplayName("Номер работы")]
|
|
||||||
public int WorkId { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Работа")]
|
|
||||||
public string WorkName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Сумма")]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Статус")]
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
|
|
||||||
[DisplayName("Дата создания")]
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
|
||||||
|
|
||||||
[DisplayName("Дата выполнения")]
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ShopViewModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Название магазина")]
|
|
||||||
public string ShopName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[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();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace PlumbingRepairContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class WorkViewModel : IWorkModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[DisplayName("Название работ")]
|
|
||||||
public string WorkName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Price { get; set; }
|
|
||||||
[DisplayName("Компоненты")]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
namespace PlumbingRepairDataModels.Enums
|
|
||||||
{
|
|
||||||
public enum OrderStatus
|
|
||||||
{
|
|
||||||
Неизвестен = -1,
|
|
||||||
|
|
||||||
Принят = 0,
|
|
||||||
|
|
||||||
Выполняется = 1,
|
|
||||||
|
|
||||||
Готов = 2,
|
|
||||||
|
|
||||||
Выдан = 3
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace PlumbingRepairDataModels
|
|
||||||
{
|
|
||||||
public interface IId
|
|
||||||
{
|
|
||||||
int Id { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace PlumbingRepairDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IComponentModel : IId
|
|
||||||
{
|
|
||||||
string ComponentName { get; }
|
|
||||||
|
|
||||||
double Cost { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
namespace PlumbingRepairDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IOrderModel : IId
|
|
||||||
{
|
|
||||||
int WorkId { get; }
|
|
||||||
|
|
||||||
int Count { get; }
|
|
||||||
|
|
||||||
double Sum { get; }
|
|
||||||
|
|
||||||
OrderStatus Status { get; }
|
|
||||||
|
|
||||||
DateTime DateCreate { get; }
|
|
||||||
|
|
||||||
DateTime? DateImplement { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
namespace PlumbingRepairDataModels.Models
|
|
||||||
{
|
|
||||||
public class IShopModel
|
|
||||||
{
|
|
||||||
string ShopName { get; }
|
|
||||||
|
|
||||||
string Address { get; }
|
|
||||||
|
|
||||||
DateTime DateOpening { get; }
|
|
||||||
|
|
||||||
int maxCountWorks { get; }
|
|
||||||
|
|
||||||
Dictionary<int, (IWorkModel, int)> ShopWorks { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
namespace PlumbingRepairDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IWorkModel : IId
|
|
||||||
{
|
|
||||||
string WorkName { get; }
|
|
||||||
|
|
||||||
double Price { get; }
|
|
||||||
|
|
||||||
Dictionary<int, (IComponentModel, int)> WorkComponents { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,84 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Components
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.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;
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Components
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
context.Components.Add(newComponent);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
component.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Components.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var element = context.Orders.Include(x => x.Work).FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Orders.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Work)
|
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Work)
|
|
||||||
.Where(x => x.Id == model.Id)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Work)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
context.Orders.Add(newOrder);
|
|
||||||
context.SaveChanges();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Work)
|
|
||||||
.FirstOrDefault()
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var order = context.Orders.Include(x => x.Work).FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
order.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDatabaseImplement.Models;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class ShopStorage : IShopStorage
|
|
||||||
{
|
|
||||||
public List<ShopViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Shops
|
|
||||||
.Include(x => x.Works)
|
|
||||||
.ThenInclude(x => x.Work)
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ShopName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Shops
|
|
||||||
.Include(x => x.Works)
|
|
||||||
.ThenInclude(x => x.Work)
|
|
||||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Shops
|
|
||||||
.Include(x => x.Works)
|
|
||||||
.ThenInclude(x => x.Work)
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Insert(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var newShop = Shop.Create(context, model);
|
|
||||||
if (newShop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
context.Shops.Add(newShop);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newShop.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Update(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var shop = context.Shops.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (shop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
shop.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
shop.UpdateWorks(context, model);
|
|
||||||
transaction.Commit();
|
|
||||||
return shop.GetViewModel;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel? Delete(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var element = context.Shops
|
|
||||||
.Include(x => x.Works)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Shops.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SellWork(IWorkModel model, int count)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return false;
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
foreach (var shopWork in context.ShopWorks.Where(x => x.WorkId == model.Id))
|
|
||||||
{
|
|
||||||
int min = Math.Min(shopWork.Count, count);
|
|
||||||
if (min == shopWork.Count)
|
|
||||||
{
|
|
||||||
context.ShopWorks.Remove(shopWork);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shopWork.Count -= min;
|
|
||||||
}
|
|
||||||
count -= min;
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > 0)
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
transaction.Commit();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class WorkStorage : IWorkStorage
|
|
||||||
{
|
|
||||||
public List<WorkViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Works
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFilteredList(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Works
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.Where(x => x.WorkName.Contains(model.WorkName))
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? GetElement(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
return context.Works
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.WorkName) && x.WorkName == model.WorkName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Insert(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var newWork = Work.Create(context, model);
|
|
||||||
if (newWork == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
context.Works.Add(newWork);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newWork.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Update(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var work = context.Works.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (work == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
work.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
work.UpdateComponents(context, model);
|
|
||||||
transaction.Commit();
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Delete(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new PlumbingRepairDatabase();
|
|
||||||
var element = context.Works
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Works.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,247 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using PlumbingRepairDatabaseImplement;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PlumbingRepairDatabase))]
|
|
||||||
[Migration("20240410163831_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "6.0.27")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<string>("Address")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateOpening")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<string>("ShopName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("maxCountWorks")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Shops");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("ShopId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ShopId");
|
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
|
||||||
b.ToTable("ShopWorks");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("WorkName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Works");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
|
||||||
b.ToTable("WorkComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("WorkId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Shop", "Shop")
|
|
||||||
.WithMany("Works")
|
|
||||||
.HasForeignKey("ShopId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("WorkId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Shop");
|
|
||||||
|
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("WorkComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("WorkId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("WorkComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Works");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,181 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Components",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Cost = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Shops",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
DateOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
maxCountWorks = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Works",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
WorkName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Price = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Works", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Sum = table.Column<double>(type: "float", nullable: false),
|
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
|
||||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Works_WorkId",
|
|
||||||
column: x => x.WorkId,
|
|
||||||
principalTable: "Works",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ShopWorks",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ShopWorks", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ShopWorks_Shops_ShopId",
|
|
||||||
column: x => x.ShopId,
|
|
||||||
principalTable: "Shops",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ShopWorks_Works_WorkId",
|
|
||||||
column: x => x.WorkId,
|
|
||||||
principalTable: "Works",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "WorkComponents",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_WorkComponents", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WorkComponents_Components_ComponentId",
|
|
||||||
column: x => x.ComponentId,
|
|
||||||
principalTable: "Components",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WorkComponents_Works_WorkId",
|
|
||||||
column: x => x.WorkId,
|
|
||||||
principalTable: "Works",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_WorkId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "WorkId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ShopWorks_ShopId",
|
|
||||||
table: "ShopWorks",
|
|
||||||
column: "ShopId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ShopWorks_WorkId",
|
|
||||||
table: "ShopWorks",
|
|
||||||
column: "WorkId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_WorkComponents_ComponentId",
|
|
||||||
table: "WorkComponents",
|
|
||||||
column: "ComponentId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_WorkComponents_WorkId",
|
|
||||||
table: "WorkComponents",
|
|
||||||
column: "WorkId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ShopWorks");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "WorkComponents");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Shops");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Components");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Works");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,245 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using PlumbingRepairDatabaseImplement;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PlumbingRepairDatabase))]
|
|
||||||
partial class PlumbingRepairDatabaseModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "6.0.27")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<string>("Address")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateOpening")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<string>("ShopName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("maxCountWorks")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Shops");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("ShopId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ShopId");
|
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
|
||||||
b.ToTable("ShopWorks");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("WorkName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Works");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
|
||||||
b.ToTable("WorkComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("WorkId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Shop", "Shop")
|
|
||||||
.WithMany("Works")
|
|
||||||
.HasForeignKey("ShopId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("WorkId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Shop");
|
|
||||||
|
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("WorkComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("WorkId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("WorkComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Works");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
|
||||||
public virtual List<WorkComponent> WorkComponents { get; set; } = new();
|
|
||||||
|
|
||||||
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(ComponentViewModel model)
|
|
||||||
{
|
|
||||||
return new Component
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
[Required]
|
|
||||||
public int WorkId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
[Required]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
[Required]
|
|
||||||
public OrderStatus Status { get; set; }
|
|
||||||
[Required]
|
|
||||||
public DateTime DateCreate { get; set; }
|
|
||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public virtual Work Work { get; set; }
|
|
||||||
|
|
||||||
public static Order? Create( OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return null;
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkId = model.WorkId,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return;
|
|
||||||
Status = model.Status;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
WorkId = WorkId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
Id = Id,
|
|
||||||
WorkName = Work.WorkName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Shop
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string ShopName { get; set; } = string.Empty;
|
|
||||||
[Required]
|
|
||||||
public string Address { get; set; } = string.Empty;
|
|
||||||
[Required]
|
|
||||||
public DateTime DateOpening { get; set; }
|
|
||||||
[Required]
|
|
||||||
public int maxCountWorks { get; set; }
|
|
||||||
|
|
||||||
private Dictionary<int, (IWorkModel, int)>? _shopWorks = null;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public Dictionary<int, (IWorkModel, int)> ShopWorks
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_shopWorks == null)
|
|
||||||
{
|
|
||||||
_shopWorks = Works
|
|
||||||
.ToDictionary(recSW => recSW.WorkId, recSW => (recSW.Work as IWorkModel, recSW.Count));
|
|
||||||
}
|
|
||||||
return _shopWorks;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ForeignKey("ShopId")]
|
|
||||||
public virtual List<ShopWork> Works { get; set; } = new();
|
|
||||||
|
|
||||||
public static Shop? Create(PlumbingRepairDatabase context, ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return null;
|
|
||||||
return new Shop()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
maxCountWorks = model.maxCountWorks,
|
|
||||||
Address = model.Address,
|
|
||||||
ShopName = model.ShopName,
|
|
||||||
DateOpening = model.DateOpening,
|
|
||||||
Works = model.ShopWorks.Select(x => new ShopWork
|
|
||||||
{
|
|
||||||
Work = context.Works.First(y => y.Id == x.Key),
|
|
||||||
Count = x.Value.Item2
|
|
||||||
}).ToList()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
return;
|
|
||||||
ShopName = model.ShopName;
|
|
||||||
Address = model.Address;
|
|
||||||
DateOpening = model.DateOpening;
|
|
||||||
maxCountWorks = model.maxCountWorks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
ShopName = ShopName,
|
|
||||||
Address = Address,
|
|
||||||
DateOpening = DateOpening,
|
|
||||||
maxCountWorks = maxCountWorks,
|
|
||||||
Id = Id,
|
|
||||||
ShopWorks = ShopWorks
|
|
||||||
};
|
|
||||||
public void UpdateWorks(PlumbingRepairDatabase context, ShopBindingModel model)
|
|
||||||
{
|
|
||||||
var shopWorks = context.ShopWorks.Where(rec => rec.ShopId == model.Id).ToList();
|
|
||||||
if (shopWorks != null && shopWorks.Count > 0)
|
|
||||||
{
|
|
||||||
context.ShopWorks.RemoveRange(shopWorks.Where(rec => !model.ShopWorks.ContainsKey(rec.WorkId)));
|
|
||||||
context.SaveChanges();
|
|
||||||
// обновили количество у существующих записей
|
|
||||||
foreach (var updateWork in shopWorks)
|
|
||||||
{
|
|
||||||
updateWork.Count = model.ShopWorks[updateWork.WorkId].Item2;
|
|
||||||
model.ShopWorks.Remove(updateWork.WorkId);
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
var shop = context.Shops.First(x => x.Id == Id);
|
|
||||||
foreach (var pc in model.ShopWorks)
|
|
||||||
{
|
|
||||||
context.ShopWorks.Add(new ShopWork
|
|
||||||
{
|
|
||||||
Shop = shop,
|
|
||||||
Work = context.Works.First(x => x.Id == pc.Key),
|
|
||||||
Count = pc.Value.Item2
|
|
||||||
});
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
_shopWorks = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class ShopWork
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int WorkId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int ShopId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
public virtual Work Work { get; set; } = new();
|
|
||||||
public virtual Shop Shop { get; set; } = new();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Work : IWorkModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string WorkName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Price { get; set; }
|
|
||||||
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _workComponents = null;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_workComponents == null)
|
|
||||||
{
|
|
||||||
_workComponents = Components
|
|
||||||
.ToDictionary(recPC => recPC.ComponentId, recPC => (recPC.Component as IComponentModel, recPC.Count));
|
|
||||||
}
|
|
||||||
return _workComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ForeignKey("WorkId")]
|
|
||||||
public virtual List<WorkComponent> Components { get; set; } = new();
|
|
||||||
[ForeignKey("WorkId")]
|
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
|
||||||
|
|
||||||
public static Work Create(PlumbingRepairDatabase context, WorkBindingModel model)
|
|
||||||
{
|
|
||||||
return new Work()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkName = model.WorkName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.WorkComponents.Select(x => new WorkComponent
|
|
||||||
{
|
|
||||||
Component = context.Components.First(y => y.Id == x.Key),
|
|
||||||
Count = x.Value.Item2
|
|
||||||
}).ToList()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
WorkName = model.WorkName;
|
|
||||||
Price = model.Price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
WorkName = WorkName,
|
|
||||||
Price = Price,
|
|
||||||
WorkComponents = WorkComponents
|
|
||||||
};
|
|
||||||
|
|
||||||
public void UpdateComponents(PlumbingRepairDatabase context, WorkBindingModel model)
|
|
||||||
{
|
|
||||||
var workComponents = context.WorkComponents.Where(rec => rec.WorkId == model.Id).ToList();
|
|
||||||
if (workComponents != null && workComponents.Count > 0)
|
|
||||||
{ // удалили те, которых нет в модели
|
|
||||||
context.WorkComponents.RemoveRange(workComponents.Where(rec => !model.WorkComponents.ContainsKey(rec.ComponentId)));
|
|
||||||
context.SaveChanges();
|
|
||||||
// обновили количество у существующих записей
|
|
||||||
foreach (var updateComponent in workComponents)
|
|
||||||
{
|
|
||||||
updateComponent.Count = model.WorkComponents[updateComponent.ComponentId].Item2;
|
|
||||||
model.WorkComponents.Remove(updateComponent.ComponentId);
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
var work = context.Works.First(x => x.Id == Id);
|
|
||||||
foreach (var pc in model.WorkComponents)
|
|
||||||
{
|
|
||||||
context.WorkComponents.Add(new WorkComponent
|
|
||||||
{
|
|
||||||
Work = work,
|
|
||||||
Component = context.Components.First(x => x.Id == pc.Key),
|
|
||||||
Count = pc.Value.Item2
|
|
||||||
});
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
_workComponents = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class WorkComponent
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int WorkId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int ComponentId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
public virtual Component Component { get; set; } = new();
|
|
||||||
|
|
||||||
public virtual Work Work { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
using PlumbingRepairDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace PlumbingRepairDatabaseImplement
|
|
||||||
{
|
|
||||||
public class PlumbingRepairDatabase : DbContext
|
|
||||||
{
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
if (optionsBuilder.IsConfigured == false)
|
|
||||||
{
|
|
||||||
optionsBuilder.UseSqlServer(@"Server=localhost\SQLEXPRESS;Database=PlumbingRepairHard;Trusted_Connection=True;");
|
|
||||||
}
|
|
||||||
base.OnConfiguring(optionsBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual DbSet<Component> Components { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<Work> Works { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<WorkComponent> WorkComponents { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<Shop> Shops { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<ShopWork> ShopWorks { set; get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.27" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.27" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.27">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,66 +0,0 @@
|
|||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement
|
|
||||||
{
|
|
||||||
internal class DataFileSingleton
|
|
||||||
{
|
|
||||||
private static DataFileSingleton? instance;
|
|
||||||
|
|
||||||
private readonly string ComponentFileName = "Component.xml";
|
|
||||||
|
|
||||||
private readonly string OrderFileName = "Order.xml";
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new DataFileSingleton();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Orders.Remove(element);
|
|
||||||
source.SaveOrders();
|
|
||||||
return GetViewModel(element);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Orders
|
|
||||||
.Where(x => x.Id == model.Id)
|
|
||||||
.Select(x => GetViewModel(x))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Orders
|
|
||||||
.Select(x => GetViewModel(x))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Orders.Add(newOrder);
|
|
||||||
source.SaveOrders();
|
|
||||||
return GetViewModel(newOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
order.Update(model);
|
|
||||||
source.SaveOrders();
|
|
||||||
return GetViewModel(order);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OrderViewModel GetViewModel(Order order)
|
|
||||||
{
|
|
||||||
var viewModel = order.GetViewModel;
|
|
||||||
var work = source.Works.FirstOrDefault(x => x.Id == order.WorkId);
|
|
||||||
if (work != null)
|
|
||||||
{
|
|
||||||
viewModel.WorkName = work.WorkName;
|
|
||||||
}
|
|
||||||
return viewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairFileImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class WorkStorage : IWorkStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
|
|
||||||
public WorkStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public WorkViewModel? Delete(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Works.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Works.Remove(element);
|
|
||||||
source.SaveWorks();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? GetElement(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return source.Works
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.WorkName) && x.WorkName == model.WorkName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFilteredList(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Works
|
|
||||||
.Where(x => x.WorkName.Contains(model.WorkName))
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Works
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Insert(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Works.Count > 0 ? source.Works.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newWork = Work.Create(model);
|
|
||||||
if (newWork == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Works.Add(newWork);
|
|
||||||
source.SaveWorks();
|
|
||||||
return newWork.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Update(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
var work = source.Works.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (work == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
work.Update(model);
|
|
||||||
source.SaveWorks();
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
internal 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()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
internal class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int WorkId { 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 int Id { get; private set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
WorkId = model.WorkId,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement,
|
|
||||||
Id = model.Id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Order? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
WorkId = Convert.ToInt32(element.Element("WorkId")!.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()
|
|
||||||
{
|
|
||||||
WorkId = WorkId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
Id = Id,
|
|
||||||
};
|
|
||||||
|
|
||||||
public XElement GetXElement => new(
|
|
||||||
"Order",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("WorkId", WorkId.ToString()),
|
|
||||||
new XElement("Count", Count.ToString()),
|
|
||||||
new XElement("Sum", Sum.ToString()),
|
|
||||||
new XElement("Status", Status.ToString()),
|
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
|
||||||
new XElement("DateImplement", DateImplement.ToString())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace PlumbingRepairFileImplement.Models
|
|
||||||
{
|
|
||||||
internal class Work : IWorkModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public string WorkName { 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)>? _workComponents = null;
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_workComponents == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_workComponents = Components.ToDictionary(x => x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
|
|
||||||
}
|
|
||||||
return _workComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Work? Create(WorkBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Work()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkName = model.WorkName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.WorkComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Work? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Work()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
WorkName = element.Element("WorkName")!.Value,
|
|
||||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
|
||||||
Components = element.Element("WorkComponents")!.Elements("WorkComponent")
|
|
||||||
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(WorkBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WorkName = model.WorkName;
|
|
||||||
Price = model.Price;
|
|
||||||
Components = model.WorkComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
|
|
||||||
_workComponents = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
WorkName = WorkName,
|
|
||||||
Price = Price,
|
|
||||||
WorkComponents = WorkComponents
|
|
||||||
};
|
|
||||||
|
|
||||||
public XElement GetXElement => new("Work",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("WorkName", WorkName),
|
|
||||||
new XElement("Price", Price.ToString()),
|
|
||||||
new XElement("WorkComponents", Components.Select(x => new XElement("WorkComponent",
|
|
||||||
new XElement("Key", x.Key),
|
|
||||||
new XElement("Value", x.Value)))
|
|
||||||
.ToArray()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,35 +0,0 @@
|
|||||||
using PlumbingRepairListImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement
|
|
||||||
{
|
|
||||||
internal class DataListSingleton
|
|
||||||
{
|
|
||||||
private static DataListSingleton? _instance;
|
|
||||||
|
|
||||||
public List<Component> Components { get; set; }
|
|
||||||
|
|
||||||
public List<Order> Orders { get; set; }
|
|
||||||
|
|
||||||
public List<Work> Works { get; set; }
|
|
||||||
|
|
||||||
public List<Shop> Shops { get; set; }
|
|
||||||
|
|
||||||
private DataListSingleton()
|
|
||||||
{
|
|
||||||
Components = new List<Component>();
|
|
||||||
Orders = new List<Order>();
|
|
||||||
Works = new List<Work>();
|
|
||||||
Shops = new List<Shop>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = new DataListSingleton();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairListImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (component.ComponentName.Contains(model.ComponentName))
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && component.Id == model.Id))
|
|
||||||
{
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (model.Id <= component.Id)
|
|
||||||
{
|
|
||||||
model.Id = component.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Components.Add(newComponent);
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var component in _source.Components)
|
|
||||||
{
|
|
||||||
if (component.Id == model.Id)
|
|
||||||
{
|
|
||||||
component.Update(model);
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Components.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Components[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Components[i];
|
|
||||||
_source.Components.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairListImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Orders.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Orders[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Orders[i];
|
|
||||||
_source.Orders.RemoveAt(i);
|
|
||||||
return AttachWorkName(element.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if ( !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if ( model.Id.HasValue && order.Id == model.Id)
|
|
||||||
{
|
|
||||||
return AttachWorkName(order.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
result.Add(AttachWorkName(order.GetViewModel));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
result.Add(AttachWorkName(order.GetViewModel));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id <= order.Id)
|
|
||||||
{
|
|
||||||
model.Id = order.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Orders.Add(newOrder);
|
|
||||||
return AttachWorkName(newOrder.GetViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
order.Update(model);
|
|
||||||
return AttachWorkName(order.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private OrderViewModel AttachWorkName(OrderViewModel model)
|
|
||||||
{
|
|
||||||
var work = _source.Works.Find(b => b.Id == model.WorkId);
|
|
||||||
model.WorkName = work is null ? String.Empty : work.WorkName;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using PlumbingRepairListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ShopStorage : IShopStorage
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public ShopStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShopViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ShopViewModel>();
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
result.Add(shop.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<ShopViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.ShopName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if (shop.ShopName.Contains(model.ShopName))
|
|
||||||
{
|
|
||||||
result.Add(shop.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id))
|
|
||||||
{
|
|
||||||
return shop.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public ShopViewModel? Insert(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if (model.Id <= shop.Id)
|
|
||||||
{
|
|
||||||
model.Id = shop.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newShop = Shop.Create(model);
|
|
||||||
if (newShop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Shops.Add(newShop);
|
|
||||||
return newShop.GetViewModel;
|
|
||||||
}
|
|
||||||
public ShopViewModel? Update(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var shop in _source.Shops)
|
|
||||||
{
|
|
||||||
if (shop.Id == model.Id)
|
|
||||||
{
|
|
||||||
shop.Update(model);
|
|
||||||
return shop.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public ShopViewModel? Delete(ShopBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Shops[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Shops[i];
|
|
||||||
_source.Shops.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public bool SellWork(IWorkModel model, int count)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairListImplement.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Implements
|
|
||||||
{
|
|
||||||
public class WorkStorage : IWorkStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
|
|
||||||
public WorkStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public WorkViewModel? Delete(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Works.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Works[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Works[i];
|
|
||||||
_source.Works.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? GetElement(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var work in _source.Works)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.WorkName) && work.WorkName == model.WorkName) || (model.Id.HasValue && work.Id == model.Id))
|
|
||||||
{
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFilteredList(WorkSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<WorkViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.WorkName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var work in _source.Works)
|
|
||||||
{
|
|
||||||
if (work.WorkName.Contains(model.WorkName))
|
|
||||||
{
|
|
||||||
result.Add(work.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<WorkViewModel>();
|
|
||||||
foreach (var work in _source.Works)
|
|
||||||
{
|
|
||||||
result.Add(work.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Insert(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var work in _source.Works)
|
|
||||||
{
|
|
||||||
if (model.Id <= work.Id)
|
|
||||||
{
|
|
||||||
model.Id = work.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newWork = Work.Create(model);
|
|
||||||
if (newWork == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Works.Add(newWork);
|
|
||||||
return newWork.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel? Update(WorkBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var work in _source.Works)
|
|
||||||
{
|
|
||||||
if (work.Id == model.Id)
|
|
||||||
{
|
|
||||||
work.Update(model);
|
|
||||||
return work.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Models
|
|
||||||
{
|
|
||||||
internal 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 void Update(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Enums;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Models
|
|
||||||
{
|
|
||||||
internal class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int WorkId { get; private set; }
|
|
||||||
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
|
|
||||||
public OrderStatus Status { get; private set; }
|
|
||||||
|
|
||||||
public DateTime DateCreate { get; private set; }
|
|
||||||
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkId = model.WorkId,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement,
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Status = model.Status;
|
|
||||||
DateImplement= model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
WorkId = WorkId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Models
|
|
||||||
{
|
|
||||||
public class Shop
|
|
||||||
{
|
|
||||||
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, (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)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Shop()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ShopName = model.ShopName,
|
|
||||||
Address = model.Address,
|
|
||||||
DateOpening = model.DateOpening,
|
|
||||||
ShopWorks = model.ShopWorks,
|
|
||||||
maxCountWorks = model.maxCountWorks
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(ShopBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ShopName = model.ShopName;
|
|
||||||
Address = model.Address;
|
|
||||||
DateOpening= model.DateOpening;
|
|
||||||
ShopWorks= model.ShopWorks;
|
|
||||||
maxCountWorks= model.maxCountWorks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShopViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ShopName = ShopName,
|
|
||||||
Address = Address,
|
|
||||||
DateOpening = DateOpening,
|
|
||||||
ShopWorks = ShopWorks,
|
|
||||||
maxCountWorks = maxCountWorks
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.ViewModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement.Models
|
|
||||||
{
|
|
||||||
internal class Work : IWorkModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public string WorkName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public double Price { get; private set; }
|
|
||||||
|
|
||||||
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
|
|
||||||
public static Work? Create(WorkBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Work()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
WorkName = model.WorkName,
|
|
||||||
Price = model.Price,
|
|
||||||
WorkComponents = model.WorkComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(WorkBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WorkName = model.WorkName;
|
|
||||||
Price = model.Price;
|
|
||||||
WorkComponents = model.WorkComponents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
WorkName = WorkName,
|
|
||||||
Price = Price,
|
|
||||||
WorkComponents = WorkComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
39
PlumbingRepair/PlumbingRepairView/Form1.Designer.cs
generated
Normal file
39
PlumbingRepair/PlumbingRepairView/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace PlumbingRepairView
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <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.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
PlumbingRepair/PlumbingRepairView/Form1.cs
Normal file
10
PlumbingRepair/PlumbingRepairView/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace PlumbingRepairView
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PlumbingRepair/PlumbingRepairView/Form1.resx
Normal file
120
PlumbingRepair/PlumbingRepairView/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd: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>
|
@ -1,125 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormComponent
|
|
||||||
{
|
|
||||||
/// <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.textBoxCost = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelCost = new System.Windows.Forms.Label();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// textBoxCost
|
|
||||||
//
|
|
||||||
this.textBoxCost.Location = new System.Drawing.Point(135, 68);
|
|
||||||
this.textBoxCost.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.textBoxCost.Name = "textBoxCost";
|
|
||||||
this.textBoxCost.Size = new System.Drawing.Size(183, 31);
|
|
||||||
this.textBoxCost.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// labelCost
|
|
||||||
//
|
|
||||||
this.labelCost.AutoSize = true;
|
|
||||||
this.labelCost.Location = new System.Drawing.Point(25, 73);
|
|
||||||
this.labelCost.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.labelCost.Name = "labelCost";
|
|
||||||
this.labelCost.Size = new System.Drawing.Size(57, 25);
|
|
||||||
this.labelCost.TabIndex = 8;
|
|
||||||
this.labelCost.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(372, 126);
|
|
||||||
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 = 11;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(236, 126);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonSave.TabIndex = 10;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(135, 20);
|
|
||||||
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);
|
|
||||||
this.textBoxName.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(25, 25);
|
|
||||||
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);
|
|
||||||
this.labelName.TabIndex = 6;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// FormComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(512, 195);
|
|
||||||
this.Controls.Add(this.textBoxCost);
|
|
||||||
this.Controls.Add(this.labelCost);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormComponent";
|
|
||||||
this.Text = "Компонент";
|
|
||||||
this.Load += new System.EventHandler(this.FormComponent_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBoxCost;
|
|
||||||
private Label labelCost;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormComponent : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
|
|
||||||
private int? _id;
|
|
||||||
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormComponent_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение компонента");
|
|
||||||
var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value });
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.ComponentName;
|
|
||||||
textBoxCost.Text = view.Cost.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение компонента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new ComponentBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
ComponentName = textBoxName.Text,
|
|
||||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
|
||||||
};
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
@ -1,127 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormComponents
|
|
||||||
{
|
|
||||||
/// <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.buttonRef = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(646, 254);
|
|
||||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonRef.TabIndex = 9;
|
|
||||||
this.buttonRef.Text = "Обновить";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
this.buttonDel.Location = new System.Drawing.Point(646, 175);
|
|
||||||
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonDel.Name = "buttonDel";
|
|
||||||
this.buttonDel.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonDel.TabIndex = 8;
|
|
||||||
this.buttonDel.Text = "Удалить";
|
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(646, 96);
|
|
||||||
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonUpd.TabIndex = 7;
|
|
||||||
this.buttonUpd.Text = "Изменить";
|
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(646, 23);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonAdd.TabIndex = 6;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.dataGridView.MultiSelect = false;
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.ReadOnly = true;
|
|
||||||
this.dataGridView.RowHeadersVisible = false;
|
|
||||||
this.dataGridView.RowHeadersWidth = 62;
|
|
||||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(583, 650);
|
|
||||||
this.dataGridView.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// FormComponents
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 650);
|
|
||||||
this.Controls.Add(this.buttonRef);
|
|
||||||
this.Controls.Add(this.buttonDel);
|
|
||||||
this.Controls.Add(this.buttonUpd);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormComponents";
|
|
||||||
this.Text = "Компоненты";
|
|
||||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonRef;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormComponents : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
|
|
||||||
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление компонента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new ComponentBindingModel { Id = id }))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
@ -1,154 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormCreateOrder
|
|
||||||
{
|
|
||||||
/// <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.labelSum = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxWork = new System.Windows.Forms.ComboBox();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelWork = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelSum
|
|
||||||
//
|
|
||||||
this.labelSum.AutoSize = true;
|
|
||||||
this.labelSum.Location = new System.Drawing.Point(9, 122);
|
|
||||||
this.labelSum.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
|
||||||
this.labelSum.Name = "labelSum";
|
|
||||||
this.labelSum.Size = new System.Drawing.Size(71, 25);
|
|
||||||
this.labelSum.TabIndex = 12;
|
|
||||||
this.labelSum.Text = "Сумма:";
|
|
||||||
//
|
|
||||||
// textBoxSum
|
|
||||||
//
|
|
||||||
this.textBoxSum.Location = new System.Drawing.Point(134, 116);
|
|
||||||
this.textBoxSum.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.textBoxSum.Name = "textBoxSum";
|
|
||||||
this.textBoxSum.ReadOnly = true;
|
|
||||||
this.textBoxSum.Size = new System.Drawing.Size(359, 31);
|
|
||||||
this.textBoxSum.TabIndex = 13;
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(9, 72);
|
|
||||||
this.labelCount.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(111, 25);
|
|
||||||
this.labelCount.TabIndex = 10;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// comboBoxWork
|
|
||||||
//
|
|
||||||
this.comboBoxWork.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxWork.FormattingEnabled = true;
|
|
||||||
this.comboBoxWork.Location = new System.Drawing.Point(134, 15);
|
|
||||||
this.comboBoxWork.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.comboBoxWork.Name = "comboBoxWork";
|
|
||||||
this.comboBoxWork.Size = new System.Drawing.Size(359, 33);
|
|
||||||
this.comboBoxWork.TabIndex = 9;
|
|
||||||
this.comboBoxWork.SelectedIndexChanged += new System.EventHandler(this.ComboBoxWork_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(354, 166);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonCancel.TabIndex = 15;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(219, 166);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonSave.TabIndex = 14;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(134, 66);
|
|
||||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(359, 31);
|
|
||||||
this.textBoxCount.TabIndex = 11;
|
|
||||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
|
||||||
//
|
|
||||||
// labelWork
|
|
||||||
//
|
|
||||||
this.labelWork.AutoSize = true;
|
|
||||||
this.labelWork.Location = new System.Drawing.Point(9, 20);
|
|
||||||
this.labelWork.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
|
||||||
this.labelWork.Name = "labelWork";
|
|
||||||
this.labelWork.Size = new System.Drawing.Size(72, 25);
|
|
||||||
this.labelWork.TabIndex = 8;
|
|
||||||
this.labelWork.Text = "Работа:";
|
|
||||||
//
|
|
||||||
// FormCreateOrder
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(534, 228);
|
|
||||||
this.Controls.Add(this.labelSum);
|
|
||||||
this.Controls.Add(this.textBoxSum);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.comboBoxWork);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.labelWork);
|
|
||||||
this.Name = "FormCreateOrder";
|
|
||||||
this.Text = "Заказ";
|
|
||||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelSum;
|
|
||||||
private TextBox textBoxSum;
|
|
||||||
private Label labelCount;
|
|
||||||
private ComboBox comboBoxWork;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private Label labelWork;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormCreateOrder : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IWorkLogic _logicW;
|
|
||||||
|
|
||||||
private readonly IOrderLogic _logicO;
|
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWorkLogic logicW, IOrderLogic logicO)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logicW = logicW;
|
|
||||||
_logicO = logicO;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logicW.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxWork.DataSource = list;
|
|
||||||
comboBoxWork.DisplayMember = "WorkName";
|
|
||||||
comboBoxWork.ValueMember = "Id";
|
|
||||||
comboBoxWork.SelectedItem= null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка работ");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки работ");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CalcSum()
|
|
||||||
{
|
|
||||||
if (comboBoxWork.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(comboBoxWork.SelectedValue);
|
|
||||||
var work = _logicW.ReadElement(new WorkSearchModel { Id = id });
|
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
|
||||||
textBoxSum.Text = Math.Round(count * (work?.Price ?? 0), 2).ToString();
|
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComboBoxWork_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxWork.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Создание заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
WorkId = Convert.ToInt32(comboBoxWork.SelectedValue),
|
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
|
||||||
Sum = Convert.ToDouble(textBoxSum.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
226
PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
generated
226
PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
generated
@ -1,226 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormMain
|
|
||||||
{
|
|
||||||
/// <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.buttonRef = new System.Windows.Forms.Button();
|
|
||||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
|
||||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
|
||||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
|
||||||
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();
|
|
||||||
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();
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(1113, 373);
|
|
||||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(249, 45);
|
|
||||||
this.buttonRef.TabIndex = 11;
|
|
||||||
this.buttonRef.Text = "Обновить список";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonIssuedOrder
|
|
||||||
//
|
|
||||||
this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(1113, 297);
|
|
||||||
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
|
||||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(249, 45);
|
|
||||||
this.buttonIssuedOrder.TabIndex = 10;
|
|
||||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
|
||||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
|
||||||
//
|
|
||||||
// buttonOrderReady
|
|
||||||
//
|
|
||||||
this.buttonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonOrderReady.Location = new System.Drawing.Point(1113, 225);
|
|
||||||
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
|
||||||
this.buttonOrderReady.Size = new System.Drawing.Size(249, 45);
|
|
||||||
this.buttonOrderReady.TabIndex = 9;
|
|
||||||
this.buttonOrderReady.Text = "Заказ готов";
|
|
||||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
|
||||||
//
|
|
||||||
// buttonTakeOrderInWork
|
|
||||||
//
|
|
||||||
this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1113, 158);
|
|
||||||
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
|
||||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(249, 45);
|
|
||||||
this.buttonTakeOrderInWork.TabIndex = 8;
|
|
||||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
|
||||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
|
||||||
//
|
|
||||||
// buttonCreateOrder
|
|
||||||
//
|
|
||||||
this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(1113, 83);
|
|
||||||
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
|
||||||
this.buttonCreateOrder.Size = new System.Drawing.Size(249, 45);
|
|
||||||
this.buttonCreateOrder.TabIndex = 7;
|
|
||||||
this.buttonCreateOrder.Text = "Создать заказ";
|
|
||||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(2, 44);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.dataGridView.MultiSelect = false;
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.ReadOnly = true;
|
|
||||||
this.dataGridView.RowHeadersVisible = false;
|
|
||||||
this.dataGridView.RowHeadersWidth = 62;
|
|
||||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(1055, 533);
|
|
||||||
this.dataGridView.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// menuStrip1
|
|
||||||
//
|
|
||||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
|
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.справочникиToolStripMenuItem});
|
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(1377, 33);
|
|
||||||
this.menuStrip1.TabIndex = 12;
|
|
||||||
this.menuStrip1.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
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 = "Справочники";
|
|
||||||
//
|
|
||||||
// компоненты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);
|
|
||||||
//
|
|
||||||
// Работы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);
|
|
||||||
//
|
|
||||||
// магазины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);
|
|
||||||
//
|
|
||||||
// п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);
|
|
||||||
//
|
|
||||||
// продажаРабот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);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(1377, 602);
|
|
||||||
this.Controls.Add(this.buttonRef);
|
|
||||||
this.Controls.Add(this.buttonIssuedOrder);
|
|
||||||
this.Controls.Add(this.buttonOrderReady);
|
|
||||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
|
||||||
this.Controls.Add(this.buttonCreateOrder);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Controls.Add(this.menuStrip1);
|
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
|
||||||
this.Name = "FormMain";
|
|
||||||
this.Text = "Ремонт труб";
|
|
||||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.menuStrip1.ResumeLayout(false);
|
|
||||||
this.menuStrip1.PerformLayout();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonRef;
|
|
||||||
private Button buttonIssuedOrder;
|
|
||||||
private Button buttonOrderReady;
|
|
||||||
private Button buttonTakeOrderInWork;
|
|
||||||
private Button buttonCreateOrder;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private MenuStrip menuStrip1;
|
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem РаботыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem пToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem продажаРаботToolStripMenuItem;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,172 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormMain : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IOrderLogic _orderLogic;
|
|
||||||
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_orderLogic = orderLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _orderLogic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["WorkId"].Visible= false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
|
||||||
if (service is FormComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void РаботыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorks));
|
|
||||||
if (service is FormWorks form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
|
||||||
if (service is FormShops form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void пополнениеToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormStoreReplenishment));
|
|
||||||
if (service is FormStoreReplenishment form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
||||||
if (service is FormCreateOrder form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void продажаРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellWorks));
|
|
||||||
if (service is FormSellWorks form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<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>
|
|
||||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,126 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
246
PlumbingRepair/PlumbingRepairView/FormShop.Designer.cs
generated
246
PlumbingRepair/PlumbingRepairView/FormShop.Designer.cs
generated
@ -1,246 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormShop
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelAddress = new System.Windows.Forms.Label();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.dateTimePickerOpening = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.groupBoxComponents = new System.Windows.Forms.GroupBox();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.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(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);
|
|
||||||
this.textBoxAddress.TabIndex = 15;
|
|
||||||
//
|
|
||||||
// labelAddress
|
|
||||||
//
|
|
||||||
this.labelAddress.AutoSize = true;
|
|
||||||
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);
|
|
||||||
this.labelAddress.TabIndex = 14;
|
|
||||||
this.labelAddress.Text = "Адрес:";
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(633, 149);
|
|
||||||
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 = 17;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(633, 50);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonSave.TabIndex = 16;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
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);
|
|
||||||
this.textBoxName.TabIndex = 13;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
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);
|
|
||||||
this.labelName.TabIndex = 12;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// dateTimePickerOpening
|
|
||||||
//
|
|
||||||
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;
|
|
||||||
//
|
|
||||||
// groupBoxComponents
|
|
||||||
//
|
|
||||||
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, 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);
|
|
||||||
this.groupBoxComponents.Size = new System.Drawing.Size(797, 379);
|
|
||||||
this.groupBoxComponents.TabIndex = 19;
|
|
||||||
this.groupBoxComponents.TabStop = false;
|
|
||||||
this.groupBoxComponents.Text = "Компоненты";
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ColumnId,
|
|
||||||
this.ColumnName,
|
|
||||||
this.ColumnCount});
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(6, 29);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.dataGridView.MultiSelect = false;
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.ReadOnly = true;
|
|
||||||
this.dataGridView.RowHeadersVisible = false;
|
|
||||||
this.dataGridView.RowHeadersWidth = 62;
|
|
||||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(583, 345);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnId
|
|
||||||
//
|
|
||||||
this.ColumnId.HeaderText = "Id";
|
|
||||||
this.ColumnId.MinimumWidth = 8;
|
|
||||||
this.ColumnId.Name = "ColumnId";
|
|
||||||
this.ColumnId.ReadOnly = true;
|
|
||||||
this.ColumnId.Visible = false;
|
|
||||||
this.ColumnId.Width = 150;
|
|
||||||
//
|
|
||||||
// ColumnName
|
|
||||||
//
|
|
||||||
this.ColumnName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.ColumnName.HeaderText = "Работа";
|
|
||||||
this.ColumnName.MinimumWidth = 8;
|
|
||||||
this.ColumnName.Name = "ColumnName";
|
|
||||||
this.ColumnName.ReadOnly = true;
|
|
||||||
//
|
|
||||||
// ColumnCount
|
|
||||||
//
|
|
||||||
this.ColumnCount.HeaderText = "Количество";
|
|
||||||
this.ColumnCount.MinimumWidth = 8;
|
|
||||||
this.ColumnCount.Name = "ColumnCount";
|
|
||||||
this.ColumnCount.ReadOnly = true;
|
|
||||||
this.ColumnCount.Width = 150;
|
|
||||||
//
|
|
||||||
// labelDateOpening
|
|
||||||
//
|
|
||||||
this.labelDateOpening.AutoSize = true;
|
|
||||||
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, 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);
|
|
||||||
this.Controls.Add(this.textBoxAddress);
|
|
||||||
this.Controls.Add(this.labelAddress);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormShop";
|
|
||||||
this.Text = "Магазин";
|
|
||||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
|
||||||
this.groupBoxComponents.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBoxAddress;
|
|
||||||
private Label labelAddress;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
private DateTimePicker dateTimePickerOpening;
|
|
||||||
private GroupBox groupBoxComponents;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private DataGridViewTextBoxColumn ColumnId;
|
|
||||||
private DataGridViewTextBoxColumn ColumnName;
|
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
|
||||||
private Label labelDateOpening;
|
|
||||||
private TextBox textBoxMaxCount;
|
|
||||||
private Label labelMaxCount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormShop : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IShopLogic _logic;
|
|
||||||
|
|
||||||
private int? _id;
|
|
||||||
|
|
||||||
private Dictionary<int, (IWorkModel, int)> _shopWorks;
|
|
||||||
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
_shopWorks = new Dictionary<int, (IWorkModel, int)>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormShop_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка изделия");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value });
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка изделий магазина");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_shopWorks != null)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var pc in _shopWorks)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.WorkName, pc.Value.Item2 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки работ магазина");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение магазина");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new ShopBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
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);
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
127
PlumbingRepair/PlumbingRepairView/FormShops.Designer.cs
generated
127
PlumbingRepair/PlumbingRepairView/FormShops.Designer.cs
generated
@ -1,127 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormShops
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(786, 234);
|
|
||||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonRef.TabIndex = 19;
|
|
||||||
this.buttonRef.Text = "Обновить";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
this.buttonDel.Location = new System.Drawing.Point(786, 156);
|
|
||||||
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonDel.Name = "buttonDel";
|
|
||||||
this.buttonDel.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonDel.TabIndex = 18;
|
|
||||||
this.buttonDel.Text = "Удалить";
|
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(786, 77);
|
|
||||||
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonUpd.TabIndex = 17;
|
|
||||||
this.buttonUpd.Text = "Изменить";
|
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(786, 4);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonAdd.TabIndex = 16;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.dataGridView.MultiSelect = false;
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.ReadOnly = true;
|
|
||||||
this.dataGridView.RowHeadersVisible = false;
|
|
||||||
this.dataGridView.RowHeadersWidth = 62;
|
|
||||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(767, 446);
|
|
||||||
this.dataGridView.TabIndex = 15;
|
|
||||||
//
|
|
||||||
// FormShops
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(926, 446);
|
|
||||||
this.Controls.Add(this.buttonRef);
|
|
||||||
this.Controls.Add(this.buttonDel);
|
|
||||||
this.Controls.Add(this.buttonUpd);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormShops";
|
|
||||||
this.Text = "Магазины";
|
|
||||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonRef;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormShops : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IShopLogic _logic;
|
|
||||||
|
|
||||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormShop_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ShopWorks"].Visible = false;
|
|
||||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка магазинов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
|
||||||
if (service is FormShop form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
|
||||||
if (service is FormShop form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление магазина");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new ShopBindingModel { Id = id }))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
@ -1,153 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormStoreReplenishment
|
|
||||||
{
|
|
||||||
/// <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.labelWorkName = new System.Windows.Forms.Label();
|
|
||||||
this.labelShopName = new System.Windows.Forms.Label();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
|
||||||
this.comboBoxWork = new System.Windows.Forms.ComboBox();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(128, 109);
|
|
||||||
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;
|
|
||||||
//
|
|
||||||
// labelWorkName
|
|
||||||
//
|
|
||||||
this.labelWorkName.AutoSize = true;
|
|
||||||
this.labelWorkName.Location = new System.Drawing.Point(5, 67);
|
|
||||||
this.labelWorkName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.labelWorkName.Name = "labelWorkName";
|
|
||||||
this.labelWorkName.Size = new System.Drawing.Size(72, 25);
|
|
||||||
this.labelWorkName.TabIndex = 12;
|
|
||||||
this.labelWorkName.Text = "Работа:";
|
|
||||||
//
|
|
||||||
// labelShopName
|
|
||||||
//
|
|
||||||
this.labelShopName.AutoSize = true;
|
|
||||||
this.labelShopName.Location = new System.Drawing.Point(5, 19);
|
|
||||||
this.labelShopName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.labelShopName.Name = "labelShopName";
|
|
||||||
this.labelShopName.Size = new System.Drawing.Size(85, 25);
|
|
||||||
this.labelShopName.TabIndex = 10;
|
|
||||||
this.labelShopName.Text = "Магазин:";
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(5, 115);
|
|
||||||
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 = 14;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// comboBoxShop
|
|
||||||
//
|
|
||||||
this.comboBoxShop.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(128, 19);
|
|
||||||
this.comboBoxShop.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(359, 33);
|
|
||||||
this.comboBoxShop.TabIndex = 15;
|
|
||||||
//
|
|
||||||
// comboBoxWork
|
|
||||||
//
|
|
||||||
this.comboBoxWork.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxWork.FormattingEnabled = true;
|
|
||||||
this.comboBoxWork.Location = new System.Drawing.Point(128, 59);
|
|
||||||
this.comboBoxWork.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.comboBoxWork.Name = "comboBoxWork";
|
|
||||||
this.comboBoxWork.Size = new System.Drawing.Size(359, 33);
|
|
||||||
this.comboBoxWork.TabIndex = 16;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(15, 182);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonSave.TabIndex = 18;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(331, 182);
|
|
||||||
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 = 19;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormStoreReplenishment
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(501, 239);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.comboBoxWork);
|
|
||||||
this.Controls.Add(this.comboBoxShop);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.labelWorkName);
|
|
||||||
this.Controls.Add(this.labelShopName);
|
|
||||||
this.Name = "FormStoreReplenishment";
|
|
||||||
this.Text = "Пополнение магазина";
|
|
||||||
this.Load += new System.EventHandler(this.FormStoreReplenishment_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private Label labelWorkName;
|
|
||||||
private Label labelShopName;
|
|
||||||
private Label labelCount;
|
|
||||||
private ComboBox comboBoxShop;
|
|
||||||
private ComboBox comboBoxWork;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormStoreReplenishment : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IWorkLogic _workLogic;
|
|
||||||
|
|
||||||
private readonly IShopLogic _logicShop;
|
|
||||||
|
|
||||||
public FormStoreReplenishment(ILogger<FormStoreReplenishment> logger, IWorkLogic workLogic, IShopLogic logicShop)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_workLogic = workLogic;
|
|
||||||
_logicShop = logicShop;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormStoreReplenishment_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Works 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);
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Shops loading");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logicShop.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxShop.DisplayMember = "ShopName";
|
|
||||||
comboBoxShop.ValueMember = "Id";
|
|
||||||
comboBoxShop.DataSource = list;
|
|
||||||
comboBoxShop.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Shops loading error");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (comboBoxShop.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxWork.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите работу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Shop replenishment");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var work = _workLogic.ReadElement(new WorkSearchModel
|
|
||||||
{ Id = Convert.ToInt32(comboBoxWork.SelectedValue) });
|
|
||||||
if (work == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Работа не найдена.");
|
|
||||||
}
|
|
||||||
var operationResult = _logicShop.StoreReplenishment(new ShopSearchModel
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(comboBoxShop.SelectedValue)
|
|
||||||
},
|
|
||||||
work,
|
|
||||||
Convert.ToInt32(textBoxCount.Text));
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при проведении поставки.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Shop replenishment error");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
256
PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
generated
256
PlumbingRepair/PlumbingRepairView/FormWork.Designer.cs
generated
@ -1,256 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormWork
|
|
||||||
{
|
|
||||||
/// <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.textBoxPrice = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelPrice = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.groupBoxComponents = new System.Windows.Forms.GroupBox();
|
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.groupBoxComponents.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// textBoxPrice
|
|
||||||
//
|
|
||||||
this.textBoxPrice.Enabled = false;
|
|
||||||
this.textBoxPrice.Location = new System.Drawing.Point(126, 64);
|
|
||||||
this.textBoxPrice.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.textBoxPrice.Name = "textBoxPrice";
|
|
||||||
this.textBoxPrice.Size = new System.Drawing.Size(208, 31);
|
|
||||||
this.textBoxPrice.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
this.labelPrice.AutoSize = true;
|
|
||||||
this.labelPrice.Location = new System.Drawing.Point(15, 69);
|
|
||||||
this.labelPrice.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.labelPrice.Name = "labelPrice";
|
|
||||||
this.labelPrice.Size = new System.Drawing.Size(103, 25);
|
|
||||||
this.labelPrice.TabIndex = 9;
|
|
||||||
this.labelPrice.Text = "Стоимость:";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(126, 14);
|
|
||||||
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);
|
|
||||||
this.textBoxName.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(15, 19);
|
|
||||||
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);
|
|
||||||
this.labelName.TabIndex = 7;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(630, 53);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonAdd.TabIndex = 1;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// groupBoxComponents
|
|
||||||
//
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonRef);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonDel);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonUpd);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonAdd);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.dataGridView);
|
|
||||||
this.groupBoxComponents.Location = new System.Drawing.Point(15, 114);
|
|
||||||
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);
|
|
||||||
this.groupBoxComponents.Size = new System.Drawing.Size(797, 480);
|
|
||||||
this.groupBoxComponents.TabIndex = 11;
|
|
||||||
this.groupBoxComponents.TabStop = false;
|
|
||||||
this.groupBoxComponents.Text = "Компоненты";
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(630, 285);
|
|
||||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonRef.TabIndex = 4;
|
|
||||||
this.buttonRef.Text = "Обновить";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
this.buttonDel.Location = new System.Drawing.Point(630, 205);
|
|
||||||
this.buttonDel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonDel.Name = "buttonDel";
|
|
||||||
this.buttonDel.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonDel.TabIndex = 3;
|
|
||||||
this.buttonDel.Text = "Удалить";
|
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(630, 127);
|
|
||||||
this.buttonUpd.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonUpd.TabIndex = 2;
|
|
||||||
this.buttonUpd.Text = "Изменить";
|
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ColumnId,
|
|
||||||
this.ColumnName,
|
|
||||||
this.ColumnCount});
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(6, 29);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.dataGridView.MultiSelect = false;
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.ReadOnly = true;
|
|
||||||
this.dataGridView.RowHeadersVisible = false;
|
|
||||||
this.dataGridView.RowHeadersWidth = 62;
|
|
||||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(583, 446);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnId
|
|
||||||
//
|
|
||||||
this.ColumnId.HeaderText = "Id";
|
|
||||||
this.ColumnId.MinimumWidth = 8;
|
|
||||||
this.ColumnId.Name = "ColumnId";
|
|
||||||
this.ColumnId.ReadOnly = true;
|
|
||||||
this.ColumnId.Visible = false;
|
|
||||||
this.ColumnId.Width = 150;
|
|
||||||
//
|
|
||||||
// ColumnName
|
|
||||||
//
|
|
||||||
this.ColumnName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.ColumnName.HeaderText = "Компонент";
|
|
||||||
this.ColumnName.MinimumWidth = 8;
|
|
||||||
this.ColumnName.Name = "ColumnName";
|
|
||||||
this.ColumnName.ReadOnly = true;
|
|
||||||
//
|
|
||||||
// ColumnCount
|
|
||||||
//
|
|
||||||
this.ColumnCount.HeaderText = "Количество";
|
|
||||||
this.ColumnCount.MinimumWidth = 8;
|
|
||||||
this.ColumnCount.Name = "ColumnCount";
|
|
||||||
this.ColumnCount.ReadOnly = true;
|
|
||||||
this.ColumnCount.Width = 150;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(645, 605);
|
|
||||||
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 = 13;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(509, 605);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(126, 45);
|
|
||||||
this.buttonSave.TabIndex = 12;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// FormWork
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 656);
|
|
||||||
this.Controls.Add(this.textBoxPrice);
|
|
||||||
this.Controls.Add(this.labelPrice);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.groupBoxComponents);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Name = "FormWork";
|
|
||||||
this.Text = "Работа";
|
|
||||||
this.Load += new System.EventHandler(this.FormWork_Load);
|
|
||||||
this.groupBoxComponents.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBoxPrice;
|
|
||||||
private Label labelPrice;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private GroupBox groupBoxComponents;
|
|
||||||
private Button buttonRef;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private DataGridViewTextBoxColumn ColumnId;
|
|
||||||
private DataGridViewTextBoxColumn ColumnName;
|
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,208 +0,0 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
||||||
using PlumbingRepairContracts.SearchModels;
|
|
||||||
using PlumbingRepairDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
public partial class FormWork : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IWorkLogic _logic;
|
|
||||||
|
|
||||||
private int? _id;
|
|
||||||
|
|
||||||
private Dictionary<int, (IComponentModel, int)> _workComponents;
|
|
||||||
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormWork(ILogger<FormWork> logger, IWorkLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
_workComponents = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormWork_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка работы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var view = _logic.ReadElement(new WorkSearchModel { Id = _id.Value });
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.WorkName;
|
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
|
||||||
_workComponents = view.WorkComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки работы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка компонент работы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_workComponents != null)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var pc in _workComponents)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
|
||||||
}
|
|
||||||
textBoxPrice.Text = CalcPrice().ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонент работы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent));
|
|
||||||
if (service is FormWorkComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
if (_workComponents.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_workComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent));
|
|
||||||
if (service is FormWorkComponent form)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
|
||||||
form.Id = id;
|
|
||||||
form.Count = _workComponents[id].Item2;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление компонента: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
|
||||||
_workComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_workComponents == null || _workComponents.Count == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение работы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new WorkBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
WorkName = textBoxName.Text,
|
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
|
||||||
WorkComponents = _workComponents
|
|
||||||
};
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения работы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double CalcPrice()
|
|
||||||
{
|
|
||||||
double price = 0;
|
|
||||||
foreach (var elem in _workComponents)
|
|
||||||
{
|
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
|
||||||
}
|
|
||||||
return Math.Round(price * 1.1, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace PlumbingRepairView
|
|
||||||
{
|
|
||||||
partial class FormWorkComponent
|
|
||||||
{
|
|
||||||
/// <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.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxComponent = new System.Windows.Forms.ComboBox();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelComponent = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(4, 91);
|
|
||||||
this.labelCount.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(111, 25);
|
|
||||||
this.labelCount.TabIndex = 8;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// comboBoxComponent
|
|
||||||
//
|
|
||||||
this.comboBoxComponent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxComponent.FormattingEnabled = true;
|
|
||||||
this.comboBoxComponent.Location = new System.Drawing.Point(129, 34);
|
|
||||||
this.comboBoxComponent.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.comboBoxComponent.Name = "comboBoxComponent";
|
|
||||||
this.comboBoxComponent.Size = new System.Drawing.Size(359, 33);
|
|
||||||
this.comboBoxComponent.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(347, 135);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonCancel.TabIndex = 11;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(212, 135);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(125, 44);
|
|
||||||
this.buttonSave.TabIndex = 10;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(129, 85);
|
|
||||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(359, 31);
|
|
||||||
this.textBoxCount.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// labelComponent
|
|
||||||
//
|
|
||||||
this.labelComponent.AutoSize = true;
|
|
||||||
this.labelComponent.Location = new System.Drawing.Point(4, 39);
|
|
||||||
this.labelComponent.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
|
||||||
this.labelComponent.Name = "labelComponent";
|
|
||||||
this.labelComponent.Size = new System.Drawing.Size(107, 25);
|
|
||||||
this.labelComponent.TabIndex = 6;
|
|
||||||
this.labelComponent.Text = "Компонент:";
|
|
||||||
//
|
|
||||||
// FormWorkComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(513, 210);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.comboBoxComponent);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.labelComponent);
|
|
||||||
this.Name = "FormWorkComponent";
|
|
||||||
this.Text = "Компонент изделия";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelCount;
|
|
||||||
private ComboBox comboBoxComponent;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private Label labelComponent;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user