コード例 #1
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupRequirementTypeId">The group requirement type identifier.</param>
        public void ShowDetail(int groupRequirementTypeId)
        {
            RockContext                 rockContext                 = new RockContext();
            GroupRequirementType        groupRequirementType        = null;
            GroupRequirementTypeService groupRequirementTypeService = new GroupRequirementTypeService(rockContext);

            if (!groupRequirementTypeId.Equals(0))
            {
                groupRequirementType = groupRequirementTypeService.Get(groupRequirementTypeId);
                lActionTitle.Text    = ActionTitle.Edit(GroupRequirementType.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(groupRequirementType, ResolveRockUrl("~"));
            }

            if (groupRequirementType == null)
            {
                groupRequirementType = new GroupRequirementType {
                    Id = 0
                };
                groupRequirementType.RequirementCheckType = RequirementCheckType.Manual;
                lActionTitle.Text = ActionTitle.Add(GroupRequirementType.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfGroupRequirementTypeId.Value = groupRequirementType.Id.ToString();
            tbName.Text          = groupRequirementType.Name;
            tbDescription.Text   = groupRequirementType.Description;
            tbPositiveLabel.Text = groupRequirementType.PositiveLabel;
            tbNegativeLabel.Text = groupRequirementType.NegativeLabel;
            tbWarningLabel.Text  = groupRequirementType.WarningLabel;
            tbCheckboxLabel.Text = groupRequirementType.CheckboxLabel;
            cbCanExpire.Checked  = groupRequirementType.CanExpire;
            nbExpireInDays.Text  = groupRequirementType.ExpireInDays.ToString();

            ceSqlExpression.Text = groupRequirementType.SqlExpression;
            ceSqlExpression.Help = @"A SQL expression that returns a list of Person Ids that meet the criteria. Example: <pre>SELECT [Id] FROM [Person] WHERE [LastName] = 'Decker'</pre>
The SQL can include Lava merge fields:";

            ceSqlExpression.Help += groupRequirementType.GetMergeObjects(new Group()).lavaDebugInfo();

            ceWarningSqlExpression.Text = groupRequirementType.WarningSqlExpression;

            dpDataView.EntityTypeId  = EntityTypeCache.Read <Person>().Id;
            dpDataView.SelectedValue = groupRequirementType.DataViewId.ToString();

            dpWarningDataView.EntityTypeId  = EntityTypeCache.Read <Person>().Id;
            dpWarningDataView.SelectedValue = groupRequirementType.WarningDataViewId.ToString();

            hfRequirementCheckType.Value = groupRequirementType.RequirementCheckType.ConvertToInt().ToString();
        }
コード例 #2
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupRequirementTypeId">The group requirement type identifier.</param>
        public void ShowDetail( int groupRequirementTypeId )
        {
            RockContext rockContext = new RockContext();
            GroupRequirementType groupRequirementType = null;
            GroupRequirementTypeService groupRequirementTypeService = new GroupRequirementTypeService( rockContext );

            if ( !groupRequirementTypeId.Equals( 0 ) )
            {
                groupRequirementType = groupRequirementTypeService.Get( groupRequirementTypeId );
                lActionTitle.Text = ActionTitle.Edit( GroupRequirementType.FriendlyTypeName ).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity( groupRequirementType, ResolveRockUrl( "~" ) );
            }

            if ( groupRequirementType == null )
            {
                groupRequirementType = new GroupRequirementType { Id = 0 };
                groupRequirementType.RequirementCheckType = RequirementCheckType.Manual;
                lActionTitle.Text = ActionTitle.Add( GroupRequirementType.FriendlyTypeName ).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfGroupRequirementTypeId.Value = groupRequirementType.Id.ToString();
            tbName.Text = groupRequirementType.Name;
            tbDescription.Text = groupRequirementType.Description;
            tbPositiveLabel.Text = groupRequirementType.PositiveLabel;
            tbNegativeLabel.Text = groupRequirementType.NegativeLabel;
            tbWarningLabel.Text = groupRequirementType.WarningLabel;
            tbCheckboxLabel.Text = groupRequirementType.CheckboxLabel;
            cbCanExpire.Checked = groupRequirementType.CanExpire;
            nbExpireInDays.Text = groupRequirementType.ExpireInDays.ToString();

            ceSqlExpression.Text = groupRequirementType.SqlExpression;
            ceSqlExpression.Help = @"A SQL expression that returns a list of Person Ids that meet the criteria. Example: <pre>SELECT [Id] FROM [Person] WHERE [LastName] = 'Decker'</pre>
            The SQL can include Lava merge fields:";

            ceSqlExpression.Help += groupRequirementType.GetMergeObjects( new Group() ).lavaDebugInfo();

            ceWarningSqlExpression.Text = groupRequirementType.WarningSqlExpression;

            dpDataView.EntityTypeId = EntityTypeCache.Read<Person>().Id;
            dpDataView.SelectedValue = groupRequirementType.DataViewId.ToString();

            dpWarningDataView.EntityTypeId = EntityTypeCache.Read<Person>().Id;
            dpWarningDataView.SelectedValue = groupRequirementType.WarningDataViewId.ToString();

            hfRequirementCheckType.Value = groupRequirementType.RequirementCheckType.ConvertToInt().ToString();
        }
コード例 #3
0
        /// <summary>
        /// Handles the Delete event of the gList 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 gList_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            GroupRequirementTypeService service = new GroupRequirementTypeService( rockContext );
            GroupRequirementType item = service.Get( e.RowKeyId );
            if ( item != null )
            {
                string errorMessage;
                if ( !service.CanDelete( item, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                service.Delete( item );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
コード例 #4
0
        /// <summary>
        /// Handles the Delete event of the gList 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 gList_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            GroupRequirementTypeService service = new GroupRequirementTypeService(rockContext);
            GroupRequirementType        item    = service.Get(e.RowKeyId);

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

                service.Delete(item);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
コード例 #5
0
        /// <summary>
        /// Handles the Click event of the btnSave 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 btnSave_Click(object sender, EventArgs e)
        {
            GroupRequirementType groupRequirementType;

            var rockContext = new RockContext();
            GroupRequirementTypeService groupRequirementTypeService = new GroupRequirementTypeService(rockContext);

            int groupRequirementTypeId = hfGroupRequirementTypeId.Value.AsInteger();

            if (groupRequirementTypeId == 0)
            {
                groupRequirementType = new GroupRequirementType();
            }
            else
            {
                groupRequirementType = groupRequirementTypeService.Get(groupRequirementTypeId);
            }

            groupRequirementType.Name                 = tbName.Text;
            groupRequirementType.Description          = tbDescription.Text;
            groupRequirementType.CanExpire            = cbCanExpire.Checked;
            groupRequirementType.ExpireInDays         = groupRequirementType.CanExpire ? nbExpireInDays.Text.AsIntegerOrNull() : null;
            groupRequirementType.RequirementCheckType = hfRequirementCheckType.Value.ConvertToEnum <RequirementCheckType>(RequirementCheckType.Manual);

            if (groupRequirementType.RequirementCheckType == RequirementCheckType.Sql)
            {
                groupRequirementType.SqlExpression        = ceSqlExpression.Text;
                groupRequirementType.WarningSqlExpression = ceWarningSqlExpression.Text;
            }
            else
            {
                groupRequirementType.SqlExpression        = null;
                groupRequirementType.WarningSqlExpression = null;
            }

            if (groupRequirementType.RequirementCheckType == RequirementCheckType.Dataview)
            {
                groupRequirementType.DataViewId        = dpDataView.SelectedValue.AsIntegerOrNull();
                groupRequirementType.WarningDataViewId = dpWarningDataView.SelectedValue.AsIntegerOrNull();
            }
            else
            {
                groupRequirementType.DataViewId        = null;
                groupRequirementType.WarningDataViewId = null;
            }

            groupRequirementType.PositiveLabel = tbPositiveLabel.Text;
            groupRequirementType.NegativeLabel = tbNegativeLabel.Text;
            groupRequirementType.WarningLabel  = tbWarningLabel.Text;
            groupRequirementType.CheckboxLabel = tbCheckboxLabel.Text;

            if (!Page.IsValid)
            {
                return;
            }

            if (!groupRequirementType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            if (groupRequirementType.Id == 0)
            {
                groupRequirementTypeService.Add(groupRequirementType);
            }

            rockContext.SaveChanges();

            NavigateToParentPage();
        }
コード例 #6
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupRequirementTypeId">The group requirement type identifier.</param>
        public void ShowDetail(int groupRequirementTypeId)
        {
            RockContext                 rockContext                 = new RockContext();
            GroupRequirementType        groupRequirementType        = null;
            GroupRequirementTypeService groupRequirementTypeService = new GroupRequirementTypeService(rockContext);

            if (!groupRequirementTypeId.Equals(0))
            {
                groupRequirementType = groupRequirementTypeService.Get(groupRequirementTypeId);
                lActionTitle.Text    = ActionTitle.Edit(GroupRequirementType.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(groupRequirementType, ResolveRockUrl("~"));
            }

            if (groupRequirementType == null)
            {
                groupRequirementType = new GroupRequirementType {
                    Id = 0
                };
                groupRequirementType.RequirementCheckType = RequirementCheckType.Manual;
                lActionTitle.Text = ActionTitle.Add(GroupRequirementType.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfGroupRequirementTypeId.Value = groupRequirementType.Id.ToString();
            tbName.Text          = groupRequirementType.Name;
            tbDescription.Text   = groupRequirementType.Description;
            tbPositiveLabel.Text = groupRequirementType.PositiveLabel;
            tbNegativeLabel.Text = groupRequirementType.NegativeLabel;
            tbWarningLabel.Text  = groupRequirementType.WarningLabel;
            tbCheckboxLabel.Text = groupRequirementType.CheckboxLabel;
            cbCanExpire.Checked  = groupRequirementType.CanExpire;
            nbExpireInDays.Text  = groupRequirementType.ExpireInDays.ToString();

            nbSQLHelp.InnerHtml = @"A SQL expression that returns a list of Person Ids that meet the criteria. Example:
<pre>
SELECT [Id] FROM [Person]
WHERE [LastName] = 'Decker'</pre>
</pre>
The SQL can include Lava merge fields:

<ul>
   <li>Group</i>
   <li>GroupRequirementType</i>
</ul>

TIP: When calculating for a specific Person, a <strong>Person</strong> merge field will also be included. This can improve performance in cases when the system is checking requirements for a specific person. Example:

<pre>
    SELECT [Id] FROM [Person]
        WHERE [LastName] = 'Decker'
    {% if Person != empty %}
        AND [Id] = {{ Person.Id }}
    {% endif &}
</pre>
";

            nbSQLHelp.InnerHtml += groupRequirementType.GetMergeObjects(new Group(), this.CurrentPerson).lavaDebugInfo();

            ceSqlExpression.Text = groupRequirementType.SqlExpression;

            ceWarningSqlExpression.Text = groupRequirementType.WarningSqlExpression;

            dpDataView.EntityTypeId = EntityTypeCache.Get <Person>().Id;
            dpDataView.SetValue(groupRequirementType.DataViewId);

            dpWarningDataView.EntityTypeId = EntityTypeCache.Get <Person>().Id;
            dpWarningDataView.SetValue(groupRequirementType.WarningDataViewId);

            hfRequirementCheckType.Value = groupRequirementType.RequirementCheckType.ConvertToInt().ToString();
        }
コード例 #7
0
        /// <summary>
        /// Handles the Click event of the btnSave 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 btnSave_Click( object sender, EventArgs e )
        {
            GroupRequirementType groupRequirementType;

            var rockContext = new RockContext();
            GroupRequirementTypeService groupRequirementTypeService = new GroupRequirementTypeService( rockContext );

            int groupRequirementTypeId = hfGroupRequirementTypeId.Value.AsInteger();

            if (groupRequirementTypeId == 0)
            {
                groupRequirementType = new GroupRequirementType();
            }
            else
            {
                groupRequirementType = groupRequirementTypeService.Get( groupRequirementTypeId );
            }

            groupRequirementType.Name = tbName.Text;
            groupRequirementType.Description = tbDescription.Text;
            groupRequirementType.CanExpire = cbCanExpire.Checked;
            groupRequirementType.ExpireInDays = groupRequirementType.CanExpire ? nbExpireInDays.Text.AsIntegerOrNull() : null;
            groupRequirementType.RequirementCheckType = hfRequirementCheckType.Value.ConvertToEnum<RequirementCheckType>( RequirementCheckType.Manual );

            if ( groupRequirementType.RequirementCheckType == RequirementCheckType.Sql)
            {
                groupRequirementType.SqlExpression = ceSqlExpression.Text;
                groupRequirementType.WarningSqlExpression = ceWarningSqlExpression.Text;
            }
            else
            {
                groupRequirementType.SqlExpression = null;
                groupRequirementType.WarningSqlExpression = null;
            }

            if (groupRequirementType.RequirementCheckType == RequirementCheckType.Dataview)
            {
                groupRequirementType.DataViewId = dpDataView.SelectedValue.AsIntegerOrNull();
                groupRequirementType.WarningDataViewId = dpWarningDataView.SelectedValue.AsIntegerOrNull();
            }
            else
            {
                groupRequirementType.DataViewId = null;
                groupRequirementType.WarningDataViewId = null;
            }

            groupRequirementType.PositiveLabel = tbPositiveLabel.Text;
            groupRequirementType.NegativeLabel = tbNegativeLabel.Text;
            groupRequirementType.WarningLabel = tbWarningLabel.Text;
            groupRequirementType.CheckboxLabel = tbCheckboxLabel.Text;

            if ( !Page.IsValid )
            {
                return;
            }

            if ( !groupRequirementType.IsValid )
            {
                // Controls will render the error messages
                return;
            }

            if ( groupRequirementType.Id == 0 )
            {
                groupRequirementTypeService.Add( groupRequirementType );
            }

            rockContext.SaveChanges();

            NavigateToParentPage();
        }