private void DeleteDonation(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Donation?",
                                                                                            "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();
                DeletePurposes delPurp            = new DeletePurposes();

                delPurp.deletePurpose(DonationID);

                //var purpose = (from p in db.Purposes
                //               where p.PurposeID == PurposeID
                //               select p).First();

                var donation = (from d in db.Donations
                                where d.DonationID == DonationID
                                select d).First();

                //db.Purposes.Remove(purpose);
                db.Donations.Remove(donation);
                db.SaveChanges();
                MessageBox.Show("Donation Deleted.");
                this.Close();
            }
        }
Пример #2
0
        private void Delete_Grant(object sender, RoutedEventArgs e)
        {
            FCS_DBModel db = new FCS_DBModel();

            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Grant?",
                                                                                            "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                var donationPurposes = (from p in db.DonationPurposes
                                        where p.PurposeID == PurposeID
                                        select p);
                DeletePurposes delPurp = new DeletePurposes();

                delPurp.deletePurpose(DonationID);
            }
            //var purpose = (from p in db.Purposes
            //               where p.PurposeID == PurposeID
            //               select p).First();


            var donation = (from d in db.Donations
                            where d.DonationID == DonationID
                            select d).First();
            //try {
            //    var donationPurpose = (from dp in db.DonationPurposes
            //                           where dp.DonationID == donation.DonationID
            //                           select dp);
            //    foreach (var item in donationPurpose)
            //    {
            //        db.DonationPurposes.Remove(item);
            //        db.SaveChanges();
            //    }
            //}
            //catch
            //{

            //}
            var grantProposal = (from d in db.GrantProposals
                                 where d.GrantProposalID == GrantProposalID
                                 select d).First();

            grantProposal.GrantStatus = "Pending";

            db.Donations.Remove(donation);
            db.SaveChanges();
            MessageBox.Show("This grant has been deleted and its associated proposal has been set to Pending.");
            this.Close();
        }
Пример #3
0
        private void Update_Grant(object sender, RoutedEventArgs e)
        {
            FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel();
            //var purpose = (from p in db.Purposes
            //               where p.PurposeID == PurposeID
            //               select p).First();
            //purpose.PurposeName = PurposeName;
            //purpose.PurposeDescription = PurposeDescription;

            var donation = (from d in db.Donations
                            where d.DonationID == DonationID
                            select d).First();
            
            donation.DonationDate = Convert.ToDateTime(DonationDate.ToString());
            if (DonationAmount - donation.DonationAmount < 0)
            {
                MessageBox.Show("This change would result in a\nnegative balance for this donation");
            }
            else {
                if (restrictedCheckBox.IsChecked == true)
                {
                    if (PurposeComboBox.Text != "" && PurposeComboBox.Text != null)
                    {
                        DeletePurposes delPurp = new DeletePurposes();
                        delPurp.deletePurpose(DonationID);
                        Purpose p = new Purpose();
                        DonationPurpose dp = new DonationPurpose();
                        string purposeName = PurposeComboBox.SelectedItem.ToString();
                        int PurposeID = db.Purposes.Where(x => x.PurposeName == purposeName).Select(x => x.PurposeID).First();
                        donation.Restricted = true;
                        if (DonationExpiration != null && DonationExpiration.ToString() != "")
                        {
                            donation.DonationExpirationDate = Convert.ToDateTime(DonationExpiration.ToString());
                        }
                        else {
                            donation.DonationExpirationDate = null;
                        }
                        dp.DonationID = donation.DonationID;
                        dp.PurposeID = PurposeID;
                        dp.DonationPurposeAmount = DonationAmount;
                        db.DonationPurposes.Add(dp);
                        decimal donationDiff = donation.DonationAmount - DonationAmount;
                        donation.GrantProposalID = GrantProposalID;
                        donation.DonationAmount = DonationAmount;
                        donation.DonationAmountRemaining = donation.DonationAmountRemaining - donationDiff;
                        db.Entry(donation);
                        db.SaveChanges();
                        db.Entry(dp);
                        db.SaveChanges();

                    }
                    else
                    {
                        MessageBox.Show("Please enter a purpose if the donation is restrcted");
                    }
                }
                else
                {
                    DeletePurposes delPurp = new DeletePurposes();
                    delPurp.deletePurpose(DonationID);
                    donation.Restricted = false;
                    donation.DonationExpirationDate = null;
                    donation.GrantProposalID = GrantProposalID;
                    decimal donationDiff = donation.DonationAmount - DonationAmount;
                    donation.DonationAmount = DonationAmount;
                    donation.DonationAmountRemaining = donation.DonationAmountRemaining - donationDiff;
                    db.Entry(donation);
                    db.SaveChanges();
                }

                this.Close();
            }
        }
