Сдал
This commit is contained in:
parent
66da57ff3c
commit
2e03dc50a7
128
Bar/BarBusinessLogic/BusinessLogics/ImplementerLogic.cs
Normal file
128
Bar/BarBusinessLogic/BusinessLogics/ImplementerLogic.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.StoragesContracts;
|
||||
using BarContracts.BusinessLogicsContracts;
|
||||
using BarContracts.ViewModels;
|
||||
using BarContracts.BindingModels;
|
||||
|
||||
namespace BarBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ImplementerLogic : IImplementerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerStorage _implementerStorage;
|
||||
|
||||
public ImplementerLogic(ILogger<IImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerStorage = implementerStorage;
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}.Password:{Password}.Id:{ Id}", model?.ImplementerFIO, model?.Password?.Length, 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}.Password:{Password}.Id:{ Id}", model?.ImplementerFIO, model?.Password?.Length, 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 ArgumentNullException("Квалификация должна быть положительной", 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("Исполнитель с таким ФИО уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,16 +17,36 @@ namespace BarBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
static readonly object _locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
||||
model.ClientId, model.Status, model.ImplementerId, model.DateFrom, model.DateTo, 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;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
_logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
||||
model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
@ -50,7 +70,7 @@ namespace BarBusinessLogic.BusinessLogics
|
||||
}
|
||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
@ -62,16 +82,21 @@ namespace BarBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||
}
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
if (element.ImplementerId != null)
|
||||
element.ImplementerId = model.ImplementerId;
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Готов || model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
lock (_locker)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
|
142
Bar/BarBusinessLogic/BusinessLogics/WorkModeling.cs
Normal file
142
Bar/BarBusinessLogic/BusinessLogics/WorkModeling.cs
Normal file
@ -0,0 +1,142 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.BusinessLogicsContracts;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.ViewModels;
|
||||
using BarDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarBusinessLogic.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,
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// заканчиваем выполнение имитации в случае иной ошибки
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
ImplementerId = implementer.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -141,8 +141,8 @@ namespace BarClientApp.Controllers
|
||||
[HttpPost]
|
||||
public double Calc(int count, int cocktail)
|
||||
{
|
||||
var coc = APIClient.GetRequest<CocktailViewModel>($"api/main/getcocktail?cocktailId={cocktail}");
|
||||
return count * (coc?.Price ?? 1);
|
||||
var piz = APIClient.GetRequest<CocktailViewModel>($"api/main/getcocktail?cocktailId={cocktail}");
|
||||
return count * (piz?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
Bar/BarContracts/BindingModels/ImplementerBindingModel.cs
Normal file
18
Bar/BarContracts/BindingModels/ImplementerBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using BarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarContracts.BindingModels
|
||||
{
|
||||
public class ImplementerBindingModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int WorkExperience { get; set; }
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -16,7 +16,9 @@ namespace BarContracts.BindingModels
|
||||
public double Sum { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public int? ImplementerId { get; set; }
|
||||
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
using BarContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.ViewModels;
|
||||
|
||||
namespace BarContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IImplementerLogic
|
||||
{
|
||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||
bool Create(ImplementerBindingModel model);
|
||||
bool Update(ImplementerBindingModel model);
|
||||
bool Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -16,5 +16,6 @@ namespace BarContracts.BusinessLogicsContracts
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
}
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
}
|
||||
}
|
||||
|
16
Bar/BarContracts/BusinessLogicsContracts/IWorkProcess.cs
Normal file
16
Bar/BarContracts/BusinessLogicsContracts/IWorkProcess.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Запуск работ
|
||||
/// </summary>
|
||||
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||
}
|
||||
}
|
15
Bar/BarContracts/SearchModels/ImplementerSearchModel.cs
Normal file
15
Bar/BarContracts/SearchModels/ImplementerSearchModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarContracts.SearchModels
|
||||
{
|
||||
public class ImplementerSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ImplementerFIO { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using BarDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -12,5 +13,7 @@ namespace BarContracts.SearchModels
|
||||
public int? ClientId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
public OrderStatus? Status { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
}
|
||||
}
|
||||
|
21
Bar/BarContracts/StoragesContracts/IImplementerStorage.cs
Normal file
21
Bar/BarContracts/StoragesContracts/IImplementerStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarContracts.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);
|
||||
}
|
||||
}
|
27
Bar/BarContracts/ViewModels/ImplementerViewModel.cs
Normal file
27
Bar/BarContracts/ViewModels/ImplementerViewModel.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using BarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стаж работы")]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -30,5 +30,8 @@ namespace BarContracts.ViewModels
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
}
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Исполнитель")]
|
||||
public string? ImplementerFIO { get; set; } = null;
|
||||
}
|
||||
}
|
||||
|
17
Bar/BarDataModels/Models/IImplementerModel.cs
Normal file
17
Bar/BarDataModels/Models/IImplementerModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using BarDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarDataModels.Models
|
||||
{
|
||||
public interface IImplementerModel : IId
|
||||
{
|
||||
string ImplementerFIO { get; }
|
||||
string Password { get; }
|
||||
int WorkExperience { get; }
|
||||
int Qualification { get; }
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace BarDataModels.Models
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
int ClientId { get; }
|
||||
}
|
||||
int? ImplementerId { get; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ namespace BarDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-3TVINPHN\SQLEXPRESS;Initial Catalog=BarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True",
|
||||
optionsBuilder.UseSqlServer(@"Data Source=.\SQLEXPRESS;Initial Catalog=BarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True",
|
||||
options => options.EnableRetryOnFailure(
|
||||
maxRetryCount: 2,
|
||||
maxRetryCount: 5,
|
||||
maxRetryDelay: System.TimeSpan.FromSeconds(30),
|
||||
errorNumbersToAdd: null));
|
||||
}
|
||||
@ -27,5 +27,6 @@ namespace BarDatabaseImplement
|
||||
public virtual DbSet<CocktailComponent> CocktailComponents { get; set; }
|
||||
public virtual DbSet<Order> Orders { get; set; }
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
}
|
||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||
}
|
||||
}
|
||||
|
84
Bar/BarDatabaseImplement/Implements/ImplementerStorage.cs
Normal file
84
Bar/BarDatabaseImplement/Implements/ImplementerStorage.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.StoragesContracts;
|
||||
using BarContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarDatabaseImplement.Models;
|
||||
|
||||
namespace BarDatabaseImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
public List<ImplementerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BarDatabase();
|
||||
return context.Implementers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
return context.Implementers.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
return context.Implementers.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO && (!string.IsNullOrEmpty(model.Password) ? x.Password == model.Password : true)) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||
{
|
||||
var newImplementer = Implementer.Create(model);
|
||||
if (newImplementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
context.Implementers.Add(newImplementer);
|
||||
context.SaveChanges();
|
||||
return newImplementer.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new BarDatabase();
|
||||
var implementer = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (implementer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
implementer.Update(model);
|
||||
context.SaveChanges();
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||
{
|
||||
using var context = new BarDatabase();
|
||||
var implementer = context.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (implementer != null)
|
||||
{
|
||||
context.Implementers.Remove(implementer);
|
||||
context.SaveChanges();
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using BarContracts.SearchModels;
|
||||
using BarContracts.ViewModels;
|
||||
using BarContracts.StoragesContracts;
|
||||
using BarDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,89 +15,76 @@ namespace BarDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel?> GetFullList()
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BarDatabase();
|
||||
return context.Orders.Select(x => AcessCocktailsStorage(x.GetViewModel)).ToList();
|
||||
}
|
||||
public List<OrderViewModel?> GetFilteredList(OrderSearchModel model)
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.ClientId.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Status.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
if (model.Id.HasValue)
|
||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => AcessCocktailsStorage(x.GetViewModel)).ToList();
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
else if (model.ClientId.HasValue)
|
||||
return context.Orders.Where(x => x.ClientId == model.ClientId).Select(x => AcessCocktailsStorage(x.GetViewModel)).ToList();
|
||||
else
|
||||
return context.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AcessCocktailsStorage(x.GetViewModel)).ToList();
|
||||
}
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
||||
else if (model.DateFrom != null)
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
|
||||
else
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.Status.Equals(model.Status)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
return AcessCocktailsStorage(context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel);
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
var order = Order.Create(model);
|
||||
if (order == null)
|
||||
using var context = new BarDatabase();
|
||||
var order = Order.Create(model, context);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
context.Orders.Add(order);
|
||||
context.SaveChanges();
|
||||
return AcessCocktailsStorage(order.GetViewModel);
|
||||
return order.GetViewModel;
|
||||
|
||||
}
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
|
||||
using var context = new BarDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
var order = context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return AcessCocktailsStorage(order.GetViewModel);
|
||||
return order.GetViewModel;
|
||||
|
||||
}
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new BarDatabase();
|
||||
var element = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element == null)
|
||||
var element = context.Orders.Include(x => x.Cocktail).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return AcessCocktailsStorage(element.GetViewModel);
|
||||
}
|
||||
public static OrderViewModel? AcessCocktailsStorage(OrderViewModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BarDatabase();
|
||||
foreach (var cocktail in context.Cocktails)
|
||||
{
|
||||
if (cocktail.Id == model.CocktailId)
|
||||
{
|
||||
model.CocktailName = cocktail.CocktailName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace BarDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BarDatabase))]
|
||||
[Migration("20240419113527_init")]
|
||||
[Migration("20240517092627_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -116,6 +116,33 @@ namespace BarDatabaseImplement.Migrations
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
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("BarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -139,6 +166,9 @@ namespace BarDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -151,6 +181,8 @@ namespace BarDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("CocktailId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
@ -175,17 +207,27 @@ namespace BarDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BarDatabaseImplement.Models.Client", null)
|
||||
b.HasOne("BarDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BarDatabaseImplement.Models.Cocktail", null)
|
||||
b.HasOne("BarDatabaseImplement.Models.Cocktail", "Cocktail")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CocktailId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BarDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Order")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Cocktail");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Client", b =>
|
||||
@ -204,6 +246,11 @@ namespace BarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("CocktailComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Order");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
@ -55,34 +55,19 @@ namespace BarDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
CocktailId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Cocktails_CocktailId",
|
||||
column: x => x.CocktailId,
|
||||
principalTable: "Cocktails",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -112,6 +97,43 @@ namespace BarDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
||||
CocktailId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Cocktails_CocktailId",
|
||||
column: x => x.CocktailId,
|
||||
principalTable: "Cocktails",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
column: x => x.ImplementerId,
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CocktailComponents_CocktailId",
|
||||
table: "CocktailComponents",
|
||||
@ -131,6 +153,11 @@ namespace BarDatabaseImplement.Migrations
|
||||
name: "IX_Orders_CocktailId",
|
||||
table: "Orders",
|
||||
column: "CocktailId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -150,6 +177,9 @@ namespace BarDatabaseImplement.Migrations
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cocktails");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
}
|
||||
}
|
||||
}
|
@ -113,6 +113,33 @@ namespace BarDatabaseImplement.Migrations
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
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("BarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -136,6 +163,9 @@ namespace BarDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -148,6 +178,8 @@ namespace BarDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("CocktailId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
@ -172,17 +204,27 @@ namespace BarDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BarDatabaseImplement.Models.Client", null)
|
||||
b.HasOne("BarDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BarDatabaseImplement.Models.Cocktail", null)
|
||||
b.HasOne("BarDatabaseImplement.Models.Cocktail", "Cocktail")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CocktailId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BarDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Order")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Cocktail");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Client", b =>
|
||||
@ -201,6 +243,11 @@ namespace BarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("CocktailComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BarDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Order");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
70
Bar/BarDatabaseImplement/Models/Implementer.cs
Normal file
70
Bar/BarDatabaseImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.ViewModels;
|
||||
using BarDataModels.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 BarDatabaseImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Order { get; set; } = new();
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
@ -18,7 +18,8 @@ namespace BarDatabaseImplement.Models
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
[Required]
|
||||
public int? ImplementerId { get; private set; }
|
||||
[Required]
|
||||
public int CocktailId { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
@ -30,8 +31,9 @@ namespace BarDatabaseImplement.Models
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public Client Client { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
public Implementer? Implementer { get; set; }
|
||||
public Cocktail Cocktail { get; set; }
|
||||
public static Order? Create(OrderBindingModel model, BarDatabase context)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -41,12 +43,15 @@ namespace BarDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientId = model.ClientId,
|
||||
CocktailId = model.CocktailId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
CocktailId = model.CocktailId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate
|
||||
};
|
||||
DateCreate = model.DateCreate,
|
||||
Client = context.Clients.FirstOrDefault(x => x.Id == model.ClientId)!,
|
||||
Cocktail = context.Cocktails.FirstOrDefault(x => x.Id == model.CocktailId)!,
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
@ -56,25 +61,30 @@ namespace BarDatabaseImplement.Models
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel
|
||||
{
|
||||
get {
|
||||
using var context = new BarDatabase();
|
||||
return new OrderViewModel
|
||||
{
|
||||
Id = Id,
|
||||
CocktailId = CocktailId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
public OrderViewModel GetViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
using var context = new BarDatabase();
|
||||
return new OrderViewModel
|
||||
{
|
||||
Id = Id,
|
||||
CocktailId = CocktailId,
|
||||
CocktailName = Cocktail.CocktailName,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||
ImplementerFIO = context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,16 @@ namespace BarContracts.BindingModels
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string CocktailFileName = "Cocktail.xml";
|
||||
private readonly string ClientFileName = "Cocktail.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ImplementerFileName = "Implement.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Cocktail> Cocktails { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
@ -48,13 +52,17 @@ namespace BarContracts.BindingModels
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveCocktails() => SaveData(Cocktails, CocktailFileName, "Cocktails", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Orders, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveImplements() => SaveData(Implementers, ImplementerFileName, "Implements", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Cocktails = LoadData(CocktailFileName, "Cocktail", x => Cocktail.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
Implementers = LoadData(ImplementerFileName, "Implement", x => Implementer.Create(x)!)!;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
83
Bar/BarFileImplement/Implements/ImplementerStorage.cs
Normal file
83
Bar/BarFileImplement/Implements/ImplementerStorage.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.StoragesContracts;
|
||||
using BarContracts.ViewModels;
|
||||
using BarFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarFileImplement.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.SaveImplements();
|
||||
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.SaveImplements();
|
||||
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.SaveImplements();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -29,12 +29,26 @@ namespace BarFileImplement.Implements
|
||||
return source.Orders.Where(x => x.Id == model.Id)
|
||||
.Select(x => AcessCocktailsStorage(x.GetViewModel))
|
||||
.ToList();
|
||||
if (model.ClientId.HasValue && !model.Id.HasValue)
|
||||
{
|
||||
return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
if (!model.ImplementerId.HasValue && !model.Id.HasValue)
|
||||
{
|
||||
return source.Orders.Where(x => x.ImplementerId == model.ImplementerId).Select(x => x.GetViewModel).ToList();
|
||||
|
||||
}
|
||||
else
|
||||
return source.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AcessCocktailsStorage(x.GetViewModel)).ToList();
|
||||
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (model.ImplementerId.HasValue)
|
||||
{
|
||||
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||
}
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
|
77
Bar/BarFileImplement/Models/Implementer.cs
Normal file
77
Bar/BarFileImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using BarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.ViewModels;
|
||||
|
||||
|
||||
namespace BarFileImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public int WorkExperience { get; set; }
|
||||
public int Qualification { get; set; }
|
||||
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 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())
|
||||
);
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
Password = Password,
|
||||
WorkExperience = WorkExperience,
|
||||
Qualification = Qualification
|
||||
};
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
Password = model.Password;
|
||||
WorkExperience = model.WorkExperience;
|
||||
Qualification = model.Qualification;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -16,10 +16,11 @@ namespace BarFileImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int CocktailId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
@ -33,6 +34,7 @@ namespace BarFileImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
CocktailId = model.CocktailId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
@ -51,6 +53,7 @@ namespace BarFileImplement.Models
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
CocktailId = Convert.ToInt32(element.Element("CocktailId")!.Value),
|
||||
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value, new System.Globalization.CultureInfo("en-US")),
|
||||
@ -72,6 +75,7 @@ namespace BarFileImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
CocktailId = CocktailId,
|
||||
ImplementerId = ImplementerId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
@ -82,6 +86,7 @@ namespace BarFileImplement.Models
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("CocktailId", CocktailId),
|
||||
new XElement("ImplementerId", ImplementerId),
|
||||
new XElement("ClientId", ClientId),
|
||||
new XElement("Count", Count),
|
||||
new XElement("Sum", Sum),
|
||||
|
@ -16,14 +16,18 @@ namespace BarContracts.BindingModels
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Cocktail> Cocktails { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Cocktails = new List<Cocktail>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
Clients = new List<Client>();
|
||||
Implementers = new List<Implementer>();
|
||||
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
|
104
Bar/BarListImplement/Implements/ImplementerStorage.cs
Normal file
104
Bar/BarListImplement/Implements/ImplementerStorage.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.StoragesContracts;
|
||||
using BarContracts.ViewModels;
|
||||
using BarListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarListImplement.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 newImplement = Implementer.Create(model);
|
||||
if (newImplement == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Implementers.Add(newImplement);
|
||||
return newImplement.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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -36,15 +36,38 @@ namespace BarListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
else if (model.ClientId.HasValue && !model.Id.HasValue)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AccessCocktailStorage(order.GetViewModel));
|
||||
if (order.ClientId == model.ClientId)
|
||||
{
|
||||
result.Add(AccessCocktailStorage(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
else if (model.DateFrom.HasValue && model.DateFrom <= order.DateCreate && model.DateTo >= order.DateCreate)
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && !model.Id.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AccessCocktailStorage(order.GetViewModel));
|
||||
if (order.ImplementerId == model.ImplementerId)
|
||||
{
|
||||
result.Add(AccessCocktailStorage(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (model.Id.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(AccessCocktailStorage(order.GetViewModel));
|
||||
}
|
||||
else if (model.DateFrom.HasValue && model.DateFrom <= order.DateCreate && model.DateTo >= order.DateCreate)
|
||||
{
|
||||
result.Add(AccessCocktailStorage(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
55
Bar/BarListImplement/Models/Implementer.cs
Normal file
55
Bar/BarListImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.ViewModels;
|
||||
using BarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarListImplement.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
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -16,8 +16,9 @@ namespace BarListImplement.Models
|
||||
public int Id { get; private set; }
|
||||
public int CocktailId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
public DateTime DateCreate { get; private set; }
|
||||
@ -33,6 +34,7 @@ namespace BarListImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
CocktailId = model.CocktailId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
@ -49,6 +51,7 @@ namespace BarListImplement.Models
|
||||
}
|
||||
Id = model.Id;
|
||||
CocktailId = model.CocktailId;
|
||||
ImplementerId = model.ImplementerId;
|
||||
ClientId = model.ClientId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
@ -60,8 +63,9 @@ namespace BarListImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
CocktailId = CocktailId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
ImplementerId = ImplementerId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
|
@ -7,7 +7,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
107
Bar/BarRestApi/Controllers/ImplementerController.cs
Normal file
107
Bar/BarRestApi/Controllers/ImplementerController.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.BusinessLogicsContracts;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.ViewModels;
|
||||
using BarDataModels.Enums;
|
||||
|
||||
namespace BarRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ImplementerController : Controller
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,10 +11,12 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<ICocktailStorage, CocktailStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<ICocktailLogic, CocktailLogic>();
|
||||
|
||||
|
@ -5,6 +5,5 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:5159/"
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BarBusinessLogic\BarBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\BarContracts\BarContracts.csproj" />
|
||||
<ProjectReference Include="..\BarBusinessLogic\BarBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\BarContracts\BarContracts.csproj" />
|
||||
<ProjectReference Include="..\BarDatabaseImplement\BarDatabaseImplement.csproj" />
|
||||
@ -52,4 +54,10 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
4
Bar/BarView/FormCocktail.Designer.cs
generated
4
Bar/BarView/FormCocktail.Designer.cs
generated
@ -103,7 +103,7 @@
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(372, 232);
|
||||
dataGridView.TabIndex = 9;
|
||||
//
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(394, 37);
|
||||
@ -179,7 +179,7 @@
|
||||
//
|
||||
Count.HeaderText = "Количество";
|
||||
Count.Name = "Count";
|
||||
//
|
||||
//
|
||||
// FormCocktail
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
|
236
Bar/BarView/FormCreateOrder.Designer.cs
generated
236
Bar/BarView/FormCreateOrder.Designer.cs
generated
@ -1,116 +1,116 @@
|
||||
namespace BarView
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <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
|
||||
#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()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
textBoxSum = new TextBox();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxCocktail = new ComboBox();
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
textBoxSum = new TextBox();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxCocktail = new ComboBox();
|
||||
labelClient = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(40, 30);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(56, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Изделие:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(40, 66);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(75, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Количество:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(40, 98);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(48, 15);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Сумма:";
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
textBoxSum.Location = new Point(158, 95);
|
||||
textBoxSum.Name = "textBoxSum";
|
||||
textBoxSum.Size = new Size(207, 23);
|
||||
textBoxSum.TabIndex = 3;
|
||||
textBoxSum.TextChanged += textBoxSum_TextChanged;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(158, 63);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(207, 23);
|
||||
textBoxCount.TabIndex = 4;
|
||||
textBoxCount.TextChanged += textBoxCount_TextChanged;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(40, 30);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(56, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Изделие:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(40, 66);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(75, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Количество:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(40, 98);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(48, 15);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Сумма:";
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
textBoxSum.Location = new Point(158, 95);
|
||||
textBoxSum.Name = "textBoxSum";
|
||||
textBoxSum.Size = new Size(207, 23);
|
||||
textBoxSum.TabIndex = 3;
|
||||
textBoxSum.TextChanged += textBoxSum_TextChanged;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(158, 63);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(207, 23);
|
||||
textBoxCount.TabIndex = 4;
|
||||
textBoxCount.TextChanged += textBoxCount_TextChanged;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(184, 172);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(265, 172);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// comboBoxCocktail
|
||||
//
|
||||
comboBoxCocktail.FormattingEnabled = true;
|
||||
comboBoxCocktail.Location = new Point(158, 27);
|
||||
comboBoxCocktail.Name = "comboBoxCocktail";
|
||||
comboBoxCocktail.Size = new Size(207, 23);
|
||||
comboBoxCocktail.TabIndex = 8;
|
||||
comboBoxCocktail.SelectedIndexChanged += comboBoxCocktail_SelectedIndexChanged;
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// comboBoxCocktail
|
||||
//
|
||||
comboBoxCocktail.FormattingEnabled = true;
|
||||
comboBoxCocktail.Location = new Point(158, 27);
|
||||
comboBoxCocktail.Name = "comboBoxCocktail";
|
||||
comboBoxCocktail.Size = new Size(207, 23);
|
||||
comboBoxCocktail.TabIndex = 8;
|
||||
comboBoxCocktail.SelectedIndexChanged += comboBoxCocktail_SelectedIndexChanged;
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
@ -132,35 +132,35 @@
|
||||
// FormCreateOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(414, 207);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(labelClient);
|
||||
Controls.Add(comboBoxCocktail);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(textBoxSum);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateOrder";
|
||||
Text = "Заказ";
|
||||
Load += OrderForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(textBoxSum);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateOrder";
|
||||
Text = "Заказ";
|
||||
Load += OrderForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxSum;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxCocktail;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxSum;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxCocktail;
|
||||
private Label labelClient;
|
||||
private ComboBox comboBoxClient;
|
||||
}
|
||||
|
@ -15,43 +15,43 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BarView
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICocktailLogic _logicC;
|
||||
private readonly IOrderLogic _logicO;
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICocktailLogic _logicC;
|
||||
private readonly IOrderLogic _logicO;
|
||||
private readonly IClientLogic _logicCl;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ICocktailLogic
|
||||
logicC, IOrderLogic logicO, IClientLogic logicCl)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicC = logicC;
|
||||
_logicO = logicO;
|
||||
_logicCl = logicCl;
|
||||
}
|
||||
logicC, IOrderLogic logicO, IClientLogic logicCl)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicC = logicC;
|
||||
_logicO = logicO;
|
||||
_logicCl = logicCl;
|
||||
}
|
||||
|
||||
private void OrderForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка коктейлей для заказа");
|
||||
try
|
||||
{
|
||||
var list = _logicC.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxCocktail.DisplayMember = "CocktailName";
|
||||
comboBoxCocktail.ValueMember = "Id";
|
||||
comboBoxCocktail.DataSource = list;
|
||||
comboBoxCocktail.SelectedItem = null;
|
||||
}
|
||||
_logger.LogInformation("Коктейль загружен");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки коктейля");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
private void OrderForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка коктейлей для заказа");
|
||||
try
|
||||
{
|
||||
var list = _logicC.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxCocktail.DisplayMember = "CocktailName";
|
||||
comboBoxCocktail.ValueMember = "Id";
|
||||
comboBoxCocktail.DataSource = list;
|
||||
comboBoxCocktail.SelectedItem = null;
|
||||
}
|
||||
_logger.LogInformation("Коктейль загружен");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки коктейля");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
_logger.LogInformation("Загрузка пользователей для заказа");
|
||||
try
|
||||
{
|
||||
@ -73,92 +73,93 @@ namespace BarView
|
||||
|
||||
}
|
||||
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxCocktail.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxCocktail.SelectedValue);
|
||||
var cocktail = _logicC.ReadElement(new CocktailSearchModel
|
||||
{
|
||||
Id
|
||||
= id
|
||||
});
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (cocktail?.Price ?? 0),
|
||||
2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxCocktail.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxCocktail.SelectedValue);
|
||||
var cocktail = _logicC.ReadElement(new CocktailSearchModel
|
||||
{
|
||||
Id
|
||||
= id
|
||||
});
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (cocktail?.Price ?? 0),
|
||||
2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void textBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void textBoxSum_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void textBoxSum_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxCocktail.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите коктейль", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
CocktailId = Convert.ToInt32(comboBoxCocktail.SelectedValue),
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxCocktail.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите коктейль", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
CocktailId = Convert.ToInt32(comboBoxCocktail.SelectedValue),
|
||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void comboBoxCocktail_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
}
|
||||
private void comboBoxCocktail_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
167
Bar/BarView/FormImplementer.Designer.cs
generated
Normal file
167
Bar/BarView/FormImplementer.Designer.cs
generated
Normal file
@ -0,0 +1,167 @@
|
||||
namespace BarView
|
||||
{
|
||||
partial class FormImplementer
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBoxFIO = new System.Windows.Forms.TextBox();
|
||||
this.labelFIO = new System.Windows.Forms.Label();
|
||||
this.textBoxPassword = new System.Windows.Forms.TextBox();
|
||||
this.labelPassword = new System.Windows.Forms.Label();
|
||||
this.labelWorkExperience = new System.Windows.Forms.Label();
|
||||
this.numericUpDownWorkExperience = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelQualification = new System.Windows.Forms.Label();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
this.textBoxFIO.Location = new System.Drawing.Point(157, 12);
|
||||
this.textBoxFIO.Name = "textBoxFIO";
|
||||
this.textBoxFIO.Size = new System.Drawing.Size(382, 27);
|
||||
this.textBoxFIO.TabIndex = 3;
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
this.labelFIO.AutoSize = true;
|
||||
this.labelFIO.Location = new System.Drawing.Point(12, 15);
|
||||
this.labelFIO.Name = "labelFIO";
|
||||
this.labelFIO.Size = new System.Drawing.Size(139, 20);
|
||||
this.labelFIO.TabIndex = 2;
|
||||
this.labelFIO.Text = "ФИО исполнителя:";
|
||||
//
|
||||
// textBoxPassword
|
||||
//
|
||||
this.textBoxPassword.Location = new System.Drawing.Point(157, 50);
|
||||
this.textBoxPassword.Name = "textBoxPassword";
|
||||
this.textBoxPassword.Size = new System.Drawing.Size(205, 27);
|
||||
this.textBoxPassword.TabIndex = 5;
|
||||
//
|
||||
// labelPassword
|
||||
//
|
||||
this.labelPassword.AutoSize = true;
|
||||
this.labelPassword.Location = new System.Drawing.Point(12, 53);
|
||||
this.labelPassword.Name = "labelPassword";
|
||||
this.labelPassword.Size = new System.Drawing.Size(65, 20);
|
||||
this.labelPassword.TabIndex = 4;
|
||||
this.labelPassword.Text = "Пароль:";
|
||||
//
|
||||
// labelWorkExperience
|
||||
//
|
||||
this.labelWorkExperience.AutoSize = true;
|
||||
this.labelWorkExperience.Location = new System.Drawing.Point(12, 99);
|
||||
this.labelWorkExperience.Name = "labelWorkExperience";
|
||||
this.labelWorkExperience.Size = new System.Drawing.Size(105, 20);
|
||||
this.labelWorkExperience.TabIndex = 6;
|
||||
this.labelWorkExperience.Text = "Опыт работы:";
|
||||
//
|
||||
// numericUpDownWorkExperience
|
||||
//
|
||||
this.numericUpDownWorkExperience.Location = new System.Drawing.Point(157, 97);
|
||||
this.numericUpDownWorkExperience.Name = "numericUpDownWorkExperience";
|
||||
this.numericUpDownWorkExperience.Size = new System.Drawing.Size(124, 27);
|
||||
this.numericUpDownWorkExperience.TabIndex = 8;
|
||||
//
|
||||
// numericUpDownQualification
|
||||
//
|
||||
this.numericUpDownQualification.Location = new System.Drawing.Point(157, 142);
|
||||
this.numericUpDownQualification.Name = "numericUpDownQualification";
|
||||
this.numericUpDownQualification.Size = new System.Drawing.Size(124, 27);
|
||||
this.numericUpDownQualification.TabIndex = 10;
|
||||
//
|
||||
// labelQualification
|
||||
//
|
||||
this.labelQualification.AutoSize = true;
|
||||
this.labelQualification.Location = new System.Drawing.Point(12, 144);
|
||||
this.labelQualification.Name = "labelQualification";
|
||||
this.labelQualification.Size = new System.Drawing.Size(114, 20);
|
||||
this.labelQualification.TabIndex = 9;
|
||||
this.labelQualification.Text = "Квалификация:";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(422, 203);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(136, 40);
|
||||
this.buttonCancel.TabIndex = 12;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(265, 203);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(130, 40);
|
||||
this.buttonSave.TabIndex = 11;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// FormImplementer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(570, 255);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.numericUpDownQualification);
|
||||
this.Controls.Add(this.labelQualification);
|
||||
this.Controls.Add(this.numericUpDownWorkExperience);
|
||||
this.Controls.Add(this.labelWorkExperience);
|
||||
this.Controls.Add(this.textBoxPassword);
|
||||
this.Controls.Add(this.labelPassword);
|
||||
this.Controls.Add(this.textBoxFIO);
|
||||
this.Controls.Add(this.labelFIO);
|
||||
this.Name = "FormImplementer";
|
||||
this.Text = "Исполнитель";
|
||||
this.Load += new System.EventHandler(this.FormImplementer_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxFIO;
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxPassword;
|
||||
private Label labelPassword;
|
||||
private Label labelWorkExperience;
|
||||
private NumericUpDown numericUpDownWorkExperience;
|
||||
private NumericUpDown numericUpDownQualification;
|
||||
private Label labelQualification;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
104
Bar/BarView/FormImplementer.cs
Normal file
104
Bar/BarView/FormImplementer.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.BusinessLogicsContracts;
|
||||
using BarContracts.SearchModels;
|
||||
using BarContracts.ViewModels;
|
||||
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 BarView
|
||||
{
|
||||
public partial class FormImplementer : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormImplementer_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.ImplementerFIO;
|
||||
textBoxPassword.Text = view.Password;
|
||||
numericUpDownWorkExperience.Value = view.WorkExperience;
|
||||
numericUpDownQualification.Value = view.Qualification;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxPassword.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение исполнителя");
|
||||
try
|
||||
{
|
||||
var model = new ImplementerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ImplementerFIO = textBoxFIO.Text,
|
||||
Password = textBoxPassword.Text,
|
||||
WorkExperience = (int)numericUpDownWorkExperience.Value,
|
||||
Qualification = (int)numericUpDownQualification.Value
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании или обновлении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
Bar/BarView/FormImplementer.resx
Normal file
120
Bar/BarView/FormImplementer.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>
|
130
Bar/BarView/FormImplementers.Designer.cs
generated
Normal file
130
Bar/BarView/FormImplementers.Designer.cs
generated
Normal file
@ -0,0 +1,130 @@
|
||||
namespace BarView
|
||||
{
|
||||
partial class FormImplementers
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
this.buttonDel = new System.Windows.Forms.Button();
|
||||
this.buttonUpd = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ToolsPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
this.ToolsPanel.Controls.Add(this.buttonRef);
|
||||
this.ToolsPanel.Controls.Add(this.buttonDel);
|
||||
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
||||
this.ToolsPanel.TabIndex = 3;
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonRef.TabIndex = 3;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonDel.TabIndex = 2;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
||||
this.buttonUpd.Name = "buttonUpd";
|
||||
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonUpd.TabIndex = 1;
|
||||
this.buttonUpd.Text = "Изменить";
|
||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(590, 426);
|
||||
this.dataGridView.TabIndex = 2;
|
||||
//
|
||||
// FormImplementers
|
||||
//
|
||||
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.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormImplementers";
|
||||
this.Text = "Исполнители";
|
||||
this.Load += new System.EventHandler(this.FormImplementers_Load);
|
||||
this.ToolsPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel ToolsPanel;
|
||||
private Button buttonRef;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
117
Bar/BarView/FormImplementers.cs
Normal file
117
Bar/BarView/FormImplementers.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using BarContracts.BindingModels;
|
||||
using BarContracts.BusinessLogicsContracts;
|
||||
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 BarView
|
||||
{
|
||||
public partial class FormImplementers : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IImplementerLogic _logic;
|
||||
|
||||
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic implementerLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = implementerLogic;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FormImplementers_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление исполнителя");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ImplementerBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void buttonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
Bar/BarView/FormImplementers.resx
Normal file
120
Bar/BarView/FormImplementers.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>
|
377
Bar/BarView/FormMain.Designer.cs
generated
377
Bar/BarView/FormMain.Designer.cs
generated
@ -20,219 +20,192 @@
|
||||
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()
|
||||
{
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.bookToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ingridientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.cocktailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.componentsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.componentCocktailToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
this.клиентToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonCreateOrder = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonRef = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
menuStrip = new MenuStrip();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem1 = new ToolStripMenuItem();
|
||||
изделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ComponentCocktailToolStripMenuItem = new ToolStripMenuItem();
|
||||
OrdersToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(751, 34);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(158, 32);
|
||||
buttonCreateOrder.TabIndex = 1;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(751, 148);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(158, 32);
|
||||
buttonIssuedOrder.TabIndex = 4;
|
||||
buttonIssuedOrder.Text = "Заказ выдан";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
buttonRef.Location = new Point(751, 186);
|
||||
buttonRef.Name = "buttonRef";
|
||||
buttonRef.Size = new Size(158, 32);
|
||||
buttonRef.TabIndex = 5;
|
||||
buttonRef.Text = "Обновить список";
|
||||
buttonRef.UseVisualStyleBackColor = true;
|
||||
buttonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(-4, 24);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(749, 285);
|
||||
dataGridView.TabIndex = 6;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem});
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(921, 24);
|
||||
menuStrip.TabIndex = 7;
|
||||
menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem1, изделияToolStripMenuItem,
|
||||
клиентToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(94, 20);
|
||||
компонентыToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem1
|
||||
//
|
||||
компонентыToolStripMenuItem1.Name = "компонентыToolStripMenuItem1";
|
||||
компонентыToolStripMenuItem1.Size = new Size(145, 22);
|
||||
компонентыToolStripMenuItem1.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem1.Click += КомпонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// изделияToolStripMenuItem
|
||||
//
|
||||
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
изделияToolStripMenuItem.Size = new Size(145, 22);
|
||||
изделияToolStripMenuItem.Text = "Изделия";
|
||||
изделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ComponentCocktailToolStripMenuItem, OrdersToolStripMenuItem});
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// ComponentsToolStripMenuItem
|
||||
//
|
||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||
ComponentsToolStripMenuItem.Size = new Size(218, 22);
|
||||
ComponentsToolStripMenuItem.Text = "Список компонентов";
|
||||
ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// ComponentCocktailToolStripMenuItem
|
||||
//
|
||||
ComponentCocktailToolStripMenuItem.Name = "ComponentCocktailToolStripMenuItem";
|
||||
ComponentCocktailToolStripMenuItem.Size = new Size(218, 22);
|
||||
ComponentCocktailToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
ComponentCocktailToolStripMenuItem.Click += ComponentCocktailToolStripMenuItem_Click;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.bookToolStripMenuItem,
|
||||
this.отчётыToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
|
||||
this.menuStrip1.Size = new System.Drawing.Size(1149, 24);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// bookToolStripMenuItem
|
||||
//
|
||||
this.bookToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ingridientsToolStripMenuItem,
|
||||
this.cocktailsToolStripMenuItem,
|
||||
this.клиентToolStripMenuItem});
|
||||
this.bookToolStripMenuItem.Name = "bookToolStripMenuItem";
|
||||
this.bookToolStripMenuItem.Size = new System.Drawing.Size(87, 20);
|
||||
this.bookToolStripMenuItem.Text = "Справочник";
|
||||
//
|
||||
// ingridientsToolStripMenuItem
|
||||
//
|
||||
this.ingridientsToolStripMenuItem.Name = "ingridientsToolStripMenuItem";
|
||||
this.ingridientsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.ingridientsToolStripMenuItem.Text = "Ингредиенты";
|
||||
this.ingridientsToolStripMenuItem.Click += new System.EventHandler(this.IngridentsToolStripMenuItem_Click);
|
||||
//
|
||||
// cocktailsToolStripMenuItem
|
||||
//
|
||||
this.cocktailsToolStripMenuItem.Name = "cocktailsToolStripMenuItem";
|
||||
this.cocktailsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.cocktailsToolStripMenuItem.Text = "Коктейли";
|
||||
this.cocktailsToolStripMenuItem.Click += new System.EventHandler(this.CocktailsToolStripMenuItem_Click);
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.componentsToolStripMenuItem1,
|
||||
this.componentCocktailToolStripMenuItem1,
|
||||
this.ordersToolStripMenuItem});
|
||||
this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
|
||||
this.отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// componentsToolStripMenuItem1
|
||||
//
|
||||
this.componentsToolStripMenuItem1.Name = "componentsToolStripMenuItem1";
|
||||
this.componentsToolStripMenuItem1.Size = new System.Drawing.Size(205, 22);
|
||||
this.componentsToolStripMenuItem1.Text = "Коктейли";
|
||||
this.componentsToolStripMenuItem1.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||
//
|
||||
// componentCocktailToolStripMenuItem1
|
||||
//
|
||||
this.componentCocktailToolStripMenuItem1.Name = "componentCocktailToolStripMenuItem1";
|
||||
this.componentCocktailToolStripMenuItem1.Size = new System.Drawing.Size(205, 22);
|
||||
this.componentCocktailToolStripMenuItem1.Text = "Коктейль с компонентами";
|
||||
this.componentCocktailToolStripMenuItem1.Click += new System.EventHandler(this.ComponentCocktailToolStripMenuItem_Click);
|
||||
//
|
||||
// ordersToolStripMenuItem
|
||||
//
|
||||
this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
|
||||
this.ordersToolStripMenuItem.Size = new System.Drawing.Size(205, 22);
|
||||
this.ordersToolStripMenuItem.Text = "Заказы";
|
||||
this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 23);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(855, 286);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(898, 53);
|
||||
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(216, 22);
|
||||
this.buttonCreateOrder.TabIndex = 2;
|
||||
this.buttonCreateOrder.Text = "Создать заказ";
|
||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(898, 92);
|
||||
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(216, 22);
|
||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(898, 129);
|
||||
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
||||
this.buttonOrderReady.Size = new System.Drawing.Size(216, 22);
|
||||
this.buttonOrderReady.TabIndex = 4;
|
||||
this.buttonOrderReady.Text = "Заказ готов";
|
||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(898, 169);
|
||||
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(216, 22);
|
||||
this.buttonIssuedOrder.TabIndex = 5;
|
||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(898, 210);
|
||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(216, 22);
|
||||
this.buttonRef.TabIndex = 6;
|
||||
this.buttonRef.Text = "Обновить список";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
// OrdersToolStripMenuItem
|
||||
//
|
||||
//
|
||||
// клиентToolStripMenuItem
|
||||
//
|
||||
this.клиентToolStripMenuItem.Name = "клиентToolStripMenuItem";
|
||||
this.клиентToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.клиентToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
|
||||
this.клиентToolStripMenuItem.Text = "Клиент";
|
||||
this.клиентToolStripMenuItem.Click += new System.EventHandler(this.ClientToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1149, 319);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonOrderReady);
|
||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
||||
this.Controls.Add(this.buttonCreateOrder);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Бар";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
|
||||
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.employersToolStripMenuItem_Click);
|
||||
//
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(92, 20);
|
||||
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.startWorkToolStripMenuItem_Click);
|
||||
//
|
||||
//
|
||||
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
||||
OrdersToolStripMenuItem.Size = new Size(218, 22);
|
||||
OrdersToolStripMenuItem.Text = "Список заказов";
|
||||
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(921, 310);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(buttonRef);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
Text = "Бар";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem bookToolStripMenuItem;
|
||||
private ToolStripMenuItem ingridientsToolStripMenuItem;
|
||||
private ToolStripMenuItem cocktailsToolStripMenuItem;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem componentsToolStripMenuItem1;
|
||||
private ToolStripMenuItem componentCocktailToolStripMenuItem1;
|
||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||
#endregion
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private DataGridView dataGridView;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem1;
|
||||
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem ComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem ComponentCocktailToolStripMenuItem;
|
||||
private ToolStripMenuItem OrdersToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -7,187 +7,160 @@ using System.Windows.Forms;
|
||||
|
||||
namespace BarView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
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, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["CocktailId"].Visible = false;
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["CocktailId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["CocktailName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs
|
||||
e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCocktails));
|
||||
if (service is FormCocktails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void IngridentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
CocktailId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CocktailId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
};
|
||||
}
|
||||
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void ComponentCocktailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportCocktailComponents));
|
||||
if (service is FormReportCocktailComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void employersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void CocktailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCocktails));
|
||||
if (service is FormCocktails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ No{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void ComponentCocktailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportCocktailComponents));
|
||||
if (service is FormReportCocktailComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
@ -197,6 +170,5 @@ namespace BarView
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,16 @@ namespace BarView
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ICocktailStorage, CocktailStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<ICocktailLogic, CocktailLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
@ -60,7 +64,10 @@ namespace BarView
|
||||
services.AddTransient<FormCocktails>();
|
||||
services.AddTransient<FormReportCocktailComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormClients>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
18
Bar/BarView/nlog.config
Normal file
18
Bar/BarView/nlog.config
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="logs/log-${shortdate}.log" />
|
||||
</targets>
|
||||
<target name="console" xsi:type="Console" layout="Access Log|${level:uppercase=true}|${logger}|${message}">
|
||||
<highlight-row condition="true" foregroundColor="red"/>
|
||||
</target>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Info" writeTo="tofile,console" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user