Beispiel #1
0
        /// <summary>
        /// Handles the SaveClick event of the mdDetails control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void mdDetails_SaveClick(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            if (!string.IsNullOrWhiteSpace(tbTransactionAmount.Text))
            {
                var ftdService = new FinancialTransactionDetailService(rockContext);
                FinancialTransactionDetail ftd = null;
                var transactionDetailId        = int.Parse(hfIdValue.Value);
                if (transactionDetailId > 0)
                {
                    ftd = ftdService.Get(transactionDetailId);
                }
                else
                {
                    ftd = new FinancialTransactionDetail {
                        Id = 0
                    };
                }

                ftd.TransactionId = hfIdTransValue.ValueAsInt();
                ftd.AccountId     = int.Parse(ddlTransactionAccount.SelectedValue);
                ftd.Amount        = decimal.Parse(tbTransactionAmount.Text);
                ftd.Summary       = tbTransactionSummary.Text;

                if (transactionDetailId == 0)
                {
                    ftdService.Add(ftd);
                }

                rockContext.SaveChanges();
            }

            mdDetails.Hide();
            FinancialTransaction transaction = new FinancialTransaction();

            transaction = new FinancialTransactionService(rockContext).Get(hfIdTransValue.ValueAsInt());
            BindTransactionDetailGrid(transaction);
            LoadRelatedImages(transaction.Id);
        }
        /// <summary>
        /// Handles the Delete event of the gTransactionEntities 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 gTransactionEntities_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            var service     = new FinancialTransactionDetailService(rockContext);
            var detail      = service.Get(e.RowKeyId);

            if (detail == null)
            {
                return;
            }
            else
            {
                var changes  = new History.HistoryChangeList();
                var typeName = detail.EntityType.FriendlyName;
                var name     = GetEntityName(detail.EntityTypeId, detail.EntityId, rockContext);

                History.EvaluateChange(changes, "Entity Type Id", detail.EntityTypeId, null);
                History.EvaluateChange(changes, "Entity Id", detail.EntityId, null);

                detail.EntityTypeId = null;
                detail.EntityId     = null;

                changes.AddCustom("Removed", "Removed", string.Format("Removed transaction detail association to {0} {1}", typeName, name));

                HistoryService.SaveChanges(
                    rockContext,
                    typeof(FinancialTransaction),
                    Rock.SystemGuid.Category.HISTORY_FINANCIAL_TRANSACTION.AsGuid(),
                    detail.TransactionId,
                    changes
                    );

                rockContext.SaveChanges();
            }

            BindGrid();
        }
Beispiel #3
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);
        }