Пример #4
0
        private void Delete_Grant(object sender, RoutedEventArgs e)
        {
            FCS_DBModel db = new FCS_DBModel();
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Grant?", 
                 "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                var donationPurposes = (from p in db.DonationPurposes
                                    where p.PurposeID == PurposeID
                                    select p);
                DeletePurposes delPurp = new DeletePurposes();

                    delPurp.deletePurpose(DonationID);

                }
                //var purpose = (from p in db.Purposes
                //               where p.PurposeID == PurposeID
                //               select p).First();


                var donation = (from d in db.Donations
                                where d.DonationID == DonationID
                                select d).First();
                //try {
                //    var donationPurpose = (from dp in db.DonationPurposes
                //                           where dp.DonationID == donation.DonationID
                //                           select dp);
                //    foreach (var item in donationPurpose)
                //    {
                //        db.DonationPurposes.Remove(item);
                //        db.SaveChanges();
                //    }
                //}
                //catch
                //{

                //}
                var grantProposal = (from d in db.GrantProposals
                                where d.GrantProposalID == GrantProposalID
                                select d).First();
                grantProposal.GrantStatus = "Pending";

                db.Donations.Remove(donation);
                db.SaveChanges();
                MessageBox.Show("This grant has been deleted and its associated proposal has been set to Pending.");
                this.Close();
            }
Пример #5
0
        private void Update_Grant(object sender, RoutedEventArgs e)
        {
            FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel();
            //var purpose = (from p in db.Purposes
            //               where p.PurposeID == PurposeID
            //               select p).First();
            //purpose.PurposeName = PurposeName;
            //purpose.PurposeDescription = PurposeDescription;

            var donation = (from d in db.Donations
                            where d.DonationID == DonationID
                            select d).First();

            donation.DonationDate = Convert.ToDateTime(DonationDate.ToString());
            if (DonationAmount - donation.DonationAmount < 0)
            {
                MessageBox.Show("This change would result in a\nnegative balance for this donation");
            }
            else
            {
                if (restrictedCheckBox.IsChecked == true)
                {
                    if (PurposeComboBox.Text != "" && PurposeComboBox.Text != null)
                    {
                        DeletePurposes delPurp = new DeletePurposes();
                        delPurp.deletePurpose(DonationID);
                        Purpose         p           = new Purpose();
                        DonationPurpose dp          = new DonationPurpose();
                        string          purposeName = PurposeComboBox.SelectedItem.ToString();
                        int             PurposeID   = db.Purposes.Where(x => x.PurposeName == purposeName).Select(x => x.PurposeID).First();
                        donation.Restricted = true;
                        if (DonationExpiration != null && DonationExpiration.ToString() != "")
                        {
                            donation.DonationExpirationDate = Convert.ToDateTime(DonationExpiration.ToString());
                        }
                        else
                        {
                            donation.DonationExpirationDate = null;
                        }
                        dp.DonationID            = donation.DonationID;
                        dp.PurposeID             = PurposeID;
                        dp.DonationPurposeAmount = DonationAmount;
                        db.DonationPurposes.Add(dp);
                        decimal donationDiff = donation.DonationAmount - DonationAmount;
                        donation.GrantProposalID         = GrantProposalID;
                        donation.DonationAmount          = DonationAmount;
                        donation.DonationAmountRemaining = donation.DonationAmountRemaining - donationDiff;
                        db.Entry(donation);
                        db.SaveChanges();
                        db.Entry(dp);
                        db.SaveChanges();
                    }
                    else
                    {
                        MessageBox.Show("Please enter a purpose if the donation is restrcted");
                    }
                }
                else
                {
                    DeletePurposes delPurp = new DeletePurposes();
                    delPurp.deletePurpose(DonationID);
                    donation.Restricted             = false;
                    donation.DonationExpirationDate = null;
                    donation.GrantProposalID        = GrantProposalID;
                    decimal donationDiff = donation.DonationAmount - DonationAmount;
                    donation.DonationAmount          = DonationAmount;
                    donation.DonationAmountRemaining = donation.DonationAmountRemaining - donationDiff;
                    db.Entry(donation);
                    db.SaveChanges();
                }

                this.Close();
            }
        }
        private void DeleteDonation(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Donation?",
                 "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();
                DeletePurposes delPurp = new DeletePurposes();

                delPurp.deletePurpose(DonationID);

                //var purpose = (from p in db.Purposes
                //               where p.PurposeID == PurposeID
                //               select p).First();

                var donation = (from d in db.Donations
                                where d.DonationID == DonationID
                                select d).First();

                //db.Purposes.Remove(purpose);
                db.Donations.Remove(donation);
                db.SaveChanges();
                MessageBox.Show("Donation Deleted.");
                this.Close();
            }

        }