Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d0ccaea66 | |||
| 82ce660a86 | |||
| e3a1f15b7c |
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopBusinessLogic",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopListImplement", "AutoWorkshopImplement\AutoWorkshopListImplement.csproj", "{B564F5E8-2F14-4816-8481-1F9649F1F414}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopFileImplement", "AutoWorkshopFileImplement\AutoWorkshopFileImplement.csproj", "{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -39,6 +41,10 @@ Global
|
||||
{B564F5E8-2F14-4816-8481-1F9649F1F414}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B564F5E8-2F14-4816-8481-1F9649F1F414}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B564F5E8-2F14-4816-8481-1F9649F1F414}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IRepairStorage _repairStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> Logger, IShopStorage ShopStorage, IRepairStorage RepairStorage)
|
||||
{
|
||||
_logger = Logger;
|
||||
_shopStorage = ShopStorage;
|
||||
_repairStorage = RepairStorage;
|
||||
}
|
||||
|
||||
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 MakeSupply(SupplyBindingModel Model)
|
||||
{
|
||||
if (Model == null)
|
||||
throw new ArgumentNullException(nameof(Model));
|
||||
|
||||
if (Model.Count <= 0)
|
||||
throw new ArgumentException("Количество ремонтов должно быть больше 0");
|
||||
|
||||
var Shop = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
Id = Model.ShopId
|
||||
});
|
||||
|
||||
if (Shop == null)
|
||||
throw new ArgumentException("Магазина не существует");
|
||||
|
||||
if (Shop.ShopRepairs.ContainsKey(Model.RepairId))
|
||||
{
|
||||
var OldValue = Shop.ShopRepairs[Model.RepairId];
|
||||
OldValue.Item2 += Model.Count;
|
||||
Shop.ShopRepairs[Model.RepairId] = OldValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
var Repair = _repairStorage.GetElement(new RepairSearchModel
|
||||
{
|
||||
Id = Model.RepairId
|
||||
});
|
||||
|
||||
if (Repair == null)
|
||||
throw new ArgumentException($"Поставка: Товар с id:{Model.RepairId} не найденн");
|
||||
|
||||
Shop.ShopRepairs.Add(Model.RepairId, (Repair, Model.Count));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ShopBindingModel Model, bool WithParams=true)
|
||||
{
|
||||
if (Model == null)
|
||||
throw new ArgumentNullException(nameof(Model));
|
||||
|
||||
if (!WithParams)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(Model.Address))
|
||||
throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(Model.Address));
|
||||
|
||||
if (string.IsNullOrEmpty(Model.ShopName))
|
||||
throw new ArgumentException("Название магазина должно быть заполнено", nameof(Model.ShopName));
|
||||
|
||||
_logger.LogInformation("Shop. ShopName: {ShopName}. Address: {Address}. OpeningDate: {OpeningDate}. Id:{Id}",
|
||||
Model.ShopName, Model.Address, Model.OpeningDate, Model.Id);
|
||||
|
||||
var Element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
ShopName = Model.ShopName
|
||||
});
|
||||
if (Element != null && Element.Id != Model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using AutoWorkshopDataModels.Models;
|
||||
|
||||
namespace AutoWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using AutoWorkshopDataModels.Models;
|
||||
|
||||
namespace AutoWorkshopContracts.BindingModels
|
||||
{
|
||||
public class SupplyBindingModel : ISupplyModel
|
||||
{
|
||||
public int ShopId { get; set; }
|
||||
|
||||
public int RepairId { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopContracts.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 MakeSupply(SupplyBindingModel Model);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace AutoWorkshopContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopContracts.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);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace AutoWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Адрес")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime OpeningDate { get; set; }
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace AutoWorkshopDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
|
||||
string Address { get; }
|
||||
|
||||
DateTime OpeningDate { get; }
|
||||
|
||||
Dictionary<int, (IRepairModel, int)> ShopRepairs { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace AutoWorkshopDataModels.Models
|
||||
{
|
||||
public interface ISupplyModel
|
||||
{
|
||||
int ShopId { get; }
|
||||
|
||||
int RepairId { get; }
|
||||
|
||||
int Count { get; }
|
||||
}
|
||||
}
|
||||
14
AutoWorkshopFileImplement/AutoWorkshopFileImplement.csproj
Normal file
14
AutoWorkshopFileImplement/AutoWorkshopFileImplement.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoWorkshopContracts\AutoWorkshopContracts.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopDataModels\AutoWorkshopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
59
AutoWorkshopFileImplement/DataFileSingleton.cs
Normal file
59
AutoWorkshopFileImplement/DataFileSingleton.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutoWorkshopFileImplement
|
||||
{
|
||||
public class DataFileSingleton
|
||||
{
|
||||
private static DataFileSingleton? _instance;
|
||||
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string RepairFileName = "Repair.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
|
||||
public List<Order> Orders { get; private set; }
|
||||
|
||||
public List<Repair> Repairs { get; private set; }
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Repairs = LoadData(RepairFileName, "Repair", x => Repair.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
}
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DataFileSingleton();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveRepairs() => SaveData(Repairs, RepairFileName, "Repairs", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
AutoWorkshopFileImplement/Implements/ComponentStorage.cs
Normal file
82
AutoWorkshopFileImplement/Implements/ComponentStorage.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
|
||||
namespace AutoWorkshopFileImplement.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 Component = _source.Components.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Component == null)
|
||||
return null;
|
||||
|
||||
_source.Components.Remove(Component);
|
||||
_source.SaveComponents();
|
||||
|
||||
return Component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
96
AutoWorkshopFileImplement/Implements/OrderStorage.cs
Normal file
96
AutoWorkshopFileImplement/Implements/OrderStorage.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
|
||||
public OrderStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return _source.Orders.Select(x => AddRepairName(x.GetViewModel)).ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel Model)
|
||||
{
|
||||
if (!Model.Id.HasValue)
|
||||
return new();
|
||||
|
||||
return _source.Orders.Where(x => x.Id == Model.Id).Select(x => AddRepairName(x.GetViewModel)).ToList();
|
||||
}
|
||||
|
||||
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 AddRepairName(Element.GetViewModel);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel Model)
|
||||
{
|
||||
if (!Model.Id.HasValue)
|
||||
return null;
|
||||
|
||||
var Order = _source.Orders.FirstOrDefault(x => (Model.Id.HasValue && x.Id == Model.Id));
|
||||
|
||||
if (Order == null)
|
||||
return null;
|
||||
|
||||
return AddRepairName(Order.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel Model)
|
||||
{
|
||||
Model.Id = _source.Orders.Count > 0 ? _source.Orders.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var NewOrder = Order.Create(Model);
|
||||
|
||||
if (NewOrder == null)
|
||||
return null;
|
||||
|
||||
_source.Orders.Add(NewOrder);
|
||||
_source.SaveOrders();
|
||||
|
||||
return AddRepairName(NewOrder.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel Model)
|
||||
{
|
||||
var Order = _source.Orders.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Order == null)
|
||||
return null;
|
||||
|
||||
Order.Update(Model);
|
||||
_source.SaveOrders();
|
||||
|
||||
return AddRepairName(Order.GetViewModel);
|
||||
}
|
||||
|
||||
private OrderViewModel AddRepairName(OrderViewModel Model)
|
||||
{
|
||||
var SelectedRepair = _source.Repairs.FirstOrDefault(x => x.Id == Model.RepairId);
|
||||
|
||||
Model.RepairName = SelectedRepair?.RepairName ?? string.Empty;
|
||||
return Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
80
AutoWorkshopFileImplement/Implements/RepairStorage.cs
Normal file
80
AutoWorkshopFileImplement/Implements/RepairStorage.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Implements
|
||||
{
|
||||
public class RepairStorage : IRepairStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
|
||||
public RepairStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<RepairViewModel> GetFullList()
|
||||
{
|
||||
return _source.Repairs.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<RepairViewModel> GetFilteredList(RepairSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.RepairName))
|
||||
return new();
|
||||
|
||||
return _source.Repairs.Where(x => x.RepairName.Contains(Model.RepairName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public RepairViewModel? GetElement(RepairSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.RepairName) && !Model.Id.HasValue)
|
||||
return null;
|
||||
|
||||
return _source.Repairs.FirstOrDefault(x => (!string.IsNullOrEmpty(Model.RepairName) && x.RepairName == Model.RepairName) || (Model.Id.HasValue && x.Id == Model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public RepairViewModel? Insert(RepairBindingModel Model)
|
||||
{
|
||||
Model.Id = _source.Repairs.Count > 0 ? _source.Repairs.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var NewRepair = Repair.Create(Model);
|
||||
|
||||
if (NewRepair == null)
|
||||
return null;
|
||||
|
||||
_source.Repairs.Add(NewRepair);
|
||||
_source.SaveRepairs();
|
||||
|
||||
return NewRepair.GetViewModel;
|
||||
}
|
||||
|
||||
public RepairViewModel? Update(RepairBindingModel Model)
|
||||
{
|
||||
var Repair = _source.Repairs.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Repair == null)
|
||||
return null;
|
||||
|
||||
Repair.Update(Model);
|
||||
_source.SaveRepairs();
|
||||
|
||||
return Repair.GetViewModel;
|
||||
}
|
||||
|
||||
public RepairViewModel? Delete(RepairBindingModel Model)
|
||||
{
|
||||
var Repair = _source.Repairs.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Repair == null)
|
||||
return null;
|
||||
|
||||
_source.Repairs.Remove(Repair);
|
||||
_source.SaveRepairs();
|
||||
|
||||
return Repair.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
65
AutoWorkshopFileImplement/Models/Component.cs
Normal file
65
AutoWorkshopFileImplement/Models/Component.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public static Component? Create(ComponentBindingModel Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return null;
|
||||
|
||||
return new Component()
|
||||
{
|
||||
Id = Model.Id,
|
||||
ComponentName = Model.ComponentName,
|
||||
Cost = Model.Cost
|
||||
};
|
||||
}
|
||||
|
||||
public static Component? Create(XElement Element)
|
||||
{
|
||||
if (Element is 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 is 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())
|
||||
);
|
||||
}
|
||||
}
|
||||
90
AutoWorkshopFileImplement/Models/Order.cs
Normal file
90
AutoWorkshopFileImplement/Models/Order.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Enums;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int RepairId { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
public DateTime DateCreate { get; private set; }
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return null;
|
||||
|
||||
return new Order()
|
||||
{
|
||||
Id = Model.Id,
|
||||
RepairId = Model.RepairId,
|
||||
Count = Model.Count,
|
||||
Sum = Model.Sum,
|
||||
Status = Model.Status,
|
||||
DateCreate = Model.DateCreate,
|
||||
DateImplement = Model.DateImplement
|
||||
};
|
||||
}
|
||||
|
||||
public static Order? Create(XElement Element)
|
||||
{
|
||||
if (Element is null)
|
||||
return null;
|
||||
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(Element.Attribute("Id")!.Value),
|
||||
RepairId = Convert.ToInt32(Element.Element("RepairId")!.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 is null)
|
||||
return;
|
||||
|
||||
Status = Model.Status;
|
||||
DateImplement = Model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
RepairId = RepairId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
|
||||
public XElement GetXElement => new(
|
||||
"Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("RepairId", RepairId),
|
||||
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())
|
||||
);
|
||||
}
|
||||
}
|
||||
90
AutoWorkshopFileImplement/Models/Repair.cs
Normal file
90
AutoWorkshopFileImplement/Models/Repair.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Models
|
||||
{
|
||||
public class Repair : IRepairModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string RepairName { 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)>? _RepairComponents = null;
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> RepairComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RepairComponents == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_RepairComponents = Components.ToDictionary(x =>
|
||||
x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
|
||||
}
|
||||
return _RepairComponents;
|
||||
}
|
||||
}
|
||||
|
||||
public static Repair? Create(RepairBindingModel Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return null;
|
||||
|
||||
return new Repair()
|
||||
{
|
||||
Id = Model.Id,
|
||||
RepairName = Model.RepairName,
|
||||
Price = Model.Price,
|
||||
Components = Model.RepairComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static Repair? Create(XElement Element)
|
||||
{
|
||||
if (Element is null)
|
||||
return null;
|
||||
|
||||
return new Repair()
|
||||
{
|
||||
Id = Convert.ToInt32(Element.Attribute("Id")!.Value),
|
||||
RepairName = Element.Element("RepairName")!.Value,
|
||||
Price = Convert.ToDouble(Element.Element("Price")!.Value),
|
||||
Components = Element.Element("RepairComponents")!.Elements("RepairComponent").ToDictionary(x =>
|
||||
Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(RepairBindingModel Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return;
|
||||
|
||||
RepairName = Model.RepairName;
|
||||
Price = Model.Price;
|
||||
Components = Model.RepairComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_RepairComponents = null;
|
||||
}
|
||||
|
||||
public RepairViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
RepairName = RepairName,
|
||||
Price = Price,
|
||||
RepairComponents = RepairComponents
|
||||
};
|
||||
|
||||
public XElement GetXElement => new(
|
||||
"Repair",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("RepairName", RepairName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("RepairComponents", Components.Select(x =>
|
||||
new XElement("RepairComponent", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,12 @@ namespace AutoWorkshopListImplement
|
||||
public List<Order> Orders { get; set; }
|
||||
|
||||
public List<Repair> Repairs { get; set; }
|
||||
|
||||
public List<Shop> Shops { get; set; }
|
||||
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Repairs = new List<Repair>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
|
||||
public static DataListSingleton GetInstance()
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopListImplement.Models;
|
||||
|
||||
namespace AutoWorkshopListImplement.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 is 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 Shop = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
|
||||
namespace AutoWorkshopListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; private set; } = new();
|
||||
|
||||
public static Shop? Create(ShopBindingModel? Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return null;
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = Model.Id,
|
||||
ShopName = Model.ShopName,
|
||||
Address = Model.Address,
|
||||
OpeningDate = Model.OpeningDate
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return;
|
||||
|
||||
ShopName = Model.ShopName;
|
||||
Address = Model.Address;
|
||||
OpeningDate = Model.OpeningDate;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopRepairs = ShopRepairs
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoWorkshopBusinessLogic\AutoWorkshopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopFileImplement\AutoWorkshopFileImplement.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopImplement\AutoWorkshopListImplement.csproj" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.8" />
|
||||
|
||||
146
AutoWorkshopView/Forms/Shop/FormCreateSupply.Designer.cs
generated
146
AutoWorkshopView/Forms/Shop/FormCreateSupply.Designer.cs
generated
@@ -1,146 +0,0 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
partial class FormCreateSupply
|
||||
{
|
||||
/// <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
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ShopComboBox = new ComboBox();
|
||||
ShopLabel = new Label();
|
||||
RepairLabel = new Label();
|
||||
RepairComboBox = new ComboBox();
|
||||
CountLabel = new Label();
|
||||
CountTextbox = new TextBox();
|
||||
CancelButton = new Button();
|
||||
SaveButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ShopComboBox
|
||||
//
|
||||
ShopComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
ShopComboBox.FormattingEnabled = true;
|
||||
ShopComboBox.Location = new Point(101, 9);
|
||||
ShopComboBox.Margin = new Padding(3, 2, 3, 2);
|
||||
ShopComboBox.Name = "ShopComboBox";
|
||||
ShopComboBox.Size = new Size(302, 23);
|
||||
ShopComboBox.TabIndex = 0;
|
||||
//
|
||||
// ShopLabel
|
||||
//
|
||||
ShopLabel.AutoSize = true;
|
||||
ShopLabel.Location = new Point(10, 12);
|
||||
ShopLabel.Name = "ShopLabel";
|
||||
ShopLabel.Size = new Size(60, 15);
|
||||
ShopLabel.TabIndex = 1;
|
||||
ShopLabel.Text = "Магазин: ";
|
||||
//
|
||||
// RepairLabel
|
||||
//
|
||||
RepairLabel.AutoSize = true;
|
||||
RepairLabel.Location = new Point(11, 39);
|
||||
RepairLabel.Name = "RepairLabel";
|
||||
RepairLabel.Size = new Size(51, 15);
|
||||
RepairLabel.TabIndex = 2;
|
||||
RepairLabel.Text = "Ремонт:";
|
||||
//
|
||||
// RepairComboBox
|
||||
//
|
||||
RepairComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
RepairComboBox.FormattingEnabled = true;
|
||||
RepairComboBox.Location = new Point(101, 36);
|
||||
RepairComboBox.Margin = new Padding(3, 2, 3, 2);
|
||||
RepairComboBox.Name = "RepairComboBox";
|
||||
RepairComboBox.Size = new Size(302, 23);
|
||||
RepairComboBox.TabIndex = 3;
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
CountLabel.AutoSize = true;
|
||||
CountLabel.Location = new Point(11, 66);
|
||||
CountLabel.Name = "CountLabel";
|
||||
CountLabel.Size = new Size(78, 15);
|
||||
CountLabel.TabIndex = 4;
|
||||
CountLabel.Text = "Количество: ";
|
||||
//
|
||||
// CountTextbox
|
||||
//
|
||||
CountTextbox.Location = new Point(101, 63);
|
||||
CountTextbox.Margin = new Padding(3, 2, 3, 2);
|
||||
CountTextbox.Name = "CountTextbox";
|
||||
CountTextbox.Size = new Size(302, 23);
|
||||
CountTextbox.TabIndex = 5;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(301, 100);
|
||||
CancelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(102, 29);
|
||||
CancelButton.TabIndex = 6;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(183, 100);
|
||||
SaveButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(102, 29);
|
||||
SaveButton.TabIndex = 7;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// FormCreateSupply
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(417, 143);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(CountTextbox);
|
||||
Controls.Add(CountLabel);
|
||||
Controls.Add(RepairComboBox);
|
||||
Controls.Add(RepairLabel);
|
||||
Controls.Add(ShopLabel);
|
||||
Controls.Add(ShopComboBox);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormCreateSupply";
|
||||
Text = "Создание поставки";
|
||||
Load += FormCreateSupply_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox ShopComboBox;
|
||||
private Label ShopLabel;
|
||||
private Label RepairLabel;
|
||||
private ComboBox RepairComboBox;
|
||||
private Label CountLabel;
|
||||
private TextBox CountTextbox;
|
||||
private Button CancelButton;
|
||||
private Button SaveButton;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
public partial class FormCreateSupply : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRepairLogic _repairLogic;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
private List<ShopViewModel> _shopList = new List<ShopViewModel>();
|
||||
private List<RepairViewModel> _RepairList = new List<RepairViewModel>();
|
||||
|
||||
public FormCreateSupply(ILogger<FormCreateSupply> Logger, IRepairLogic RepairLogic, IShopLogic ShopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_repairLogic = RepairLogic;
|
||||
_shopLogic = ShopLogic;
|
||||
}
|
||||
|
||||
private void FormCreateSupply_Load(object sender, EventArgs e)
|
||||
{
|
||||
_shopList = _shopLogic.ReadList(null);
|
||||
_RepairList = _repairLogic.ReadList(null);
|
||||
|
||||
if (_shopList != null)
|
||||
{
|
||||
ShopComboBox.DisplayMember = "ShopName";
|
||||
ShopComboBox.ValueMember = "Id";
|
||||
ShopComboBox.DataSource = _shopList;
|
||||
ShopComboBox.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка магазинов для поставок");
|
||||
}
|
||||
|
||||
if (_RepairList != null)
|
||||
{
|
||||
RepairComboBox.DisplayMember = "RepairName";
|
||||
RepairComboBox.ValueMember = "Id";
|
||||
RepairComboBox.DataSource = _RepairList;
|
||||
RepairComboBox.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка ремонтов для поставок");
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ShopComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (RepairComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Создание поставки");
|
||||
|
||||
try
|
||||
{
|
||||
var OperationResult = _shopLogic.MakeSupply(new SupplyBindingModel
|
||||
{
|
||||
ShopId = Convert.ToInt32(ShopComboBox.SelectedValue),
|
||||
RepairId = Convert.ToInt32(RepairComboBox.SelectedValue),
|
||||
Count = Convert.ToInt32(CountTextbox.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 CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?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>
|
||||
196
AutoWorkshopView/Forms/Shop/FormShop.Designer.cs
generated
196
AutoWorkshopView/Forms/Shop/FormShop.Designer.cs
generated
@@ -1,196 +0,0 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
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()
|
||||
{
|
||||
NameLabel = new Label();
|
||||
NameTextBox = new TextBox();
|
||||
AddressTextBox = new TextBox();
|
||||
AddressLabel = new Label();
|
||||
CancelButton = new Button();
|
||||
SaveButton = new Button();
|
||||
ViewDataGrid = new DataGridView();
|
||||
IdColumn = new DataGridViewTextBoxColumn();
|
||||
RepairNameColumn = new DataGridViewTextBoxColumn();
|
||||
CountColumn = new DataGridViewTextBoxColumn();
|
||||
OpeningDateLabel = new Label();
|
||||
OpenDateTimePicker = new DateTimePicker();
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// NameLabel
|
||||
//
|
||||
NameLabel.AutoSize = true;
|
||||
NameLabel.Location = new Point(10, 12);
|
||||
NameLabel.Name = "NameLabel";
|
||||
NameLabel.Size = new Size(65, 15);
|
||||
NameLabel.TabIndex = 0;
|
||||
NameLabel.Text = "Название: ";
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(112, 9);
|
||||
NameTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(240, 23);
|
||||
NameTextBox.TabIndex = 1;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
AddressTextBox.Location = new Point(112, 36);
|
||||
AddressTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
AddressTextBox.Name = "AddressTextBox";
|
||||
AddressTextBox.Size = new Size(240, 23);
|
||||
AddressTextBox.TabIndex = 3;
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
AddressLabel.AutoSize = true;
|
||||
AddressLabel.Location = new Point(12, 39);
|
||||
AddressLabel.Name = "AddressLabel";
|
||||
AddressLabel.Size = new Size(46, 15);
|
||||
AddressLabel.TabIndex = 2;
|
||||
AddressLabel.Text = "Адрес: ";
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(395, 343);
|
||||
CancelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(114, 33);
|
||||
CancelButton.TabIndex = 5;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(276, 343);
|
||||
SaveButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(114, 33);
|
||||
SaveButton.TabIndex = 6;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// ViewDataGrid
|
||||
//
|
||||
ViewDataGrid.AllowUserToAddRows = false;
|
||||
ViewDataGrid.AllowUserToDeleteRows = false;
|
||||
ViewDataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
ViewDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
ViewDataGrid.Columns.AddRange(new DataGridViewColumn[] { IdColumn, RepairNameColumn, CountColumn });
|
||||
ViewDataGrid.Location = new Point(10, 108);
|
||||
ViewDataGrid.Margin = new Padding(3, 2, 3, 2);
|
||||
ViewDataGrid.Name = "ViewDataGrid";
|
||||
ViewDataGrid.ReadOnly = true;
|
||||
ViewDataGrid.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
|
||||
ViewDataGrid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||
ViewDataGrid.RowTemplate.Height = 29;
|
||||
ViewDataGrid.Size = new Size(498, 230);
|
||||
ViewDataGrid.TabIndex = 7;
|
||||
//
|
||||
// IdColumn
|
||||
//
|
||||
IdColumn.HeaderText = "Id";
|
||||
IdColumn.MinimumWidth = 6;
|
||||
IdColumn.Name = "IdColumn";
|
||||
IdColumn.ReadOnly = true;
|
||||
IdColumn.Visible = false;
|
||||
//
|
||||
// RepairNameColumn
|
||||
//
|
||||
RepairNameColumn.HeaderText = "Ремонт";
|
||||
RepairNameColumn.MinimumWidth = 6;
|
||||
RepairNameColumn.Name = "RepairNameColumn";
|
||||
RepairNameColumn.ReadOnly = true;
|
||||
//
|
||||
// CountColumn
|
||||
//
|
||||
CountColumn.HeaderText = "Количество";
|
||||
CountColumn.MinimumWidth = 6;
|
||||
CountColumn.Name = "CountColumn";
|
||||
CountColumn.ReadOnly = true;
|
||||
//
|
||||
// OpeningDateLabel
|
||||
//
|
||||
OpeningDateLabel.AutoSize = true;
|
||||
OpeningDateLabel.Location = new Point(10, 69);
|
||||
OpeningDateLabel.Name = "OpeningDateLabel";
|
||||
OpeningDateLabel.Size = new Size(87, 15);
|
||||
OpeningDateLabel.TabIndex = 8;
|
||||
OpeningDateLabel.Text = "Дата открытия";
|
||||
//
|
||||
// OpenDateTimePicker
|
||||
//
|
||||
OpenDateTimePicker.Location = new Point(112, 63);
|
||||
OpenDateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||
OpenDateTimePicker.Name = "OpenDateTimePicker";
|
||||
OpenDateTimePicker.Size = new Size(240, 23);
|
||||
OpenDateTimePicker.TabIndex = 9;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(519, 385);
|
||||
Controls.Add(OpenDateTimePicker);
|
||||
Controls.Add(OpeningDateLabel);
|
||||
Controls.Add(ViewDataGrid);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(AddressTextBox);
|
||||
Controls.Add(AddressLabel);
|
||||
Controls.Add(NameTextBox);
|
||||
Controls.Add(NameLabel);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormShop";
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label NameLabel;
|
||||
private TextBox NameTextBox;
|
||||
private TextBox AddressTextBox;
|
||||
private Label AddressLabel;
|
||||
private Button CancelButton;
|
||||
private Button SaveButton;
|
||||
private DataGridView ViewDataGrid;
|
||||
private DataGridViewTextBoxColumn IdColumn;
|
||||
private DataGridViewTextBoxColumn RepairNameColumn;
|
||||
private DataGridViewTextBoxColumn CountColumn;
|
||||
private Label OpeningDateLabel;
|
||||
private DateTimePicker OpenDateTimePicker;
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
private Dictionary<int, (IRepairModel, int)> _shopRepairs;
|
||||
private DateTime? _openingDate = null;
|
||||
|
||||
public FormShop(ILogger<FormShop> Logger, IShopLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
_shopRepairs = new Dictionary<int, (IRepairModel, 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)
|
||||
{
|
||||
NameTextBox.Text = View.ShopName;
|
||||
AddressTextBox.Text = View.Address;
|
||||
OpenDateTimePicker.Value = View.OpeningDate;
|
||||
_shopRepairs = View.ShopRepairs ?? new Dictionary<int, (IRepairModel, int)>();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка ремонтов в магазине");
|
||||
|
||||
try
|
||||
{
|
||||
if (_shopRepairs != null)
|
||||
{
|
||||
ViewDataGrid.Rows.Clear();
|
||||
foreach (var ShopRepair in _shopRepairs)
|
||||
{
|
||||
ViewDataGrid.Rows.Add(new object[] { ShopRepair.Key, ShopRepair.Value.Item1.RepairName, ShopRepair.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(AddressTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
|
||||
try
|
||||
{
|
||||
var Model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = NameTextBox.Text,
|
||||
Address = AddressTextBox.Text,
|
||||
OpeningDate = OpenDateTimePicker.Value
|
||||
};
|
||||
|
||||
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 CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?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>
|
||||
136
AutoWorkshopView/Forms/Shop/FormShops.Designer.cs
generated
136
AutoWorkshopView/Forms/Shop/FormShops.Designer.cs
generated
@@ -1,136 +0,0 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
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()
|
||||
{
|
||||
ToolsPanel = new Panel();
|
||||
RefreshButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
AddButton = new Button();
|
||||
ViewDataGrid = new DataGridView();
|
||||
ToolsPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
ToolsPanel.Controls.Add(RefreshButton);
|
||||
ToolsPanel.Controls.Add(DeleteButton);
|
||||
ToolsPanel.Controls.Add(UpdateButton);
|
||||
ToolsPanel.Controls.Add(AddButton);
|
||||
ToolsPanel.Location = new Point(532, 9);
|
||||
ToolsPanel.Margin = new Padding(3, 2, 3, 2);
|
||||
ToolsPanel.Name = "ToolsPanel";
|
||||
ToolsPanel.Size = new Size(117, 320);
|
||||
ToolsPanel.TabIndex = 3;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(3, 105);
|
||||
RefreshButton.Margin = new Padding(3, 2, 3, 2);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(110, 27);
|
||||
RefreshButton.TabIndex = 3;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(3, 74);
|
||||
DeleteButton.Margin = new Padding(3, 2, 3, 2);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(110, 27);
|
||||
DeleteButton.TabIndex = 2;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(3, 43);
|
||||
UpdateButton.Margin = new Padding(3, 2, 3, 2);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(110, 27);
|
||||
UpdateButton.TabIndex = 1;
|
||||
UpdateButton.Text = "Изменить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += UpdateButton_Click;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(3, 12);
|
||||
AddButton.Margin = new Padding(3, 2, 3, 2);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(110, 27);
|
||||
AddButton.TabIndex = 0;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ViewDataGrid
|
||||
//
|
||||
ViewDataGrid.AllowUserToAddRows = false;
|
||||
ViewDataGrid.AllowUserToDeleteRows = false;
|
||||
ViewDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
ViewDataGrid.Location = new Point(10, 9);
|
||||
ViewDataGrid.Margin = new Padding(3, 2, 3, 2);
|
||||
ViewDataGrid.Name = "ViewDataGrid";
|
||||
ViewDataGrid.ReadOnly = true;
|
||||
ViewDataGrid.RowHeadersWidth = 51;
|
||||
ViewDataGrid.RowTemplate.Height = 29;
|
||||
ViewDataGrid.Size = new Size(516, 320);
|
||||
ViewDataGrid.TabIndex = 2;
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(660, 338);
|
||||
Controls.Add(ToolsPanel);
|
||||
Controls.Add(ViewDataGrid);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormShops";
|
||||
Text = "Магазины";
|
||||
Load += FormShops_Load;
|
||||
ToolsPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel ToolsPanel;
|
||||
private Button RefreshButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
private Button AddButton;
|
||||
private DataGridView ViewDataGrid;
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
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 FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
ViewDataGrid.DataSource = List;
|
||||
ViewDataGrid.Columns["Id"].Visible = false;
|
||||
ViewDataGrid.Columns["ShopRepairs"].Visible = false;
|
||||
ViewDataGrid.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_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 UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ViewDataGrid.SelectedRows.Count == 1)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (Service is FormShop Form)
|
||||
{
|
||||
Form.Id = Convert.ToInt32(ViewDataGrid.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ViewDataGrid.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int Id = Convert.ToInt32(ViewDataGrid.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 RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?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>
|
||||
33
AutoWorkshopView/MainForm.Designer.cs
generated
33
AutoWorkshopView/MainForm.Designer.cs
generated
@@ -32,9 +32,6 @@
|
||||
ToolStripMenu = new ToolStripMenuItem();
|
||||
ComponentsStripMenuItem = new ToolStripMenuItem();
|
||||
RepairStripMenuItem = new ToolStripMenuItem();
|
||||
ShopsToolStripMenuItem = new ToolStripMenuItem();
|
||||
OperationToolStripMenuItem = new ToolStripMenuItem();
|
||||
TransactionToolStripMenuItem = new ToolStripMenuItem();
|
||||
DataGridView = new DataGridView();
|
||||
CreateOrderButton = new Button();
|
||||
TakeInWorkButton = new Button();
|
||||
@@ -48,7 +45,7 @@
|
||||
// MenuStrip
|
||||
//
|
||||
MenuStrip.ImageScalingSize = new Size(20, 20);
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu, OperationToolStripMenuItem });
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu });
|
||||
MenuStrip.Location = new Point(0, 0);
|
||||
MenuStrip.Name = "MenuStrip";
|
||||
MenuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
@@ -58,7 +55,7 @@
|
||||
//
|
||||
// ToolStripMenu
|
||||
//
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem, ShopsToolStripMenuItem });
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem });
|
||||
ToolStripMenu.Name = "ToolStripMenu";
|
||||
ToolStripMenu.Size = new Size(94, 20);
|
||||
ToolStripMenu.Text = "Справочники";
|
||||
@@ -77,31 +74,8 @@
|
||||
RepairStripMenuItem.Text = "Ремонты";
|
||||
RepairStripMenuItem.Click += RepairsStripMenuItem_Click;
|
||||
//
|
||||
// ShopsToolStripMenuItem
|
||||
//
|
||||
ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
||||
ShopsToolStripMenuItem.Size = new Size(145, 22);
|
||||
ShopsToolStripMenuItem.Text = "Магазины";
|
||||
ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
|
||||
//
|
||||
// OperationToolStripMenuItem
|
||||
//
|
||||
OperationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { TransactionToolStripMenuItem });
|
||||
OperationToolStripMenuItem.Name = "OperationToolStripMenuItem";
|
||||
OperationToolStripMenuItem.Size = new Size(75, 20);
|
||||
OperationToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// TransactionToolStripMenuItem
|
||||
//
|
||||
TransactionToolStripMenuItem.Name = "TransactionToolStripMenuItem";
|
||||
TransactionToolStripMenuItem.Size = new Size(125, 22);
|
||||
TransactionToolStripMenuItem.Text = "Поставка";
|
||||
TransactionToolStripMenuItem.Click += TransactionToolStripMenuItem_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.AllowUserToAddRows = false;
|
||||
DataGridView.AllowUserToDeleteRows = false;
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(10, 23);
|
||||
DataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||
@@ -201,8 +175,5 @@
|
||||
private Button ReadyButton;
|
||||
private Button IssuedButton;
|
||||
private Button RefreshButton;
|
||||
private ToolStripMenuItem ShopsToolStripMenuItem;
|
||||
private ToolStripMenuItem OperationToolStripMenuItem;
|
||||
private ToolStripMenuItem TransactionToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopView.Forms;
|
||||
using AutoWorkshopView.Forms.Shop;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView
|
||||
@@ -165,25 +164,5 @@ namespace AutoWorkshopView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
|
||||
if (Service is FormShops Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void TransactionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
|
||||
|
||||
if (Service is FormCreateSupply Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using AutoWorkshopBusinessLogic.BusinessLogics;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopListImplement.Implements;
|
||||
using AutoWorkshopFileImplement.Implements;
|
||||
using AutoWorkshopView.Forms;
|
||||
using AutoWorkshopView.Forms.Shop;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
@@ -39,12 +37,9 @@ namespace AutoWorkshopView
|
||||
Services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
Services.AddTransient<IRepairStorage, RepairStorage>();
|
||||
Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
Services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
Services.AddTransient<IRepairLogic, RepairLogic>();
|
||||
Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
Services.AddTransient<MainForm>();
|
||||
Services.AddTransient<FormComponent>();
|
||||
@@ -53,9 +48,6 @@ namespace AutoWorkshopView
|
||||
Services.AddTransient<FormRepair>();
|
||||
Services.AddTransient<FormRepairComponent>();
|
||||
Services.AddTransient<FormRepairs>();
|
||||
Services.AddTransient<FormShop>();
|
||||
Services.AddTransient<FormShops>();
|
||||
Services.AddTransient<FormCreateSupply>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user