private void EditDonor(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; DonorsDataGrid p = (DonorsDataGrid)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; var db = new FCS_DBModel(); if (p.DonorType == "Individual") { //Open in individual view Models.DonorContact query = (from doncontacts in db.DonorContacts where doncontacts.DonorID == p.DonorID select doncontacts).First(); UpdateIndividualDonor id = new UpdateIndividualDonor(p, query, StaffRole); id.dType.SelectedIndex = 1; id.oName.IsEnabled = false; id.ShowDialog(); } else if (p.DonorType == "Anonymous") { Models.DonorContact query = (from doncontacts in db.DonorContacts where doncontacts.DonorID == p.DonorID select doncontacts).First(); UpdateIndividualDonor id = new UpdateIndividualDonor(p, query, StaffRole); id.ShowDialog(); id.UpdateIndDonor.IsEnabled = false; id.dType.SelectedIndex = 2; id.fName.IsEnabled = false; id.lName.IsEnabled = false; id.oName.IsEnabled = false; id.donA1.IsEnabled = false; id.donA2.IsEnabled = false; id.cPhone.IsEnabled = false; id.dCity.IsEnabled = false; id.cPhone.IsEnabled = false; id.dState.IsEnabled = false; id.dZip.IsEnabled = false; id.cEmail.IsEnabled = false; } else { UpdateDonor up = new UpdateDonor(p, StaffRole); up.ShowDialog(); } } catch { } // Refresh the grid after editing Refresh_DonorGrid(sender, e); }
private void EditDonor(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; DonorsDataGrid p = (DonorsDataGrid)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; var db = new FCS_DBModel(); if (p.DonorType == "Individual") { //Open in individual view Models.DonorContact query = (from doncontacts in db.DonorContacts where doncontacts.DonorID == p.DonorID select doncontacts).First(); UpdateIndividualDonor id = new UpdateIndividualDonor(p, query, StaffRole); id.dType.SelectedIndex = 1; id.oName.IsEnabled = false; id.ShowDialog(); } else if (p.DonorType == "Anonymous") { Models.DonorContact query = (from doncontacts in db.DonorContacts where doncontacts.DonorID == p.DonorID select doncontacts).First(); UpdateIndividualDonor id = new UpdateIndividualDonor(p, query, StaffRole); id.ShowDialog(); id.UpdateIndDonor.IsEnabled = false; id.dType.SelectedIndex = 2; id.fName.IsEnabled = false; id.lName.IsEnabled = false; id.oName.IsEnabled = false; id.donA1.IsEnabled = false; id.donA2.IsEnabled = false; id.cPhone.IsEnabled = false; id.dCity.IsEnabled = false; id.cPhone.IsEnabled = false; id.dState.IsEnabled = false; id.dZip.IsEnabled = false; id.cEmail.IsEnabled = false; } else { UpdateDonor up = new UpdateDonor(p, StaffRole); up.ShowDialog(); } } catch { } // Refresh the grid after editing Refresh_DonorGrid(sender, e); }