コード例 #1
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();
        }
コード例 #2
0
        /// <summary>
        /// Event when the user clicks to delete the pledge
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rptPledges_Delete(object sender, CommandEventArgs e)
        {
            var pledgeGuid    = e.CommandArgument.ToStringSafe().AsGuid();
            var rockContext   = new RockContext();
            var pledgeService = new FinancialPledgeService(rockContext);
            var pledge        = pledgeService.Get(pledgeGuid);

            string errorMessage;

            if (pledge == null)
            {
                return;
            }

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

            pledgeService.Delete(pledge);
            rockContext.SaveChanges();

            ShowDetail();
        }
コード例 #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)
        {
            var    rockContext   = new RockContext();
            var    pledgeService = new FinancialPledgeService(rockContext);
            var    pledge        = pledgeService.Get(e.RowKeyId);
            string errorMessage;

            if (pledge == null)
            {
                return;
            }

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

            pledgeService.Delete(pledge);
            rockContext.SaveChanges();

            BindGrid();
        }