Example #1
0
        private void OnIndividualBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
        {
            _currentIndividual = uxIndividualBindingSource.Current as Entities.Individual;

            if (_currentIndividual != null)
            {
                _currentIndividual.Validate();
            }
            //_Individual.Validate();
            OnCurrentEntityChanged();
        }
        /// <summary>
        /// Retrieves the location identified by m_locationId from the organisation and populates the form controls.
        /// Only occurs in update mode.
        /// </summary>
        private void LoadLocation()
        {
            // retrieve the location and store it in viewstate
            Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation();
            m_location            = facOrganisationLocation.GetLocationForOrganisationLocationId(m_locationId);
            ViewState[C_LOCATION] = m_location;

            Facade.IIndividual facIndividual = new Facade.Individual();
            _individual = facIndividual.GetForOrganisationLocationID(m_location.OrganisationLocationId);

            if (_individual != null)
            {
                ViewState["VS_Individual"] = _individual;
                // populate the form controls
                cboTitle.ClearSelection();
                cboTitle.Items.FindByValue(_individual.Title.ToString()).Selected = true;
                txtFirstNames.Text = _individual.FirstNames;
                txtLastName.Text   = _individual.LastName;
                if (_individual.Contacts.GetForContactType(eContactType.Email) != null)
                {
                    txtEmailAddress.Text = _individual.Contacts.GetForContactType(eContactType.Email).ContactDetail;
                }
            }

            // location information
            txtLocationName.Text = m_location.OrganisationLocationName;
            cboType.Items.FindByValue(((int)m_location.OrganisationLocationType).ToString()).Selected = true;
            txtTelephone.Text = m_location.TelephoneNumber;
            txtFax.Text       = m_location.FaxNumber;

            // post town information
            cboClosestTown.Text          = m_location.Point.PostTown.TownName;
            cboClosestTown.SelectedValue = m_location.Point.PostTown.TownId.ToString();

            // address information
            txtAddressLine1.Text = m_location.Point.Address.AddressLine1;
            txtAddressLine2.Text = m_location.Point.Address.AddressLine2;
            txtAddressLine3.Text = m_location.Point.Address.AddressLine3;
            txtPostTown.Text     = m_location.Point.Address.PostTown;
            txtCounty.Text       = m_location.Point.Address.County;
            txtPostCode.Text     = m_location.Point.Address.PostCode;
            txtLongitude.Text    = m_location.Point.Address.Longitude.ToString();
            txtLatitude.Text     = m_location.Point.Address.Latitude.ToString();

            if (m_isUpdate)
            {
                cboTrafficArea.Items.FindByValue(m_location.Point.Address.TrafficArea.TrafficAreaId.ToString()).Selected = true;
                cboCountry.SelectedValue = m_location.Point.Address.CountryId.ToString();
            }

            btnAdd.Text = "Update";
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.AddEditOrganisations, eSystemPortion.AddEditPoints, eSystemPortion.GeneralUsage);
            btnAdd.Enabled = Orchestrator.WebUI.Security.Authorise.CanAccess(eSystemPortion.AddEditOrganisations, eSystemPortion.AddEditPoints);

            m_organisationName = Convert.ToString(Request.QueryString["organisationName"]);
            m_identityId       = Convert.ToInt32(Request.QueryString["identityId"]);
            m_locationId       = Convert.ToInt32(Request.QueryString["organisationLocationId"]);

            SetWhereIAm();
            if (m_locationId > 0)
            {
                m_isUpdate = true;
            }

            if (!IsPostBack)
            {
                PopulateStaticControls();
                ConfigureReturnLink();

                if (m_isUpdate)
                {
                    LoadLocation();
                }
                else
                {
                    this.txtLocationName.Text = m_organisationName + " - ";
                }
            }
            else
            {
                // retrieve the location from the view state
                m_location  = (Entities.OrganisationLocation)ViewState[C_LOCATION];
                _individual = (Entities.Individual)ViewState["VS_Individual"];
            }

            infringementDisplay.Visible = false;
        }
        /// <summary>
        /// Populates the location object with the new information.
        /// </summary>
        private void PopulateLocation()
        {
            Entities.Point thisPoint;

            if (m_location == null)
            {
                // adding a new location, configure identity and a new address
                m_location            = new Orchestrator.Entities.OrganisationLocation();
                m_location.IdentityId = m_identityId;
                thisPoint             = new Entities.Point();
                m_location.Point      = thisPoint;
            }
            else
            {
                thisPoint = m_location.Point;
            }

            if (_individual == null)
            {
                _individual = new Orchestrator.Entities.Individual();
                _individual.IndividualType = eIndividualType.Contact;
            }

            //Set the indiviudal details;
            _individual.FirstNames = txtFirstNames.Text;
            _individual.LastName   = txtLastName.Text;
            _individual.Title      = (eTitle)Enum.Parse(typeof(eTitle), cboTitle.SelectedValue);
            if (_individual.Contacts == null)
            {
                _individual.Contacts = new Orchestrator.Entities.ContactCollection();
            }

            _individual.Contacts.Add(new Orchestrator.Entities.Contact(eContactType.Email, txtEmailAddress.Text));
            _individual.Contacts.Add(new Orchestrator.Entities.Contact(eContactType.Telephone, txtTelephone.Text));
            _individual.Contacts.Add(new Orchestrator.Entities.Contact(eContactType.Fax, txtFax.Text));


            // Update the location based on it's settings.
            // location information
            m_location.OrganisationLocationName = txtLocationName.Text;
            m_location.OrganisationLocationType = (eOrganisationLocationType)Enum.Parse(typeof(eOrganisationLocationType), cboType.SelectedValue.Replace(" ", ""), true);
            m_location.TelephoneNumber          = txtTelephone.Text;
            m_location.FaxNumber = txtFax.Text;

            // address information
            thisPoint.Description = m_organisationName + " - " + txtPostTown.Text;
            Facade.IPostTown facPostTown = new Facade.Point();
            thisPoint.PostTown = facPostTown.GetPostTownForTownId(Convert.ToInt32(cboClosestTown.SelectedValue));
            if (thisPoint.Address == null)
            {
                thisPoint.Address = new Entities.Address();
            }
            thisPoint.Address.AddressType  = eAddressType.Correspondence;
            thisPoint.Address.AddressLine1 = txtAddressLine1.Text;
            thisPoint.Address.AddressLine2 = txtAddressLine2.Text;
            thisPoint.Address.AddressLine3 = txtAddressLine3.Text;
            thisPoint.Address.PostTown     = txtPostTown.Text;
            thisPoint.Address.County       = txtCounty.Text;
            thisPoint.Address.PostCode     = txtPostCode.Text;
            thisPoint.Address.Longitude    = Decimal.Parse(txtLongitude.Text);
            thisPoint.Address.Latitude     = Decimal.Parse(txtLatitude.Text);
            if (thisPoint.Address.TrafficArea == null)
            {
                thisPoint.Address.TrafficArea = new Entities.TrafficArea();
            }

            thisPoint.Address.CountryDescription        = cboCountry.SelectedItem.Text;
            thisPoint.Address.CountryId                 = Convert.ToInt32(cboCountry.SelectedValue);
            thisPoint.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);
            thisPoint.IdentityId       = m_identityId;
            thisPoint.Latitude         = thisPoint.Address.Latitude;
            thisPoint.Longitude        = thisPoint.Address.Longitude;
            thisPoint.OrganisationName = m_organisationName;

            Facade.IOrganisation facOrganisation            = new Facade.Organisation();
            Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(thisPoint.IdentityId);

            // set the radius if the address was changed by addressLookup
            // if the org has a default, use it, if not, use the system default.
            if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
            {
                if (organisation.Defaults[0].DefaultGeofenceRadius == null)
                {
                    thisPoint.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                }
                else
                {
                    thisPoint.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                }
            }
        }
		private void OnIndividualBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentIndividual = uxIndividualBindingSource.Current as Entities.Individual;
			
			if (_currentIndividual != null)
			{
				_currentIndividual.Validate();
			}
			//_Individual.Validate();
			OnCurrentEntityChanged();
		}