Exemple #1
0
        void cboPoint_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            cboPoint.Items.Clear();
            int    identityId = 0;
            string searchText = "";

            if (e.Context["FilterString"] != null && e.Context["FilterString"].ToString() != "")
            {
                string[] values = e.Context["FilterString"].ToString().Split(';');
                try { identityId = int.Parse(values[0]); }
                catch { }
                if (values.Length > 1 && values[1] != "false" && !string.IsNullOrEmpty(values[1]))
                {
                    searchText = values[1];
                }
                else if (!string.IsNullOrEmpty(e.Text))
                {
                    searchText = e.Text;
                }
            }
            else
            {
                searchText = e.Context["FilterString"].ToString();
            }

            Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point();
            DataSet ds = facPoint.GetAllForOrganisation(identityId, ePointType.Any, 0, searchText);

            System.Diagnostics.Debug.Write(e.Value + " " + e.Text);

            int itemsPerRequest = 20;
            int itemOffset      = e.NumberOfItems;
            int endOffset       = itemOffset + itemsPerRequest;

            if (endOffset > ds.Tables[0].Rows.Count)
            {
                endOffset = ds.Tables[0].Rows.Count;
            }

            DataTable dt = ds.Tables[0];

            Telerik.Web.UI.RadComboBoxItem rcItem = null;
            for (int i = itemOffset; i < endOffset; i++)
            {
                rcItem       = new Telerik.Web.UI.RadComboBoxItem();
                rcItem.Text  = dt.Rows[i]["Description"].ToString();
                rcItem.Value = dt.Rows[i]["PointId"].ToString();
                cboPoint.Items.Add(rcItem);
            }

            if (dt.Rows.Count > 0)
            {
                e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString());
            }
        }
Exemple #2
0
        void cboPoint_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            // Set the identity id to use for the point filtering
            int identityId = 0;

            switch ((eInstructionType)m_instruction.InstructionTypeId)
            {
            case eInstructionType.Load:
                identityId = m_job.IdentityId;
                break;

            case eInstructionType.Drop:
                identityId = m_instruction.ClientsCustomerIdentityID;
                break;
            }

            cboPoint.Items.Clear();
            int    townId     = 0;
            string searchText = "";

            if (e.Context["FilterString"] != null && e.Context["FilterString"].ToString() != "")
            {
                string[] values = e.Context["FilterString"].ToString().Split(';');
                if (values.Length > 1)
                {
                    identityId = int.Parse(values[0]);
                    townId     = int.Parse(values[1]);
                    if (values.Length > 1 && values[2] != "false")
                    {
                        searchText = values[2];
                    }
                }
                else
                {
                    searchText = e.Context["FilterString"].ToString();
                }
            }
            else
            {
                searchText = e.Text;
            }

            Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point();
            DataSet ds = facPoint.GetAllForOrganisation(identityId, ePointType.Any, townId, searchText);

            int itemsPerRequest = 20;
            int itemOffset      = e.NumberOfItems;
            int endOffset       = itemOffset + itemsPerRequest;

            if (endOffset > ds.Tables[0].Rows.Count)
            {
                endOffset = ds.Tables[0].Rows.Count;
            }

            DataTable dt = ds.Tables[0];

            Telerik.Web.UI.RadComboBoxItem rcItem = null;
            for (int i = itemOffset; i < endOffset; i++)
            {
                rcItem       = new Telerik.Web.UI.RadComboBoxItem();
                rcItem.Text  = dt.Rows[i]["Description"].ToString();
                rcItem.Value = dt.Rows[i]["PointId"].ToString();
                cboPoint.Items.Add(rcItem);
            }

            if (dt.Rows.Count > 0)
            {
                e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString());
            }
        }
