Compare commits

..

2 Commits

Author SHA1 Message Date
3e3dc0cf2d Сдана Lab6Base 2023-04-10 09:58:11 +04:00
e5e0cddc9b fix 2023-04-10 08:55:05 +04:00
7 changed files with 211 additions and 287 deletions

View File

@ -38,13 +38,11 @@
this.списокДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.бланкиПоДокументамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.бланкиПоДокументамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonSetToWork = new System.Windows.Forms.Button();
this.buttonSetToDone = new System.Windows.Forms.Button();
this.buttonSetToFinish = new System.Windows.Forms.Button(); this.buttonSetToFinish = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button();
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout(); this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
@ -132,6 +130,13 @@
this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click); this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
// //
// запускРаботToolStripMenuItem
//
this.запускРаботToolStripMenuItem.Name = апускРаботToolStripMenuItem";
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
//
// dataGridView // dataGridView
// //
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@ -152,29 +157,9 @@
this.buttonCreateOrder.UseVisualStyleBackColor = true; this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click); this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
// //
// buttonSetToWork
//
this.buttonSetToWork.Location = new System.Drawing.Point(933, 80);
this.buttonSetToWork.Name = "buttonSetToWork";
this.buttonSetToWork.Size = new System.Drawing.Size(194, 29);
this.buttonSetToWork.TabIndex = 3;
this.buttonSetToWork.Text = "Отдать на выполнение";
this.buttonSetToWork.UseVisualStyleBackColor = true;
this.buttonSetToWork.Click += new System.EventHandler(this.buttonSetToWork_Click);
//
// buttonSetToDone
//
this.buttonSetToDone.Location = new System.Drawing.Point(933, 115);
this.buttonSetToDone.Name = "buttonSetToDone";
this.buttonSetToDone.Size = new System.Drawing.Size(194, 29);
this.buttonSetToDone.TabIndex = 4;
this.buttonSetToDone.Text = "Заказ готов";
this.buttonSetToDone.UseVisualStyleBackColor = true;
this.buttonSetToDone.Click += new System.EventHandler(this.buttonSetToDone_Click);
//
// buttonSetToFinish // buttonSetToFinish
// //
this.buttonSetToFinish.Location = new System.Drawing.Point(933, 150); this.buttonSetToFinish.Location = new System.Drawing.Point(933, 80);
this.buttonSetToFinish.Name = "buttonSetToFinish"; this.buttonSetToFinish.Name = "buttonSetToFinish";
this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29); this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29);
this.buttonSetToFinish.TabIndex = 5; this.buttonSetToFinish.TabIndex = 5;
@ -192,13 +177,6 @@
this.buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click); this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
// //
// запускРаботToolStripMenuItem
//
this.запускРаботToolStripMenuItem.Name = апускРаботToolStripMenuItem";
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
//
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
@ -206,8 +184,6 @@
this.ClientSize = new System.Drawing.Size(1139, 450); this.ClientSize = new System.Drawing.Size(1139, 450);
this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonSetToFinish); this.Controls.Add(this.buttonSetToFinish);
this.Controls.Add(this.buttonSetToDone);
this.Controls.Add(this.buttonSetToWork);
this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip); this.Controls.Add(this.menuStrip);
@ -231,8 +207,6 @@
private ToolStripMenuItem документыToolStripMenuItem; private ToolStripMenuItem документыToolStripMenuItem;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonSetToWork;
private Button buttonSetToDone;
private Button buttonSetToFinish; private Button buttonSetToFinish;
private Button buttonUpdate; private Button buttonUpdate;
private ToolStripMenuItem отчетыToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem;

View File

