Пример #1
0
        /// <summary>
        /// Get the Financial Transaction Alert Types.
        /// </summary>
        private IQueryable <FinancialTransactionAlertType> GetFinancialTransactionAlertTypes(RockContext rockContext = null)
        {
            rockContext = rockContext ?? new RockContext();
            var financialTransactionAlertTypeService = new FinancialTransactionAlertTypeService(rockContext);

            return(financialTransactionAlertTypeService.Queryable().OrderBy(s => s.Order).ThenBy(s => s.Name));
        }
Пример #2
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="financialTransactionAlertTypeId">The financial transaction alert type id.</param>
        private void ShowEdit(int financialTransactionAlertTypeId)
        {
            FinancialTransactionAlertType financialTransactionAlertType = null;

            if (financialTransactionAlertTypeId > 0)
            {
                financialTransactionAlertType = new FinancialTransactionAlertTypeService(new RockContext()).Get(financialTransactionAlertTypeId);
            }

            if (financialTransactionAlertType == null)
            {
                financialTransactionAlertType = new FinancialTransactionAlertType();
            }

            BindControl();
            tbName.Text = financialTransactionAlertType.Name;
            hfFinancialTransactionAlertTypeId.Value = financialTransactionAlertType.Id.ToString();
            cpCampus.SetValue(financialTransactionAlertType.CampusId);
            apAlertAccount.SetValue(financialTransactionAlertType.FinancialAccountId);
            cbAlertIncludeChildAccounts.Checked = financialTransactionAlertType.IncludeChildFinancialAccounts;
            rblAlertType.SetValue(( int )financialTransactionAlertType.AlertType);

            UpdateSensitivityDescriptions(financialTransactionAlertType.AlertType);

            cbContinueIfMatched.Checked         = financialTransactionAlertType.ContinueIfMatched;
            nbRepeatPreventionDuration.Text     = financialTransactionAlertType.RepeatPreventionDuration.ToStringSafe();
            nbAmountSensitivityScale.Text       = financialTransactionAlertType.AmountSensitivityScale.ToStringSafe();
            nbFrequencySensitivityScale.Text    = financialTransactionAlertType.FrequencySensitivityScale.ToStringSafe();
            cbMinimumGiftAmount.Value           = financialTransactionAlertType.MinimumGiftAmount;
            cbMaximumGiftAmount.Value           = financialTransactionAlertType.MaximumGiftAmount;
            cbMinimumMedianGiftAmount.Value     = financialTransactionAlertType.MinimumMedianGiftAmount;
            cbMaximumMedianGiftAmount.Value     = financialTransactionAlertType.MaximumMedianGiftAmount;
            nbMaxDaysSinceLastGift.IntegerValue = financialTransactionAlertType.MaximumDaysSinceLastGift;
            dvpPersonDataView.SetValue(financialTransactionAlertType.DataViewId);
            cbSendBusEvent.Checked = financialTransactionAlertType.SendBusEvent;
            wtpLaunchWorkflow.SetValue(financialTransactionAlertType.WorkflowTypeId);
            gpNotificationGroup.GroupId = financialTransactionAlertType.AlertSummaryNotificationGroupId;
            dwpDaysToRunAlertType.SelectedDaysOfWeek = (financialTransactionAlertType.RunDays ?? DayOfWeekFlag.All).AsDayOfWeekList();

            if (financialTransactionAlertType.ConnectionOpportunity != null)
            {
                ddlConnectionType.SetValue(financialTransactionAlertType.ConnectionOpportunity.ConnectionTypeId);
                ddlConnectionType_SelectedIndexChanged(null, null);
                ddlConnectionOpportunity.SetValue(financialTransactionAlertType.ConnectionOpportunityId);
            }
            else
            {
                int?connectionTypeId = null;
                ddlConnectionType.SetValue(connectionTypeId);
                ddlConnectionType_SelectedIndexChanged(null, null);
            }

            ddlDonorSystemCommunication.SetValue(financialTransactionAlertType.SystemCommunicationId);
            ddlAccountParticipantSystemCommunication.SetValue(financialTransactionAlertType.AccountParticipantSystemCommunicationId);
            mdAlertDetails.Show();
        }
