private void BtnRegister_Click(object sender, RoutedEventArgs e) { bool flag = ValidateValues(); if (slot <= appointmentArray.Length && flag == true) { if (appointmentArray[slot].Patient == null) { appointmentError.Content = ""; appointmentArray[slot].Patient = CreateNewPatient(); appointmentArray[slot].Patient.Time = appointmentCombo.SelectedValue.ToString(); appointmentArray[slot].Time = appointmentCombo.SelectedValue.ToString(); saveList.Add(appointmentArray[slot]); saveList.Sort(); } else if (appointmentArray[slot].Patient != null) { appointmentError.Foreground = Brushes.Red; appointmentError.Content = "Slot Aready Taken"; } } else { genralError.Foreground = Brushes.Red; genralError.Content = "Error Registering Customer"; } if (appointmentArray[slot].Patient != null) { Applist.Add(appointmentArray[slot].Patient); TimeList.RemoveAt(selectedIndex); } MyGrid.ItemsSource = Applist; //TimeList.Remove(appointmentCombo.SelectedValue.ToString()); }