diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs index d72a23a..542ea33 100644 --- a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs +++ b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs @@ -36,12 +36,14 @@ textBoxSum = new TextBox(); buttonSave = new Button(); buttonCancel = new Button(); + labelClient = new Label(); + comboBoxClient = new ComboBox(); SuspendLayout(); // // labelName // labelName.AutoSize = true; - labelName.Location = new Point(90, 35); + labelName.Location = new Point(90, 77); labelName.Name = "labelName"; labelName.Size = new Size(84, 25); labelName.TabIndex = 0; @@ -50,7 +52,7 @@ // labelCount // labelCount.AutoSize = true; - labelCount.Location = new Point(63, 92); + labelCount.Location = new Point(63, 134); labelCount.Name = "labelCount"; labelCount.Size = new Size(111, 25); labelCount.TabIndex = 1; @@ -59,7 +61,7 @@ // labelSum // labelSum.AutoSize = true; - labelSum.Location = new Point(90, 155); + labelSum.Location = new Point(103, 197); labelSum.Name = "labelSum"; labelSum.Size = new Size(71, 25); labelSum.TabIndex = 2; @@ -68,7 +70,7 @@ // comboBoxPastry // comboBoxPastry.FormattingEnabled = true; - comboBoxPastry.Location = new Point(192, 32); + comboBoxPastry.Location = new Point(192, 74); comboBoxPastry.Name = "comboBoxPastry"; comboBoxPastry.Size = new Size(434, 33); comboBoxPastry.TabIndex = 3; @@ -76,7 +78,7 @@ // // textBoxCount // - textBoxCount.Location = new Point(192, 92); + textBoxCount.Location = new Point(192, 134); textBoxCount.Name = "textBoxCount"; textBoxCount.Size = new Size(434, 31); textBoxCount.TabIndex = 4; @@ -84,7 +86,7 @@ // // textBoxSum // - textBoxSum.Location = new Point(192, 155); + textBoxSum.Location = new Point(192, 197); textBoxSum.Name = "textBoxSum"; textBoxSum.ReadOnly = true; textBoxSum.Size = new Size(434, 31); @@ -110,11 +112,30 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += buttonCancel_Click; // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(103, 20); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(71, 25); + labelClient.TabIndex = 8; + labelClient.Text = "Клиент:"; + // + // comboBoxClient + // + comboBoxClient.FormattingEnabled = true; + comboBoxClient.Location = new Point(192, 12); + comboBoxClient.Name = "comboBoxClient"; + comboBoxClient.Size = new Size(434, 33); + comboBoxClient.TabIndex = 9; + // // FormCreateOrder // AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(779, 333); + Controls.Add(comboBoxClient); + Controls.Add(labelClient); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(textBoxSum); @@ -140,5 +161,7 @@ private TextBox textBoxSum; private Button buttonSave; private Button buttonCancel; + private Label labelClient; + private ComboBox comboBoxClient; } } \ No newline at end of file diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.cs b/Confectionery/ConfectioneryView/FormCreateOrder.cs index 835c490..cc0310c 100644 --- a/Confectionery/ConfectioneryView/FormCreateOrder.cs +++ b/Confectionery/ConfectioneryView/FormCreateOrder.cs @@ -21,13 +21,16 @@ namespace ConfectioneryView private readonly ILogger _logger; private readonly IPastryLogic _logicP; private readonly IOrderLogic _logicO; + private readonly IClientLogic _logicC; private List? _list; - public FormCreateOrder(ILogger logger, IPastryLogic logicP, IOrderLogic logicO) + private List? _listClients; + public FormCreateOrder(ILogger logger, IPastryLogic logicP, IOrderLogic logicO, IClientLogic logicC) { InitializeComponent(); _logger = logger; _logicP = logicP; _logicO = logicO; + _logicC = logicC; } private void buttonSave_Click(object sender, EventArgs e) @@ -44,11 +47,17 @@ namespace ConfectioneryView MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + if (comboBoxClient.SelectedValue == null) + { + MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } _logger.LogInformation("Создание заказа"); try { var operationResult = _logicO.CreateOrder(new OrderBindingModel { + ClientId = Convert.ToInt32(comboBoxClient.SelectedValue), PastryId = Convert.ToInt32(comboBoxPastry.SelectedValue), Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) @@ -83,6 +92,15 @@ namespace ConfectioneryView comboBoxPastry.SelectedItem = null; _logger.LogInformation("Загрузка кондитерского изделия для заказа"); } + _listClients = _logicC.ReadList(null); + if (_listClients != null) + { + comboBoxClient.DisplayMember = "ClientFIO"; + comboBoxClient.ValueMember = "Id"; + comboBoxClient.DataSource = _listClients; + comboBoxClient.SelectedItem = null; + _logger.LogInformation("Загрузка клиентов для заказа"); + } } private void CalcSum() { diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.resx b/Confectionery/ConfectioneryView/FormCreateOrder.resx index f298a7b..af32865 100644 --- a/Confectionery/ConfectioneryView/FormCreateOrder.resx +++ b/Confectionery/ConfectioneryView/FormCreateOrder.resx @@ -1,4 +1,64 @@ - + + +