PIbd-23 Dolgov D. A. Lab Work 1 #1

Closed
devil_1nc wants to merge 3 commits from LabWork01 into main
59 changed files with 3791 additions and 0 deletions

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,118 @@
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using AbstractSoftwareInstallationDataModels;
namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
{
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage OrderStorage)
{
_logger = logger;
_orderStorage = OrderStorage;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.PackageId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор у суши", nameof(model.PackageId));
}
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}. SushiId: { SushiId}", model.Id, model.Sum, model.PackageId);
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. Orderid:{ 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 CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Неизвестен)
{
_logger.LogWarning("Order status is incorrect");
return false;
}
model.Status = OrderStatus.Принят;
model.DateCreate = DateTime.Now;
if (_orderStorage.Insert(model) == null)
{
model.Status = OrderStatus.Неизвестен;
_logger.LogWarning("Failed to insert order into a storage");
return false;
}
return true;
}
public bool StatusUpdate(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("Status update to " + _newStatus.ToString() + " operation failed. Order status incorrect.");
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)
{
model.Status--;
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Выполняется);
}
public bool DeliveryOrder(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Выдан);
}
public bool FinishOrder(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Готов);
}
}
}

View File

@ -0,0 +1,110 @@
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
{
public class PackageLogic : IPackageLogic
{
private readonly ILogger _logger;
private readonly IPackageStorage _packageStorage;
public PackageLogic(ILogger<PackageLogic> logger, IPackageStorage PackageStorage)
{
_logger = logger;
_packageStorage = PackageStorage;
}
public List<PackageViewModel>? ReadList(PackageSearchModel? model)
{
_logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{ Id}", model?.PackageName, model?.Id);
var list = model == null ? _packageStorage.GetFullList() : _packageStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public PackageViewModel? ReadElement(PackageSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{ Id}", model.PackageName, model.Id);
var element = _packageStorage.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(PackageBindingModel model)
{
CheckModel(model);
if (_packageStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(PackageBindingModel model)
{
CheckModel(model);
if (_packageStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PackageBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_packageStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(PackageBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.PackageName))
{
throw new ArgumentNullException("Нет названия пакета",
nameof(model.PackageName));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена пакета должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Package. PackageName:{PackageName}.Price:{Price}. Id: {Id}", model.PackageName, model.Price, model.Id);
var element = _packageStorage.GetElement(new PackageSearchModel
{
PackageName = model.PackageName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Пакет с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,108 @@
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
namespace AbstractSoftwareInstallationBusinessLogic
{
public class SoftwareLogic : ISoftwareLogic
{
private readonly ILogger _logger;
private readonly ISoftwareStorage _softwareStorage;
public SoftwareLogic(ILogger<SoftwareLogic> logger, ISoftwareStorage SoftwareStorage)
{
_logger = logger;
_softwareStorage = SoftwareStorage;
}
public List<SoftwareViewModel>? ReadList(SoftwareSearchModel? model)
{
_logger.LogInformation("ReadList. SoftwareName:{SoftwareName}.Id:{ Id}", model?.SoftwareName, model?.Id);
var list = model == null ? _softwareStorage.GetFullList() : _softwareStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public SoftwareViewModel? ReadElement(SoftwareSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. SoftwareName:{SoftwareName}.Id:{ Id}", model.SoftwareName, model.Id);
var element = _softwareStorage.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(SoftwareBindingModel model)
{
CheckModel(model);
if (_softwareStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(SoftwareBindingModel model)
{
CheckModel(model);
if (_softwareStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(SoftwareBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_softwareStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(SoftwareBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.SoftwareName))
{
throw new ArgumentNullException("Нет названия ПО", nameof(model.SoftwareName));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Цена ПО должна быть больше 0", nameof(model.Cost));
}
_logger.LogInformation("Software. SoftwareName:{SoftwareName}.Cost:{ Cost}. Id: { Id}", model.SoftwareName, model.Cost, model.Id);
var element = _softwareStorage.GetElement(new SoftwareSearchModel
{
SoftwareName = model.SoftwareName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("ПО с таким названием уже есть");
}
}
}}

View File

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

View File

@ -0,0 +1,21 @@
using AbstractSoftwareInstallationDataModels;
using AbstractSoftwareInstallationDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
public int PackageId { 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; }
}
}

View File

@ -0,0 +1,18 @@
using AbstractSoftwareInstallationDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.BindingModels
{
public class PackageBindingModel : IPackageModel
{
public int Id { get; set; }
public string PackageName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware{get;set;} = new();
}
}

View File

@ -0,0 +1,11 @@
using AbstractSoftwareInstallationDataModels.Models;
namespace AbstractSoftwareInstallationContracts.BindingModels
{
public class SoftwareBindingModel : ISoftwareModel
{
public int Id { get; set; }
public string SoftwareName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
namespace AbstractSoftwareInstallationContracts.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);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
{
public interface IPackageLogic
{
List<PackageViewModel>? ReadList(PackageSearchModel? model);
PackageViewModel? ReadElement(PackageSearchModel model);
bool Create(PackageBindingModel model);
bool Update(PackageBindingModel model);
bool Delete(PackageBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
{
public interface ISoftwareLogic
{
List<SoftwareViewModel>? ReadList(SoftwareSearchModel? model);
SoftwareViewModel? ReadElement(SoftwareSearchModel model);
bool Create(SoftwareBindingModel model);
bool Update(SoftwareBindingModel model);
bool Delete(SoftwareBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.SearchModels
{
public class PackageSearchModel
{
public int? Id { get; set; }
public string? PackageName { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.SearchModels
{
public class SoftwareSearchModel
{
public int? Id { get; set; }
public string? SoftwareName { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
namespace AbstractSoftwareInstallationContracts.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);
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
namespace AbstractSoftwareInstallationContracts.StoragesContracts
{
public interface IPackageStorage
{
List<PackageViewModel> GetFullList();
List<PackageViewModel> GetFilteredList(PackageSearchModel model);
PackageViewModel? GetElement(PackageSearchModel model);
PackageViewModel? Insert(PackageBindingModel model);
PackageViewModel? Update(PackageBindingModel model);
PackageViewModel? Delete(PackageBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.ViewModels;
namespace AbstractSoftwareInstallationContracts.StoragesContracts
{
public interface ISoftwareStorage
{
List<SoftwareViewModel> GetFullList();
List<SoftwareViewModel> GetFilteredList(SoftwareSearchModel model);
SoftwareViewModel? GetElement(SoftwareSearchModel model);
SoftwareViewModel? Insert(SoftwareBindingModel model);
SoftwareViewModel? Update(SoftwareBindingModel model);
SoftwareViewModel? Delete(SoftwareBindingModel model);
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.ComponentModel;
using AbstractSoftwareInstallationDataModels;
using AbstractSoftwareInstallationDataModels.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер заказа")]
public int Id { get; set; }
public int PackageId { get; set; }
[DisplayName("Пакет")]
public string PackageName { 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; }
}
}

View File

@ -0,0 +1,25 @@
using AbstractSoftwareInstallationDataModels.Models;
using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.ViewModels
{
public class PackageViewModel : IPackageModel
{
public int Id { get; set; }
[DisplayName("Имя пакета")]
public string PackageName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware
{
get;
set;
} = new();
}
}

View File

@ -0,0 +1,19 @@
using AbstractSoftwareInstallationDataModels.Models;
using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationContracts.ViewModels
{
public class SoftwareViewModel : ISoftwareModel
{
public int Id { get; set; }
[DisplayName("Название")]
public string SoftwareName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationDataModels.Models
{
public interface IOrderModel : IId
{
int PackageId { get; }
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationDataModels.Models
{
public interface IPackageModel : IId
{
string PackageName { get; }
double Price { get; }
Dictionary<int, (ISoftwareModel, int)> PackageSoftware { get; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationDataModels.Models
{
public interface ISoftwareModel : IId
{
string SoftwareName { get; }
double Cost { get; }
}
}

View File

@ -0,0 +1,11 @@
namespace AbstractSoftwareInstallationDataModels
{
public enum OrderStatus
{
Неизвестен = -1,
Принят = 0,
Выполняется = 1,
Готов = 2,
Выдан = 3
}
}

View File

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

View File

@ -0,0 +1,31 @@
using AbstractSoftwareInstallationListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationListImplement
{
public class DataListSingleton
{
private static DataListSingleton? _instance;
public List<Software> Softwares { get; set; }
public List<Order> Orders { get; set; }
public List<Package> Packages { get; set; }
private DataListSingleton()
{
Softwares = new List<Software>();
Orders = new List<Order>();
Packages = new List<Package>();
}
public static DataListSingleton GetInstance()
{
if (_instance == null)
{
_instance = new DataListSingleton();
}
return _instance;
}
}
}

View File

@ -0,0 +1,122 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationListImplement;
using AbstractSoftwareInstallationListImplement.Models;
namespace AbstractOrderInstallationListImplement.Implements
{
public class OrderStorage : IOrderStorage
{
private readonly DataListSingleton _source;
public OrderStorage()
{
_source = DataListSingleton.GetInstance();
}
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 GetViewModel(order);
}
}
return null;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
result.Add(GetViewModel(order));
}
}
return result;
}
public List<OrderViewModel> GetFullList()
{
var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
result.Add(GetViewModel(order));
}
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 GetViewModel(newOrder);
}
public OrderViewModel? Update(OrderBindingModel model)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
order.Update(model);
return GetViewModel(order);
}
}
return null;
}
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 GetViewModel(element);
}
}
return null;
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var package in _source.Packages)
{
if (package.Id == order.PackageId)
{
viewModel.PackageName = package.PackageName;
break;
}
}
return viewModel;
}
}
}

View File

@ -0,0 +1,109 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationListImplement;
using AbstractSoftwareInstallationListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractPackageInstallationListImplement.Implements
{
public class PackageStorage : IPackageStorage
{
private readonly DataListSingleton _source;
public PackageStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<PackageViewModel> GetFullList()
{
var result = new List<PackageViewModel>();
foreach (var package in _source.Packages)
{
result.Add(package.GetViewModel);
}
return result;
}
public List<PackageViewModel> GetFilteredList(PackageSearchModel
model)
{
var result = new List<PackageViewModel>();
if (string.IsNullOrEmpty(model.PackageName))
{
return result;
}
foreach (var package in _source.Packages)
{
if (package.PackageName.Contains(model.PackageName))
{
result.Add(package.GetViewModel);
}
}
return result;
}
public PackageViewModel? GetElement(PackageSearchModel model)
{
if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue)
{
return null;
}
foreach (var package in _source.Packages)
{
if ((!string.IsNullOrEmpty(model.PackageName) &&
package.PackageName == model.PackageName) ||
(model.Id.HasValue && package.Id == model.Id))
{
return package.GetViewModel;
}
}
return null;
}
public PackageViewModel? Insert(PackageBindingModel model)
{
model.Id = 1;
foreach (var package in _source.Packages)
{
if (model.Id <= package.Id)
{
model.Id = package.Id + 1;
}
}
var newPackage = Package.Create(model);
if (newPackage == null)
{
return null;
}
_source.Packages.Add(newPackage);
return newPackage.GetViewModel;
}
public PackageViewModel? Update(PackageBindingModel model)
{
foreach (var package in _source.Packages)
{
if (package.Id == model.Id)
{
package.Update(model);
return package.GetViewModel;
}
}
return null;
}
public PackageViewModel? Delete(PackageBindingModel model)
{
for (int i = 0; i < _source.Packages.Count; ++i)
{
if (_source.Packages[i].Id == model.Id)
{
var element = _source.Packages[i];
_source.Packages.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -0,0 +1,105 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationListImplement.Models;
namespace AbstractSoftwareInstallationListImplement.Implements
{
public class SoftwareStorage : ISoftwareStorage
{
private readonly DataListSingleton _source;
public SoftwareStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<SoftwareViewModel> GetFullList()
{
var result = new List<SoftwareViewModel>();
foreach (var component in _source.Softwares)
{
result.Add(component.GetViewModel);
}
return result;
}
public List<SoftwareViewModel> GetFilteredList(SoftwareSearchModel
model)
{
var result = new List<SoftwareViewModel>();
if (string.IsNullOrEmpty(model.SoftwareName))
{
return result;
}
foreach (var component in _source.Softwares)
{
if (component.SoftwareName.Contains(model.SoftwareName))
{
result.Add(component.GetViewModel);
}
}
return result;
}
public SoftwareViewModel? GetElement(SoftwareSearchModel model)
{
if (string.IsNullOrEmpty(model.SoftwareName) && !model.Id.HasValue)
{
return null;
}
foreach (var software in _source.Softwares)
{
if ((!string.IsNullOrEmpty(model.SoftwareName) &&
software.SoftwareName == model.SoftwareName) ||
(model.Id.HasValue && software.Id == model.Id))
{
return software.GetViewModel;
}
}
return null;
}
public SoftwareViewModel? Insert(SoftwareBindingModel model)
{
model.Id = 1;
foreach (var software in _source.Softwares)
{
if (model.Id <= software.Id)
{
model.Id = software.Id + 1;
}
}
var newSoftware = Software.Create(model);
if (newSoftware == null)
{
return null;
}
_source.Softwares.Add(newSoftware);
return newSoftware.GetViewModel;
}
public SoftwareViewModel? Update(SoftwareBindingModel model)
{
foreach (var component in _source.Softwares)
{
if (component.Id == model.Id)
{
component.Update(model);
return component.GetViewModel;
}
throw new ArgumentNullException("Новая цена", nameof(model.Cost));
}
return null;
}
public SoftwareViewModel? Delete(SoftwareBindingModel model)
{
for (int i = 0; i < _source.Softwares.Count; ++i)
{
if (_source.Softwares[i].Id == model.Id)
{
var element = _source.Softwares[i];
_source.Softwares.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -0,0 +1,59 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationDataModels;
using AbstractSoftwareInstallationDataModels.Models;
namespace AbstractSoftwareInstallationListImplement.Models
{
public class Order : IOrderModel
{
public int PackageId { 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
{
PackageId = model.PackageId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
Id = model.Id,
};
}
public void Update(OrderBindingModel model)
{
if (model == null)
{
return;
}
Status = model.Status;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
PackageId = PackageId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}

View File

@ -0,0 +1,50 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractSoftwareInstallationListImplement.Models
{
public class Package : IPackageModel
{
public string PackageName { get; private set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (ISoftwareModel, int)> PackageSoftware { get; private set; } = new Dictionary<int, (ISoftwareModel, int)>();
public int Id { get; private set; }
public static Package? Create(PackageBindingModel? model)
{
if (model == null) return null;
return new Package
{
Id = model.Id,
PackageName = model.PackageName,
Price = model.Price,
PackageSoftware = model.PackageSoftware
};
}
public void Update(PackageBindingModel? model)
{
if (model == null)
{
return;
}
PackageName = model.PackageName;
Price = model.Price;
PackageSoftware = model.PackageSoftware;
}
public PackageViewModel GetViewModel => new()
{
Id = Id,
PackageName = PackageName,
Price = Price,
PackageSoftware = PackageSoftware
};
}
}

View File

@ -0,0 +1,43 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationDataModels.Models;
namespace AbstractSoftwareInstallationListImplement.Models
{
public class Software : ISoftwareModel
{
public string SoftwareName { get; private set; } = String.Empty;
public double Cost { get; set; }
public int Id { get; private set; }
public static Software? Create(SoftwareBindingModel? model)
{
if (model == null)
{
return null;
}
return new Software()
{
Id = model.Id,
SoftwareName = model.SoftwareName,
Cost = model.Cost
};
}
public void Update(SoftwareBindingModel? model)
{
if (model == null)
{
return;
}
SoftwareName = model.SoftwareName;
Cost = model.Cost;
}
public SoftwareViewModel GetViewModel => new()
{
Id = Id,
SoftwareName = SoftwareName,
Cost = Cost
};
}
}

View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationView", "SoftwareInstallation\SoftwareInstallationView.csproj", "{18A0C203-2758-444C-AF35-2635F88FDB35}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationDataModels", "AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj", "{A883A624-D446-4834-9C5F-6364F0E66314}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationContracts", "AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj", "{4DA94347-C949-462B-B361-18D297C65CC2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationBusinessLogic", "AbstractSoftwareInstallationBusinessLogic\AbstractSoftwareInstallationBusinessLogic.csproj", "{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractSoftwareInstallationListImplement", "AbstractSoftwareInstallationListImplement\AbstractSoftwareInstallationListImplement.csproj", "{31AD2872-9651-476A-9868-C4404FEEB0E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{18A0C203-2758-444C-AF35-2635F88FDB35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18A0C203-2758-444C-AF35-2635F88FDB35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18A0C203-2758-444C-AF35-2635F88FDB35}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18A0C203-2758-444C-AF35-2635F88FDB35}.Release|Any CPU.Build.0 = Release|Any CPU
{A883A624-D446-4834-9C5F-6364F0E66314}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A883A624-D446-4834-9C5F-6364F0E66314}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A883A624-D446-4834-9C5F-6364F0E66314}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A883A624-D446-4834-9C5F-6364F0E66314}.Release|Any CPU.Build.0 = Release|Any CPU
{4DA94347-C949-462B-B361-18D297C65CC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DA94347-C949-462B-B361-18D297C65CC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DA94347-C949-462B-B361-18D297C65CC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DA94347-C949-462B-B361-18D297C65CC2}.Release|Any CPU.Build.0 = Release|Any CPU
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Release|Any CPU.Build.0 = Release|Any CPU
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31AD2872-9651-476A-9868-C4404FEEB0E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65E51AEC-89CD-4164-8821-934839107D27}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,145 @@
namespace SoftwareInstallationView
{
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.comboBoxPackage = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.textBoxSum = new System.Windows.Forms.TextBox();
this.labelPackage = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.labelSum = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// comboBoxPackage
//
this.comboBoxPackage.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxPackage.FormattingEnabled = true;
this.comboBoxPackage.Location = new System.Drawing.Point(110, 24);
this.comboBoxPackage.Name = "comboBoxPackage";
this.comboBoxPackage.Size = new System.Drawing.Size(310, 23);
this.comboBoxPackage.TabIndex = 0;
this.comboBoxPackage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged);
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(110, 62);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(310, 23);
this.textBoxCount.TabIndex = 1;
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(110, 101);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.Size = new System.Drawing.Size(310, 23);
this.textBoxSum.TabIndex = 2;
//
// labelPackage
//
this.labelPackage.AutoSize = true;
this.labelPackage.Location = new System.Drawing.Point(29, 27);
this.labelPackage.Name = "labelPackage";
this.labelPackage.Size = new System.Drawing.Size(42, 15);
this.labelPackage.TabIndex = 3;
this.labelPackage.Text = "Пакет:";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(29, 65);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 4;
this.labelCount.Text = "Количество:";
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(29, 104);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(48, 15);
this.labelSum.TabIndex = 5;
this.labelSum.Text = "Сумма:";
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(247, 132);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 6;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(345, 132);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Отменить";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(450, 167);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelPackage);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.comboBoxPackage);
this.Name = "FormCreateOrder";
this.Text = "Заказ";
this.ResumeLayout(false);
this.PerformLayout();
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
}
#endregion
private ComboBox comboBoxPackage;
private TextBox textBoxCount;
private TextBox textBoxSum;
private Label labelPackage;
private Label labelCount;
private Label labelSum;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,128 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SoftwareInstallationView
{
public partial class FormCreateOrder : Form
{
private readonly ILogger _logger;
private readonly IPackageLogic _logicP;
private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPackageLogic logicP, IOrderLogic logicO)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicO = logicO;
LoadData();
}
private void LoadData()
{
_logger.LogInformation("Загрузка пакетов для заказа");
try
{
var list = _logicP.ReadList(null);
if (list != null)
{
comboBoxPackage.DisplayMember = "PackageName";
comboBoxPackage.ValueMember = "Id";
comboBoxPackage.DataSource = list;
comboBoxPackage.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки пакетов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
LoadData();
}
private void CalcSum()
{
if (comboBoxPackage.SelectedValue != null &&
!string.IsNullOrEmpty(textBoxCount.Text))
{
try
{
int id = Convert.ToInt32(comboBoxPackage.SelectedValue);
var product = _logicP.ReadElement(new PackageSearchModel
{
Id = id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.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 ComboBoxProduct_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 (comboBoxPackage.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
PackageId = Convert.ToInt32(comboBoxPackage.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();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,174 @@
namespace SoftwareInstallationView
{
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.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
this.buttonOrderReady = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.packageToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.storageToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(1, 31);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(602, 230);
this.dataGridView.TabIndex = 0;
//
// buttonCreateOrder
//
this.buttonCreateOrder.Location = new System.Drawing.Point(628, 31);
this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(153, 23);
this.buttonCreateOrder.TabIndex = 2;
this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
//
// buttonTakeOrderInWork
//
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(628, 75);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(153, 23);
this.buttonTakeOrderInWork.TabIndex = 3;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click);
//
// buttonOrderReady
//
this.buttonOrderReady.Location = new System.Drawing.Point(628, 123);
this.buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(153, 23);
this.buttonOrderReady.TabIndex = 4;
this.buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true;
this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click);
//
// buttonIssuedOrder
//
this.buttonIssuedOrder.Location = new System.Drawing.Point(628, 171);
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(153, 23);
this.buttonIssuedOrder.TabIndex = 5;
this.buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(628, 219);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(153, 23);
this.buttonRef.TabIndex = 6;
this.buttonRef.Text = "Обновить список";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.guideToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(803, 24);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// guideToolStripMenuItem
//
this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.packageToolStripMenuItem2,
this.storageToolStripMenuItem3});
this.guideToolStripMenuItem.Name = "guideToolStripMenuItem";
this.guideToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
this.guideToolStripMenuItem.Text = "Справочники";
//
// packageToolStripMenuItem2
//
this.packageToolStripMenuItem2.Name = "packageToolStripMenuItem2";
this.packageToolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
this.packageToolStripMenuItem2.Text = "Пакеты";
this.packageToolStripMenuItem2.Click += new System.EventHandler(this.packageToolStripMenuItem_Click);
//
// storageToolStripMenuItem3
//
this.storageToolStripMenuItem3.Name = "storageToolStripMenuItem3";
this.storageToolStripMenuItem3.Size = new System.Drawing.Size(180, 22);
this.storageToolStripMenuItem3.Text = "ПО";
this.storageToolStripMenuItem3.Click += new System.EventHandler(this.softwareToolStripMenuItem_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(803, 263);
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 = "Магазин программного обеспечения";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
this.Load += new System.EventHandler(this.FormMain_Load);
}
#endregion
private DataGridView dataGridView;
private Button buttonCreateOrder;
private Button buttonTakeOrderInWork;
private Button buttonOrderReady;
private Button buttonIssuedOrder;
private Button buttonRef;
private MenuStrip menuStrip1;
private ToolStripMenuItem guideToolStripMenuItem;
private ToolStripMenuItem packageToolStripMenuItem2;
private ToolStripMenuItem storageToolStripMenuItem3;
}
}

View File

@ -0,0 +1,160 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using SoftwareInstallation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SoftwareInstallationView
{
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()
{
_logger.LogInformation("Загрузка заказов");
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["PackageId"].Visible = false;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
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 softwareToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSoftwares));
if (service is FormSoftwares form)
{
form.ShowDialog();
}
}
private void packageToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackages));
if (service is FormPackages form)
{
form.ShowDialog();
}
}
private void buttonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,63 @@
<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>

View File

@ -0,0 +1,225 @@
namespace SoftwareInstallationView
{
partial class FormPackage
{
/// <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.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxPrice = new System.Windows.Forms.TextBox();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnSoftware = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBoxSoftware = new System.Windows.Forms.GroupBox();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.labelName = new System.Windows.Forms.Label();
this.labelPrice = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.groupBoxSoftware.SuspendLayout();
this.SuspendLayout();
//
// textBox1
//
this.textBoxName.Location = new System.Drawing.Point(131, 12);
this.textBoxName.Name = "textBox1";
this.textBoxName.Size = new System.Drawing.Size(343, 23);
this.textBoxName.TabIndex = 0;
//
// textBox2
//
this.textBoxPrice.Location = new System.Drawing.Point(131, 57);
this.textBoxPrice.Name = "textBox2";
this.textBoxPrice.Size = new System.Drawing.Size(174, 23);
this.textBoxPrice.TabIndex = 1;
//
// dataGridView1
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnId,
this.ColumnSoftware,
this.ColumnCount});
this.dataGridView.Location = new System.Drawing.Point(6, 22);
this.dataGridView.Name = "dataGridView1";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(444, 299);
this.dataGridView.TabIndex = 2;
//
// ColumnId
//
this.ColumnId.HeaderText = "Id";
this.ColumnId.Name = "ColumnId";
this.ColumnId.Visible = false;
//
// ColumnSoftware
//
this.ColumnSoftware.HeaderText = "ПО";
this.ColumnSoftware.Name = "ColumnSoftware";
this.ColumnSoftware.Width = 300;
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount";
//
// groupBoxSoftware
//
this.groupBoxSoftware.Controls.Add(this.buttonUpdate);
this.groupBoxSoftware.Controls.Add(this.buttonDelete);
this.groupBoxSoftware.Controls.Add(this.dataGridView);
this.groupBoxSoftware.Controls.Add(this.buttonEdit);
this.groupBoxSoftware.Controls.Add(this.buttonAdd);
this.groupBoxSoftware.Location = new System.Drawing.Point(21, 105);
this.groupBoxSoftware.Name = "groupBoxSoftware";
this.groupBoxSoftware.Size = new System.Drawing.Size(586, 327);
this.groupBoxSoftware.TabIndex = 3;
this.groupBoxSoftware.TabStop = false;
this.groupBoxSoftware.Text = "ПО";
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(473, 22);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(98, 29);
this.buttonAdd.TabIndex = 0;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(473, 75);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(98, 31);
this.buttonEdit.TabIndex = 1;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(473, 135);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(98, 31);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(473, 194);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(98, 29);
this.buttonUpdate.TabIndex = 4;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(376, 438);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(98, 23);
this.buttonSave.TabIndex = 5;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(494, 438);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(98, 23);
this.buttonCancel.TabIndex = 6;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(55, 15);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(62, 15);
this.labelName.TabIndex = 7;
this.labelName.Text = "Название:";
//
// labelPrice
//
this.labelPrice.AutoSize = true;
this.labelPrice.Location = new System.Drawing.Point(55, 60);
this.labelPrice.Name = "labelPrice";
this.labelPrice.Size = new System.Drawing.Size(70, 15);
this.labelPrice.TabIndex = 8;
this.labelPrice.Text = "Стоимость:";
//
// FormPackage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(633, 472);
this.Controls.Add(this.labelPrice);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxPrice);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.groupBoxSoftware);
this.Name = "FormPackage";
this.Text = "Пакет";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.groupBoxSoftware.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private TextBox textBoxPrice;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn ColumnSoftware;
private DataGridViewTextBoxColumn ColumnCount;
private GroupBox groupBoxSoftware;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
private Button buttonSave;
private Button buttonCancel;
private Label labelName;
private Label labelPrice;
}
}

View File

@ -0,0 +1,228 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationDataModels.Models;
using Microsoft.Extensions.Logging;
using SoftwareInstallation;
namespace SoftwareInstallationView
{
public partial class FormPackage : Form
{
private readonly ILogger _logger;
private readonly IPackageLogic _logic;
private int? _id;
private Dictionary<int, (ISoftwareModel, int)> _packageSoftwares;
public int Id { set { _id = value; } }
public FormPackage(ILogger<FormPackage> logger, IPackageLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_packageSoftwares = new Dictionary<int, (ISoftwareModel, int)>();
}
private void FormPackage_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка ПО");
try
{
var view = _logic.ReadElement(new PackageSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.PackageName;
textBoxPrice.Text = view.Price.ToString();
_packageSoftwares = view.PackageSoftware ?? new Dictionary<int, (ISoftwareModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки ПО");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
_logger.LogInformation("Загрузка ПО пакета");
try
{
if (_packageSoftwares != null)
{
dataGridView.Rows.Clear();
foreach (var pc in _packageSoftwares)
{
dataGridView.Rows.Add(new object[]
{
pc.Key,
pc.Value.Item1.
SoftwareName,
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(FormPackageSoftware));
if (service is FormPackageSoftware form)
{
if (form.ShowDialog() == DialogResult.OK)
{
if (form.SoftwareModel == null)
{
return;
}
_logger.LogInformation("Добавление нового ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
if (_packageSoftwares.ContainsKey(form.Id))
{
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
}
else
{
_packageSoftwares.Add(form.Id, (form.SoftwareModel, form.Count));
}
LoadData();
}
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
if (service is FormPackageSoftware form)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _packageSoftwares[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
if (form.SoftwareModel == null)
{
return;
}
_logger.LogInformation("Изменение ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
LoadData();
}
}
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_logger.LogInformation("Удаление ПО: { SoftwareName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
_packageSoftwares?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void buttonUpdate_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 (_packageSoftwares == null || _packageSoftwares.Count == 0)
{
MessageBox.Show("Заполните ПО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение пакета");
try
{
var model = new PackageBindingModel
{
Id = _id ?? 0,
PackageName = textBoxName.Text,
Price = Convert.ToDouble(textBoxPrice.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();
}
private double CalcPrice()
{
double price = 0;
foreach (var elem in _packageSoftwares)
{
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
}
return Math.Round(price * 1.1, 2);
}
}
}

View File

@ -0,0 +1,78 @@
<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="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnSoftware.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnSoftware.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,119 @@
namespace SoftwareInstallationView
{
partial class FormPackageSoftware
{
/// <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.textBox1 = new System.Windows.Forms.TextBox();
this.comboBoxSoftware = new System.Windows.Forms.ComboBox();
this.labelSoftware = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(101, 65);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(273, 23);
this.textBox1.TabIndex = 0;
//
// comboBoxSoftware
//
this.comboBoxSoftware.FormattingEnabled = true;
this.comboBoxSoftware.Location = new System.Drawing.Point(101, 24);
this.comboBoxSoftware.Name = "comboBoxSoftware";
this.comboBoxSoftware.Size = new System.Drawing.Size(273, 23);
this.comboBoxSoftware.TabIndex = 1;
//
// labelSoftware
//
this.labelSoftware.AutoSize = true;
this.labelSoftware.Location = new System.Drawing.Point(20, 27);
this.labelSoftware.Name = "labelSoftware";
this.labelSoftware.Size = new System.Drawing.Size(28, 15);
this.labelSoftware.TabIndex = 2;
this.labelSoftware.Text = "ПО:";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(20, 68);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 3;
this.labelCount.Text = "Количество:";
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(195, 103);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 27);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(299, 103);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 27);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormPackageSoftware
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(403, 142);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelSoftware);
this.Controls.Add(this.comboBoxSoftware);
this.Controls.Add(this.textBox1);
this.Name = "FormPackageSoftware";
this.Text = "ПО пакета";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBox1;
private ComboBox comboBoxSoftware;
private Label labelSoftware;
private Label labelCount;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,84 @@
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.ViewModels;
using AbstractSoftwareInstallationDataModels.Models;
namespace SoftwareInstallationView
{
public partial class FormPackageSoftware : Form
{
private readonly List<SoftwareViewModel>? _list;
public int Id
{
get
{
return Convert.ToInt32(comboBoxSoftware.SelectedValue);
}
set
{
comboBoxSoftware.SelectedValue = value;
}
}
public ISoftwareModel? SoftwareModel
{
get
{
if (_list == null)
{
return null;
}
foreach (var elem in _list)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int Count
{
get { return Convert.ToInt32(textBox1.Text); }
set
{ textBox1.Text = value.ToString(); }
}
public FormPackageSoftware(ISoftwareLogic logic)
{
InitializeComponent();
_list = logic.ReadList(null);
if (_list != null)
{
comboBoxSoftware.DisplayMember = "SoftwareName";
comboBoxSoftware.ValueMember = "Id";
comboBoxSoftware.DataSource = _list;
comboBoxSoftware.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxSoftware.SelectedValue == null)
{
MessageBox.Show("Выберите компонент", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
namespace SoftwareInstallationView
{
partial class FormPackages
{
/// <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.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
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.dataGridView.Location = new System.Drawing.Point(1, 1);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(445, 373);
this.dataGridView.TabIndex = 10;
//
// ColumnId
//
this.ColumnId.FillWeight = 200F;
this.ColumnId.HeaderText = "Id";
this.ColumnId.Name = "ColumnId";
this.ColumnId.Visible = false;
this.ColumnId.Width = 200;
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(461, 193);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(97, 30);
this.buttonUpdate.TabIndex = 9;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(461, 135);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(97, 30);
this.buttonDelete.TabIndex = 8;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(461, 79);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(97, 30);
this.buttonEdit.TabIndex = 7;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(461, 22);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(97, 30);
this.buttonAdd.TabIndex = 6;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormPackages
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(565, 374);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormPackages";
this.Text = "FormPackages";
Review

Заголовок формы оформлен неверно

Заголовок формы оформлен неверно
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
private DataGridViewTextBoxColumn ColumnId;
}
}

View File

@ -0,0 +1,107 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using SoftwareInstallation;
namespace SoftwareInstallationView
{
public partial class FormPackages : Form
{
private readonly ILogger _logger;
private readonly IPackageLogic _logic;
public FormPackages(ILogger<FormPackages> logger, IPackageLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
LoadData();
}
private void FormPackages_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["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["PackageSoftware"].Visible = false;
}
_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(FormPackage));
if (service is FormPackage form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
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 PackageBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
if (service is FormPackage form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
}
}

View File

@ -0,0 +1,63 @@
<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="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,118 @@
namespace SoftwareInstallation
{
partial class FormSoftware
{
/// <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.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxCost = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.labelCost = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(94, 28);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(316, 23);
this.textBoxName.TabIndex = 0;
//
// textBoxCost
//
this.textBoxCost.Location = new System.Drawing.Point(94, 76);
this.textBoxCost.Name = "textBoxCost";
this.textBoxCost.Size = new System.Drawing.Size(156, 23);
this.textBoxCost.TabIndex = 1;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(29, 28);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(62, 15);
this.labelName.TabIndex = 2;
this.labelName.Text = "Название:";
//
// labelCost
//
this.labelCost.AutoSize = true;
this.labelCost.Location = new System.Drawing.Point(29, 76);
this.labelCost.Name = "labelCost";
this.labelCost.Size = new System.Drawing.Size(38, 15);
this.labelCost.TabIndex = 3;
this.labelCost.Text = "Цена:";
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(195, 115);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(103, 26);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(307, 115);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(103, 26);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отменить";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormSoftware
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(441, 153);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.labelCost);
this.Controls.Add(this.labelName);
this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.textBoxName);
this.Name = "FormSoftware";
this.Text = "Программное обеспечение";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private TextBox textBoxCost;
private Label labelName;
private Label labelCost;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,89 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SoftwareInstallation
{
public partial class FormSoftware : Form
{
private readonly ILogger _logger;
private readonly ISoftwareLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormSoftware(ILogger<FormSoftware> logger, ISoftwareLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormSoftware_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Ïîëó÷åíèå êîìïîíåíòà");
var view = _logic.ReadElement(new SoftwareSearchModel
{
Id =
_id.Value
});
if (view != null)
{
textBoxName.Text = view.SoftwareName;
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 SoftwareBindingModel
{
Id = _id ?? 0,
SoftwareName = 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();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,125 @@
namespace SoftwareInstallationView
{
partial class FormSoftwares
{
/// <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.buttonAdd = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(461, 23);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(97, 30);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(461, 80);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(97, 30);
this.buttonEdit.TabIndex = 2;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(461, 136);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(97, 30);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(461, 194);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(97, 30);
this.buttonUpdate.TabIndex = 4;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// dataGridView
//
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.dataGridView.Location = new System.Drawing.Point(1, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(445, 410);
this.dataGridView.TabIndex = 5;
//
// ColumnId
//
this.ColumnId.FillWeight = 200F;
this.ColumnId.HeaderText = "Id";
this.ColumnId.Name = "ColumnId";
this.ColumnId.Visible = false;
this.ColumnId.Width = 200;
//
// FormSoftwares
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(581, 413);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormSoftwares";
this.Text = "Программные обеспечения";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonAdd;
private Button buttonEdit;
private Button buttonDelete;
private Button buttonUpdate;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnId;
}
}

View File

@ -0,0 +1,108 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using SoftwareInstallation;
namespace SoftwareInstallationView
{
public partial class FormSoftwares : Form
{
public FormSoftwares(ILogger<FormSoftwares> logger, ISoftwareLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
LoadData();
}
private readonly ILogger _logger;
private readonly ISoftwareLogic _logic;
private void FormSoftwares_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["SoftwareName"].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(FormSoftware));
if (service is FormSoftware form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
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 SoftwareBindingModel
{
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)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSoftware));
if (service is FormSoftware form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
}
}

View File

@ -0,0 +1,63 @@
<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="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,54 @@
using AbstractOrderInstallationListImplement.Implements;
using AbstractPackageInstallationListImplement.Implements;
using AbstractSoftwareInstallationBusinessLogic;
using AbstractSoftwareInstallationBusinessLogic.BusinessLogic;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.StoragesContracts;
using AbstractSoftwareInstallationListImplement.Implements;
using SoftwareInstallationView;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
namespace SoftwareInstallation
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<ISoftwareStorage, SoftwareStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPackageStorage, PackageStorage>();
services.AddTransient<ISoftwareLogic, SoftwareLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPackageLogic, PackageLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormSoftware>();
services.AddTransient<FormSoftwares>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormPackage>();
services.AddTransient<FormPackageSoftware>();
services.AddTransient<FormPackages>();
}
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AbstractSoftwareInstallationBusinessLogic\AbstractSoftwareInstallationBusinessLogic.csproj" />
<ProjectReference Include="..\AbstractSoftwareInstallationListImplement\AbstractSoftwareInstallationListImplement.csproj" />
</ItemGroup>
</Project>