Готовенько
This commit is contained in:
parent
bfdc16f530
commit
44825a7cdd
@ -17,10 +17,10 @@ namespace ClothShopBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage
|
||||
componentStorage)
|
||||
clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientStorage = componentStorage;
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
|
@ -0,0 +1,123 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.BusinessLogicContracts;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.StoragesContracts;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ImplementerLogic : IImplementerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerStorage _implementerStorage;
|
||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage
|
||||
implementerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerStorage = implementerStorage;
|
||||
}
|
||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ImplementerFIO:{ClientFIO}. Id:{ Id}", model?.ImplementerFIO, model?.Id);
|
||||
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ImplementerFIO:{ImplementerFIO}.Id:{ Id}", model.ImplementerFIO, model.Id);
|
||||
var element = _implementerStorage.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(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_implementerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_implementerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ImplementerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_implementerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password));
|
||||
}
|
||||
if (model.WorkExperience < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Стаж меньше 0", nameof(model.WorkExperience));
|
||||
}
|
||||
if (model.Qualification < 0)
|
||||
{
|
||||
throw new ArgumentException("Квалификация меньше 0", nameof(model.Qualification));
|
||||
}
|
||||
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}." +
|
||||
"Password:{ Password}. WorkExperience:{ WorkExperience}. Qualification:{ Qualification}. Id: { Id} ",
|
||||
model.ImplementerFIO, model.Password, model.WorkExperience, model.Qualification, model.Id);
|
||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,94 +15,119 @@ namespace ClothShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
static readonly object locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
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)
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() :
|
||||
_orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество заказов должно быть больше нуля");
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена заказа должна быть больше нуля");
|
||||
}
|
||||
_logger.LogInformation("Order. OrderId:{Id}. Sum:{Sum}", model.Id, model.Sum);
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (model.Status != OrderStatus.Неизвестен)
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
return false;
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
||||
var element = _orderStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
model.Status = OrderStatus.Принят;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
CheckModel(model);
|
||||
if (model.Status != OrderStatus.Неизвестен) return false;
|
||||
model.Status = OrderStatus.Принят;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element == null)
|
||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
_logger.LogWarning("Find order failed");
|
||||
return false;
|
||||
CheckModel(model, false);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("Read operation failed");
|
||||
return false;
|
||||
}
|
||||
if (element.Status != status - 1)
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||
}
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
if (element.ImplementerId.HasValue) model.ImplementerId = element.ImplementerId;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
if (element.Status != status - 1)
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
_logger.LogWarning("Status change failed");
|
||||
throw new InvalidOperationException("Невозможно перевести состояние заказа");
|
||||
lock (locker)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
}
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Готов);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Готов);
|
||||
}
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
_logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
139
ClothShop/ClothShopBusinessLogic/BusinessLogics/WorkModeling.cs
Normal file
139
ClothShop/ClothShopBusinessLogic/BusinessLogics/WorkModeling.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.BusinessLogicContracts;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkModeling : IWorkProcess
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly Random _rnd;
|
||||
private IOrderLogic? _orderLogic;
|
||||
public WorkModeling(ILogger<WorkModeling> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_rnd = new Random(1000);
|
||||
}
|
||||
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic
|
||||
orderLogic)
|
||||
{
|
||||
_orderLogic = orderLogic;
|
||||
var implementers = implementerLogic.ReadList(null);
|
||||
if (implementers == null)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Implementers is null");
|
||||
return;
|
||||
}
|
||||
var orders = _orderLogic.ReadList(new OrderSearchModel
|
||||
{
|
||||
Status = OrderStatus.Принят
|
||||
});
|
||||
if (orders == null || orders.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||
foreach (var implementer in implementers)
|
||||
{
|
||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||
}
|
||||
}
|
||||
/// Иммитация работы исполнителя
|
||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer,
|
||||
List<OrderViewModel> orders)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await RunOrderInWork(implementer);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var order in orders)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
|
||||
// пытаемся назначить заказ на исполнителя
|
||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
// делаем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id);
|
||||
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// заканчиваем выполнение имитации в случае иной ошибки
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementer.Id,
|
||||
Status = OrderStatus.Выполняется
|
||||
}));
|
||||
if (runOrder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
||||
// доделываем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = runOrder.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// заказа может не быть, просто игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace ClothShopClientApp
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
@ -16,6 +17,7 @@ namespace ClothShopClientApp
|
||||
_client.DefaultRequestHeaders.Accept.Add(new
|
||||
MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
@ -35,9 +37,6 @@ namespace ClothShopClientApp
|
||||
var data = new StringContent(json, Encoding.UTF8,
|
||||
"application/json");
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
var a = response.Result;
|
||||
var b = response.Result.Content;
|
||||
var c = response.Result.Content.ReadAsStringAsync();
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
|
@ -7,6 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="jQuery" Version="3.7.1" />
|
||||
<PackageReference Include="Microsoft.jQuery.Unobtrusive.Ajax" Version="3.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Turner.Infrastructure.Crud.EntityFrameworkCore" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
|
@ -4,6 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - ClothShopClientApp</title>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/ClothShopClientApp.styles.css" asp-append-version="true" />
|
||||
|
@ -0,0 +1,18 @@
|
||||
using ClothShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopContracts.BindingModels
|
||||
{
|
||||
public class ImplementerBindingModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace ClothShopContracts.BindingModels
|
||||
public int ClientId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public int? ImplementerId { get; set; } = null;
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
@ -0,0 +1,20 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IImplementerLogic
|
||||
{
|
||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||
bool Create(ImplementerBindingModel model);
|
||||
bool Update(ImplementerBindingModel model);
|
||||
bool Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace ClothShopContracts.BusinessLogicContracts
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IWorkProcess
|
||||
{
|
||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopContracts.SearchModels
|
||||
{
|
||||
public class ImplementerSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||
public string? Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ClothShopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -10,6 +11,8 @@ namespace ClothShopContracts.SearchModels
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public OrderStatus? Status { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopContracts.StoragesContracts
|
||||
{
|
||||
public interface IImplementerStorage
|
||||
{
|
||||
List<ImplementerViewModel> GetFullList();
|
||||
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using ClothShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Стаж работы")]
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; } = 0;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -18,6 +18,9 @@ namespace ClothShopContracts.ViewModels
|
||||
public string TextileName { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public int? ImplementerId { get; set; } = null;
|
||||
[DisplayName("Исполнитель")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
|
17
ClothShop/ClothShopDataModels/Models/IImplementerModel.cs
Normal file
17
ClothShop/ClothShopDataModels/Models/IImplementerModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopDataModels.Models
|
||||
{
|
||||
public interface IImplementerModel
|
||||
{
|
||||
string ImplementerFIO { get; }
|
||||
string Password { get; }
|
||||
int WorkExperience { get; }
|
||||
int Qualification { get; }
|
||||
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace ClothShopDataModels.Models
|
||||
int ClientId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
int? ImplementerId { get; }
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
|
@ -19,5 +19,6 @@ namespace ClothShopDatabaseImplement
|
||||
public virtual DbSet<TextileComponent> TextileComponents { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.StoragesContracts;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopDatabaseImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ClothShopDatabase();
|
||||
return context.Implementers
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
return context.Implementers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
var res = Implementer.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
context.Implementers.Add(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,14 +17,14 @@ namespace ClothShopDatabaseImplement.Implements
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
return context.Orders.Include(x => x.Textiles).Include(x => x.Client)
|
||||
return context.Orders.Include(x => x.Textiles).Include(x => x.Client).Include(x => x.Implementer)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
return context.Orders.Include(x => x.Textiles).Include(x => x.Client)
|
||||
return context.Orders.Include(x => x.Textiles).Include(x => x.Client).Include(x => x.Implementer)
|
||||
.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
@ -42,7 +42,10 @@ namespace ClothShopDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new ClothShopDatabase();
|
||||
return context.Orders.Include(x => x.Textiles).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Textiles).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(
|
||||
x => ((model.Id.HasValue && x.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
x.ImplementerId == model.ImplementerId && x.Status == model.Status)))?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -59,7 +62,7 @@ namespace ClothShopDatabaseImplement.Implements
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
var order = context.Orders.Include(x => x.Textiles).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id);
|
||||
var order = context.Orders.Include(x => x.Textiles).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
@ -71,7 +74,7 @@ namespace ClothShopDatabaseImplement.Implements
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ClothShopDatabase();
|
||||
var element = context.Orders.Include(x => x.Textiles).Include(x => x.Client).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Orders.Include(x => x.Textiles).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace ClothShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ClothShopDatabase))]
|
||||
[Migration("20240518182542_InitialCreate")]
|
||||
[Migration("20240525142829_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -69,6 +69,33 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -89,6 +116,9 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -102,6 +132,8 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("TextileId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -161,6 +193,10 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ClothShopDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("ClothShopDatabaseImplement.Models.Textile", "Textiles")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("TextileId")
|
||||
@ -169,6 +205,8 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Textiles");
|
||||
});
|
||||
|
||||
@ -201,6 +239,11 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
b.Navigation("TextileComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Textile", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
@ -38,6 +38,22 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Textiles",
|
||||
columns: table => new
|
||||
@ -64,7 +80,8 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
TextileId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false)
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ImplementerId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -75,6 +92,11 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
column: x => x.ImplementerId,
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Textiles_TextileId",
|
||||
column: x => x.TextileId,
|
||||
@ -115,6 +137,11 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_TextileId",
|
||||
table: "Orders",
|
||||
@ -142,6 +169,9 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
@ -67,6 +67,33 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -87,6 +114,9 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -100,6 +130,8 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("TextileId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -159,6 +191,10 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ClothShopDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("ClothShopDatabaseImplement.Models.Textile", "Textiles")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("TextileId")
|
||||
@ -167,6 +203,8 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Textiles");
|
||||
});
|
||||
|
||||
@ -199,6 +237,11 @@ namespace ClothShopDatabaseImplement.Migrations
|
||||
b.Navigation("TextileComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClothShopDatabaseImplement.Models.Textile", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
64
ClothShop/ClothShopDatabaseImplement/Models/Implementer.cs
Normal file
64
ClothShop/ClothShopDatabaseImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopDatabaseImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int Qualification { get; set; } = 0;
|
||||
[Required]
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
WorkExperience = model.WorkExperience,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
WorkExperience = WorkExperience,
|
||||
};
|
||||
}
|
||||
}
|
@ -24,6 +24,8 @@ namespace ClothShopDatabaseImplement.Models
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public virtual Client? Client { get; private set; }
|
||||
public int? ImplementerId { get; private set; } = null;
|
||||
public virtual Implementer? Implementer { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
@ -41,6 +43,7 @@ namespace ClothShopDatabaseImplement.Models
|
||||
DateImplement = model.DateImplement,
|
||||
TextileId = model.TextileId,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
};
|
||||
}
|
||||
|
||||
@ -52,12 +55,14 @@ namespace ClothShopDatabaseImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
TextileId = TextileId,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
@ -65,7 +70,8 @@ namespace ClothShopDatabaseImplement.Models
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
TextileName = Textiles?.TextileName ?? string.Empty,
|
||||
ClientFIO = Client?.ClientFIO ?? string.Empty
|
||||
ClientFIO = Client?.ClientFIO ?? string.Empty,
|
||||
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,20 @@
|
||||
using System.Xml.Linq;
|
||||
namespace ClothShopFileImplement
|
||||
{
|
||||
public class DataFileSingleton
|
||||
internal class DataFileSingleton
|
||||
{
|
||||
private static DataFileSingleton? instance;
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string TextileFileName = "Textile.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ImplementerFileName = "Implementer.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Textile> Textiles { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -26,12 +28,14 @@ namespace ClothShopFileImplement
|
||||
public void SaveTextiles() => SaveData(Textiles, TextileFileName, "Textiles", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Textiles = LoadData(TextileFileName, "Textile", x => Textile.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
|
@ -0,0 +1,83 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.StoragesContracts;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopFileImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
return source.Implementers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel
|
||||
model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Implementers
|
||||
.Where(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO.Contains(model.ImplementerFIO)) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password.Contains(model.Password)))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
return source.Implementers
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x =>
|
||||
x.Id) + 1 : 1;
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Implementers.Add(newImplementer);
|
||||
source.SaveImplementers();
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (implementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
implementer.Update(model);
|
||||
source.SaveImplementers();
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
var element = source.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Implementers.Remove(element);
|
||||
source.SaveImplementers();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,19 +16,24 @@ namespace ClothShopFileImplement.Implements
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders
|
||||
.Select(x => AccessTextileStorage(x.GetViewModel))
|
||||
.Select(x => AccessStorage(x.GetViewModel))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => AccessTextileStorage(x.GetViewModel))
|
||||
.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||
&&
|
||||
(!model.ClientId.HasValue || x.ClientId == model.ClientId)
|
||||
&&
|
||||
(!model.Status.HasValue || x.Status == model.Status)
|
||||
)
|
||||
)
|
||||
.Select(x => AccessStorage(x.GetViewModel))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@ -38,7 +43,11 @@ namespace ClothShopFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return AccessTextileStorage(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel);
|
||||
return AccessStorage(source.Orders
|
||||
.FirstOrDefault(
|
||||
x => (model.Id.HasValue && x.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
x.ImplementerId == model.ImplementerId && x.Status == model.Status))?.GetViewModel ?? new());
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -51,7 +60,7 @@ namespace ClothShopFileImplement.Implements
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return AccessTextileStorage(newOrder.GetViewModel);
|
||||
return AccessStorage(newOrder.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -63,7 +72,7 @@ namespace ClothShopFileImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return AccessTextileStorage(order.GetViewModel);
|
||||
return AccessStorage(order.GetViewModel);
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
@ -73,23 +82,24 @@ namespace ClothShopFileImplement.Implements
|
||||
{
|
||||
source.Orders.Remove(element);
|
||||
source.SaveOrders();
|
||||
return AccessTextileStorage(element.GetViewModel);
|
||||
return AccessStorage(element.GetViewModel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel AccessTextileStorage(OrderViewModel model)
|
||||
public OrderViewModel AccessStorage(OrderViewModel model)
|
||||
{
|
||||
if (model == null)
|
||||
return null;
|
||||
foreach (var Textile in source.Textiles)
|
||||
{
|
||||
if (Textile.Id == model.TextileId)
|
||||
{
|
||||
model.TextileName = Textile.TextileName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var textile = source.Textiles.FirstOrDefault(x => x.Id == model.Id);
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||
if (textile != null)
|
||||
model.TextileName = textile.TextileName;
|
||||
if (client != null)
|
||||
model.ClientFIO = client.ClientFIO;
|
||||
if (implementer != null)
|
||||
model.ImplementerFIO = implementer.ImplementerFIO;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
78
ClothShop/ClothShopFileImplement/Models/Implementer.cs
Normal file
78
ClothShop/ClothShopFileImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ClothShopFileImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
WorkExperience = model.WorkExperience,
|
||||
Qualification = model.Qualification
|
||||
};
|
||||
}
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Qualification = model.Qualification;
|
||||
}
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
WorkExperience = WorkExperience,
|
||||
Qualification = Qualification
|
||||
};
|
||||
public static Implementer? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
||||
Password = element.Element("Password")!.Value,
|
||||
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public XElement GetXElement => new("Implementer",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ImplementerFIO", ImplementerFIO),
|
||||
new XElement("Password", Password),
|
||||
new XElement("Qualification", Qualification.ToString()),
|
||||
new XElement("WorkExperience", WorkExperience.ToString())
|
||||
);
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace ClothShopFileImplement.Models
|
||||
public OrderStatus Status { get; private set; }
|
||||
public DateTime DateCreate { get; private set; }
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public int? ImplementerId { get; private set; } = null;
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
@ -32,6 +33,7 @@ namespace ClothShopFileImplement.Models
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
ImplementerId = model.ImplementerId,
|
||||
};
|
||||
}
|
||||
public static Order? Create(XElement element)
|
||||
@ -49,7 +51,8 @@ namespace ClothShopFileImplement.Models
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value.ToString()),
|
||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(element.Element("DateImplement")!.Value),
|
||||
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel model)
|
||||
@ -60,6 +63,7 @@ namespace ClothShopFileImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
@ -71,6 +75,7 @@ namespace ClothShopFileImplement.Models
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ImplementerId = ImplementerId
|
||||
};
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
@ -80,7 +85,8 @@ namespace ClothShopFileImplement.Models
|
||||
new XElement("Count", Count),
|
||||
new XElement("Status", Status.ToString()),
|
||||
new XElement("DateCreate", DateCreate.ToString()),
|
||||
new XElement("DateImplement", DateImplement.ToString())
|
||||
new XElement("DateImplement", DateImplement.ToString()),
|
||||
new XElement("ImplementerId", ImplementerId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using ClothShopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
@ -15,6 +16,7 @@ namespace ClothShopListImplement
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Textile> Textiles { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
|
||||
private DataListSingleton()
|
||||
{
|
||||
@ -22,6 +24,7 @@ namespace ClothShopListImplement
|
||||
Orders = new List<Order>();
|
||||
Textiles = new List<Textile>();
|
||||
Clients = new List<Client>();
|
||||
Implementers = new List<Implementer>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -0,0 +1,103 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.StoragesContracts;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopListImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel
|
||||
model)
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if ((string.IsNullOrEmpty(model.ImplementerFIO) || implementer.ImplementerFIO == model.ImplementerFIO) &&
|
||||
(!model.Id.HasValue || implementer.Id == model.Id) && (string.IsNullOrEmpty(model.Password) || implementer.Password == model.Password))
|
||||
{
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.Id <= implementer.Id)
|
||||
{
|
||||
model.Id = implementer.Id + 1;
|
||||
}
|
||||
}
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Implementers.Add(newImplementer);
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.Id == implementer.Id)
|
||||
{
|
||||
implementer.Update(model);
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Implementers.Count; ++i)
|
||||
{
|
||||
if (_source.Implementers[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Implementers[i];
|
||||
_source.Implementers.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ namespace ClothShopListImplement.Implements
|
||||
var result = new List<OrderViewModel>();
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AccessTextileStorage(order.GetViewModel));
|
||||
result.Add(AccessStorage(order.GetViewModel));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -33,11 +33,14 @@ namespace ClothShopListImplement.Implements
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if ((!model.Id.HasValue || order.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo) &&
|
||||
(!model.ClientId.HasValue || order.ClientId == model.ClientId))
|
||||
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo)
|
||||
&&
|
||||
(!model.ClientId.HasValue || order.ClientId == model.ClientId)
|
||||
&&
|
||||
(!model.Status.HasValue || order.Status == model.Status))
|
||||
{
|
||||
result.Add(AccessTextileStorage(order.GetViewModel));
|
||||
result.Add(AccessStorage(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -50,9 +53,11 @@ namespace ClothShopListImplement.Implements
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
if ((model.Id.HasValue && order.Id == model.Id) ||
|
||||
(model.ImplementerId.HasValue && model.Status.HasValue &&
|
||||
order.ImplementerId == model.ImplementerId && order.Status == model.Status))
|
||||
{
|
||||
return order.GetViewModel;
|
||||
return AccessStorage(order.GetViewModel);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -101,24 +106,19 @@ namespace ClothShopListImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel AccessTextileStorage(OrderViewModel model)
|
||||
public OrderViewModel AccessStorage(OrderViewModel model)
|
||||
{
|
||||
foreach (var Textile in _source.Textiles)
|
||||
{
|
||||
if (Textile.Id == model.TextileId)
|
||||
{
|
||||
model.TextileName = Textile.TextileName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public OrderViewModel AccessClientStorage(OrderViewModel model)
|
||||
{
|
||||
var client = _source.Clients.FirstOrDefault(x => x.Id == model.ClientId);
|
||||
if (model == null)
|
||||
return null;
|
||||
var textile = _source.Textiles.FirstOrDefault(x => x.Id == model.Id);
|
||||
var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
|
||||
if (textile != null)
|
||||
model.TextileName = textile.TextileName;
|
||||
if (client != null)
|
||||
model.ClientFIO = client.ClientFIO;
|
||||
if (implementer != null)
|
||||
model.ImplementerFIO = implementer.ImplementerFIO;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
54
ClothShop/ClothShopListImplement/Models/Implementer.cs
Normal file
54
ClothShop/ClothShopListImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClothShopListImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int WorkExperience { get; set; } = 0;
|
||||
public int Qualification { get; set; } = 0;
|
||||
public static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Implementer()
|
||||
{
|
||||
Id = model.Id,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
Password = model.Password,
|
||||
WorkExperience = model.WorkExperience,
|
||||
Qualification = model.Qualification
|
||||
};
|
||||
}
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Qualification = model.Qualification;
|
||||
}
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
WorkExperience = WorkExperience,
|
||||
Qualification = Qualification
|
||||
};
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ namespace ClothShopListImplement.Models
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public int Id { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -36,6 +37,7 @@ namespace ClothShopListImplement.Models
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id,
|
||||
ImplementerId = model.ImplementerId,
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
@ -46,6 +48,7 @@ namespace ClothShopListImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
@ -57,6 +60,7 @@ namespace ClothShopListImplement.Models
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
Status = Status,
|
||||
ImplementerId = ImplementerId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
103
ClothShop/ClothShopRestApi/Controllers/ImplementerController.cs
Normal file
103
ClothShop/ClothShopRestApi/Controllers/ImplementerController.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.BusinessLogicContracts;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using ClothShopContracts.ViewModels;
|
||||
using ClothShopDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ClothShopRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ImplementerController : ControllerBase
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _order;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public ImplementerController(IOrderLogic order, IImplementerLogic logic,
|
||||
ILogger<ImplementerController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_order = order;
|
||||
_logic = logic;
|
||||
}
|
||||
[HttpGet]
|
||||
public ImplementerViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
ImplementerFIO = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetNewOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
Status = OrderStatus.Принят
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public OrderViewModel? GetImplementerOrder(int implementerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementerId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.TakeOrderInWork(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу",
|
||||
model.Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.FinishOrder(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<ITextileStorage, TextileStorage>();
|
||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<ITextileLogic, TextileLogic>();
|
||||
|
112
ClothShop/ClothShopView/FormComponents.Designer.cs
generated
112
ClothShop/ClothShopView/FormComponents.Designer.cs
generated
@ -28,81 +28,79 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonRefresh = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
buttonRefresh = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
this.buttonRefresh.Location = new System.Drawing.Point(642, 209);
|
||||
this.buttonRefresh.Name = "buttonRefresh";
|
||||
this.buttonRefresh.Size = new System.Drawing.Size(120, 39);
|
||||
this.buttonRefresh.TabIndex = 9;
|
||||
this.buttonRefresh.Text = "Обновить";
|
||||
this.buttonRefresh.UseVisualStyleBackColor = true;
|
||||
this.buttonRefresh.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
buttonRefresh.Location = new Point(642, 209);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(120, 39);
|
||||
buttonRefresh.TabIndex = 9;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRef_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(642, 149);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(120, 39);
|
||||
this.buttonDelete.TabIndex = 8;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
buttonDelete.Location = new Point(642, 149);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(120, 39);
|
||||
buttonDelete.TabIndex = 8;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDel_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(642, 86);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(120, 39);
|
||||
this.buttonUpdate.TabIndex = 7;
|
||||
this.buttonUpdate.Text = "Изменить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
buttonUpdate.Location = new Point(642, 86);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(120, 39);
|
||||
buttonUpdate.TabIndex = 7;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(642, 26);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(120, 39);
|
||||
this.buttonAdd.TabIndex = 6;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
buttonAdd.Location = new Point(642, 26);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(120, 39);
|
||||
buttonAdd.TabIndex = 6;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(1, -1);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(593, 450);
|
||||
this.dataGridView.TabIndex = 5;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(1, -1);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(593, 450);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonRefresh);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormComponents";
|
||||
this.Text = "Компоненты";
|
||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormComponents";
|
||||
Text = "Компоненты";
|
||||
Load += FormComponents_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
350
ClothShop/ClothShopView/FormMain.Designer.cs
generated
350
ClothShop/ClothShopView/FormMain.Designer.cs
generated
@ -20,199 +20,191 @@
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
menuStrip = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
изделиеToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportTextilesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportTextileComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportOrdeersToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonRefresh = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonCreateOrder = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 31);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(1073, 377);
|
||||
dataGridView.TabIndex = 8;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, ReportToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1331, 28);
|
||||
menuStrip.TabIndex = 7;
|
||||
menuStrip.Text = "Меню справочников";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, клиентыToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(182, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// изделиеToolStripMenuItem
|
||||
//
|
||||
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
|
||||
изделиеToolStripMenuItem.Size = new Size(182, 26);
|
||||
изделиеToolStripMenuItem.Text = "Изделие";
|
||||
изделиеToolStripMenuItem.Click += TextileToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(182, 26);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportToolStripMenuItem
|
||||
//
|
||||
ReportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ReportTextilesToolStripMenuItem, ReportTextileComponentsToolStripMenuItem, ReportOrdeersToolStripMenuItem });
|
||||
ReportToolStripMenuItem.Name = "ReportToolStripMenuItem";
|
||||
ReportToolStripMenuItem.Size = new Size(73, 24);
|
||||
ReportToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// ReportTextilesToolStripMenuItem
|
||||
//
|
||||
ReportTextilesToolStripMenuItem.Name = "ReportTextilesToolStripMenuItem";
|
||||
ReportTextilesToolStripMenuItem.Size = new Size(276, 26);
|
||||
ReportTextilesToolStripMenuItem.Text = "Список изделий";
|
||||
ReportTextilesToolStripMenuItem.Click += ReportComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportTextileComponentsToolStripMenuItem
|
||||
//
|
||||
ReportTextileComponentsToolStripMenuItem.Name = "ReportTextileComponentsToolStripMenuItem";
|
||||
ReportTextileComponentsToolStripMenuItem.Size = new Size(276, 26);
|
||||
ReportTextileComponentsToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
ReportTextileComponentsToolStripMenuItem.Click += ReportTextileComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportOrdeersToolStripMenuItem
|
||||
//
|
||||
ReportOrdeersToolStripMenuItem.Name = "ReportOrdeersToolStripMenuItem";
|
||||
ReportOrdeersToolStripMenuItem.Size = new Size(276, 26);
|
||||
ReportOrdeersToolStripMenuItem.Text = "Список заказов";
|
||||
ReportOrdeersToolStripMenuItem.Click += ReportOrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(1107, 318);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(212, 38);
|
||||
buttonRefresh.TabIndex = 13;
|
||||
buttonRefresh.Text = "Обновить список";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRef_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(1107, 237);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(212, 38);
|
||||
buttonIssuedOrder.TabIndex = 12;
|
||||
buttonIssuedOrder.Text = "Заказ выдан";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(1107, 163);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(212, 38);
|
||||
buttonOrderReady.TabIndex = 11;
|
||||
buttonOrderReady.Text = "Заказ готов";
|
||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
buttonOrderReady.Click += ButtonOrderReady_Click;
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(1107, 109);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(212, 38);
|
||||
buttonTakeOrderInWork.TabIndex = 10;
|
||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(1107, 48);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(212, 38);
|
||||
buttonCreateOrder.TabIndex = 9;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1331, 417);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonOrderReady);
|
||||
Controls.Add(buttonTakeOrderInWork);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Name = "FormMain";
|
||||
Text = "Заказы";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
menuStrip = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
изделиеToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportTextilesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportTextileComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportOrdeersToolStripMenuItem = new ToolStripMenuItem();
|
||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonRefresh = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonCreateOrder = new Button();
|
||||
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 31);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(1073, 377);
|
||||
dataGridView.TabIndex = 8;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, ReportToolStripMenuItem, запускРаботToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1331, 28);
|
||||
menuStrip.TabIndex = 7;
|
||||
menuStrip.Text = "Меню справочников";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += ComponentsStripMenuItem_Click;
|
||||
//
|
||||
// изделиеToolStripMenuItem
|
||||
//
|
||||
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
|
||||
изделиеToolStripMenuItem.Size = new Size(224, 26);
|
||||
изделиеToolStripMenuItem.Text = "Изделие";
|
||||
изделиеToolStripMenuItem.Click += TextilesStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportToolStripMenuItem
|
||||
//
|
||||
ReportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ReportTextilesToolStripMenuItem, ReportTextileComponentsToolStripMenuItem, ReportOrdeersToolStripMenuItem });
|
||||
ReportToolStripMenuItem.Name = "ReportToolStripMenuItem";
|
||||
ReportToolStripMenuItem.Size = new Size(73, 24);
|
||||
ReportToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// ReportTextilesToolStripMenuItem
|
||||
//
|
||||
ReportTextilesToolStripMenuItem.Name = "ReportTextilesToolStripMenuItem";
|
||||
ReportTextilesToolStripMenuItem.Size = new Size(276, 26);
|
||||
ReportTextilesToolStripMenuItem.Text = "Список изделий";
|
||||
ReportTextilesToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportTextileComponentsToolStripMenuItem
|
||||
//
|
||||
ReportTextileComponentsToolStripMenuItem.Name = "ReportTextileComponentsToolStripMenuItem";
|
||||
ReportTextileComponentsToolStripMenuItem.Size = new Size(276, 26);
|
||||
ReportTextileComponentsToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
ReportTextileComponentsToolStripMenuItem.Click += компонентыПоКомпьютерамToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportOrdeersToolStripMenuItem
|
||||
//
|
||||
ReportOrdeersToolStripMenuItem.Name = "ReportOrdeersToolStripMenuItem";
|
||||
ReportOrdeersToolStripMenuItem.Size = new Size(276, 26);
|
||||
ReportOrdeersToolStripMenuItem.Text = "Список заказов";
|
||||
ReportOrdeersToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
запускРаботToolStripMenuItem.Size = new Size(114, 24);
|
||||
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(1107, 318);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(212, 38);
|
||||
buttonRefresh.TabIndex = 13;
|
||||
buttonRefresh.Text = "Обновить список";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += RefreshButton_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(1107, 237);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(212, 38);
|
||||
buttonIssuedOrder.TabIndex = 12;
|
||||
buttonIssuedOrder.Text = "Заказ выдан";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += IssuedButton_Click;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(1107, 48);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(212, 38);
|
||||
buttonCreateOrder.TabIndex = 9;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += CreateOrderButton_Click;
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
исполнителиToolStripMenuItem.Size = new Size(224, 26);
|
||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1331, 417);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Name = "FormMain";
|
||||
Text = "Заказы";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridView dataGridView;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem изделиеToolStripMenuItem;
|
||||
private Button buttonRefresh;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonCreateOrder;
|
||||
private ToolStripMenuItem ReportToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportTextilesToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportTextileComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportOrdeersToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -19,18 +19,31 @@ namespace ClothShopView
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
|
||||
private void ComponentsStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
@ -42,8 +55,8 @@ namespace ClothShopView
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["TextileId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["TextileName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
@ -53,15 +66,8 @@ namespace ClothShopView
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void TextileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
||||
private void TextilesStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTextiles));
|
||||
if (service is FormTextiles form)
|
||||
@ -70,7 +76,52 @@ namespace ClothShopView
|
||||
}
|
||||
}
|
||||
|
||||
private void clientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void списокКомпонентовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveTextilesToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void компонентыПоКомпьютерамToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportTextileComponents));
|
||||
if (service is FormReportTextileComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
@ -78,17 +129,27 @@ namespace ClothShopView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
|
||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||
if (service is ImplementersForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private OrderBindingModel CreateBindingModel(int id)
|
||||
|
||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic
|
||||
)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
|
||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
@ -101,12 +162,12 @@ namespace ClothShopView
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
};
|
||||
}
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
|
||||
private void TakeInWorkButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
@ -120,19 +181,18 @@ namespace ClothShopView
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||
|
||||
private void ReadyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
||||
id);
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
|
||||
@ -149,14 +209,13 @@ namespace ClothShopView
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
|
||||
private void IssuedButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
|
||||
id);
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
|
||||
@ -170,47 +229,15 @@ namespace ClothShopView
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ReportComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveTextilesToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void ReportTextileComponentsToolStripMenuItem_Click(object sender,
|
||||
EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormReportTextileComponents));
|
||||
if (service is FormReportTextileComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ReportOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
162
ClothShop/ClothShopView/ImplementerForm.Designer.cs
generated
Normal file
162
ClothShop/ClothShopView/ImplementerForm.Designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
||||
namespace ClothShopView
|
||||
{
|
||||
partial class ImplementerForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
PasswordTextBox = new TextBox();
|
||||
FIOTextBox = new TextBox();
|
||||
labelPassword = new Label();
|
||||
labelName = new Label();
|
||||
WorkExperienceTextBox = new TextBox();
|
||||
QualificationTextBox = new TextBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(395, 161);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 17;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += CancelButton_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(286, 161);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 16;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += SaveButton_Click;
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
PasswordTextBox.Location = new Point(123, 63);
|
||||
PasswordTextBox.Name = "PasswordTextBox";
|
||||
PasswordTextBox.Size = new Size(366, 27);
|
||||
PasswordTextBox.TabIndex = 15;
|
||||
//
|
||||
// FIOTextBox
|
||||
//
|
||||
FIOTextBox.Location = new Point(123, 11);
|
||||
FIOTextBox.Name = "FIOTextBox";
|
||||
FIOTextBox.Size = new Size(366, 27);
|
||||
FIOTextBox.TabIndex = 14;
|
||||
//
|
||||
// labelPassword
|
||||
//
|
||||
labelPassword.AutoSize = true;
|
||||
labelPassword.Location = new Point(16, 64);
|
||||
labelPassword.Name = "labelPassword";
|
||||
labelPassword.Size = new Size(62, 20);
|
||||
labelPassword.TabIndex = 13;
|
||||
labelPassword.Text = "Пароль";
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(16, 12);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(45, 20);
|
||||
labelName.TabIndex = 12;
|
||||
labelName.Text = "ФИО:";
|
||||
//
|
||||
// WorkExperienceTextBox
|
||||
//
|
||||
WorkExperienceTextBox.Location = new Point(123, 107);
|
||||
WorkExperienceTextBox.Name = "WorkExperienceTextBox";
|
||||
WorkExperienceTextBox.Size = new Size(115, 27);
|
||||
WorkExperienceTextBox.TabIndex = 18;
|
||||
//
|
||||
// QualificationTextBox
|
||||
//
|
||||
QualificationTextBox.Location = new Point(364, 107);
|
||||
QualificationTextBox.Name = "QualificationTextBox";
|
||||
QualificationTextBox.Size = new Size(125, 27);
|
||||
QualificationTextBox.TabIndex = 19;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(16, 111);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(102, 20);
|
||||
label1.TabIndex = 20;
|
||||
label1.Text = "Стаж работы:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(244, 110);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(114, 20);
|
||||
label2.TabIndex = 21;
|
||||
label2.Text = "Квалификация:";
|
||||
//
|
||||
// ImplementerForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(522, 220);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(QualificationTextBox);
|
||||
Controls.Add(WorkExperienceTextBox);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(PasswordTextBox);
|
||||
Controls.Add(FIOTextBox);
|
||||
Controls.Add(labelPassword);
|
||||
Controls.Add(labelName);
|
||||
Name = "ImplementerForm";
|
||||
Text = "ImplementerForm";
|
||||
Load += ImplementerForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox PasswordTextBox;
|
||||
private TextBox FIOTextBox;
|
||||
private Label labelPassword;
|
||||
private Label labelName;
|
||||
private TextBox WorkExperienceTextBox;
|
||||
private TextBox QualificationTextBox;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
}
|
||||
}
|
109
ClothShop/ClothShopView/ImplementerForm.cs
Normal file
109
ClothShop/ClothShopView/ImplementerForm.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.BusinessLogicContracts;
|
||||
using ClothShopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 ClothShopView
|
||||
{
|
||||
public partial class ImplementerForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public ImplementerForm(ILogger<ImplementerForm> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ImplementerForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id =
|
||||
_id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
FIOTextBox.Text = view.ImplementerFIO;
|
||||
PasswordTextBox.Text = view.Password;
|
||||
QualificationTextBox.Text = view.Qualification.ToString();
|
||||
WorkExperienceTextBox.Text = view.WorkExperience.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FIOTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(PasswordTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните пароль", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение компонента");
|
||||
try
|
||||
{
|
||||
var model = new ImplementerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ImplementerFIO = FIOTextBox.Text,
|
||||
Password = PasswordTextBox.Text,
|
||||
Qualification = Convert.ToInt32(QualificationTextBox.Text),
|
||||
WorkExperience = Convert.ToInt32(WorkExperienceTextBox.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 CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
ClothShop/ClothShopView/ImplementerForm.resx
Normal file
120
ClothShop/ClothShopView/ImplementerForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
114
ClothShop/ClothShopView/ImplementersForm.Designer.cs
generated
Normal file
114
ClothShop/ClothShopView/ImplementersForm.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace ClothShopView
|
||||
{
|
||||
partial class ImplementersForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonRefresh = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(642, 211);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(120, 39);
|
||||
buttonRefresh.TabIndex = 14;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += RefreshButton_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(642, 151);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(120, 39);
|
||||
buttonDelete.TabIndex = 13;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += DeleteButton_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(642, 88);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(120, 39);
|
||||
buttonUpdate.TabIndex = 12;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ChangeButton_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(642, 28);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(120, 39);
|
||||
buttonAdd.TabIndex = 11;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += CreateButton_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(1, 1);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(593, 450);
|
||||
dataGridView.TabIndex = 10;
|
||||
//
|
||||
// ImplementersForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ImplementersForm";
|
||||
Text = "ImplementersForm";
|
||||
Load += ImplementersForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonRefresh;
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
124
ClothShop/ClothShopView/ImplementersForm.cs
Normal file
124
ClothShop/ClothShopView/ImplementersForm.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using ClothShopContracts.BindingModels;
|
||||
using ClothShopContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 ClothShopView
|
||||
{
|
||||
public partial class ImplementersForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
public ImplementersForm(ILogger<ImplementersForm> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ImplementersForm_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["ImplementerFIO"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Password"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Qualification"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["WorkExperience"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_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 ImplementerBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
ClothShop/ClothShopView/ImplementersForm.resx
Normal file
120
ClothShop/ClothShopView/ImplementersForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -48,6 +48,9 @@ namespace ClothShopView
|
||||
services.AddTransient<ITextileLogic, TextileLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
@ -59,6 +62,8 @@ namespace ClothShopView
|
||||
services.AddTransient<FormReportTextileComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<ImplementerForm>();
|
||||
services.AddTransient<ImplementersForm>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
Loading…
Reference in New Issue
Block a user