Example #1
0
        private void repReferences_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Entities.OrganisationReferenceCollection organisationReferences = (Entities.OrganisationReferenceCollection)repReferences.DataSource;

                HtmlInputHidden hidOrganisationReferenceId = (HtmlInputHidden)e.Item.FindControl("hidOrganisationReferenceId");
                PlaceHolder     plcHolder = (PlaceHolder)e.Item.FindControl("plcHolder");

                int organisationReferenceId = Convert.ToInt32(hidOrganisationReferenceId.Value);

                // Configure the validator controls
                CustomValidator validatorControl = null;

                Entities.OrganisationReference reference = organisationReferences.FindByReferenceId(organisationReferenceId);
                switch (reference.DataType)
                {
                case eOrganisationReferenceDataType.Decimal:
                    validatorControl = new CustomValidator();
                    validatorControl.ServerValidate += new ServerValidateEventHandler(validatorControl_ServerValidateDecimal);
                    break;

                case eOrganisationReferenceDataType.FreeText:
                    // No additional validation required.
                    break;

                case eOrganisationReferenceDataType.Integer:
                    validatorControl = new CustomValidator();
                    validatorControl.ServerValidate += new ServerValidateEventHandler(validatorControl_ServerValidateInteger);
                    break;
                }

                if (validatorControl != null)
                {
                    // Configure the validator properties
                    validatorControl.ControlToValidate = "txtReferenceValue";
                    validatorControl.Display           = ValidatorDisplay.Dynamic;
                    validatorControl.ErrorMessage      = "Please supply a " + reference.Description + ".";
                    validatorControl.Text = "<img src=\"../images/error.png\"  Title=\"Please supply a " + reference.Description + ".\" />";
                    validatorControl.EnableClientScript = false;

                    plcHolder.Controls.Add(validatorControl);
                }
            }
        }
Example #2
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            btnNext.DisableServerSideValidation();

            if (Page.IsValid)
            {
                // Populate the references
                if (txtLoadNumber.Text.Trim().Length == 0)
                {
                    txtLoadNumber.Text = GenerateLoadNumber();
                }

                m_job.LoadNumber = txtLoadNumber.Text;

                // Ensure there is a reference collection available
                if (m_job.References == null)
                {
                    m_job.References = new Entities.JobReferenceCollection();
                }

                int    referenceId;
                string referenceValue;

                foreach (RepeaterItem item in repReferences.Items)
                {
                    referenceId    = Convert.ToInt32(((HtmlInputHidden)item.FindControl("hidOrganisationReferenceId")).Value);
                    referenceValue = ((TextBox)item.FindControl("txtReferenceValue")).Text;

                    // Find the existing reference field and update it
                    Entities.JobReference jobReference = m_job.References.GetForReferenceId(referenceId);

                    if (jobReference == null)
                    {
                        // Create a new reference and add it to the reference collection
                        jobReference       = new Entities.JobReference();
                        jobReference.JobId = m_jobId;
                        jobReference.Value = referenceValue;
                        jobReference.OrganisationReference = m_clientReferences.FindByReferenceId(referenceId);

                        m_job.References.Add(jobReference);
                    }
                    else
                    {
                        jobReference.Value = referenceValue;
                    }
                }

                // Update the job session variable
                Session[wizard.C_JOB] = m_job;

                if (m_isUpdate)
                {
                    string userId = ((Entities.CustomPrincipal)Page.User).UserName;

                    Facade.IJob facJob = new Facade.Job();
                    facJob.Update(m_job, userId);

                    Session[wizard.C_JOB] = null;
                    GoToStep("JD");
                }
                else
                {
                    bool jumpToDetails = Session[wizard.C_JUMP_TO_DETAILS] != null && ((bool)Session[wizard.C_JUMP_TO_DETAILS]);
                    Session[wizard.C_JUMP_TO_DETAILS] = false;

                    Session[wizard.C_POINT_TYPE]  = ePointType.Collect;
                    Session[wizard.C_INSTRUCTION] = null;

                    if (jumpToDetails)
                    {
                        GoToStep("JD");
                    }
                    else
                    {
                        GoToStep("P");
                    }
                }
            }
            else
            {
                if (!rfvLoadNumber.IsValid)
                {
                    // Cause the load number validator to be ignored.
                    btnNext.NoFormValList = rfvLoadNumber.ClientID;
                }
            }
        }
Example #3
0
        private void repReferences_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Entities.OrganisationReferenceCollection organisationReferences = (Entities.OrganisationReferenceCollection)repReferences.DataSource;

            HtmlInputHidden hidOrganisationReferenceId = (HtmlInputHidden)e.Item.FindControl("hidOrganisationReferenceId");
            PlaceHolder     plcHolder = (PlaceHolder)e.Item.FindControl("plcHolder");

            int organisationReferenceId = Convert.ToInt32(hidOrganisationReferenceId.Value);

            if (!IsPostBack && m_job.References != null)
            {
                // Make sure the value is in place
                TextBox txtReferenceValue          = (TextBox)e.Item.FindControl("txtReferenceValue");
                Entities.JobReference currentValue = m_job.References.GetForReferenceId(organisationReferenceId);
                if (currentValue != null)
                {
                    txtReferenceValue.Text = currentValue.Value;
                }
            }

            // Configure the validator controls
            CustomValidator validatorControl = null;

            Entities.OrganisationReference reference = organisationReferences.FindByReferenceId(organisationReferenceId);
            switch (reference.DataType)
            {
            case eOrganisationReferenceDataType.Decimal:
                validatorControl = new CustomValidator();
                validatorControl.ServerValidate += new ServerValidateEventHandler(validatorControl_ServerValidateDecimal);
                break;

            case eOrganisationReferenceDataType.FreeText:
                // No additional validation required.
                break;

            case eOrganisationReferenceDataType.Integer:
                validatorControl = new CustomValidator();
                validatorControl.ServerValidate += new ServerValidateEventHandler(validatorControl_ServerValidateInteger);
                break;
            }

            if (validatorControl != null)
            {
                // Configure the validator properties
                validatorControl.ControlToValidate = "txtReferenceValue";
                validatorControl.Display           = ValidatorDisplay.Dynamic;
                validatorControl.ErrorMessage      = "Please supply a " + reference.Description + ".";
                validatorControl.Text = "<img src=\"../../images/error.png\"  Title=\"Please supply a " + reference.Description + ".\" />";
                validatorControl.EnableClientScript = false;

                plcHolder.Controls.Add(validatorControl);
            }

            if (m_isUpdate)
            {
                // Populate the text box with the value already configured for the reference
                TextBox txtReferenceValue = (TextBox)e.Item.FindControl("txtReferenceValue");

                // Find the reference
                Entities.JobReference jobReference = m_job.References.GetForReferenceId(organisationReferenceId);
                if (jobReference != null)
                {
                    txtReferenceValue.Text = jobReference.Value;
                }
            }
        }