правки мои правки
This commit is contained in:
parent
6edf5c3919
commit
534316c2bd
@ -108,8 +108,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonSave.Location = new Point(10, 342);
|
||||
buttonSave.Location = new Point(205, 250);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(140, 53);
|
||||
buttonSave.TabIndex = 8;
|
||||
@ -119,7 +118,6 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(346, 250);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
|
@ -128,12 +128,8 @@
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.EnableHeadersVisualStyles = false;
|
||||
dataGridView.Location = new Point(1, 32);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(755, 243);
|
||||
|
@ -34,11 +34,8 @@ namespace CarpentryWorkshopView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["WoodId"].Visible = false;
|
||||
dataGridView.Columns["WoodName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
static readonly object blocking = new object();
|
||||
static readonly object locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
@ -64,34 +64,41 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
CheckModel(model);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("Read operation failed");
|
||||
return false;
|
||||
}
|
||||
if (element.Status != status - 1)
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||
}
|
||||
if (element.ImplementerId.HasValue)
|
||||
model.ImplementerId = element.ImplementerId;
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("Read operation failed");
|
||||
return false;
|
||||
}
|
||||
if (element.Status != status - 1)
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||
}
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
lock (blocking)
|
||||
OrderStatus oldStatus = model.Status;
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
model.DateImplement = DateTime.Now;
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
model.Status = oldStatus;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarpentryWorkshopBusinessLogic\CarpentryWorkshopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\CarpentryWorkshopContracts\CarpentryWorkshopContracts.csproj" />
|
||||
<ProjectReference Include="..\CarpentryWorkshopDatabaseImplement\CarpentryWorkshopDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using CarpentryWorkshopContracts.BindingModel;
|
||||
using CarpentryWorkshopContracts.BindingModels;
|
||||
using CarpentryWorkshopContracts.BusinessLogicsContracts;
|
||||
using CarpentryWorkshopContracts.SearchModel;
|
||||
using CarpentryWorkshopContracts.SearchModels;
|
||||
using CarpentryWorkshopContracts.ViewModels;
|
||||
using CarpentryWorkshopDataModels.Enums;
|
||||
|
||||
|
@ -12,9 +12,11 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IWoodStorage, WoodStorage>();
|
||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IWoodLogic, WoodLogic>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at
|
||||
https://aka.ms/aspnetcore/swashbuckle
|
||||
|
Loading…
Reference in New Issue
Block a user