вроде всё работает
This commit is contained in:
parent
31655eb324
commit
6d93b02536
@ -91,6 +91,7 @@
|
|||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(272, 27);
|
textBoxCount.Size = new Size(272, 27);
|
||||||
textBoxCount.TabIndex = 5;
|
textBoxCount.TabIndex = 5;
|
||||||
|
textBoxCount.TextChanged += textBoxCount_TextChanged;
|
||||||
//
|
//
|
||||||
// textBoxSum
|
// textBoxSum
|
||||||
//
|
//
|
||||||
@ -107,6 +108,7 @@
|
|||||||
comboBoxSushi.Name = "comboBoxSushi";
|
comboBoxSushi.Name = "comboBoxSushi";
|
||||||
comboBoxSushi.Size = new Size(272, 28);
|
comboBoxSushi.Size = new Size(272, 28);
|
||||||
comboBoxSushi.TabIndex = 7;
|
comboBoxSushi.TabIndex = 7;
|
||||||
|
comboBoxSushi.SelectedIndexChanged += comboBoxSushi_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// FormCreateOrder
|
// FormCreateOrder
|
||||||
//
|
//
|
||||||
@ -123,7 +125,7 @@
|
|||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Name = "FormCreateOrder";
|
Name = "FormCreateOrder";
|
||||||
Text = "Заказ";
|
Text = "Заказ";
|
||||||
Load += this.FormCreateOrder_Load;
|
Load += FormCreateOrder_Load;
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,15 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
ButtonCancel_Click(sender, e);
|
ButtonCancel_Click(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void textBoxCount_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
TextBoxCount_TextChanged(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ComboBoxSushi_SelectedIndexChanged(sender, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.VisualBasic.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace SushiBar.Forms
|
namespace SushiBar.Forms
|
||||||
{
|
{
|
||||||
@ -21,12 +24,15 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logicS.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxSushi.Items.AddRange(list.ToArray());
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка суши для заказа");
|
_logger.LogInformation("Загрузка суши для заказа");
|
||||||
|
List<SushiViewModel>? _list = _logicS.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxSushi.DisplayMember = "SushiName";
|
||||||
|
comboBoxSushi.ValueMember = "Id";
|
||||||
|
comboBoxSushi.DataSource = _list;
|
||||||
|
comboBoxSushi.SelectedItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using SushiBarBusinessLogic.BusinessLogics;
|
using SushiBarBusinessLogic.BusinessLogics;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarDataModels.Enums;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace SushiBar.Forms
|
namespace SushiBar.Forms
|
||||||
@ -40,8 +41,7 @@ namespace SushiBar.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
e)
|
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
if (service is FormComponents form)
|
if (service is FormComponents form)
|
||||||
@ -74,7 +74,7 @@ namespace SushiBar.Forms
|
|||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
@ -27,6 +27,7 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["SushiComponents"].Visible = false;
|
||||||
dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка суши");
|
_logger.LogInformation("Загрузка суши");
|
||||||
|
@ -49,57 +49,58 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
return ToNextStatus(model, OrderStatus.Выполняется);
|
||||||
if (model.Status != OrderStatus.Принят)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Wrong Order Status");
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Выполняется;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
return ToNextStatus(model, OrderStatus.Выдан);
|
||||||
if (model.Status != OrderStatus.Выполняется)
|
}
|
||||||
|
|
||||||
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return ToNextStatus(model, OrderStatus.Готов);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
var element = _orderStorage.GetElement(new OrderSearchModel()
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Wrong Order Status");
|
Id = model.Id
|
||||||
_logger.LogWarning("Insert operation failed");
|
});
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(element));
|
||||||
|
}
|
||||||
|
|
||||||
|
model.SushiId = element.SushiId;
|
||||||
|
model.DateCreate = element.DateCreate;
|
||||||
|
model.DateImplement = element.DateImplement;
|
||||||
|
model.Status = element.Status;
|
||||||
|
model.Count = element.Count;
|
||||||
|
model.Sum = element.Sum;
|
||||||
|
|
||||||
|
if (model.Status != orderStatus - 1)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status update to " + orderStatus + " operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = OrderStatus.Готов;
|
model.Status = orderStatus;
|
||||||
|
|
||||||
|
if (model.Status == OrderStatus.Выдан)
|
||||||
|
{
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
model.Status--;
|
||||||
|
_logger.LogWarning("Changing status operation faled");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (model.Status != OrderStatus.Готов)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Wrong Order Status");
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Выдан;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -18,13 +18,24 @@ namespace SushiBarListImplement.Implements
|
|||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(order.GetViewModel);
|
result.Add(AttachSushiName(order.GetViewModel));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
|
if (model == null || !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.Id == model.Id)
|
||||||
|
{
|
||||||
|
result.Add(AttachSushiName(order.GetViewModel));
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
@ -37,7 +48,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if (model.Id.HasValue && order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return order.GetViewModel;
|
return AttachSushiName(order.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -58,7 +69,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_source.Orders.Add(newOrder);
|
_source.Orders.Add(newOrder);
|
||||||
return newOrder.GetViewModel;
|
return AttachSushiName(newOrder.GetViewModel);
|
||||||
}
|
}
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -67,7 +78,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
return order.GetViewModel;
|
return AttachSushiName(order.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -80,10 +91,22 @@ namespace SushiBarListImplement.Implements
|
|||||||
{
|
{
|
||||||
var element = _source.Orders[i];
|
var element = _source.Orders[i];
|
||||||
_source.Orders.RemoveAt(i);
|
_source.Orders.RemoveAt(i);
|
||||||
return element.GetViewModel;
|
return AttachSushiName(element.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
private OrderViewModel AttachSushiName(OrderViewModel model)
|
||||||
|
{
|
||||||
|
foreach (var sushi in _source.Sushis)
|
||||||
|
{
|
||||||
|
if (sushi.Id == model.SushiId)
|
||||||
|
{
|
||||||
|
model.SushiName = sushi.SushiName;
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user