private void Delete_Grant_Proposal(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Grant Proposal?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var grantproposal = (from p in db.GrantProposals where p.GrantProposalID == GrantProposalID select p).First(); db.GrantProposals.Remove(grantproposal); db.SaveChanges(); MessageBox.Show("This Grant Proposal has been deleted."); this.Close(); } }
private void Delete_Contact(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Contact?" , "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var donorContact = (from p in db.DonorContacts where p.ContactID == ContactID select p).First(); db.DonorContacts.Remove(donorContact); db.SaveChanges(); MessageBox.Show("Contact Deleted."); this.Close(); } }
private void Delete_Contact(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Contact?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var donorContact = (from p in db.DonorContacts where p.ContactID == ContactID select p).First(); db.DonorContacts.Remove(donorContact); db.SaveChanges(); MessageBox.Show("Contact Deleted."); this.Close(); } }
private void Delete_Expense(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Session?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var expense = (from exp in db.Expenses where exp.ExpenseID == Session.ExpenseID select exp).First(); var expenses = (from exp in db.Expenses where exp.AppointmentID == expense.AppointmentID select exp).ToList(); int?DonationID = expense.DonationID; int?AppointmentID = expense.AppointmentID; db.Expenses.Remove(expense); //Add money back to the donation if (expense.DonorBill > 0) { var donation = (from d in db.Donations where d.DonationID == DonationID select d).First(); donation.DonationAmountRemaining = donation.DonationAmountRemaining + expense.DonorBill; db.SaveChanges(); } if (expenses.Count == 1) { var appt = (from d in db.Appointments where d.AppointmentID == AppointmentID select d).First(); db.Appointments.Remove(appt); db.SaveChanges(); } db.SaveChanges(); //MessageBox.Show("This session has been deleted."); this.Close(); } }
private void Update_Contact(object sender, RoutedEventArgs e) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var contact = (from p in db.DonorContacts where p.ContactID == ContactID select p).First(); contact.ContactFirstName = ContactFirstName; contact.ContactLastName = ContactLastName; contact.ContactPhone = ContactPhone; contact.ContactEmail = ContactEmail; if (ContactPhone.Length < 11) { db.SaveChanges(); MessageBox.Show("Updated contact successfully."); this.Close(); } else { MessageBox.Show("An invalid phone number has been entered"); } }
private void Delete_Event(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Event?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var event1 = (from d in db.FundRaisingEvents where d.EventID == EventID select d).First(); var donations = (from p in db.Donations where p.EventID == EventID select p); foreach (var don in donations) { db.Donations.Remove(don); } db.FundRaisingEvents.Remove(event1); db.SaveChanges(); MessageBox.Show("This Grant has been deleted and the Proposal\nassociated with this grant has been set to Pending."); this.Close(); } }
private void UpdateDonor(object sender, RoutedEventArgs e) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var donor = (from d in db.Donors where d.DonorID == DonorID select d).First(); var contact = (from c in db.DonorContacts where c.ContactID == ContactID select c).First(); contact.ContactFirstName = DonorFirstName; contact.ContactLastName = DonorLastName; donor.OrganizationName = OrganizationName; donor.DonorAddress1 = DonorAddress1; donor.DonorAddress2 = DonorAddress2; contact.ContactPhone = ContactPhone; contact.ContactEmail = ContactEmail; donor.DonorState = DonorState; donor.DonorCity = DonorCity; donor.DonorZip = DonorZip; db.SaveChanges(); this.Close(); }
private void Delete_Expense(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Session?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var expense = (from exp in db.Expenses where exp.ExpenseID == Session.ExpenseID select exp).First(); var expenses = (from exp in db.Expenses where exp.AppointmentID == expense.AppointmentID select exp).ToList(); int? DonationID = expense.DonationID; int? AppointmentID = expense.AppointmentID; db.Expenses.Remove(expense); //Add money back to the donation if (expense.DonorBill > 0) { var donation = (from d in db.Donations where d.DonationID == DonationID select d).First(); donation.DonationAmountRemaining = donation.DonationAmountRemaining + expense.DonorBill; db.SaveChanges(); } if (expenses.Count == 1) { var appt = (from d in db.Appointments where d.AppointmentID == AppointmentID select d).First(); db.Appointments.Remove(appt); db.SaveChanges(); } db.SaveChanges(); //MessageBox.Show("This session has been deleted."); this.Close(); } }
private void Delete_Event(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Event?" , "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); var event1 = (from d in db.FundRaisingEvents where d.EventID == EventID select d).First(); var donations = (from p in db.Donations where p.EventID == EventID select p); foreach (var don in donations) { db.Donations.Remove(don); } db.FundRaisingEvents.Remove(event1); db.SaveChanges(); MessageBox.Show("This Grant has been deleted and the Proposal\nassociated with this grant has been set to Pending."); this.Close(); } }