Пример #3
0
        /// <summary>
        /// Handles the SaveClick event of the modalDetails 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 mdAlertDetails_SaveClick(object sender, EventArgs e)
        {
            int financialTransactionAlertTypeId = hfFinancialTransactionAlertTypeId.Value.AsIntegerOrNull() ?? 0;

            var rockContext = new RockContext();
            var financialTransactionAlertTypeService = new FinancialTransactionAlertTypeService(rockContext);
            FinancialTransactionAlertType financialTransactionAlertType = null;

            if (financialTransactionAlertTypeId != 0)
            {
                financialTransactionAlertType = financialTransactionAlertTypeService.Get(financialTransactionAlertTypeId);
            }

            if (financialTransactionAlertType == null)
            {
                financialTransactionAlertType = new FinancialTransactionAlertType();
                financialTransactionAlertTypeService.Add(financialTransactionAlertType);
            }

            financialTransactionAlertType.Name                                    = tbName.Text;
            financialTransactionAlertType.CampusId                                = cpCampus.SelectedCampusId;
            financialTransactionAlertType.FinancialAccountId                      = apAlertAccount.SelectedValueAsId();
            financialTransactionAlertType.IncludeChildFinancialAccounts           = cbAlertIncludeChildAccounts.Checked;
            financialTransactionAlertType.AlertType                               = rblAlertType.SelectedValueAsEnum <AlertType>();
            financialTransactionAlertType.ContinueIfMatched                       = cbContinueIfMatched.Checked;
            financialTransactionAlertType.RepeatPreventionDuration                = nbRepeatPreventionDuration.Text.AsIntegerOrNull();
            financialTransactionAlertType.AmountSensitivityScale                  = nbAmountSensitivityScale.Text.AsDecimalOrNull();
            financialTransactionAlertType.FrequencySensitivityScale               = nbFrequencySensitivityScale.Text.AsDecimalOrNull();
            financialTransactionAlertType.MinimumGiftAmount                       = cbMinimumGiftAmount.Value;
            financialTransactionAlertType.MaximumGiftAmount                       = cbMaximumGiftAmount.Value;
            financialTransactionAlertType.MinimumMedianGiftAmount                 = cbMinimumMedianGiftAmount.Value;
            financialTransactionAlertType.MaximumMedianGiftAmount                 = cbMaximumMedianGiftAmount.Value;
            financialTransactionAlertType.MaximumDaysSinceLastGift                = nbMaxDaysSinceLastGift.IntegerValue;
            financialTransactionAlertType.DataViewId                              = dvpPersonDataView.SelectedValueAsInt();
            financialTransactionAlertType.SendBusEvent                            = cbSendBusEvent.Checked;
            financialTransactionAlertType.ConnectionOpportunityId                 = ddlConnectionOpportunity.SelectedValueAsId();
            financialTransactionAlertType.SystemCommunicationId                   = ddlDonorSystemCommunication.SelectedValueAsId();
            financialTransactionAlertType.AccountParticipantSystemCommunicationId = ddlAccountParticipantSystemCommunication.SelectedValueAsId();
            financialTransactionAlertType.WorkflowTypeId                          = wtpLaunchWorkflow.SelectedValueAsId();
            financialTransactionAlertType.AlertSummaryNotificationGroupId         = gpNotificationGroup.GroupId;
            financialTransactionAlertType.RunDays                                 = dwpDaysToRunAlertType.SelectedDaysOfWeekAsFlags();
            rockContext.SaveChanges();

            hfFinancialTransactionAlertTypeId.Value = string.Empty;
            mdAlertDetails.Hide();

            BindAlerts();
        }
