Пример #1
0
        /// <summary>
        /// Handles the ItemDataBound event of the rptIgnoreCampusChanges control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rptIgnoreCampusChanges_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var              ignoreCampusChangeRow = e.Item.DataItem as IgnoreCampusChangeRow;
            CampusPicker     fromCampus            = e.Item.FindControl("cpFromCampus") as CampusPicker;
            CampusPicker     toCampus = e.Item.FindControl("cpToCampus") as CampusPicker;
            RockDropDownList ddlCampusAttendanceOrGiving = e.Item.FindControl("ddlAttendanceOrGiving") as RockDropDownList;

            if (ignoreCampusChangeRow != null && fromCampus != null && toCampus != null && ddlCampusAttendanceOrGiving != null)
            {
                fromCampus.Campuses         = _campuses;
                fromCampus.SelectedCampusId = ignoreCampusChangeRow.FromCampusId;

                toCampus.Campuses         = _campuses;
                toCampus.SelectedCampusId = ignoreCampusChangeRow.ToCampusId;

                if (ignoreCampusChangeRow.CampusCriteria.HasValue)
                {
                    ddlCampusAttendanceOrGiving.SetValue(ignoreCampusChangeRow.CampusCriteria.ConvertToInt());
                }
                else
                {
                    ddlCampusAttendanceOrGiving.SetValue(string.Empty);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var campusPicker = new CampusPicker {
                ID = id
            };

            campusPicker.IncludeInactive = (configurationValues != null && configurationValues.ContainsKey(INCLUDE_INACTIVE_KEY) && configurationValues[INCLUDE_INACTIVE_KEY].Value.AsBoolean());
            return(campusPicker);
        }
Пример #3
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            CampusPicker campusPicker = new CampusPicker();

            campusPicker.ID       = filterControl.ID + "_campusPicker";
            campusPicker.Label    = "Campus";
            campusPicker.Campuses = CampusCache.All();
            filterControl.Controls.Add(campusPicker);

            return(new Control[] { campusPicker });
        }
Пример #4
0
        /// <summary>
        /// Sets the value.
        /// Expects value as a Campus.Guid as string
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            CampusPicker campusPicker = control as CampusPicker;

            if (campusPicker != null)
            {
                Guid guid = value.AsGuid();

                // get the item (or null) and set it
                var campus = CampusCache.Read(guid);
                campusPicker.SelectedCampusId = campus == null ? 0 : campus.Id;
            }
        }
Пример #5
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            CampusPicker campusPicker = new CampusPicker();

            campusPicker.ID       = filterControl.ID + "_0";
            campusPicker.Label    = string.Empty;
            campusPicker.CssClass = $"{ControlClassName}";
            campusPicker.Campuses = CampusCache.All(IncludeInactive);

            filterControl.Controls.Add(campusPicker);

            return(new Control[] { campusPicker });
        }
Пример #6
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            CampusPicker campusPicker = new CampusPicker();

            campusPicker.ID       = filterControl.ID + "_0";
            campusPicker.Label    = string.Empty;
            campusPicker.CssClass = "js-campus-picker";
            campusPicker.Campuses = CampusCache.All();

            filterControl.Controls.Add(campusPicker);

            return(new Control[1] {
                campusPicker
            });
        }
Пример #7
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var campusPicker = new CampusPicker {
                ID = id
            };

            var campusList = CampusCache.All();

            if (campusList.Any())
            {
                campusPicker.Campuses = campusList;
                return(campusPicker);
            }

            return(null);
        }
Пример #8
0
        /// <summary>
        /// Sets the value.
        /// Expects value as a Campus.Guid as string
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            CampusPicker campusPicker = control as CampusPicker;

            if (campusPicker != null)
            {
                Guid?guid     = value.AsGuidOrNull();
                int? campusId = null;

                // get the item (or null) and set it
                if (guid.HasValue)
                {
                    campusId = CampusCache.Get(guid.Value)?.Id;
                }

                campusPicker.SelectedCampusId = campusId;
            }
        }
Пример #9
0
        /// <summary>
        /// Reads new values entered by the user for the field
        /// returns Campus.Guid as string
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            CampusPicker campusPicker = control as CampusPicker;

            if (campusPicker != null)
            {
                int?campusId = campusPicker.SelectedCampusId;
                if (campusId.HasValue)
                {
                    var campus = CampusCache.Get(campusId.Value);
                    if (campus != null)
                    {
                        return(campus.Guid.ToString());
                    }
                }
            }

            return(string.Empty);
        }
