From 394ecca149875a3e2a6e93b082bc2fd4b0ab665e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Wed, 20 Nov 2024 13:39:30 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=D1=8E,=20=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B0=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppShopInternetOption19/Forms/FormEdit_Add.cs | 7 ++----- .../UserComponentsOption19/SelectComponent.cs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/UserComponentsOption19/AppShopInternetOption19/Forms/FormEdit_Add.cs b/UserComponentsOption19/AppShopInternetOption19/Forms/FormEdit_Add.cs index 5eceedc..5bf56f3 100644 --- a/UserComponentsOption19/AppShopInternetOption19/Forms/FormEdit_Add.cs +++ b/UserComponentsOption19/AppShopInternetOption19/Forms/FormEdit_Add.cs @@ -19,9 +19,7 @@ namespace AppShopInternetOption19 _orderStatusLogic = orderStatusLogic; InitializeComponent(); - List statuses = new List() { "готов", "не готов" }; - - selectComponentOrderStatus.FillList(statuses); + selectComponentOrderStatus.FillList(_orderStatusLogic.ReadList(null), "Name"); textBoxFIO.TextChanged += valueChanged; textBoxGoodDescription.TextChanged += valueChanged; @@ -119,8 +117,7 @@ namespace AppShopInternetOption19 } catch (Exception ex) { - - throw; + MessageBox.Show(ex.Message); } } } diff --git a/UserComponentsOption19/UserComponentsOption19/SelectComponent.cs b/UserComponentsOption19/UserComponentsOption19/SelectComponent.cs index 16fe78b..8e62385 100644 --- a/UserComponentsOption19/UserComponentsOption19/SelectComponent.cs +++ b/UserComponentsOption19/UserComponentsOption19/SelectComponent.cs @@ -13,11 +13,18 @@ //comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged; } - public void FillList(List list) + public void FillList(List list, string property) where Y : class { - foreach (string item in list) + ClearList(); + + foreach (var item in list) { - comboBox.Items.Add(item); + var propName = item.GetType().GetProperty(property); + if(propName != null) + { + var value = propName.GetValue(item)?.ToString(); + comboBox.Items.Add(value); + } } //comboBox.SelectedIndex = rand.Next(list.Count); }