//Save edit or delete new type private void BtnDelete_Click(object sender, RoutedEventArgs e) { if (IconDelete.Kind == MaterialDesignThemes.Wpf.PackIconKind.DeleteCircle) { Dialog a = new Dialog() { Message = "Are you sure to delete this Type product?" }; a.Owner = Window.GetWindow(this); if (a.ShowDialog() == false) { return; } Type_product pro = listProductType.SelectedItem as Type_product; manage.DeleteTypeProduct(pro.ID); listProductType.ItemsSource = new ObservableCollection <Type_product>(manage.Load_ProductType()); listProductType.SelectedIndex = -1; //xóa các textbox txbDescrip.Clear(); txbIdtype.Clear(); txbNameType.Clear(); btnDelete.IsEnabled = false; btnEditProduct.IsEnabled = false; if (refreshCombobox != null) { refreshCombobox.Invoke(true); } } if (IconDelete.Kind == MaterialDesignThemes.Wpf.PackIconKind.ContentSave) { if (CheckInput()) { Dialog b = new Dialog() { Message = "Are you sure to add this type product?" }; b.Owner = Window.GetWindow(this); if (b.ShowDialog() == true) { btnAdd.IsEnabled = true; manage.AddNewTypeproduct(txbIdtype.Text, txbNameType.Text); listProductType.ItemsSource = new ObservableCollection <Type_product>(manage.Load_ProductType()); IconDelete.Kind = MaterialDesignThemes.Wpf.PackIconKind.DeleteCircle; btnDelete.ToolTip = "Delete product"; IconEdit.Kind = MaterialDesignThemes.Wpf.PackIconKind.Edit; listProductType.SelectedIndex = listProductType.Items.Count - 1; listProductType.IsEnabled = true; TextboxSet(false); } } } }