Пример #10
0
        /// <summary>
        /// Gets the ignore campus changes repeater data.
        /// </summary>
        private void GetIgnoreCampusChangesRepeaterData()
        {
            _ignoreCampusChangeRows = new List <IgnoreCampusChangeRow>();

            foreach (RepeaterItem item in rptIgnoreCampusChanges.Items)
            {
                CampusPicker     fromCampus        = item.FindControl("cpFromCampus") as CampusPicker;
                CampusPicker     toCampus          = item.FindControl("cpToCampus") as CampusPicker;
                HiddenField      hiddenField       = item.FindControl("hfRowId") as HiddenField;
                RockDropDownList ddlCampusCriteria = item.FindControl("ddlAttendanceOrGiving") as RockDropDownList;

                _ignoreCampusChangeRows.Add(new IgnoreCampusChangeRow
                {
                    Id             = hiddenField.ValueAsInt(),
                    ToCampusId     = toCampus.SelectedCampusId,
                    FromCampusId   = fromCampus.SelectedCampusId,
                    CampusCriteria = ddlCampusCriteria.SelectedValueAsEnumOrNull <CampusCriteria>()
                });
            }
        }
Пример #11
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var campusPicker = new CampusPicker {
                ID = id
            };

            var allCampuses = CampusCache.All();

            bool includeInactive = (configurationValues != null && configurationValues.ContainsKey(INCLUDE_INACTIVE_KEY) && configurationValues[INCLUDE_INACTIVE_KEY].Value.AsBoolean());

            var campusList = allCampuses
                             .Where(c => !c.IsActive.HasValue || c.IsActive.Value || includeInactive)
                             .ToList();

            if (campusList.Any())
            {
                campusPicker.Campuses = campusList;
                return(campusPicker);
            }

            return(null);
        }
