示例#1
0
        public void cboPoint_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Orchestrator.Entities.Point selectedPoint = null;

            if (cboPoint.SelectedValue != String.Empty)
            {
                Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point();
                selectedPoint = facPoint.GetPointForPointId(this.PointID);
            }

            UpdateControls(selectedPoint);
        }
示例#2
0
        //-----------------------------------------------------------------------------------------------------------

        private Orchestrator.WebUI.Services.Point GetPointForWebService(int pointID)
        {
            Orchestrator.Facade.IPoint        facPoint      = new Orchestrator.Facade.Point();
            Orchestrator.Entities.Point       selectedPoint = facPoint.GetPointForPointId(pointID);
            Orchestrator.WebUI.Services.Point p             = new Orchestrator.WebUI.Services.Point();

            p.PointID     = selectedPoint.PointId;
            p.Description = selectedPoint.Description;
            p.Latitide    = (double)selectedPoint.Latitude;
            p.Latitude    = (double)selectedPoint.Latitude; // added a correctly spelt version but left the old one to prevent having to change everything.

            p.Longitude          = (double)selectedPoint.Longitude;
            p.ClosestTownID      = selectedPoint.PostTown.TownId;
            p.ClosestTown        = selectedPoint.PostTown.TownName;
            p.IdentityID         = selectedPoint.IdentityId;
            p.OrganisationName   = selectedPoint.OrganisationName;
            p.PointNotes         = selectedPoint.PointNotes;
            p.PointCode          = selectedPoint.PointCode;
            p.PhoneNumber        = selectedPoint.PhoneNumber;
            p.AddressID          = selectedPoint.Address.AddressId;
            p.AddressLine1       = selectedPoint.Address.AddressLine1;
            p.AddressLine2       = selectedPoint.Address.AddressLine2;
            p.AddressLine3       = selectedPoint.Address.AddressLine3;
            p.PostTown           = selectedPoint.Address.PostTown;
            p.County             = selectedPoint.Address.County;
            p.PostCode           = selectedPoint.Address.PostCode;
            p.CountryID          = selectedPoint.Address.CountryId;
            p.CountryDescription = selectedPoint.Address.CountryDescription;

            p.GeofencePoints = new List <LatLong>();

            string points = string.Empty;

            for (int i = 0; i < selectedPoint.Geofence.STNumPoints(); i++)
            {
                SqlGeography point  = selectedPoint.Geofence.STPointN(i + 1);
                LatLong      latLon = new LatLong()
                {
                    Latitude = (double)point.Lat, Longitude = (double)point.Long
                };
                p.GeofencePoints.Add(latLon);
            }

            return(p);
        }
示例#3
0
        public Orchestrator.WebUI.Services.Point UpdatePoint(Orchestrator.WebUI.Services.Point p, string userId)
        {
            Orchestrator.WebUI.Services.Point returnPoint   = null;
            Orchestrator.Facade.IPoint        facPoint      = new Orchestrator.Facade.Point();
            Orchestrator.Entities.Point       selectedPoint = facPoint.GetPointForPointId(p.PointID);
            selectedPoint.Description                = p.Description;
            selectedPoint.Latitude                   = (decimal)p.Latitide;
            selectedPoint.Longitude                  = (decimal)p.Longitude;
            selectedPoint.PostTown.TownId            = p.ClosestTownID;
            selectedPoint.PostTown.TownName          = p.ClosestTown;
            selectedPoint.PointNotes                 = p.PointNotes;
            selectedPoint.PointCode                  = p.PointCode;
            selectedPoint.PhoneNumber                = p.PhoneNumber;
            selectedPoint.Address.AddressLine1       = p.AddressLine1;
            selectedPoint.Address.AddressLine2       = p.AddressLine2;
            selectedPoint.Address.AddressLine3       = p.AddressLine3;
            selectedPoint.Address.PostTown           = p.PostTown;
            selectedPoint.Address.County             = p.County;
            selectedPoint.Address.PostCode           = p.PostCode;
            selectedPoint.Address.CountryId          = p.CountryID;
            selectedPoint.Address.CountryDescription = p.CountryDescription;

            Entities.FacadeResult facResult = facPoint.Update(selectedPoint, userId);

            if (facResult.Success)
            {
                returnPoint = this.GetPointForWebService(selectedPoint.PointId);
            }
            else
            {
                foreach (BusinessRuleInfringement i in facResult.Infringements)
                {
                    p.ErrorMeesage += String.Format("{0} : {1}{2}", i.Key, i.Description, Environment.NewLine);
                }

                returnPoint = p;
            }

            return(returnPoint);
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //this.CboCountryLoad();


                rfvPoint.Enabled = PointSelectionRequired;

                Orchestrator.Facade.IPoint  facPoint      = new Orchestrator.Facade.Point();
                Orchestrator.Entities.Point selectedPoint = facPoint.GetPointForPointId(this.PointID);

                if (this.Width.Value != 0)
                {
                    this.cboPoint.Width       = this.Width;
                    this.cboClosestTown.Width = this.Width;
                }

                //Reset the Depot
                this.Depot       = string.Empty;
                this.CountryCode = string.Empty;

                if (selectedPoint != null)
                {
                    cboPoint.SelectedValue = selectedPoint.IdentityId.ToString() + "," + selectedPoint.PointId.ToString();

                    if (ShowFullAddress)
                    {
                        string fullAddress = selectedPoint.Address.ToString();
                        fullAddress            = fullAddress.Replace("\n", "");
                        fullAddress            = fullAddress.Replace("\r", "<br>");
                        lblFullAddress.Text    = fullAddress;
                        pnlFullAddress.Visible = true;
                    }

                    if (!String.IsNullOrEmpty(selectedPoint.Address.PostCode))
                    {
                        //Change to only show the first depot for a postcode (as there should be only one anyway)
                        //Get the Depot Codes for this Point's PostCode
                        //string depots = string.Empty;

                        //foreach (string depotCode in
                        //    EF.Depot.GetForPostCode(selectedPoint.Address.PostCode).Select(d => d.Code))
                        //{
                        //    depots += depotCode + ", ";
                        //}
                        //if (depots.Length > 0)
                        //{
                        //    depots = depots.Remove(depots.Length - 2);
                        //    lblDepot.Text = string.Format("Depot {0}", depots);
                        //}
                        //else
                        //    lblDepot.Text = "";

                        //We have a postcode so try to lookup a depot
                        var depot = EF.Depot.GetForPostCode(selectedPoint.Address.PostCode).FirstOrDefault();

                        if (depot != null)
                        {
                            this.Depot       = depot.Code;
                            this.CountryCode = depot.CountryCode ?? string.Empty;
                        }
                    }

                    if (this.IsDepotVisible)
                    {
                        lblDepot.Text = string.Format("Depot {0}", this.Depot);
                    }

                    this.lnkPointGeography.OnClientClick = "javascript:" + this.ClientID + "_UpdateGeography(" + selectedPoint.PointId + "); return false;";
                }
                if (this.EditMode)
                {
                    this.PointEditMode();
                }
            }
            else
            {
                this.divDuplicateAddress.Visible = false;
            }
        }