edit formcreateorder
This commit is contained in:
parent
875842b96a
commit
3d3d2ec217
@ -11,12 +11,14 @@ namespace Pizzeria
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IPizzaLogic _logicP;
|
private readonly IPizzaLogic _logicP;
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
|
private readonly IClientLogic _logicC;
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPizzaLogic logicP, IOrderLogic logicO)
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPizzaLogic logicP, IOrderLogic logicO, IClientLogic logicC)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicP = logicP;
|
_logicP = logicP;
|
||||||
|
_logicC = logicC;
|
||||||
_logicO = logicO;
|
_logicO = logicO;
|
||||||
}
|
}
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
@ -32,12 +34,29 @@ namespace Pizzeria
|
|||||||
comboBoxPizza.DataSource = _list;
|
comboBoxPizza.DataSource = _list;
|
||||||
comboBoxPizza.SelectedItem = null;
|
comboBoxPizza.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка при загрузке пиццы для заказа");
|
_logger.LogError(ex, "Ошибка при загрузке пиццы для заказа");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Loading clients for order");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clientList = _logicC.ReadList(null);
|
||||||
|
if (clientList != null)
|
||||||
|
{
|
||||||
|
comboBoxClient.DisplayMember = "ClientFIO";
|
||||||
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
comboBoxClient.DataSource = clientList;
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading clients for order");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalcSum()
|
private void CalcSum()
|
||||||
@ -52,7 +71,7 @@ namespace Pizzeria
|
|||||||
Id = id
|
Id = id
|
||||||
});
|
});
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
int count = Convert.ToInt32(textBoxCount.Text);
|
||||||
textBoxSum.Text = Math.Round(count * (Pizza?.Price ?? 0),2).ToString();
|
textBoxSum.Text = Math.Round(count * (Pizza?.Price ?? 0), 2).ToString();
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
_logger.LogInformation("Расчет суммы заказа");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -89,7 +108,12 @@ namespace Pizzeria
|
|||||||
}
|
}
|
||||||
if (comboBoxPizza.SelectedValue == null)
|
if (comboBoxPizza.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите пицца", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxClient.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Создание заказа");
|
_logger.LogInformation("Создание заказа");
|
||||||
@ -98,6 +122,7 @@ namespace Pizzeria
|
|||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
PizzaId = Convert.ToInt32(comboBoxPizza.SelectedValue),
|
PizzaId = Convert.ToInt32(comboBoxPizza.SelectedValue),
|
||||||
|
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user