private void dataGrid_MyPrescriptions_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.indexSelected = dataGrid_MyPrescriptions.SelectedIndex; if (indexSelected == -1 || presList.Count <= indexSelected) { presSelected = null; updteBtn_pres.IsEnabled = false; return; } ; updteBtn_pres.IsEnabled = true; //presSelected = (prescription)presList.ElementAt<prescription>(dataGrid_Pres.SelectedIndex); presSelected = (Prescription)dataGrid_MyPrescriptions.SelectedItem; if (presSelected.Patient == null) { return; } else if (presSelected.Patient.pat_type != null) { mypresc_pattype.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(presSelected.Patient.pat_type); } if (presSelected.Patient.pat_type.Equals("outdoor")) { mypresc_disease.IsEnabled = false; } else if (presSelected.Patient.pat_type.Equals("indoor")) { IndoorPatient indo = hmsfac.getIndoorByPid(presSelected.pat_id); mypresc_disease.IsEnabled = true; mypresc_disease.Text = indo.indpat_disease; } mypresc_med.Text = presSelected.Medicine.med_name; mypresc_dosage.Text = presSelected.presc_dosage; }