コード例 #1
0
ファイル: CreatePledge.ascx.cs プロジェクト: shelsonjava/Rock
        /// <summary>
        /// Handles the Click event of the btnConfirmYes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnConfirmYes_Click(object sender, EventArgs e)
        {
            var pledges = Session["CachedPledges"] as List <FinancialPledge>;

            if (pledges == null)
            {
                return;
            }

            RockTransactionScope.WrapTransaction(() =>
            {
                foreach (var pledge in pledges)
                {
                    if (pledge == null || !pledge.IsValid)
                    {
                        continue;
                    }

                    var pledgeService = new FinancialPledgeService();
                    pledgeService.Add(pledge, CurrentPersonId);
                    pledgeService.Save(pledge, CurrentPersonId);
                }

                Session.Remove("CachedPledges");
                ShowReceipt(pledges.Select(p => p.Id));
            });
        }
コード例 #2
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            FinancialPledge pledge;
            var             pledgeService = new FinancialPledgeService();
            var             pledgeId      = int.Parse(hfPledgeId.Value);

            if (pledgeId == 0)
            {
                pledge = new FinancialPledge();
                pledgeService.Add(pledge, CurrentPersonId);
            }
            else
            {
                pledge = pledgeService.Get(pledgeId);
            }

            pledge.PersonId    = ppPerson.PersonId;
            pledge.AccountId   = int.Parse(fpFund.SelectedValue);
            pledge.TotalAmount = decimal.Parse(tbAmount.Text);

            pledge.StartDate = dpDateRange.LowerValue.Value;
            pledge.EndDate   = dpDateRange.UpperValue.Value;
            pledge.PledgeFrequencyValueId = int.Parse(ddlFrequencyType.SelectedValue);

            if (!pledge.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            RockTransactionScope.WrapTransaction(() => pledgeService.Save(pledge, CurrentPersonId));
            NavigateToParentPage();
        }
コード例 #3
0
        /// <summary>
        /// Handles the Delete event of the gPledges control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gPledges_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var pledgeService = new FinancialPledgeService();
                var pledge        = pledgeService.Get((int)e.RowKeyValue);
                string errorMessage;

                if (pledge == null)
                {
                    return;
                }

                if (!pledgeService.CanDelete(pledge, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                pledgeService.Delete(pledge, CurrentPersonId);
                pledgeService.Save(pledge, CurrentPersonId);
            });

            BindGrid();
        }
コード例 #4
0
ファイル: CreatePledge.ascx.cs プロジェクト: shelsonjava/Rock
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (new UnitOfWorkScope())
            {
                RockTransactionScope.WrapTransaction(() =>
                {
                    var pledgeService = new FinancialPledgeService();
                    var person        = FindPerson();
                    var pledges       = GetPledges(person).ToList();

                    // Does this person already have a pledge for these accounts?
                    // If so, give them the option to create a new one?
                    var personPledgeAccountIds = pledgeService.Queryable()
                                                 .Where(p => p.PersonId == person.Id)
                                                 .Select(p => p.AccountId)
                                                 .ToList();

                    if (Accounts.Any(a => personPledgeAccountIds.Contains(a.Id)))
                    {
                        pnlConfirm.Visible = true;
                        Session.Add("CachedPledges", pledges);
                        return;
                    }

                    foreach (var pledge in pledges)
                    {
                        if (!pledge.IsValid)
                        {
                            continue;
                        }

                        pledgeService.Add(pledge, person.Id);
                        pledgeService.Save(pledge, person.Id);
                    }

                    ShowReceipt(pledges.Select(p => p.Id));
                });
            }
        }