/// <summary> /// Retrieves the reference identified by m_referenceId from the organisation and populates the form controls. /// Only occurs in update mode. /// </summary> private void LoadReference() { // retrieve the reference and store it in viewstate Facade.IOrganisationReference facOrganisationReference = new Facade.Organisation(); m_reference = facOrganisationReference.GetReferenceForOrganisationReferenceId(m_referenceId); ViewState[C_REFERENCE_VS] = m_reference; // populate the form controls txtDescription.Text = m_reference.Description; cboDataType.SelectedValue = Utilities.UnCamelCase(m_reference.DataType.ToString()); cboStatus.SelectedValue = Utilities.UnCamelCase(m_reference.Status.ToString()); btnAdd.Text = "Update"; }
/// <summary> /// Populates the reference object with the new information. /// </summary> private void PopulateReference() { if (m_reference == null) { // adding a new reference, configure identity m_reference = new Orchestrator.Entities.OrganisationReference(); m_reference.IdentityId = m_identityId; } // Update the reference based on it's settings. m_reference.Description = txtDescription.Text; m_reference.DataType = (eOrganisationReferenceDataType)Enum.Parse(typeof(eOrganisationReferenceDataType), cboDataType.SelectedValue.Replace(" ", ""), true); m_reference.Status = (eOrganisationReferenceStatus)Enum.Parse(typeof(eOrganisationReferenceStatus), cboStatus.SelectedValue.Replace(" ", ""), true); m_reference.DisplayOnInvoice = chkCanDisplayOnInvoice.Checked; m_reference.MandatoryOnOrder = chkIsMandatoryOnOrder.Checked; }
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); } } }
protected void Page_Load(object sender, System.EventArgs e) { Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.AddEditOrganisations); m_identityId = Int32.Parse(Request.QueryString["identityId"]); m_referenceId = Convert.ToInt32(Request.QueryString["organisationReferenceId"]); if (m_referenceId > 0) { m_isUpdate = true; ViewState[C_REFERENCE_ID_VS] = m_referenceId; } else { m_referenceId = Convert.ToInt32(ViewState[C_REFERENCE_ID_VS]); if (m_referenceId > 0) { m_isUpdate = true; } } if (!IsPostBack) { PopulateStaticControls(); ConfigureReturnLink(); if (m_isUpdate) { LoadReference(); } } else { // retrieve the reference from the viewstate m_reference = (Entities.OrganisationReference)ViewState[C_REFERENCE_VS]; } }
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; } } }