Пример #12
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var campusPicker = new CampusPicker {
                ID = id
            };

            if (configurationValues == null)
            {
                return(campusPicker);
            }

            campusPicker.IncludeInactive = configurationValues.ContainsKey(INCLUDE_INACTIVE_KEY) && configurationValues[INCLUDE_INACTIVE_KEY].Value.AsBoolean();

            if (configurationValues.ContainsKey(FILTER_CAMPUS_TYPES_KEY))
            {
                campusPicker.CampusTypesFilter = configurationValues[FILTER_CAMPUS_TYPES_KEY].Value.SplitDelimitedValues(false).ToList().AsIntegerList();
            }

            if (configurationValues.ContainsKey(FILTER_CAMPUS_STATUS_KEY))
            {
                campusPicker.CampusStatusFilter = configurationValues[FILTER_CAMPUS_STATUS_KEY].Value.SplitDelimitedValues(false).ToList().AsIntegerList();
            }

            if (configurationValues.ContainsKey(FORCE_VISIBLE_KEY))
            {
                campusPicker.ForceVisible = configurationValues[FORCE_VISIBLE_KEY].Value.AsBoolean();
            }

            if (configurationValues.ContainsKey(SELECTABLE_CAMPUSES_KEY) && configurationValues[SELECTABLE_CAMPUSES_KEY].Value.IsNotNullOrWhiteSpace())
            {
                int[] selectableValues   = configurationValues[SELECTABLE_CAMPUSES_KEY].Value.Split(',').Select(int.Parse).ToArray();
                var   selectableCampuses = CampusCache.All().Where(c => selectableValues.Contains(c.Id)).ToList();
                campusPicker.Campuses = selectableCampuses;
            }

            return(campusPicker);
        }
        /// <summary>
        /// Gets the person control for this field's <see cref="PersonFieldType"/>
        /// </summary>
        /// <param name="setValue">if set to <c>true</c> [set value].</param>
        /// <param name="fieldValue">The field value.</param>
        /// <param name="familyMemberSelected">if set to <c>true</c> [family member selected].</param>
        /// <param name="validationGroup">The validation group.</param>
        /// <returns></returns>
        public Control GetPersonControl(bool setValue, object fieldValue, bool familyMemberSelected, string validationGroup)
        {
            RegistrationTemplateFormField field = this;
            Control personFieldControl          = null;

            switch (field.PersonFieldType)
            {
            case RegistrationPersonFieldType.FirstName:
                var tbFirstName = new RockTextBox
                {
                    ID              = "tbFirstName",
                    Label           = "First Name",
                    Required        = field.IsRequired,
                    CssClass        = "js-first-name",
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbFirstName;
                break;

            case RegistrationPersonFieldType.LastName:
                var tbLastName = new RockTextBox
                {
                    ID              = "tbLastName",
                    Label           = "Last Name",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbLastName;
                break;

            case RegistrationPersonFieldType.MiddleName:
                var tbMiddleName = new RockTextBox
                {
                    ID              = "tbMiddleName",
                    Label           = "Middle Name",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                // Enable the middle name field if it is currently disabled but required and there is no value.
                if (!tbMiddleName.Enabled && tbMiddleName.Required && tbMiddleName.Text.IsNullOrWhiteSpace())
                {
                    tbMiddleName.Enabled = true;
                }

                personFieldControl = tbMiddleName;
                break;

            case RegistrationPersonFieldType.Campus:
                var cpHomeCampus = new CampusPicker
                {
                    ID               = "cpHomeCampus",
                    Label            = "Campus",
                    Required         = field.IsRequired,
                    ValidationGroup  = validationGroup,
                    Campuses         = CampusCache.All(false),
                    SelectedCampusId = setValue && fieldValue != null?fieldValue.ToString().AsIntegerOrNull() : null
                };

                personFieldControl = cpHomeCampus;
                break;

            case RegistrationPersonFieldType.Address:
                var acAddress = new AddressControl
                {
                    ID    = "acAddress",
                    Label = "Address",
                    UseStateAbbreviation   = true,
                    UseCountryAbbreviation = false,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

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

                personFieldControl = acAddress;
                break;

            case RegistrationPersonFieldType.Email:
                var tbEmail = new EmailBox
                {
                    ID              = "tbEmail",
                    Label           = "Email",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbEmail;
                break;

            case RegistrationPersonFieldType.Birthdate:
                var bpBirthday = new BirthdayPicker
                {
                    ID              = "bpBirthday",
                    Label           = "Birthday",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    SelectedDate    = setValue && fieldValue != null ? fieldValue as DateTime? : null
                };

                personFieldControl = bpBirthday;
                break;

            case RegistrationPersonFieldType.Grade:
                var gpGrade = new GradePicker
                {
                    ID                    = "gpGrade",
                    Label                 = "Grade",
                    Required              = field.IsRequired,
                    ValidationGroup       = validationGroup,
                    UseAbbreviation       = true,
                    UseGradeOffsetAsValue = true,
                    CssClass              = "input-width-md"
                };

                personFieldControl = gpGrade;

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

                break;

            case RegistrationPersonFieldType.Gender:
                var ddlGender = new RockDropDownList
                {
                    ID              = "ddlGender",
                    Label           = "Gender",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                };

                ddlGender.BindToEnum <Gender>(true, new Gender[1] {
                    Gender.Unknown
                });

                personFieldControl = ddlGender;

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

                break;

            case RegistrationPersonFieldType.MaritalStatus:
                var dvpMaritalStatus = new DefinedValuePicker
                {
                    ID              = "dvpMaritalStatus",
                    Label           = "Marital Status",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                dvpMaritalStatus.DefinedTypeId = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid()).Id;
                personFieldControl             = dvpMaritalStatus;

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

                break;

            case RegistrationPersonFieldType.AnniversaryDate:
                var dppAnniversaryDate = new DatePartsPicker
                {
                    ID              = "dppAnniversaryDate",
                    Label           = "Anniversary Date",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    SelectedDate    = setValue && fieldValue != null ? fieldValue as DateTime? : null
                };

                personFieldControl = dppAnniversaryDate;
                break;

            case RegistrationPersonFieldType.MobilePhone:
                var dvMobilePhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE);
                if (dvMobilePhone == null)
                {
                    break;
                }

                var ppMobile = new PhoneNumberBox
                {
                    ID              = "ppMobile",
                    Label           = dvMobilePhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var mobilePhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppMobile.CountryCode = mobilePhoneNumber != null ? mobilePhoneNumber.CountryCode : string.Empty;
                ppMobile.Number      = mobilePhoneNumber != null?mobilePhoneNumber.ToString() : string.Empty;

                personFieldControl = ppMobile;
                break;

            case RegistrationPersonFieldType.HomePhone:
                var dvHomePhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME);
                if (dvHomePhone == null)
                {
                    break;
                }

                var ppHome = new PhoneNumberBox
                {
                    ID              = "ppHome",
                    Label           = dvHomePhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var homePhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppHome.CountryCode = homePhoneNumber != null ? homePhoneNumber.CountryCode : string.Empty;
                ppHome.Number      = homePhoneNumber != null?homePhoneNumber.ToString() : string.Empty;

                personFieldControl = ppHome;
                break;

            case RegistrationPersonFieldType.WorkPhone:
                var dvWorkPhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK);
                if (dvWorkPhone == null)
                {
                    break;
                }

                var ppWork = new PhoneNumberBox
                {
                    ID              = "ppWork",
                    Label           = dvWorkPhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var workPhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppWork.CountryCode = workPhoneNumber != null ? workPhoneNumber.CountryCode : string.Empty;
                ppWork.Number      = workPhoneNumber != null?workPhoneNumber.ToString() : string.Empty;

                personFieldControl = ppWork;
                break;

            case RegistrationPersonFieldType.ConnectionStatus:
                var dvpConnectionStatus = new DefinedValuePicker
                {
                    ID              = "dvpConnectionStatus",
                    Label           = "Connection Status",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                dvpConnectionStatus.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)).Id;

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

                personFieldControl = dvpConnectionStatus;
                break;
            }

            return(personFieldControl);
        }