private void comboBox_BrandsEditModel_SelectionChanged(object sender, SelectionChangedEventArgs e) { List <Model> models; Brand brand = (Brand)comboBox_BrandsEditModel.SelectedItem; Category cat = (Category)comboBox_CategoriesEditModel.SelectedItem; try { models = sql.getModelByCategoryAndBrandAll(cat.NameCategory, brand.NameBrand); } catch { models = sql.getModelByCategoryAndBrandAll(comboBox_CategoriesEditModel.Text, comboBox_BrandsEditModel.Text); } models.Sort(); comboBox_ModelEditModel.ItemsSource = models; comboBox_ModelEditModel.DisplayMemberPath = "NameModel"; comboBox_ModelEditModel.SelectedIndex = 0; textBox_newNameModelEditModel.Text = comboBox_ModelEditModel.Text; }
public void LoadModelByCategoryAndBrand() { Brand brand = (Brand)comboBox_BrandsEditRepair.SelectedItem; List <Model> models = sql.getModelByCategoryAndBrandAll(comboBox_CategoriesEditRepair.Text, brand.NameBrand); models.Sort(); comboBox_ModelsEditRepair.ItemsSource = models; comboBox_ModelsEditRepair.DisplayMemberPath = "NameModel"; comboBox_ModelsEditRepair.SelectedIndex = 0; if (device != null) { comboBox_ModelsEditRepair.Text = device.Model; } models = null; }