Пример #4
0
        /// <summary>
        /// Deletes the financial transaction alert type.
        /// </summary>
        /// <param name="financialTransactionAlertTypeId">The financial transaction alert type id.</param>
        private void DeleteFinancialTransactionAlertType(int financialTransactionAlertTypeId)
        {
            using (var rockContext = new RockContext())
            {
                var financialTransactionAlertTypeService = new FinancialTransactionAlertTypeService(rockContext);
                var financialTransactionAlertType        = financialTransactionAlertTypeService.Get(financialTransactionAlertTypeId);
                if (financialTransactionAlertType != null)
                {
                    string errorMessage;
                    if (!financialTransactionAlertTypeService.CanDelete(financialTransactionAlertType, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    rockContext.WrapTransaction(() =>
                    {
                        financialTransactionAlertTypeService.Delete(financialTransactionAlertType);
                        rockContext.SaveChanges();
                    });
                }
            }
        }
        /// <summary>
        /// Binds the filter.
        /// </summary>
        private void BindFilter()
        {
            // Set the date range
            var startDate = PageParameter(PageParameterKey.StartDate).AsDateTime();
            var endDate   = PageParameter(PageParameterKey.EndDate).AsDateTime();

            if (startDate.HasValue || endDate.HasValue)
            {
                drpDateRange.Visible = false;
            }
            else
            {
                drpDateRange.DelimitedValues = gfAlertFilter.GetUserPreference(FilterKey.DateRange);
            }

            // Bind alert types and categories if there is no query param
            var alertTypeId = PageParameter(PageParameterKey.AlertTypeId).AsIntegerOrNull();

            if (alertTypeId.HasValue)
            {
                cblAlertTypes.Visible    = false;
                cblAlertCategory.Visible = false;
            }
            else
            {
                // Bind alert types: the names of the alert types
                using (var rockContext = new RockContext())
                {
                    var alertTypeService = new FinancialTransactionAlertTypeService(rockContext);

                    cblAlertTypes.DataTextField  = "Value";
                    cblAlertTypes.DataValueField = "Key";
                    cblAlertTypes.DataSource     = alertTypeService.Queryable()
                                                   .AsNoTracking()
                                                   .Select(at => new
                    {
                        Key   = at.Id,
                        Value = at.Name
                    })
                                                   .ToList();

                    cblAlertTypes.DataBind();
                }

                var alertTypesValue = gfAlertFilter.GetUserPreference(FilterKey.AlertTypes);

                if (!string.IsNullOrWhiteSpace(alertTypesValue))
                {
                    cblAlertTypes.SetValues(alertTypesValue.Split(';').ToList());
                }

                // Bind alert categories: gratitude and follow-up
                cblAlertCategory.BindToEnum <AlertType>();
                var alertCategoryValue = gfAlertFilter.GetUserPreference(FilterKey.AlertCategory);

                if (!string.IsNullOrWhiteSpace(alertCategoryValue))
                {
                    cblAlertCategory.SetValues(alertCategoryValue.Split(';').ToList());
                }
            }

            // Don't show the person picker if the current context is already a specific person.
            if (GetPerson() != null)
            {
                ppPerson.Visible = false;
            }
            else
            {
                ppPerson.Visible = true;
                var personId = gfAlertFilter.GetUserPreference(FilterKey.Person).AsIntegerOrNull();
                if (personId.HasValue)
                {
                    var person = new PersonService(new RockContext()).Get(personId.Value);
                    ppPerson.SetValue(person);
                }
                else
                {
                    ppPerson.SetValue(null);
                }
            }

            // Set the transaction amount filter
            nreTransactionAmount.DelimitedValues = gfAlertFilter.GetUserPreference(FilterKey.TransactionAmount);

            // Campus picker
            if (GetCampusFromQuery() != null)
            {
                cpCampus.Visible = false;
            }
            else
            {
                cpCampus.SelectedCampusId = gfAlertFilter.GetUserPreference(FilterKey.Campus).AsIntegerOrNull();
            }
        }