SetValue() public method

Sets the value.
public SetValue ( WorkflowType workflowType ) : void
workflowType WorkflowType The Workflow Type.
return void
Example #1
0
        /// <summary>
        /// Reads the instance.
        /// </summary>
        /// <param name="instance">The instance.</param>
        public void SetValue(RegistrationInstance instance)
        {
            EnsureChildControls();

            if (instance != null)
            {
                _tbName.Text = instance.Name;
                if (ShowActive)
                {
                    _cbIsActive.Checked = instance.IsActive;
                }
                _ceDetails.Text            = instance.Details;
                _dtpStart.SelectedDateTime = instance.StartDateTime;
                _dtpEnd.SelectedDateTime   = instance.EndDateTime;
                _nbMaxAttendees.Text       = instance.MaxAttendees.ToString();
                _wtpRegistrationWorkflow.SetValue(instance.RegistrationWorkflowTypeId);

                Person contactPerson = null;
                if (instance.ContactPersonAlias != null && instance.ContactPersonAlias.Person != null)
                {
                    contactPerson = instance.ContactPersonAlias.Person;
                }
                else if (instance.ContactPersonAliasId.HasValue)
                {
                    using (var rockContext = new RockContext())
                    {
                        contactPerson = new PersonAliasService(rockContext)
                                        .Queryable()
                                        .Where(p => p.Id == instance.ContactPersonAliasId.Value)
                                        .Select(p => p.Person)
                                        .FirstOrDefault();
                    }
                }
                _ppContact.SetValue(contactPerson);

                _pnContactPhone.Text             = instance.ContactPhone;
                _ebContactEmail.Text             = instance.ContactEmail;
                _cbCost.Text                     = instance.Cost.HasValue ? instance.Cost.Value.ToString() : string.Empty;
                _cbCost.Visible                  = instance.RegistrationTemplate != null && (instance.RegistrationTemplate.SetCostOnInstance ?? false);
                _cbMinimumInitialPayment.Text    = instance.MinimumInitialPayment.HasValue ? instance.MinimumInitialPayment.Value.ToString() : string.Empty;
                _cbMinimumInitialPayment.Visible = instance.RegistrationTemplate != null && (instance.RegistrationTemplate.SetCostOnInstance ?? false);
                _cbDefaultPaymentAmount.Text     = instance.DefaultPayment.HasValue ? instance.DefaultPayment.Value.ToString() : string.Empty;
                _cbDefaultPaymentAmount.Visible  = instance.RegistrationTemplate != null && (instance.RegistrationTemplate.SetCostOnInstance ?? false);
                _apAccount.SetValue(instance.AccountId);
                _apAccount.Visible = instance.RegistrationTemplate != null && instance.RegistrationTemplate.FinancialGatewayId.HasValue;
                _dtpSendReminder.SelectedDateTime       = instance.SendReminderDateTime;
                _cbReminderSent.Checked                 = instance.ReminderSent;
                _htmlRegistrationInstructions.Text      = instance.RegistrationInstructions;
                _htmlAdditionalReminderDetails.Text     = instance.AdditionalReminderDetails;
                _htmlAdditionalConfirmationDetails.Text = instance.AdditionalConfirmationDetails;
            }
            else
            {
                _tbName.Text               = string.Empty;
                _cbIsActive.Checked        = true;
                _ceDetails.Text            = string.Empty;
                _dtpStart.SelectedDateTime = null;
                _dtpEnd.SelectedDateTime   = null;
                _nbMaxAttendees.Text       = string.Empty;
                _wtpRegistrationWorkflow.SetValue(null);
                _ppContact.SetValue(null);
                _pnContactPhone.Text          = string.Empty;
                _ebContactEmail.Text          = string.Empty;
                _cbCost.Text                  = string.Empty;
                _cbMinimumInitialPayment.Text = string.Empty;
                _cbDefaultPaymentAmount.Text  = string.Empty;
                _apAccount.SetValue(null);
                _dtpSendReminder.SelectedDateTime       = null;
                _cbReminderSent.Checked                 = false;
                _htmlRegistrationInstructions.Text      = string.Empty;
                _htmlAdditionalReminderDetails.Text     = string.Empty;
                _htmlAdditionalConfirmationDetails.Text = string.Empty;
            }
        }
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
        {
            var containerControl = new DynamicControlsPanel();
            containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add( containerControl );

            WorkflowTypePicker workflowTypePicker = new WorkflowTypePicker();
            workflowTypePicker.ID = filterControl.ID + "_workflowTypePicker";
            workflowTypePicker.Label = "Workflow Type";
            workflowTypePicker.SelectItem += workflowTypePicker_SelectItem;
            workflowTypePicker.Visible = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add( workflowTypePicker );

            // set the WorkflowTypePicker selected value now so we can create the other controls the depending on know the workflowTypeid
            var hfItem = workflowTypePicker.ControlsOfTypeRecursive<HiddenFieldWithClass>().Where( a => a.CssClass.Contains( "js-item-id-value" ) ).FirstOrDefault();
            int? workflowTypeId = filterControl.Page.Request.Params[hfItem.UniqueID].AsIntegerOrNull();
            workflowTypePicker.SetValue( workflowTypeId );
            workflowTypePicker_SelectItem( workflowTypePicker, new EventArgs() );

            return new Control[] { containerControl };
        }