/// <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 Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { ListControl editControl; bool useDescription = configurationValues != null && configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean(); int? definedTypeId = configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY) ? configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull() : null; if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean()) { editControl = new DefinedValuesPicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; editControl.AddCssClass("checkboxlist-group"); } else { editControl = new DefinedValuePicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } if (definedTypeId.HasValue) { return(editControl); } return(null); }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { var controls = new List <Control>(); var ddlStringFilterComparison = ComparisonHelper.ComparisonControl(ComparisonHelper.StringFilterComparisonTypes); ddlStringFilterComparison.ID = string.Format("{0}_{1}", filterControl.ID, controls.Count()); ddlStringFilterComparison.AddCssClass("js-filter-compare"); filterControl.Controls.Add(ddlStringFilterComparison); controls.Add(ddlStringFilterComparison); var tbPostalCode = new RockTextBox(); tbPostalCode.ID = filterControl.ID + "_tbPostalCode"; tbPostalCode.AddCssClass("js-filter-control"); filterControl.Controls.Add(tbPostalCode); controls.Add(tbPostalCode); var dvpLocationType = new DefinedValuePicker(); dvpLocationType.ID = filterControl.ID + "_ddlLocationType"; dvpLocationType.Label = "Location Type"; dvpLocationType.DataValueField = "Id"; dvpLocationType.DataTextField = "Value"; DefinedTypeCache locationDefinedType = DefinedTypeCache.Get(SystemGuid.DefinedType.GROUP_LOCATION_TYPE.AsGuid()); dvpLocationType.DefinedTypeId = locationDefinedType.Id; dvpLocationType.Items.Insert(0, new ListItem("(All Location Types)", "")); filterControl.Controls.Add(dvpLocationType); controls.Add(dvpLocationType); return(controls.ToArray()); }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { var lp = new LocationPicker(); lp.ID = filterControl.ID + "_lp"; lp.Label = "Location"; lp.AllowedPickerModes = LocationPickerMode.Named | LocationPickerMode.Polygon; lp.SetBestPickerModeForLocation(null); lp.CssClass = "col-lg-4"; filterControl.Controls.Add(lp); Panel panel = new Panel(); panel.CssClass = "col-lg-8"; filterControl.Controls.Add(panel); var dvpLocationType = new DefinedValuePicker(); dvpLocationType.ID = filterControl.ID + "_dvpLocationType"; dvpLocationType.Label = "Location Type"; dvpLocationType.DataValueField = "Id"; dvpLocationType.DataTextField = "Value"; DefinedTypeCache locationDefinedType = DefinedTypeCache.Get(SystemGuid.DefinedType.GROUP_LOCATION_TYPE.AsGuid()); dvpLocationType.DefinedTypeId = locationDefinedType.Id; panel.Controls.Add(dvpLocationType); return(new Control[3] { lp, dvpLocationType, panel }); }
/// <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(); Controls.Clear(); var selectedNumberGuids = SelectedNumbers; //GetAttributeValue( "FilterCategories" ).SplitDelimitedValues( true ).AsGuidList(); var definedType = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.COMMUNICATION_SMS_FROM)); dvpFrom = new DefinedValuePicker(); dvpFrom.ID = string.Format("dvpFrom_{0}", this.ID); dvpFrom.Label = "From"; dvpFrom.Help = "The number to originate message from (configured under Admin Tools > Communications > SMS Phone Numbers)."; if (selectedNumberGuids.Any()) { dvpFrom.SelectedIndex = -1; dvpFrom.DataSource = definedType.DefinedValues.Where(v => selectedNumberGuids.Contains(v.Guid)).Select(v => new { v.Description, v.Id }); dvpFrom.DataTextField = "Description"; dvpFrom.DataValueField = "Id"; dvpFrom.DataBind(); } else { dvpFrom.DefinedTypeId = definedType.Id; } dvpFrom.Required = true; Controls.Add(dvpFrom); rcwMessage = new RockControlWrapper(); rcwMessage.ID = string.Format("rcwMessage_{0}", this.ID); rcwMessage.Label = "Message"; rcwMessage.Help = "<span class='tip tip-lava'></span>"; Controls.Add(rcwMessage); mfpMessage = new MergeFieldPicker(); mfpMessage.ID = string.Format("mfpMergeFields_{0}", this.ID); mfpMessage.MergeFields.Clear(); mfpMessage.MergeFields.Add("GlobalAttribute"); mfpMessage.MergeFields.Add("Rock.Model.Person"); mfpMessage.CssClass += " margin-b-sm pull-right"; mfpMessage.SelectItem += mfpMergeFields_SelectItem; rcwMessage.Controls.Add(mfpMessage); lblCount = new Label(); lblCount.CssClass = "badge margin-all-sm pull-right"; lblCount.ID = string.Format("lblCount_{0}", this.ID); lblCount.Visible = this.CharacterLimit > 0; rcwMessage.Controls.Add(lblCount); tbMessage = new RockTextBox(); tbMessage.ID = string.Format("tbTextMessage_{0}", this.ID); tbMessage.TextMode = TextBoxMode.MultiLine; tbMessage.Rows = 3; tbMessage.Required = true; rcwMessage.Controls.Add(tbMessage); }
/// <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 Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { ListControl editControl; bool useDescription = configurationValues != null && configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean(); int? definedTypeId = configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY) ? configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull() : null; if (definedTypeId.HasValue) { var definedType = DefinedTypeCache.Get(definedTypeId.Value); } if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean()) { if (configurationValues != null && configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { editControl = new DefinedValuesPickerEnhanced { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } else { editControl = new DefinedValuesPicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } } else { editControl = new DefinedValuePicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; if (configurationValues != null && configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { (( DefinedValuePicker )editControl).EnhanceForLongLists = true; } } if (editControl is IDefinedValuePicker) { (editControl as IDefinedValuePicker).IncludeInactive = configurationValues.GetValueOrNull(INCLUDE_INACTIVE_KEY).AsBooleanOrNull() ?? false; } if (definedTypeId.HasValue) { return(editControl); } return(null); }
/// <summary> /// Creates the HTML controls required to configure this type of field /// </summary> /// <returns></returns> public override List <Control> ConfigurationControls() { var controls = base.ConfigurationControls(); var locationTypeDefinedType = DefinedTypeCache.Get(SystemGuid.DefinedType.LOCATION_TYPE.AsGuid()); var dvpLocationType = new DefinedValuePicker(); controls.Add(dvpLocationType); dvpLocationType.AutoPostBack = true; dvpLocationType.SelectedIndexChanged += OnQualifierUpdated; dvpLocationType.Label = "Location Type"; dvpLocationType.DefinedTypeId = locationTypeDefinedType.Id; var lpParentLocation = new LocationPicker(); controls.Add(lpParentLocation); lpParentLocation.Label = "Parent Location"; lpParentLocation.Required = true; lpParentLocation.AllowedPickerModes = LocationPickerMode.Named; lpParentLocation.CurrentPickerMode = LocationPickerMode.Named; lpParentLocation.SelectLocation += OnQualifierUpdated; var cbAllowAddingNewLocations = new RockCheckBox(); controls.Add(cbAllowAddingNewLocations); cbAllowAddingNewLocations.AutoPostBack = true; cbAllowAddingNewLocations.CheckedChanged += OnQualifierUpdated; cbAllowAddingNewLocations.Label = "Allow Adding New Locations"; var cbShowCityState = new RockCheckBox(); controls.Add(cbShowCityState); cbShowCityState.AutoPostBack = true; cbShowCityState.CheckedChanged += OnQualifierUpdated; cbShowCityState.Label = "Show City / State"; var cbAddressRequired = new RockCheckBox(); controls.Add(cbAddressRequired); cbAddressRequired.AutoPostBack = true; cbAddressRequired.CheckedChanged += OnQualifierUpdated; cbAddressRequired.Label = "Address Required"; return(controls); }
/// <summary> /// Creates the HTML controls required to configure this type of field /// </summary> /// <returns></returns> public override List <Control> ConfigurationControls() { var controls = base.ConfigurationControls(); var dvpTemplateBlock = new DefinedValuePicker(); dvpTemplateBlock.DisplayDescriptions = true; controls.Add(dvpTemplateBlock); dvpTemplateBlock.AutoPostBack = true; dvpTemplateBlock.SelectedIndexChanged += OnQualifierUpdated; var definedType = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.TEMPLATE_BLOCK.AsGuid()); dvpTemplateBlock.DefinedTypeId = definedType?.Id; dvpTemplateBlock.Label = "Template Block"; dvpTemplateBlock.Help = "An optional setting to select template block from.."; return(controls); }
/// <summary> /// Creates the HTML controls required to configure this type of field /// </summary> /// <returns></returns> public override List <Control> ConfigurationControls() { var controls = base.ConfigurationControls(); var dvpGroupTypePurpose = new DefinedValuePicker(); dvpGroupTypePurpose.DisplayDescriptions = true; controls.Add(dvpGroupTypePurpose); dvpGroupTypePurpose.AutoPostBack = true; dvpGroupTypePurpose.SelectedIndexChanged += OnQualifierUpdated; var definedType = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.GROUPTYPE_PURPOSE.AsGuid()); dvpGroupTypePurpose.DefinedTypeId = definedType?.Id; dvpGroupTypePurpose.Label = "Purpose"; dvpGroupTypePurpose.Help = "An optional setting to limit the selection of group types to those that have the selected purpose."; return(controls); }
/// <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 Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { Control editControl; bool useDescription = configurationValues != null && configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean(); int? definedTypeId = configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY) ? configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull() : null; int repeatColumns = (configurationValues != null && configurationValues.ContainsKey(REPEAT_COLUMNS_KEY) ? configurationValues[REPEAT_COLUMNS_KEY].Value.AsIntegerOrNull() : null) ?? 4; bool allowAdd = configurationValues != null && configurationValues.ContainsKey(ALLOW_ADDING_NEW_VALUES_KEY) ? configurationValues[ALLOW_ADDING_NEW_VALUES_KEY].Value.AsBoolean() : false; bool enhanceForLongLists = configurationValues != null && configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean(); bool allowMultiple = configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean(); if (allowMultiple) { if (allowAdd) { editControl = new DefinedValuePickerWithAddMultipleSelect { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, RepeatColumns = repeatColumns, IsAllowAddDefinedValue = allowAdd, EnhanceForLongLists = enhanceForLongLists }; } else { if (enhanceForLongLists) { editControl = new DefinedValuesPickerEnhanced { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } else { editControl = new DefinedValuesPicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, RepeatColumns = repeatColumns }; } } } else { //TODO: The add versions of the controls are not working with AttributeValuesContainer, so keep the old ones for now if (allowAdd) { editControl = new DefinedValuePickerWithAddSingleSelect { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, IsAllowAddDefinedValue = allowAdd, EnhanceForLongLists = enhanceForLongLists }; } else { editControl = new DefinedValuePicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, EnhanceForLongLists = enhanceForLongLists }; } } if (editControl is IDefinedValuePicker) { (editControl as IDefinedValuePicker).IncludeInactive = configurationValues.GetValueOrNull(INCLUDE_INACTIVE_KEY).AsBooleanOrNull() ?? false; } if (definedTypeId.HasValue) { return(editControl); } return(null); }
/// <summary> /// Creates the table controls. /// </summary> /// <param name="batchId">The batch identifier.</param> /// <param name="dataViewId">The data view identifier.</param> private void BindHtmlGrid(int?batchId, int?dataViewId) { _financialTransactionDetailList = null; RockContext rockContext = new RockContext(); nbSaveSuccess.Visible = false; btnSave.Visible = false; List <DataControlField> tableColumns = new List <DataControlField>(); tableColumns.Add(new RockLiteralField { ID = "lPerson", HeaderText = "Person" }); tableColumns.Add(new RockLiteralField { ID = "lAmount", HeaderText = "Amount" }); tableColumns.Add(new RockLiteralField { ID = "lAccount", HeaderText = "Account" }); tableColumns.Add(new RockLiteralField { ID = "lTransactionType", HeaderText = "Transaction Type" }); string entityColumnHeading = this.GetAttributeValue("EntityColumnHeading"); if (string.IsNullOrEmpty(entityColumnHeading)) { if (_transactionEntityType != null) { entityColumnHeading = _entityTypeQualifiedName; } } tableColumns.Add(new RockLiteralField { ID = "lEntityColumn", HeaderText = entityColumnHeading }); var additionalColumns = this.GetAttributeValue(CustomGridColumnsConfig.AttributeKey).FromJsonOrNull <CustomGridColumnsConfig>(); if (additionalColumns != null) { foreach (var columnConfig in additionalColumns.ColumnsConfig) { int insertPosition; if (columnConfig.PositionOffsetType == CustomGridColumnsConfig.ColumnConfig.OffsetType.LastColumn) { insertPosition = tableColumns.Count - columnConfig.PositionOffset; } else { insertPosition = columnConfig.PositionOffset; } var column = columnConfig.GetGridColumn(); tableColumns.Insert(insertPosition, column); insertPosition++; } } StringBuilder headers = new StringBuilder(); foreach (var tableColumn in tableColumns) { if (tableColumn.HeaderStyle.CssClass.IsNotNullOrWhiteSpace()) { headers.AppendFormat("<th class='{0}'>{1}</th>", tableColumn.HeaderStyle.CssClass, tableColumn.HeaderText); } else { headers.AppendFormat("<th>{0}</th>", tableColumn.HeaderText); } } lHeaderHtml.Text = headers.ToString(); int?transactionId = this.PageParameter("TransactionId").AsIntegerOrNull(); if (batchId.HasValue || dataViewId.HasValue || transactionId.HasValue) { var financialTransactionDetailQuery = new FinancialTransactionDetailService(rockContext).Queryable() .Include(a => a.Transaction) .Include(a => a.Transaction.AuthorizedPersonAlias.Person); if (batchId.HasValue) { financialTransactionDetailQuery = financialTransactionDetailQuery.Where(a => a.Transaction.BatchId == batchId.Value); } if (dataViewId.HasValue && dataViewId > 0) { var dataView = new DataViewService(rockContext).Get(dataViewId.Value); List <string> errorMessages; var transactionDetailIdsQry = dataView.GetQuery(null, rockContext, null, out errorMessages).Select(a => a.Id); financialTransactionDetailQuery = financialTransactionDetailQuery.Where(a => transactionDetailIdsQry.Contains(a.Id)); } if (transactionId.HasValue) { financialTransactionDetailQuery = financialTransactionDetailQuery.Where(a => transactionId == a.TransactionId); } int maxResults = this.GetAttributeValue("MaxNumberofResults").AsIntegerOrNull() ?? 1000; _financialTransactionDetailList = financialTransactionDetailQuery.OrderByDescending(a => a.Transaction.TransactionDateTime).Take(maxResults).ToList(); phTableRows.Controls.Clear(); btnSave.Visible = _financialTransactionDetailList.Any(); string appRoot = this.ResolveRockUrl("~/"); string themeRoot = this.ResolveRockUrl("~~/"); foreach (var financialTransactionDetail in _financialTransactionDetailList) { var tr = new HtmlGenericContainer("tr"); foreach (var tableColumn in tableColumns) { var literalControl = new LiteralControl(); if (tableColumn is RockLiteralField) { tr.Controls.Add(literalControl); var literalTableColumn = tableColumn as RockLiteralField; if (literalTableColumn.ID == "lPerson") { literalControl.Text = string.Format("<td>{0}</td>", financialTransactionDetail.Transaction.AuthorizedPersonAlias); } else if (literalTableColumn.ID == "lAmount") { literalControl.Text = string.Format("<td>{0}</td>", financialTransactionDetail.Amount.FormatAsCurrency()); } else if (literalTableColumn.ID == "lAccount") { literalControl.Text = string.Format("<td>{0}</td>", financialTransactionDetail.Account.ToString()); } else if (literalTableColumn.ID == "lTransactionType") { literalControl.ID = "lTransactionType_" + financialTransactionDetail.Id.ToString(); literalControl.Text = string.Format("<td>{0}</td>", financialTransactionDetail.Transaction.TransactionTypeValue); } else if (literalTableColumn.ID == "lEntityColumn") { var tdEntityControls = new HtmlGenericContainer("td") { ID = "pnlEntityControls_" + financialTransactionDetail.Id.ToString() }; tr.Controls.Add(tdEntityControls); if (_transactionEntityType != null) { if (_transactionEntityType.Id == EntityTypeCache.GetId <GroupMember>()) { var ddlGroup = new RockDropDownList { ID = "ddlGroup_" + financialTransactionDetail.Id.ToString(), EnhanceForLongLists = true }; ddlGroup.Label = "Group"; ddlGroup.AutoPostBack = true; ddlGroup.SelectedIndexChanged += ddlGroup_SelectedIndexChanged; tdEntityControls.Controls.Add(ddlGroup); var ddlGroupMember = new RockDropDownList { ID = "ddlGroupMember_" + financialTransactionDetail.Id.ToString(), Visible = false, EnhanceForLongLists = true }; ddlGroupMember.Label = "Group Member"; tdEntityControls.Controls.Add(ddlGroupMember); } else if (_transactionEntityType.Id == EntityTypeCache.GetId <Group>()) { var ddlGroup = new RockDropDownList { ID = "ddlGroup_" + financialTransactionDetail.Id.ToString(), EnhanceForLongLists = true }; ddlGroup.AutoPostBack = false; tdEntityControls.Controls.Add(ddlGroup); } else if (_transactionEntityType.Id == EntityTypeCache.GetId <DefinedValue>()) { var ddlDefinedValue = new DefinedValuePicker { ID = "ddlDefinedValue_" + financialTransactionDetail.Id.ToString(), EnhanceForLongLists = true }; tdEntityControls.Controls.Add(ddlDefinedValue); } else if (_transactionEntityType.SingleValueFieldType != null) { var entityPicker = _transactionEntityType.SingleValueFieldType.Field.EditControl(new Dictionary <string, Rock.Field.ConfigurationValue>(), "entityPicker_" + financialTransactionDetail.Id.ToString()); tdEntityControls.Controls.Add(entityPicker); } } } } else if (tableColumn is LavaField) { tr.Controls.Add(literalControl); var lavaField = tableColumn as LavaField; Dictionary <string, object> mergeValues = new Dictionary <string, object>(); mergeValues.Add("Row", financialTransactionDetail); string lavaOutput = lavaField.LavaTemplate.ResolveMergeFields(mergeValues); // Resolve any dynamic url references lavaOutput = lavaOutput.Replace("~~/", themeRoot).Replace("~/", appRoot); if (lavaField.ItemStyle.CssClass.IsNotNullOrWhiteSpace()) { literalControl.Text = string.Format("<td class='{0}'>{1}</td>", lavaField.ItemStyle.CssClass, lavaOutput); } else { literalControl.Text = string.Format("<td>{0}</td>", lavaOutput); } } } phTableRows.Controls.Add(tr); pnlTransactions.Visible = true; } } else { pnlTransactions.Visible = false; } }
/// <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); }
/// <summary> /// Creates the table controls. /// </summary> /// <param name="batchId">The batch identifier.</param> private void CreateTableControls(int?batchId) { RockContext rockContext = new RockContext(); nbSaveSuccess.Visible = false; btnSave.Visible = false; if (_transactionEntityType != null) { lEntityHeaderText.Text = _transactionEntityType.FriendlyName; } if (batchId.HasValue) { var financialTransactionDetailQuery = new FinancialTransactionDetailService(rockContext).Queryable(); var financialTransactionDetailList = financialTransactionDetailQuery.Where(a => a.Transaction.BatchId == batchId.Value).OrderByDescending(a => a.Transaction.TransactionDateTime).ToList(); phTableRows.Controls.Clear(); btnSave.Visible = financialTransactionDetailList.Any(); foreach (var financialTransactionDetail in financialTransactionDetailList) { var tr = new HtmlGenericContainer("tr"); tr.Controls.Add(new LiteralControl { Text = string.Format("<td>{0}</td>", financialTransactionDetail.Transaction.AuthorizedPersonAlias) }); tr.Controls.Add(new LiteralControl { Text = string.Format("<td>{0}</td>", financialTransactionDetail.Amount.FormatAsCurrency()) }); tr.Controls.Add(new LiteralControl { Text = string.Format("<td>{0}</td>", financialTransactionDetail.Account) }); tr.Controls.Add(new LiteralControl { ID = "lTransactionType_" + financialTransactionDetail.Id.ToString(), Text = string.Format("<td>{0}</td>", financialTransactionDetail.Transaction.TransactionTypeValue) }); var tdEntityControls = new HtmlGenericContainer("td") { ID = "pnlEntityControls_" + financialTransactionDetail.Id.ToString() }; tr.Controls.Add(tdEntityControls); if (_transactionEntityType != null) { if (_transactionEntityType.Id == EntityTypeCache.GetId <GroupMember>()) { var ddlGroup = new RockDropDownList { ID = "ddlGroup_" + financialTransactionDetail.Id.ToString() }; ddlGroup.Label = "Group"; ddlGroup.AutoPostBack = true; ddlGroup.SelectedIndexChanged += ddlGroup_SelectedIndexChanged; tdEntityControls.Controls.Add(ddlGroup); var ddlGroupMember = new RockDropDownList { ID = "ddlGroupMember_" + financialTransactionDetail.Id.ToString(), Visible = false }; ddlGroupMember.Label = "Group Member"; tdEntityControls.Controls.Add(ddlGroupMember); } else if (_transactionEntityType.Id == EntityTypeCache.GetId <Group>()) { var ddlGroup = new RockDropDownList { ID = "ddlGroup_" + financialTransactionDetail.Id.ToString() }; ddlGroup.AutoPostBack = true; ddlGroup.SelectedIndexChanged += ddlGroup_SelectedIndexChanged; tdEntityControls.Controls.Add(ddlGroup); } else if (_transactionEntityType.Id == EntityTypeCache.GetId <DefinedValue>()) { var ddlDefinedValue = new DefinedValuePicker { ID = "ddlDefinedValue_" + financialTransactionDetail.Id.ToString() }; tdEntityControls.Controls.Add(ddlDefinedValue); } else if (_transactionEntityType.SingleValueFieldType != null) { var entityPicker = _transactionEntityType.SingleValueFieldType.Field.EditControl(new Dictionary <string, Rock.Field.ConfigurationValue>(), "entityPicker_" + financialTransactionDetail.Id.ToString()); tdEntityControls.Controls.Add(entityPicker); } } phTableRows.Controls.Add(tr); pnlTransactions.Visible = true; } } else { pnlTransactions.Visible = false; } }