From 77889d887eb2326dd50a35421c55eabef048cca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 18 Feb 2023 16:14:11 +0400 Subject: [PATCH 1/2] fix --- ConfectionaryFileImplement/OrderStorage.cs | 8 ++++---- ConfectionaryFileImplement/Pastry.cs | 1 - Confectionery/FormCreateOrder.Designer.cs | 2 +- Confectionery/FormCreateOrder.cs | 8 +++----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ConfectionaryFileImplement/OrderStorage.cs b/ConfectionaryFileImplement/OrderStorage.cs index aae2076..c2dc788 100644 --- a/ConfectionaryFileImplement/OrderStorage.cs +++ b/ConfectionaryFileImplement/OrderStorage.cs @@ -63,14 +63,14 @@ namespace ConfectioneryFileImplement public OrderViewModel? Update(OrderBindingModel model) { - var pastry = _source.Orders.FirstOrDefault(x => x.Id == model.Id); - if (pastry == null) + var order = _source.Orders.FirstOrDefault(x => x.Id == model.Id); + if (order == null) { return null; } - pastry.Update(model); + order.Update(model); _source.SaveOrders(); - return pastry.GetViewModel; + return order.GetViewModel; } } } diff --git a/ConfectionaryFileImplement/Pastry.cs b/ConfectionaryFileImplement/Pastry.cs index f32067c..6138c0c 100644 --- a/ConfectionaryFileImplement/Pastry.cs +++ b/ConfectionaryFileImplement/Pastry.cs @@ -1,7 +1,6 @@ using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.ViewModels; using ConfectioneryDataModels.Models; -using ConfectioneryDataModels.Models; using System.Xml.Linq; namespace ConfectioneryFileImplement.Models diff --git a/Confectionery/FormCreateOrder.Designer.cs b/Confectionery/FormCreateOrder.Designer.cs index 7047902..ab9a95b 100644 --- a/Confectionery/FormCreateOrder.Designer.cs +++ b/Confectionery/FormCreateOrder.Designer.cs @@ -103,7 +103,7 @@ this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Size = new System.Drawing.Size(214, 23); this.textBoxCount.TabIndex = 6; - this.textBoxCount.Click += new System.EventHandler(this.TextBoxCount_TextChanged); + this.textBoxCount.ValueChanged += new System.EventHandler(this.TextBoxCount_TextChanged); // // textBoxSum // diff --git a/Confectionery/FormCreateOrder.cs b/Confectionery/FormCreateOrder.cs index 47cd686..01b08ad 100644 --- a/Confectionery/FormCreateOrder.cs +++ b/Confectionery/FormCreateOrder.cs @@ -39,8 +39,7 @@ namespace ConfectioneryView } private void CalcSum() { - if (comboBoxPastry.SelectedValue != null && - !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxPastry.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { @@ -49,9 +48,8 @@ namespace ConfectioneryView { Id = id }); - int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), - 2).ToString(); + int count = Convert.ToInt32(textBoxCount.Value); + textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) From cb864c03537e1ca1194bb621f32795436fe94b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 18 Feb 2023 18:52:30 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BF=D0=BE=D0=B4=D1=81=D1=87=D0=B5=D1=82=20?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Confectionery/FormCreateOrder.Designer.cs | 2 +- Confectionery/FormCreateOrder.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Confectionery/FormCreateOrder.Designer.cs b/Confectionery/FormCreateOrder.Designer.cs index 7047902..ab9a95b 100644 --- a/Confectionery/FormCreateOrder.Designer.cs +++ b/Confectionery/FormCreateOrder.Designer.cs @@ -103,7 +103,7 @@ this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Size = new System.Drawing.Size(214, 23); this.textBoxCount.TabIndex = 6; - this.textBoxCount.Click += new System.EventHandler(this.TextBoxCount_TextChanged); + this.textBoxCount.ValueChanged += new System.EventHandler(this.TextBoxCount_TextChanged); // // textBoxSum // diff --git a/Confectionery/FormCreateOrder.cs b/Confectionery/FormCreateOrder.cs index 47cd686..703c7b2 100644 --- a/Confectionery/FormCreateOrder.cs +++ b/Confectionery/FormCreateOrder.cs @@ -39,19 +39,17 @@ namespace ConfectioneryView } private void CalcSum() { - if (comboBoxPastry.SelectedValue != null && - !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxPastry.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { int id = Convert.ToInt32(comboBoxPastry.SelectedValue); - var pastry = _logicP.ReadElement(new PastrySearchModel + var pastry = _logicP.ReadElement(new() { Id = id }); - int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), - 2).ToString(); + int count = Convert.ToInt32(textBoxCount.Value); + textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex)