private void DeleteTimeTable(object obj) { if (MessageBox.Show("Are you Sure You want to Delete this Record?", "Pinna Fitness", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes) { try { SelectedTimeTable.Enabled = false; var stat = _timeTableService.Disable(SelectedTimeTable); if (stat == string.Empty) { TimeTables.Remove(SelectedTimeTable); } else { MessageBox.Show("Can't Delete, may be the data is already in use..." + Environment.NewLine + stat, "Can't Delete", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show("Can't Delete, may be the data is already in use..." + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, "Can't Delete", MessageBoxButton.OK, MessageBoxImage.Error); } } }