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