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

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.labelSum = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label(); this.labelCount = new System.Windows.Forms.Label();
this.labelName = 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(); this.SuspendLayout();
// //
// buttonCancel // 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22); this.buttonCancel.Size = new System.Drawing.Size(82, 22);
@ -51,7 +53,7 @@
// //
// buttonSave // 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22); this.buttonSave.Size = new System.Drawing.Size(82, 22);
@ -62,7 +64,7 @@
// //
// textBoxSum // 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxSum.Name = "textBoxSum"; this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.ReadOnly = true; this.textBoxSum.ReadOnly = true;
@ -71,7 +73,7 @@
// //
// textBoxCount // 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(230, 23); this.textBoxCount.Size = new System.Drawing.Size(230, 23);
@ -81,7 +83,7 @@
// comboBoxDish // comboBoxDish
// //
this.comboBoxDish.FormattingEnabled = true; 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.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxDish.Name = "comboBoxDish"; this.comboBoxDish.Name = "comboBoxDish";
this.comboBoxDish.Size = new System.Drawing.Size(230, 23); this.comboBoxDish.Size = new System.Drawing.Size(230, 23);
@ -91,7 +93,7 @@
// labelSum // labelSum
// //
this.labelSum.AutoSize = true; 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.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(48, 15); this.labelSum.Size = new System.Drawing.Size(48, 15);
this.labelSum.TabIndex = 10; this.labelSum.TabIndex = 10;
@ -100,7 +102,7 @@
// labelCount // labelCount
// //
this.labelCount.AutoSize = true; 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.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(75, 15); this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 9; this.labelCount.TabIndex = 9;
@ -109,17 +111,37 @@
// labelName // labelName
// //
this.labelName.AutoSize = true; 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.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(79, 15); this.labelName.Size = new System.Drawing.Size(79, 15);
this.labelName.TabIndex = 8; this.labelName.TabIndex = 8;
this.labelName.Text = "Набор блюд:"; 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 // FormCreateOrder
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxSum); this.Controls.Add(this.textBoxSum);
@ -146,5 +168,7 @@
private Label labelSum; private Label labelSum;
private Label labelCount; private Label labelCount;
private Label labelName; private Label labelName;
private Label Client;
private ComboBox comboBoxClient;
} }
} }

View File

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