@ -136,59 +136,6 @@ namespace LawFirmView
} }
} }
private void buttonSetToWork_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void buttonSetToDone_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("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSetToFinish_Click(object sender, EventArgs e) private void buttonSetToFinish_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)

View File

@ -35,7 +35,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
_logger.LogWarning("DoWork. Implementers is null"); _logger.LogWarning("DoWork. Implementers is null");
return; return;
} }
var orders = _orderLogic.ReadList(new OrderSearchModel { Statuses = new() { OrderStatus.Принят, OrderStatus.Выполняется } }); var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
if (orders == null || orders.Count == 0) if (orders == null || orders.Count == 0)
{ {
_logger.LogWarning("DoWork. Orders is null or empty"); _logger.LogWarning("DoWork. Orders is null or empty");
@ -64,11 +64,12 @@ namespace LawFirmBusinessLogic.BusinessLogics
{ {
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
// пытаемся назначить заказ на исполнителя // пытаемся назначить заказ на исполнителя
_orderLogic.TakeOrderInWork(new OrderBindingModel if (_orderLogic.TakeOrderInWork(new OrderBindingModel
{ {
Id = order.Id, Id = order.Id,
ImplementerId = implementer.Id ImplementerId = implementer.Id
}); }))
{
// делаем работу // делаем работу
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
@ -80,6 +81,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
// отдыхаем // отдыхаем
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
} }
}
// кто-то мог уже перехватить заказ, игнорируем ошибку // кто-то мог уже перехватить заказ, игнорируем ошибку
catch (InvalidOperationException ex) catch (InvalidOperationException ex)
{ {

View File

@ -14,6 +14,6 @@ namespace LawFirmContracts.SearchModels
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
public int? ClientId { get; set; } public int? ClientId { get; set; }
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
public List<OrderStatus>? Statuses { get; set; } public OrderStatus? Status { get; set; }
} }
} }

View File

@ -26,14 +26,14 @@ namespace LawFirmDatabaseImplement.Implements
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer) .Include(x => x.Implementer)
.FirstOrDefault(x => .FirstOrDefault(x =>
(model.Statuses == null || model.Statuses != null && model.Statuses.Contains(x.Status)) && (model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId || model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
model.Id.HasValue && x.Id == model.Id)?.GetViewModel; model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Statuses == null) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
{ {
return new(); return new();
} }
@ -47,12 +47,12 @@ namespace LawFirmDatabaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
if (model.Statuses!= null) if (model.Status!= null)
{ {
return context.Orders return context.Orders
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer) .Include(x => x.Implementer)
.Where(x => model.Statuses.Contains(x.Status)) .Where(x => model.Status.Equals(x.Status))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -22,7 +22,7 @@ namespace LawFirmFileImplement.Implements
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {
if (model.ImplementerId.HasValue && model.Statuses != null) return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Statuses.Contains(x.Status))?.GetViewModel; if (model.ImplementerId.HasValue && model.Status != null) return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
if (model.ImplementerId.HasValue) if (model.ImplementerId.HasValue)
{ {
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel; return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
@ -36,7 +36,7 @@ namespace LawFirmFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Statuses == null) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
{ {
return new(); return new();
} }
@ -47,10 +47,10 @@ namespace LawFirmFileImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
if (model.Statuses != null) if (model.Status != null)
{ {
return source.Orders return source.Orders
.Where(x => model.Statuses.Contains(x.Status)) .Where(x => model.Status.Equals(x.Status))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -32,7 +32,7 @@ namespace LawFirmListImplements.Implements
{ {
return GetViewModel(order); return GetViewModel(order);
} }
else if (model.ImplementerId.HasValue && model.Statuses != null && order.ImplementerId == model.ImplementerId && model.Statuses.Contains(order.Status)) else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Equals(order.Status))
{ {
return GetViewModel(order); return GetViewModel(order);
} }
@ -77,11 +77,11 @@ namespace LawFirmListImplements.Implements
} }
} }
} }
if (model.Statuses != null) if (model.Status != null)
{ {
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (model.Statuses.Contains(order.Status)) if (model.Status.Equals(order.Status))
{ {
result.Add(GetViewModel(order)); result.Add(GetViewModel(order));
} }