Exemple #3
0
        void btnAlterPoint_Click(object sender, EventArgs e)
        {
            Page.Validate("AlterPoint");

            if (Page.IsValid)
            {
                int ownerID = 0;

                #region Validate that the Point Name is Unique for this Organisation
                bool foundPointName = false;
                lblError.Visible = false;
                Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point();
                Entities.Point             point    = facPoint.GetPointForPointId(PointID);

                ownerID = new Facade.Organisation().GetForName(cboNewPointOwner.Text).IdentityId;

                DataSet pointNames = facPoint.GetAllForOrganisation(ownerID, ePointType.Any, txtDescription.Text);
                foreach (DataRow row in pointNames.Tables[0].Rows)
                {
                    if (((string)row["Description"]) == txtDescription.Text && point.PointId != (int)row["PointId"])
                    {
                        foundPointName = true;
                    }
                }
                #endregion

                if (foundPointName)
                {
                    lblError.Text          = "The Description must be unique for this organisation.";
                    lblError.ForeColor     = Color.Red;
                    lblError.Visible       = true;
                    pnlPoint.Visible       = false;
                    pnlNewPoint.Visible    = true;
                    pnlFullAddress.Visible = false;
                }
                else
                {
                    Orchestrator.Facade.IPostTown  facPostTown = new Orchestrator.Facade.Point();
                    Orchestrator.Entities.PostTown town        = facPostTown.GetPostTownForTownId(int.Parse(cboClosestTown.SelectedValue));

                    // Set the point owner and description
                    point.OrganisationName = cboPoint.Text;
                    point.IdentityId       = ownerID;
                    point.Description      = txtDescription.Text;
                    point.PointCode        = this.txtPointCode.Text;

                    // Get the point type
                    switch (this.PointType)
                    {
                    case ePointType.Collect:
                        point.Collect = true;
                        break;

                    case ePointType.Deliver:
                        point.Deliver = true;
                        break;

                    case ePointType.Any:
                        point.Collect = true;
                        point.Deliver = true;
                        break;
                    }

                    // set the address
                    Orchestrator.Entities.Address address = new Orchestrator.Entities.Address();
                    address.AddressLine1       = txtAddressLine1.Text;
                    address.AddressLine2       = txtAddressLine2.Text;
                    address.AddressLine3       = txtAddressLine3.Text;
                    address.AddressType        = eAddressType.Point;
                    address.County             = txtCounty.Text;
                    address.CountryDescription = this.cboCountry.Text;
                    address.CountryId          = Convert.ToInt32(this.cboCountry.SelectedValue);
                    address.IdentityId         = ownerID;
                    decimal latitude = 0;
                    if (decimal.TryParse(hidLat.Value, out latitude))
                    {
                        address.Latitude = latitude;
                    }
                    decimal longitude = 0;
                    if (decimal.TryParse(hidLon.Value, out longitude))
                    {
                        address.Longitude = longitude;
                    }
                    address.PostCode = txtPostCode.Text.ToUpper();
                    address.PostTown = txtPostTown.Text;
                    if (address.TrafficArea == null)
                    {
                        address.TrafficArea = new Orchestrator.Entities.TrafficArea();
                    }

                    Facade.IOrganisation facOrganisation            = new Facade.Organisation();
                    Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(point.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 != null)
                        {
                            if (organisation.Defaults.Count > 0 && organisation.Defaults[0].DefaultGeofenceRadius.HasValue)
                            {
                                point.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                            }
                            else
                            {
                                point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                            }
                        }
                        else
                        {
                            point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                        }
                    }

                    // Get the Traffic Area for this Point
                    address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);

                    point.Address   = address;
                    point.Longitude = address.Longitude;
                    point.Latitude  = address.Latitude;
                    point.PostTown  = town;

                    point.PointNotes = txtPointNotes.Text;

                    if (ClientUserOrganisationIdentityID > 0)
                    {
                        point.PointStateId = ePointState.Unapproved;
                    }
                    else
                    {
                        point.PointStateId = ePointState.Approved;
                    }

                    point.PhoneNumber = txtPhoneNumber.Text;

                    string userId = ((Orchestrator.Entities.CustomPrincipal)Page.User).UserName;

                    // Create the new point
                    Entities.FacadeResult result = facPoint.Update(point, userId);

                    if (result.Success)
                    {
                        // get the Point with all parts populated.
                        this.SelectedPoint     = point;
                        cboPoint.Text          = point.Description;
                        cboPoint.SelectedValue = point.IdentityId.ToString() + "," + point.PointId.ToString();

                        pnlNewPoint.Visible             = false;
                        pnlPoint.Visible                = true;
                        inpCreateNewPointSelected.Value = string.Empty;
                    }
                    else
                    {
                        for (int i = 0; i < result.Infringements.Count; i++)
                        {
                            lblError.Text += result.Infringements[i].Description + Environment.NewLine;
                        }

                        lblError.ForeColor     = Color.Red;
                        lblError.Visible       = true;
                        pnlPoint.Visible       = false;
                        pnlNewPoint.Visible    = true;
                        pnlFullAddress.Visible = false;
                    }
                }
            }
        }