/// <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"; }
/// <summary> /// Updates the location /// </summary> /// <returns>true if the update succeeded, false otherwise</returns> private bool UpdateLocation() { Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation(); string userId = ((Entities.CustomPrincipal)Page.User).UserName; Entities.FacadeResult result = facOrganisationLocation.Update(m_location, _individual, userId); if (!result.Success) { infringementDisplay.Infringements = result.Infringements; infringementDisplay.DisplayInfringments(); } m_location = facOrganisationLocation.GetLocationForOrganisationLocationId(m_location.OrganisationLocationId); cboTrafficArea.SelectedValue = m_location.Point.Address.TrafficArea.TrafficAreaId.ToString(); return(result.Success); }