private void patbtn_delete_Click(object sender, RoutedEventArgs e) { if (patselected == null) { return; } MessageBoxResult result = MessageBox.Show("Do you want to delete " + patselected.pat_name + "'s record?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (!(MessageBoxResult.Yes == result)) { return; } hmsfac.remove(patselected); patientList.Remove(patselected); dataGrid_Patient.Items.Refresh(); indpatList = hmsfac.getIndoors(); dataGrid_IndoorPatients.Items.Refresh(); this.patnametxt_update.Text = ""; this.patdatepicker_update.Text = ""; this.patcombobox_updatedoc.Text = ""; this.patbtn_delete.IsEnabled = false; this.patrbmale_update.IsChecked = false; this.patrbfemale_update.IsChecked = false; }