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); }
public UpdateDonor(DonorsDataGrid d, string StaffRole) { StaffDBRole = StaffRole; DonorAddress1 = d.DonorAddress1; DonorAddress2 = d.DonorAddress2; DonorCity = d.DonorCity; DonorState = d.DonorState; DonorType = d.DonorType; DonorZip = d.DonorZip; DonorID = d.DonorID; OrganizationName = d.OrganizationName; InitializeComponent(); text_OrganizationName.Focus(); }
private void EditDonor_Click(object sender, RoutedEventArgs e) { if (DonorsDataGrid.CurrentItem == null) { return; } DC = new BloodBankDBDataContext(); int selectedRowIndex = DonorsDataGrid.Items.IndexOf(DonorsDataGrid.CurrentItem); int Id = IdList[selectedRowIndex]; var Donor = (from D in DC.Donors where D.Id == Id select D).Single(); EditDonor form = new EditDonor(Donor); form.ShowDialog(); ApplyFilter(); DonorsDataGrid.UnselectAll(); }
public UpdateIndividualDonor(DonorsDataGrid p, Models.DonorContact d, string staffDBRole) { DonorFirstName = p.DonorFirstName; DonorLastName = p.DonorLastName; OrganizationName = p.OrganizationName; DonorAddress1 = p.DonorAddress1; DonorAddress2 = p.DonorAddress2; ContactPhone = d.ContactPhone; ContactEmail = d.ContactEmail; DonorState = p.DonorState; DonorCity = p.DonorCity; DonorZip = p.DonorZip; DonorID = p.DonorID; ContactID = d.ContactID; StaffDBRole = staffDBRole; InitializeComponent(); fName.Focus(); }