private void BtnEditProduct_Click(object sender, RoutedEventArgs e) { if (IconEdit.Kind == MaterialDesignThemes.Wpf.PackIconKind.Edit) { txbDescrip.IsEnabled = txbNameType.IsEnabled = true; txbIdtype.IsEnabled = false; IconEdit.Kind = MaterialDesignThemes.Wpf.PackIconKind.ContentSave; btnEditProduct.ToolTip = "Save change"; btnAdd.IsEnabled = false; listProductType.IsEnabled = false; IconDelete.Kind = MaterialDesignThemes.Wpf.PackIconKind.Cancel; btnDelete.ToolTip = "Cancel change"; } else if (IconEdit.Kind == MaterialDesignThemes.Wpf.PackIconKind.ContentSave) { Dialog a = new Dialog() { Message = "Are you sure to save ?" }; a.Owner = Window.GetWindow(this); if (a.ShowDialog() == true) { Type_product pro = listProductType.SelectedItem as Type_product; manage.EditProduct(pro.ID, txbNameType.Text); listProductType.ItemsSource = new ObservableCollection <Type_product>(manage.Load_ProductType()); IconDelete.Kind = MaterialDesignThemes.Wpf.PackIconKind.DeleteCircle; btnDelete.ToolTip = "Delete product"; listProductType.IsEnabled = true; IconEdit.Kind = MaterialDesignThemes.Wpf.PackIconKind.Edit; btnEditProduct.ToolTip = "Edit product"; listProductType.SelectedIndex = listProductType.Items.Count - 1; txbDescrip.IsEnabled = txbIdtype.IsEnabled = txbNameType.IsEnabled = false; btnAdd.IsEnabled = true; if (refreshCombobox != null) { refreshCombobox.Invoke(true); } } } else if (IconEdit.Kind == MaterialDesignThemes.Wpf.PackIconKind.Cancel) { Dialog a = new Dialog() { Message = "Are you sure to cancel ?" }; a.Owner = Window.GetWindow(this); if (a.ShowDialog() == true) { txbDescrip.IsEnabled = txbIdtype.IsEnabled = txbNameType.IsEnabled = false; listProductType.IsEnabled = true; IconDelete.Kind = MaterialDesignThemes.Wpf.PackIconKind.DeleteCircle; btnDelete.ToolTip = "Delete product"; btnDelete.IsEnabled = false; btnAdd.IsEnabled = true; IconEdit.Kind = MaterialDesignThemes.Wpf.PackIconKind.Edit; btnEditProduct.ToolTip = "Edit product"; btnEditProduct.IsEnabled = false; listProductType.SelectedIndex = -1; } else { txbIdtype.Focus(); } } }