изменение формы добавления заказа

This commit is contained in:
Николай 2023-03-25 21:29:24 +04:00
parent fdf3e5a37c
commit 0076173e6a
2 changed files with 52 additions and 13 deletions

View File

@ -36,11 +36,13 @@
this.labelSum = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.labelName = new System.Windows.Forms.Label();
this.Client = new System.Windows.Forms.Label();
this.comboBoxClient = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(241, 90);
this.buttonCancel.Location = new System.Drawing.Point(241, 161);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
@ -51,7 +53,7 @@
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(153, 90);
this.buttonSave.Location = new System.Drawing.Point(153, 161);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
@ -62,7 +64,7 @@
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(93, 63);
this.textBoxSum.Location = new System.Drawing.Point(93, 134);
this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.ReadOnly = true;
@ -71,7 +73,7 @@
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(93, 36);
this.textBoxCount.Location = new System.Drawing.Point(93, 107);
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(230, 23);
@ -81,7 +83,7 @@
// comboBoxDish
//
this.comboBoxDish.FormattingEnabled = true;
this.comboBoxDish.Location = new System.Drawing.Point(93, 9);
this.comboBoxDish.Location = new System.Drawing.Point(93, 80);
this.comboBoxDish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxDish.Name = "comboBoxDish";
this.comboBoxDish.Size = new System.Drawing.Size(230, 23);
@ -91,7 +93,7 @@
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 63);
this.labelSum.Location = new System.Drawing.Point(12, 134);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(48, 15);
this.labelSum.TabIndex = 10;
@ -100,7 +102,7 @@
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 36);
this.labelCount.Location = new System.Drawing.Point(12, 107);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 9;
@ -109,17 +111,37 @@
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(12, 9);
this.labelName.Location = new System.Drawing.Point(12, 80);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(79, 15);
this.labelName.TabIndex = 8;
this.labelName.Text = "Набор блюд:";
//
// Client
//
this.Client.AutoSize = true;
this.Client.Location = new System.Drawing.Point(12, 46);
this.Client.Name = "Client";
this.Client.Size = new System.Drawing.Size(49, 15);
this.Client.TabIndex = 16;
this.Client.Text = "Клиент:";
//
// comboBoxClient
//
this.comboBoxClient.FormattingEnabled = true;
this.comboBoxClient.Location = new System.Drawing.Point(93, 53);
this.comboBoxClient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxClient.Name = "comboBoxClient";
this.comboBoxClient.Size = new System.Drawing.Size(230, 23);
this.comboBoxClient.TabIndex = 18;
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(343, 128);
this.ClientSize = new System.Drawing.Size(343, 194);
this.Controls.Add(this.comboBoxClient);
this.Controls.Add(this.Client);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxSum);
@ -146,5 +168,7 @@
private Label labelSum;
private Label labelCount;
private Label labelName;
private Label Client;
private ComboBox comboBoxClient;
}
}

View File

@ -10,6 +10,7 @@ namespace FoodOrdersView
private readonly ILogger _logger;
private readonly IDishLogic _logicD;
private readonly IOrderLogic _logicO;
private readonly IClientLogic _clientLogic;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IDishLogic logicS, IOrderLogic logicO)
{
InitializeComponent();
@ -22,14 +23,22 @@ namespace FoodOrdersView
_logger.LogInformation("Загрузка Набор блюд для заказа");
try
{
var list = _logicD.ReadList(null);
if (list != null)
var dishList = _logicD.ReadList(null);
if (dishList != null)
{
comboBoxDish.DisplayMember = "DishName";
comboBoxDish.ValueMember = "Id";
comboBoxDish.DataSource = list;
comboBoxDish.DataSource = dishList;
comboBoxDish.SelectedItem = null;
}
var clientList = _clientLogic.ReadList(null);
if (clientList != null)
{
comboBoxClient.DisplayMember = "Email";
comboBoxClient.ValueMember = "Id";
comboBoxClient.DataSource = clientList;
comboBoxClient.SelectedItem = null;
}
}
catch (Exception ex)
@ -76,7 +85,12 @@ namespace FoodOrdersView
}
if (comboBoxDish.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;
}
_logger.LogInformation("Создание заказа");
@ -85,6 +99,7 @@ namespace FoodOrdersView
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
DishId = Convert.ToInt32(comboBoxDish.SelectedValue),
ClientId = Convert.ToInt32(comboBoxDish.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});