コード例 #1
0
        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click(object sender, EventArgs e)
        {
            int?        parentAccountId = null;
            RockContext rockContext     = new RockContext();

            FinancialAccountService accountService = new FinancialAccountService(rockContext);
            AuthService             authService    = new AuthService(rockContext);
            FinancialAccount        account        = accountService.Get(hfAccountId.Value.AsInteger());

            if (account != null)
            {
                if (!account.IsAuthorized(Authorization.EDIT, this.CurrentPerson))
                {
                    mdDeleteWarning.Show("You are not authorized to delete this account.", ModalAlertType.Information);
                    return;
                }

                parentAccountId = account.ParentAccountId;
                string errorMessage;
                if (!accountService.CanDelete(account, out errorMessage))
                {
                    mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                accountService.Delete(account);

                rockContext.SaveChanges();
            }

            // reload page, selecting the deleted account's parent
            var qryParams = new Dictionary <string, string>();

            if (parentAccountId != null)
            {
                qryParams["AccountId"] = parentAccountId.ToString();
            }

            qryParams["ExpandedIds"] = PageParameter("ExpandedIds");

            NavigateToPage(RockPage.Guid, qryParams);
        }
コード例 #2
0
        /// <summary>
        /// Handles the Delete event of the rGridAccount 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 rGridAccount_Delete(object sender, RowEventArgs e)
        {
            var accountService = new FinancialAccountService();
            var account        = accountService.Get((int)e.RowKeyValue);

            if (account != null)
            {
                string errorMessage;
                if (!accountService.CanDelete(account, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                accountService.Delete(account, CurrentPersonId);
                accountService.Save(account, CurrentPersonId);
            }

            BindGrid();
        }
コード例 #3
0
        /// <summary>
        /// Handles the Delete event of the rGridAccount 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 rGridAccount_Delete(object sender, RowEventArgs e)
        {
            var rockContext    = new RockContext();
            var accountService = new FinancialAccountService(rockContext);
            var account        = accountService.Get(e.RowKeyId);

            if (account != null)
            {
                string errorMessage;
                if (!accountService.CanDelete(account, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                accountService.Delete(account);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
コード例 #4
0
ファイル: AccountList.ascx.cs プロジェクト: NewPointe/Rockit
        /// <summary>
        /// Handles the Delete event of the rGridAccount 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 rGridAccount_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var accountService = new FinancialAccountService( rockContext );
            var account = accountService.Get( e.RowKeyId );
            if ( account != null )
            {
                string errorMessage;
                if ( !accountService.CanDelete( account, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                accountService.Delete( account );
                rockContext.SaveChanges();
            }

            BindGrid();
        }