Пример #1
0
        /// <summary>
        /// Handles the Delete event of the gTransactionDetails control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gTransactionDetails_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext = new RockContext();
            var ftdService  = new FinancialTransactionDetailService(rockContext);
            var ftd         = ftdService.Get(e.RowKeyId);

            if (ftd != null)
            {
                string errorMessage;
                if (!ftdService.CanDelete(ftd, out errorMessage))
                {
                    maGridWarning.Show(errorMessage, Rock.Web.UI.Controls.ModalAlertType.Information);
                    return;
                }

                ftdService.Delete(ftd);
                rockContext.SaveChanges();
            }

            FinancialTransaction transaction = new FinancialTransaction();

            transaction = new FinancialTransactionService(rockContext).Get(hfIdTransValue.ValueAsInt());
            BindTransactionDetailGrid(transaction);
        }