private void BtnAddCatalogItem_Click(object sender, RoutedEventArgs e) { var catalogItemsWindow = new UnitQtyItmesWindow(); catalogItemsWindow.ShowDialog(); _catalogItems = CatalogTable.SelectFromCatalogTable(); foreach (var panleItem in PanelProductRecord.Children) { var prevSelectedItem = -1; var AddBoxItem = panleItem as AddBoxUC; if (AddBoxItem.ComboBoxUnitQty.SelectedValue != null) { prevSelectedItem = int.Parse(AddBoxItem.ComboBoxUnitQty.SelectedValue.ToString()); } AddBoxItem.ComboBoxUnitQty.ItemsSource = null; AddBoxItem.ComboBoxUnitQty.ItemsSource = _catalogItems; AddBoxItem.ComboBoxUnitQty.DisplayMemberPath = "CatalogValue"; AddBoxItem.ComboBoxUnitQty.SelectedValuePath = "CatalogId"; foreach (var item in _catalogItems) { if (item.CatalogId != prevSelectedItem) { continue; } AddBoxItem.ComboBoxUnitQty.SelectedValue = prevSelectedItem; break; } } }
private void BtnAddCatalogItem_Click(object sender, RoutedEventArgs e) { var catalogItemsWindow = new UnitQtyItmesWindow(); catalogItemsWindow.ShowDialog(); var catalogItems = CatalogTable.SelectFromCatalogTable(); foreach (var panleItem in PanelProductRecord.Children) { var searchBoxItem = panleItem as SearchBoxUC; searchBoxItem.ComboBoxUnitQty.ItemsSource = null; searchBoxItem.ComboBoxUnitQty.ItemsSource = catalogItems; searchBoxItem.ComboBoxUnitQty.DisplayMemberPath = "CatalogValue"; searchBoxItem.ComboBoxUnitQty.SelectedValuePath = "CatalogId"; } }
private void RadButton_Click(object sender, RoutedEventArgs e) { var catalogItemsWindow = new UnitQtyItmesWindow { Changed = false }; catalogItemsWindow.ShowDialog(); if (catalogItemsWindow.Changed) { ComboBoxUnitQty.ItemsSource = CatalogTable.SelectFromCatalogTable(); ComboBoxUnitQty.DisplayMemberPath = "CatalogValue"; ComboBoxUnitQty.SelectedValuePath = "CatalogId"; ComboBoxUnitQty.SelectedIndex = ComboBoxUnitQty.Items.Count - 1; } else { var product = ProductTable.SelectSingleProduct(Pid); if (product.Catalog == null) { return; } ComboBoxUnitQty.SelectedValue = product.Catalog.CatalogValue; } }