Наследование: RockDropDownList
Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewFamilyMembersRow" /> class.
 /// </summary>
 public NewFamilyMembersRow()
     : base()
 {
     _rblRole = new RockRadioButtonList();
     _ddlTitle = new DropDownList();
     _tbFirstName = new RockTextBox();
     _tbLastName = new RockTextBox();
     _ddlSuffix = new DropDownList();
     _ddlConnectionStatus = new DropDownList();
     _rblGender = new RockRadioButtonList();
     _dpBirthdate = new DatePicker();
     _ddlGradePicker = new GradePicker { UseAbbreviation = true, UseGradeOffsetAsValue = true };
     _ddlGradePicker.Label = string.Empty;
     _lbDelete = new LinkButton();
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewFamilyMembersRow" /> class.
 /// </summary>
 public NewFamilyMembersRow()
     : base()
 {
     _rblRole             = new RockRadioButtonList();
     _ddlTitle            = new DropDownList();
     _tbFirstName         = new RockTextBox();
     _tbLastName          = new RockTextBox();
     _ddlSuffix           = new DropDownList();
     _ddlConnectionStatus = new DropDownList();
     _rblGender           = new RockRadioButtonList();
     _dpBirthdate         = new DatePicker();
     _ddlGradePicker      = new GradePicker {
         UseAbbreviation = true, UseGradeOffsetAsValue = true
     };
     _ddlGradePicker.Label = string.Empty;
     _lbDelete             = new LinkButton();
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewGroupMembersRow" /> class.
 /// </summary>
 public PreRegistrationChildRow()
     : base()
 {
     _lNickName      = new RockLiteral();
     _lLastName      = new RockLiteral();
     _tbNickName     = new RockTextBox();
     _tbLastName     = new RockTextBox();
     _ddlSuffix      = new DefinedValuePicker();
     _ddlGender      = new RockDropDownList();
     _dpBirthdate    = new DatePicker();
     _ddlGradePicker = new GradePicker {
         UseAbbreviation = true, UseGradeOffsetAsValue = true
     };
     _ddlGradePicker.Label = string.Empty;
     _pnbMobile            = new PhoneNumberBox();
     _ddlRelationshipType  = new RockDropDownList();
     _phAttributes         = new PlaceHolder();
     _lbDelete             = new LinkButton();
 }
Пример #4
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Panel pnlRow = new Panel
            {
                ID       = "pnlRow",
                CssClass = "row"
            };

            this.Controls.Add(pnlRow);

            Panel pnlCol1 = new Panel
            {
                ID       = "pnlCol1",
                CssClass = "col-sm-4"
            };

            pnlRow.Controls.Add(pnlCol1);
            _dvpPersonTitle = new DefinedValuePicker
            {
                ID              = "_dvpPersonTitle",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_TITLE.AsGuid()),
                Label           = "Title",
                CssClass        = "input-width-md",
                ValidationGroup = ValidationGroup
            };

            pnlCol1.Controls.Add(_dvpPersonTitle);

            _tbPersonFirstName = new RockTextBox
            {
                ID               = "tbPersonFirstName",
                Label            = "First Name",
                Required         = true,
                AutoCompleteType = AutoCompleteType.None,
                ValidationGroup  = ValidationGroup
            };

            pnlCol1.Controls.Add(_tbPersonFirstName);

            _tbPersonLastName = new RockTextBox
            {
                ID               = "tbPersonLastName",
                Label            = "Last Name",
                Required         = true,
                AutoCompleteType = AutoCompleteType.None,
                ValidationGroup  = ValidationGroup
            };

            pnlCol1.Controls.Add(_tbPersonLastName);

            _dvpPersonSuffix = new DefinedValuePicker
            {
                ID              = "dvpPersonSuffix",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_SUFFIX.AsGuid()),
                Label           = "Suffix",
                CssClass        = "input-width-md",
                ValidationGroup = ValidationGroup
            };

            pnlCol1.Controls.Add(_dvpPersonSuffix);

            Panel pnlCol2 = new Panel
            {
                ID       = "pnlCol2",
                CssClass = "col-sm-4"
            };

            pnlRow.Controls.Add(pnlCol2);

            _dvpPersonConnectionStatus = new DefinedValuePicker
            {
                ID              = "dvpPersonConnectionStatus",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS.AsGuid()),
                Label           = "Connection Status",
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            pnlCol2.Controls.Add(_dvpPersonConnectionStatus);

            _rblPersonRole = new RockRadioButtonList
            {
                ID              = "rblPersonRole",
                Label           = "Role",
                RepeatDirection = RepeatDirection.Horizontal,
                DataTextField   = "Name",
                DataValueField  = "Id",
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            pnlCol2.Controls.Add(_rblPersonRole);

            _rblPersonGender = new RockRadioButtonList
            {
                ID              = "rblPersonGender",
                Label           = "Gender",
                RepeatDirection = RepeatDirection.Horizontal,
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            pnlCol2.Controls.Add(_rblPersonGender);

            Panel pnlCol3 = new Panel {
                ID = "pnlCol3", CssClass = "col-sm-4"
            };

            pnlRow.Controls.Add(pnlCol3);

            _dpPersonBirthDate = new DatePicker
            {
                ID    = "dpPersonBirthDate",
                Label = "Birthdate",
                AllowFutureDateSelection = false,
                ForceParse      = false,
                ValidationGroup = ValidationGroup
            };

            pnlCol3.Controls.Add(_dpPersonBirthDate);

            _ddlGradePicker = new GradePicker
            {
                ID                    = "ddlGradePicker",
                Label                 = "Grade",
                UseAbbreviation       = true,
                UseGradeOffsetAsValue = true,
                ValidationGroup       = ValidationGroup
            };

            pnlCol3.Controls.Add(_ddlGradePicker);

            _dvpPersonMaritalStatus = new DefinedValuePicker
            {
                ID              = "_vpPersonMaritalStatus",
                Label           = "Marital Status",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid()),
                ValidationGroup = ValidationGroup
            };

            pnlCol3.Controls.Add(_dvpPersonMaritalStatus);

            _ebPersonEmail = new EmailBox
            {
                ID              = "dbPersonEmail",
                Label           = "Email",
                ValidationGroup = ValidationGroup
            };

            pnlCol3.Controls.Add(_ebPersonEmail);

            var groupType = GroupTypeCache.GetFamilyGroupType();

            _rblPersonRole.DataSource = groupType.Roles.OrderBy(r => r.Order).ToList();
            _rblPersonRole.DataBind();

            _rblPersonGender.Items.Clear();
            _rblPersonGender.Items.Add(new ListItem(Gender.Male.ConvertToString(), Gender.Male.ConvertToInt().ToString()));
            _rblPersonGender.Items.Add(new ListItem(Gender.Female.ConvertToString(), Gender.Female.ConvertToInt().ToString()));
            _rblPersonGender.Items.Add(new ListItem(Gender.Unknown.ConvertToString(), Gender.Unknown.ConvertToInt().ToString()));
        }
        /// <summary>
        /// Adds the filter controls and grid columns for all of the registration template's form fields
        /// that were configured to 'Show on Grid'
        /// </summary>
        private void AddDynamicControls()
        {
            phRegistrantFormFieldFilters.Controls.Clear();

            // Remove any of the dynamic person fields
            var dynamicColumns = new List<string> {
                "PersonAlias.Person.BirthDate",
            };
            foreach ( var column in gRegistrants.Columns
                .OfType<BoundField>()
                .Where( c => dynamicColumns.Contains( c.DataField ) )
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove any of the dynamic attribute fields
            foreach ( var column in gRegistrants.Columns
                .OfType<AttributeField>()
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove the fees field
            foreach ( var column in gRegistrants.Columns
                .OfType<TemplateField>()
                .Where( c => c.HeaderText == "Fees" )
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove the delete field
            foreach ( var column in gRegistrants.Columns
                .OfType<DeleteField>()
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove any of the dynamic attribute fields on group placements grid
            foreach ( var column in gGroupPlacements.Columns
                .OfType<AttributeField>()
                .ToList() )
            {
                gGroupPlacements.Columns.Remove( column );
            }

            // Remove the delete field
            foreach ( var column in gRegistrants.Columns
                .OfType<GroupPickerField>()
                .ToList() )
            {
                gGroupPlacements.Columns.Remove( column );
            }

            if ( RegistrantFields != null )
            {
                foreach ( var field in RegistrantFields )
                {
                    if ( field.FieldSource == RegistrationFieldSource.PersonField && field.PersonFieldType.HasValue )
                    {
                        switch ( field.PersonFieldType.Value )
                        {
                            case RegistrationPersonFieldType.Campus:
                                {
                                    var ddlCampus = new RockDropDownList();
                                    ddlCampus.ID = "ddlCampus";
                                    ddlCampus.Label = "Home Campus";
                                    ddlCampus.DataValueField = "Id";
                                    ddlCampus.DataTextField = "Name";
                                    ddlCampus.DataSource = CampusCache.All();
                                    ddlCampus.DataBind();
                                    ddlCampus.Items.Insert( 0, new ListItem( "", "" ) );
                                    ddlCampus.SetValue( fRegistrants.GetUserPreference( "Home Campus" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlCampus );

                                    var templateField = new RockLiteralField();
                                    templateField.ID = "lCampus";
                                    templateField.HeaderText = "Campus";
                                    gRegistrants.Columns.Add( templateField );

                                    var templateField2 = new RockLiteralField();
                                    templateField2.ID = "lCampus";
                                    templateField2.HeaderText = "Campus";
                                    gGroupPlacements.Columns.Add( templateField2 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Email:
                                {
                                    var tbEmailFilter = new RockTextBox();
                                    tbEmailFilter.ID = "tbEmailFilter";
                                    tbEmailFilter.Label = "Email";
                                    tbEmailFilter.Text = fRegistrants.GetUserPreference( "Email" );
                                    phRegistrantFormFieldFilters.Controls.Add( tbEmailFilter );

                                    string dataFieldExpression = "PersonAlias.Person.Email";
                                    var emailField = new RockBoundField();
                                    emailField.DataField = dataFieldExpression;
                                    emailField.HeaderText = "Email";
                                    emailField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( emailField );

                                    var emailField2 = new RockBoundField();
                                    emailField2.DataField = dataFieldExpression;
                                    emailField2.HeaderText = "Email";
                                    emailField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( emailField2 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Birthdate:
                                {
                                    var drpBirthdateFilter = new DateRangePicker();
                                    drpBirthdateFilter.ID = "drpBirthdateFilter";
                                    drpBirthdateFilter.Label = "Birthdate Range";
                                    drpBirthdateFilter.DelimitedValues = fRegistrants.GetUserPreference( "Birthdate Range" );
                                    phRegistrantFormFieldFilters.Controls.Add( drpBirthdateFilter );

                                    string dataFieldExpression = "PersonAlias.Person.BirthDate";
                                    var birthdateField = new DateField();
                                    birthdateField.DataField = dataFieldExpression;
                                    birthdateField.HeaderText = "Birthdate";
                                    birthdateField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( birthdateField );

                                    var birthdateField2 = new DateField();
                                    birthdateField2.DataField = dataFieldExpression;
                                    birthdateField2.HeaderText = "Birthdate";
                                    birthdateField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( birthdateField2 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Grade:
                                {
                                    var gpGradeFilter = new GradePicker();
                                    gpGradeFilter.ID = "gpGradeFilter";
                                    gpGradeFilter.Label = "Grade";
                                    gpGradeFilter.UseAbbreviation = true;
                                    gpGradeFilter.UseGradeOffsetAsValue = true;
                                    gpGradeFilter.CssClass = "input-width-md";
                                    // Since 12th grade is the 0 Value, we need to handle the "no user preference" differently
                                    // by not calling SetValue otherwise it will select 12th grade.
                                    var gradeUserPreference = fRegistrants.GetUserPreference( "Grade" ).AsIntegerOrNull();
                                    if ( gradeUserPreference != null )
                                    {
                                        gpGradeFilter.SetValue( gradeUserPreference );
                                    }
                                    phRegistrantFormFieldFilters.Controls.Add( gpGradeFilter );

                                    string dataFieldExpression = "PersonAlias.Person.GraduationYear";
                                    var gradeField = new RockBoundField();
                                    gradeField.DataField = dataFieldExpression;
                                    gradeField.HeaderText = "Graduation Year";
                                    gradeField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( gradeField );

                                    var gradeField2 = new RockBoundField();
                                    gradeField2.DataField = dataFieldExpression;
                                    gradeField2.HeaderText = "Graduation Year";
                                    gradeField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( gradeField2 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Gender:
                                {
                                    var ddlGenderFilter = new RockDropDownList();
                                    ddlGenderFilter.BindToEnum<Gender>( true );
                                    ddlGenderFilter.ID = "ddlGenderFilter";
                                    ddlGenderFilter.Label = "Gender";
                                    ddlGenderFilter.SetValue( fRegistrants.GetUserPreference( "Gender" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlGenderFilter );

                                    string dataFieldExpression = "PersonAlias.Person.Gender";
                                    var genderField = new EnumField();
                                    genderField.DataField = dataFieldExpression;
                                    genderField.HeaderText = "Gender";
                                    genderField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( genderField );

                                    var genderField2 = new EnumField();
                                    genderField2.DataField = dataFieldExpression;
                                    genderField2.HeaderText = "Gender";
                                    genderField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( genderField2 );
                                    break;
                                }

                            case RegistrationPersonFieldType.MaritalStatus:
                                {
                                    var ddlMaritalStatusFilter = new RockDropDownList();
                                    ddlMaritalStatusFilter.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid() ), true );
                                    ddlMaritalStatusFilter.ID = "ddlMaritalStatusFilter";
                                    ddlMaritalStatusFilter.Label = "Marital Status";
                                    ddlMaritalStatusFilter.SetValue( fRegistrants.GetUserPreference( "Marital Status" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlMaritalStatusFilter );

                                    string dataFieldExpression = "PersonAlias.Person.MaritalStatusValue.Value";
                                    var maritalStatusField = new RockBoundField();
                                    maritalStatusField.DataField = dataFieldExpression;
                                    maritalStatusField.HeaderText = "MaritalStatus";
                                    maritalStatusField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( maritalStatusField );

                                    var maritalStatusField2 = new RockBoundField();
                                    maritalStatusField2.DataField = dataFieldExpression;
                                    maritalStatusField2.HeaderText = "MaritalStatus";
                                    maritalStatusField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( maritalStatusField2 );

                                    break;
                                }

                            case RegistrationPersonFieldType.MobilePhone:
                                {
                                    var tbPhoneFilter = new RockTextBox();
                                    tbPhoneFilter.ID = "tbPhoneFilter";
                                    tbPhoneFilter.Label = "Phone";
                                    tbPhoneFilter.Text = fRegistrants.GetUserPreference( "Phone" );
                                    phRegistrantFormFieldFilters.Controls.Add( tbPhoneFilter );

                                    var phoneNumbersField = new PhoneNumbersField();
                                    phoneNumbersField.DataField = "PersonAlias.Person.PhoneNumbers";
                                    phoneNumbersField.HeaderText = "Phone(s)";
                                    gRegistrants.Columns.Add( phoneNumbersField );

                                    var phoneNumbersField2 = new PhoneNumbersField();
                                    phoneNumbersField2.DataField = "PersonAlias.Person.PhoneNumbers";
                                    phoneNumbersField2.HeaderText = "Phone(s)";
                                    gGroupPlacements.Columns.Add( phoneNumbersField2 );

                                    break;
                                }
                        }
                    }
                    else if ( field.Attribute != null )
                    {
                        var attribute = field.Attribute;
                        var control = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter );
                        if ( control != null )
                        {
                            if ( control is IRockControl )
                            {
                                var rockControl = (IRockControl)control;
                                rockControl.Label = attribute.Name;
                                rockControl.Help = attribute.Description;
                                phRegistrantFormFieldFilters.Controls.Add( control );
                            }
                            else
                            {
                                var wrapper = new RockControlWrapper();
                                wrapper.ID = control.ID + "_wrapper";
                                wrapper.Label = attribute.Name;
                                wrapper.Controls.Add( control );
                                phRegistrantFormFieldFilters.Controls.Add( wrapper );
                            }

                            string savedValue = fRegistrants.GetUserPreference( attribute.Key );
                            if ( !string.IsNullOrWhiteSpace( savedValue ) )
                            {
                                try
                                {
                                    var values = JsonConvert.DeserializeObject<List<string>>( savedValue );
                                    attribute.FieldType.Field.SetFilterValues( control, attribute.QualifierValues, values );
                                }
                                catch { }
                            }
                        }

                        string dataFieldExpression = attribute.Id.ToString() + attribute.Key;
                        bool columnExists = gRegistrants.Columns.OfType<AttributeField>().FirstOrDefault( a => a.DataField.Equals( dataFieldExpression ) ) != null;
                        if ( !columnExists )
                        {
                            AttributeField boundField = new AttributeField();
                            boundField.DataField = dataFieldExpression;
                            boundField.AttributeId = attribute.Id;
                            boundField.HeaderText = attribute.Name;

                            AttributeField boundField2 = new AttributeField();
                            boundField2.DataField = dataFieldExpression;
                            boundField2.AttributeId = attribute.Id;
                            boundField2.HeaderText = attribute.Name;

                            var attributeCache = Rock.Web.Cache.AttributeCache.Read( attribute.Id );
                            if ( attributeCache != null )
                            {
                                boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                                boundField2.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                            }

                            gRegistrants.Columns.Add( boundField );
                            gGroupPlacements.Columns.Add( boundField2 );
                        }
                    }
                }
            }

            // Add fee column
            var feeField = new RockLiteralField();
            feeField.ID = "lFees";
            feeField.HeaderText = "Fees";
            gRegistrants.Columns.Add( feeField );

            var deleteField = new DeleteField();
            gRegistrants.Columns.Add( deleteField );
            deleteField.Click += gRegistrants_Delete;

            var groupPickerField = new GroupPickerField();
            groupPickerField.HeaderText = "Group";
            groupPickerField.RootGroupId = gpGroupPlacementParentGroup.SelectedValueAsInt();
            gGroupPlacements.Columns.Add( groupPickerField );
        }
Пример #6
0
        /// <summary>
        /// Creates the person field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="setValue">if set to <c>true</c> [set value].</param>
        /// <param name="fieldValue">The field value.</param>
        private void CreatePersonField( RegistrationTemplateFormField field, bool setValue, object fieldValue )
        {
            switch ( field.PersonFieldType )
            {
                case RegistrationPersonFieldType.FirstName:
                    {
                        var tbFirstName = new RockTextBox();
                        tbFirstName.ID = "tbFirstName";
                        tbFirstName.Label = "First Name";
                        tbFirstName.Required = field.IsRequired;
                        tbFirstName.ValidationGroup = BlockValidationGroup;
                        tbFirstName.AddCssClass( "js-first-name" );
                        phRegistrantControls.Controls.Add( tbFirstName );

                        if ( setValue && fieldValue != null )
                        {
                            tbFirstName.Text = fieldValue.ToString();
                        }

                        break;
                    }

                case RegistrationPersonFieldType.LastName:
                    {
                        var tbLastName = new RockTextBox();
                        tbLastName.ID = "tbLastName";
                        tbLastName.Label = "Last Name";
                        tbLastName.Required = field.IsRequired;
                        tbLastName.ValidationGroup = BlockValidationGroup;
                        phRegistrantControls.Controls.Add( tbLastName );

                        if ( setValue && fieldValue != null )
                        {
                            tbLastName.Text = fieldValue.ToString();
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Campus:
                    {
                        var cpHomeCampus = new CampusPicker();
                        cpHomeCampus.ID = "cpHomeCampus";
                        cpHomeCampus.Label = "Campus";
                        cpHomeCampus.Required = field.IsRequired;
                        cpHomeCampus.ValidationGroup = BlockValidationGroup;
                        cpHomeCampus.Campuses = CampusCache.All( false );

                        phRegistrantControls.Controls.Add( cpHomeCampus );

                        if ( setValue && fieldValue != null )
                        {
                            cpHomeCampus.SelectedCampusId = fieldValue.ToString().AsIntegerOrNull();
                        }
                        break;
                    }

                case RegistrationPersonFieldType.Address:
                    {
                        var acAddress = new AddressControl();
                        acAddress.ID = "acAddress";
                        acAddress.Label = "Address";
                        acAddress.UseStateAbbreviation = true;
                        acAddress.UseCountryAbbreviation = false;
                        acAddress.Required = field.IsRequired;
                        acAddress.ValidationGroup = BlockValidationGroup;

                        phRegistrantControls.Controls.Add( acAddress );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue as Location;
                            acAddress.SetValues( value );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Email:
                    {
                        var tbEmail = new EmailBox();
                        tbEmail.ID = "tbEmail";
                        tbEmail.Label = "Email";
                        tbEmail.Required = field.IsRequired;
                        tbEmail.ValidationGroup = BlockValidationGroup;
                        phRegistrantControls.Controls.Add( tbEmail );

                        if ( setValue && fieldValue != null )
                        {
                            tbEmail.Text = fieldValue.ToString();
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Birthdate:
                    {
                        var bpBirthday = new BirthdayPicker();
                        bpBirthday.ID = "bpBirthday";
                        bpBirthday.Label = "Birthday";
                        bpBirthday.Required = field.IsRequired;
                        bpBirthday.ValidationGroup = BlockValidationGroup;
                        phRegistrantControls.Controls.Add( bpBirthday );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue as DateTime?;
                            bpBirthday.SelectedDate = value;
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Grade:
                    {
                        var gpGrade = new GradePicker();
                        gpGrade.ID = "gpGrade";
                        gpGrade.Label = "Grade";
                        gpGrade.Required = field.IsRequired;
                        gpGrade.ValidationGroup = BlockValidationGroup;
                        gpGrade.UseAbbreviation = true;
                        gpGrade.UseGradeOffsetAsValue = true;
                        gpGrade.CssClass = "input-width-md";
                        phRegistrantControls.Controls.Add( gpGrade );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue.ToString().AsIntegerOrNull();
                            gpGrade.SetValue( Person.GradeOffsetFromGraduationYear( value ) );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Gender:
                    {
                        var ddlGender = new RockDropDownList();
                        ddlGender.ID = "ddlGender";
                        ddlGender.Label = "Gender";
                        ddlGender.Required = field.IsRequired;
                        ddlGender.ValidationGroup = BlockValidationGroup;
                        ddlGender.BindToEnum<Gender>( false );

                        // change the 'Unknow' value to be blank instead
                        ddlGender.Items.FindByValue( "0" ).Text = string.Empty;

                        phRegistrantControls.Controls.Add( ddlGender );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue.ToString().ConvertToEnumOrNull<Gender>() ?? Gender.Unknown;
                            ddlGender.SetValue( value.ConvertToInt() );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.MaritalStatus:
                    {
                        var ddlMaritalStatus = new RockDropDownList();
                        ddlMaritalStatus.ID = "ddlMaritalStatus";
                        ddlMaritalStatus.Label = "Marital Status";
                        ddlMaritalStatus.Required = field.IsRequired;
                        ddlMaritalStatus.ValidationGroup = BlockValidationGroup;
                        ddlMaritalStatus.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid() ), true );
                        phRegistrantControls.Controls.Add( ddlMaritalStatus );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue.ToString().AsInteger();
                            ddlMaritalStatus.SetValue( value );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.MobilePhone:
                    {
                        var dv = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE );
                        if ( dv != null )
                        {
                            var ppMobile = new PhoneNumberBox();
                            ppMobile.ID = "ppMobile";
                            ppMobile.Label = dv.Value;
                            ppMobile.Required = field.IsRequired;
                            ppMobile.ValidationGroup = BlockValidationGroup;
                            ppMobile.CountryCode = PhoneNumber.DefaultCountryCode();

                            phRegistrantControls.Controls.Add( ppMobile );

                            if ( setValue && fieldValue != null )
                            {
                                var value = fieldValue as PhoneNumber;
                                if ( value != null )
                                {
                                    ppMobile.CountryCode = value.CountryCode;
                                    ppMobile.Number = value.ToString();
                                }
                            }
                        }

                        break;
                    }
                case RegistrationPersonFieldType.HomePhone:
                    {
                        var dv = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME );
                        if ( dv != null )
                        {
                            var ppHome = new PhoneNumberBox();
                            ppHome.ID = "ppHome";
                            ppHome.Label = dv.Value;
                            ppHome.Required = field.IsRequired;
                            ppHome.ValidationGroup = BlockValidationGroup;
                            ppHome.CountryCode = PhoneNumber.DefaultCountryCode();

                            phRegistrantControls.Controls.Add( ppHome );

                            if ( setValue && fieldValue != null )
                            {
                                var value = fieldValue as PhoneNumber;
                                if ( value != null )
                                {
                                    ppHome.CountryCode = value.CountryCode;
                                    ppHome.Number = value.ToString();
                                }
                            }
                        }

                        break;
                    }

                case RegistrationPersonFieldType.WorkPhone:
                    {
                        var dv = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK );
                        if ( dv != null )
                        {
                            var ppWork = new PhoneNumberBox();
                            ppWork.ID = "ppWork";
                            ppWork.Label = dv.Value;
                            ppWork.Required = field.IsRequired;
                            ppWork.ValidationGroup = BlockValidationGroup;
                            ppWork.CountryCode = PhoneNumber.DefaultCountryCode();

                            phRegistrantControls.Controls.Add( ppWork );

                            if ( setValue && fieldValue != null )
                            {
                                var value = fieldValue as PhoneNumber;
                                if ( value != null )
                                {
                                    ppWork.CountryCode = value.CountryCode;
                                    ppWork.Number = value.ToString();
                                }
                            }
                        }

                        break;
                    }
            }
        }
Пример #7
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            _phControls = new DynamicPlaceholder {
                ID = "phControls"
            };
            this.Controls.Add(_phControls);

            _pnlRow = new DynamicControlsPanel {
                ID = "pnlRow", CssClass = "row"
            };
            _pnlCol1 = new DynamicControlsPanel {
                ID = "pnlCol1", CssClass = "col-sm-4"
            };
            _pnlCol2 = new DynamicControlsPanel {
                ID = "pnlCol2", CssClass = "col-sm-4"
            };
            _pnlCol3 = new DynamicControlsPanel {
                ID = "pnlCol3", CssClass = "col-sm-4"
            };
            _phControls.Controls.Add(_pnlRow);
            _pnlRow.Controls.Add(_pnlCol1);
            _pnlRow.Controls.Add(_pnlCol2);
            _pnlRow.Controls.Add(_pnlCol3);


            _hfPersonId = new HiddenField
            {
                ID = "_hfPersonId"
            };

            _phControls.Controls.Add(_hfPersonId);

            _dvpPersonTitle = new DefinedValuePicker
            {
                ID              = "_dvpPersonTitle",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_TITLE.AsGuid()),
                Label           = "Title",
                CssClass        = "input-width-md",
                ValidationGroup = ValidationGroup
            };

            _tbPersonFirstName = new RockTextBox
            {
                ID               = "tbPersonFirstName",
                Label            = "First Name",
                Required         = true,
                AutoCompleteType = AutoCompleteType.None,
                ValidationGroup  = ValidationGroup
            };

            _tbPersonLastName = new RockTextBox
            {
                ID               = "tbPersonLastName",
                Label            = "Last Name",
                Required         = true,
                AutoCompleteType = AutoCompleteType.None,
                ValidationGroup  = ValidationGroup
            };

            _dvpPersonSuffix = new DefinedValuePicker
            {
                ID              = "dvpPersonSuffix",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_SUFFIX.AsGuid()),
                Label           = "Suffix",
                CssClass        = "input-width-md",
                ValidationGroup = ValidationGroup
            };

            // Have Email and PhoneNumber hidden by default
            _ebPersonEmail = new EmailBox
            {
                ID              = "ebPersonEmail",
                Label           = "Email",
                ValidationGroup = ValidationGroup,
                Visible         = false
            };

            _pnbMobilePhoneNumber = new PhoneNumberBox
            {
                Label   = "Mobile Phone",
                ID      = "pnbMobilePhoneNumber",
                Visible = false
            };

            _dvpPersonConnectionStatus = new DefinedValuePicker
            {
                ID              = "dvpPersonConnectionStatus",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS.AsGuid()),
                Label           = "Connection Status",
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            _rblPersonRole = new RockRadioButtonList
            {
                ID              = "rblPersonRole",
                Label           = "Role",
                RepeatDirection = RepeatDirection.Horizontal,
                DataTextField   = "Name",
                DataValueField  = "Id",
                Required        = true,
                ValidationGroup = ValidationGroup
            };

            _rblPersonGender = new RockRadioButtonList
            {
                ID              = "rblPersonGender",
                Label           = "Gender",
                RepeatDirection = RepeatDirection.Horizontal,
                Required        = this.RequireGender,
                ValidationGroup = this.RequireGender == true ? ValidationGroup : string.Empty,
                ShowNoneOption  = false
            };

            _bdpPersonBirthDate = new BirthdayPicker
            {
                ID              = "bdpPersonBirthDate",
                Label           = "Birthdate",
                ValidationGroup = ValidationGroup
            };

            _ddlGradePicker = new GradePicker
            {
                ID                    = "ddlGradePicker",
                Label                 = "Grade",
                UseAbbreviation       = true,
                UseGradeOffsetAsValue = true,
                ValidationGroup       = ValidationGroup
            };

            _dvpPersonMaritalStatus = new DefinedValuePicker
            {
                ID              = "dvpPersonMaritalStatus",
                Label           = "Marital Status",
                DefinedTypeId   = DefinedTypeCache.GetId(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid()),
                ValidationGroup = ValidationGroup
            };

            var groupType = GroupTypeCache.GetFamilyGroupType();

            _rblPersonRole.DataSource = groupType.Roles.OrderBy(r => r.Order).ToList();
            _rblPersonRole.DataBind();

            _rblPersonGender.Items.Clear();
            _rblPersonGender.Items.Add(new ListItem(Gender.Male.ConvertToString(), Gender.Male.ConvertToInt().ToString()));
            _rblPersonGender.Items.Add(new ListItem(Gender.Female.ConvertToString(), Gender.Female.ConvertToInt().ToString()));

            ArrangePersonControls(this.ShowInColumns);
            UpdatePersonControlLabels();
        }