Exemplo n.º 1
0
        void cboClientsCustomer_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData();
            DataSet   ds           = facRefData.GetAllJobRelatedFiltered(e.Text);
            DataTable dt           = ds.Tables[0];
            DataTable boundResults = dt.Clone();

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

            if (endOffset > dt.Rows.Count)
            {
                endOffset = dt.Rows.Count;
            }

            for (int i = itemOffset; i < endOffset; i++)
            {
                boundResults.ImportRow(dt.Rows[i]);
            }

            cboClientsCustomer.Items.Clear();
            cboClientsCustomer.DataSource = boundResults;
            cboClientsCustomer.DataBind();

            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());
            }
        }
Exemplo n.º 2
0
        void cboClient_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cboClient.Items.Clear();

            Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData();
            DataSet ds = facRefData.GetAllClientsFiltered(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]["OrganisationName"].ToString();
                rcItem.Value = dt.Rows[i]["IdentityId"].ToString();
                cboClient.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());
            }
        }
 protected void cboItem_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
 {
     cboItem.DataSource     = ItemService.GetMaterialItems(e.Text);
     cboItem.DataTextField  = "Description";
     cboItem.DataValueField = "ID";
     cboItem.DataBind();
 }
 protected void cboSupplier_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
 {
     cboSupplier.DataSource     = SupplierService.GetSuppliers(e.Text);
     cboSupplier.DataTextField  = "Name";
     cboSupplier.DataValueField = "ID";
     cboSupplier.DataBind();
 }
Exemplo n.º 5
0
        //---------------------------------------------------------------------------------------

        protected void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            cboVehicle.Items.Clear();

            Telerik.Web.UI.RadComboBoxItem rcItem = new Telerik.Web.UI.RadComboBoxItem();
            DataSet ds = null;

            Facade.IResource facResource = new Facade.Resource();
            ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, false);

            if (ds != null)
            {
                int       endOffset    = 0;
                DataTable boundResults = BindComboBoxItems(ds.Tables[0], e.NumberOfItems, out endOffset);

                cboVehicle.DataSource = boundResults;
                cboVehicle.DataBind();

                if (boundResults.Rows.Count > 0)
                {
                    e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), boundResults.Rows.Count.ToString());
                }
            }
        }
Exemplo n.º 6
0
        void cboDrivers_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cboDrivers.Items.Clear();

            Facade.IResource facResource = new Facade.Resource();
            DataSet          ds          = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Driver, false);


            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]["ResourceId"].ToString();
                cboDrivers.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());
            }
        }
        private void cboDepot_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cboDepot.Items.Clear();

            Facade.IOrganisationLocation facOrgLoc = new Facade.Organisation();
            DataSet ds = facOrgLoc.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId);

            DataTable dt = ds.Tables[0];

            Telerik.Web.UI.RadComboBoxItem rcItem = null;
            rcItem       = new Telerik.Web.UI.RadComboBoxItem();
            rcItem.Text  = "All";
            rcItem.Value = "0";
            cboDepot.Items.Add(rcItem);

            List <Telerik.Web.UI.RadComboBoxItem> comboItems = new List <Telerik.Web.UI.RadComboBoxItem>();

            dt.Rows.Cast <DataRow>().ToList().ForEach(row => comboItems.Add(
                                                          new Telerik.Web.UI.RadComboBoxItem
            {
                Text  = row["OrganisationLocationName"].ToString(),
                Value = row["OrganisationLocationId"].ToString()
            }));
            comboItems.Sort((item1, item2) => item1.Text.CompareTo(item2.Text));
            cboDepot.Items.AddRange(comboItems);
        }
Exemplo n.º 8
0
        void cboDriver_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            Facade.IResource facResource  = new Facade.Resource();
            DataSet          ds           = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Driver, false);
            DataTable        dt           = ds.Tables[0];
            DataTable        boundResults = dt.Clone();

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

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

            for (int i = itemOffset; i < endOffset; i++)
            {
                boundResults.ImportRow(dt.Rows[i]);
            }

            cboDriver.Items.Clear();
            cboDriver.DataSource = boundResults;
            cboDriver.DataBind();

            if (boundResults.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());
            }
        }
Exemplo n.º 9
0
        void cboClientsCustomer_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cboClientsCustomer.Items.Clear();

            int identityID = int.Parse(e.Context["IdentityID"].ToString());

            //The Client IdentityId is passed in the combo's ClientDataString
            //If it is empty it means that a the combo selection hasn't changed
            //so check whether it was set to a client already (i.e. the Client User scenario)
            int clientId = 0;

            if (identityID == 0)
            {
                if (!string.IsNullOrEmpty(cboClient.SelectedValue))
                {
                    int.TryParse(cboClient.SelectedValue, out clientId);
                }
            }
            else
            {
                clientId = identityID;
            }

            //A client must be specified before their Customer's can be listed
            if (clientId == 0)
            {
                return;
            }

            //Restrict the Client Customers returned to the Client selected
            Orchestrator.Facade.IOrganisation facOrganisation = new Orchestrator.Facade.Organisation();
            DataSet ds = facOrganisation.GetClientCustomersForClientFiltered(
                clientId, 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]["OrganisationName"].ToString();
                rcItem.Value = dt.Rows[i]["IdentityId"].ToString();
                cboClientsCustomer.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());
            }
        }
Exemplo n.º 10
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());
            }
        }
        private void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cboVehicle.Items.Clear();

            int depotId = 0;

            int.TryParse(cboDepot.SelectedValue, out depotId);
            Orchestrator.Facade.IVehicle facResource = new Orchestrator.Facade.Resource();

            DataSet ds = null;

            if (depotId == 0)
            {
                ds = facResource.GetAllVehicles();
            }
            else
            {
                ds = facResource.GetVehicleForDepotId(depotId);
            }

            DataTable dt = ds.Tables[0];

            Telerik.Web.UI.RadComboBoxItem rcItem = null;
            rcItem       = new Telerik.Web.UI.RadComboBoxItem();
            rcItem.Text  = "All";
            rcItem.Value = "0";
            cboVehicle.Items.Add(rcItem);

            List <int> excludedVehicles = null;

            using (var uow = DIContainer.CreateUnitOfWork())
            {
                var repo = DIContainer.CreateRepository <Repositories.IVehicleExcludedFromRevenueReportRepository>(uow);
                excludedVehicles = repo.GetExcludedVehicleIds().ToList();
                if (excludedVehicles == null)
                {
                    excludedVehicles = new List <int>();
                }
            }

            List <Telerik.Web.UI.RadComboBoxItem> comboItems =
                (from row in dt.Rows.Cast <DataRow>()
                 where !excludedVehicles.Contains(Convert.ToInt32(row["ResourceId"]))
                 select new Telerik.Web.UI.RadComboBoxItem
            {
                Value = row["ResourceId"].ToString(),
                Text = row["RegNo"].ToString()
            }).GroupBy(item => item.Value).Select(grp => grp.First()).ToList();

            comboItems.Sort((item1, item2) => item1.Text.CompareTo(item2.Text));
            cboVehicle.Items.AddRange(comboItems);
        }
Exemplo n.º 12
0
        protected void cbNotifyWhen_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cbNotifyWhen.Items.Clear();

            using (var uow = DIContainer.CreateUnitOfWork())
            {
                var repo = DIContainer.CreateRepository <Repositories.IClientCustomerNotificationConditionTypesRepository>(uow);
                List <Models.ClientCustomerNotificationConditionTypes> conditionTypes = repo.GetAll().ToList();

                cbNotifyWhen.Items.AddRange((from conditionType in conditionTypes select new Telerik.Web.UI.RadComboBoxItem
                {
                    Text = conditionType.Description,
                    Value = conditionType.Id.ToString()
                }));
            }
        }
    public void cboDefaultAttemptedDeliveryReturnPoint_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        DataSet ds = null;

        Orchestrator.Facade.Point facPoint = new Orchestrator.Facade.Point();
        int noOfRowsToReturn = 20;

        // The search text entered by the user ("e.Text") can be split into two regions delimited by a backslash.
        // Any text to the left of the first backslash (or when there is no backslash) should be used to filter the organisation name.
        // Any text to the right of a backslash should be used to filter the point description.
        char filterChar = (char)92; // Backslash character "\"

        string[] filterString = e.Text.Split(filterChar.ToString().ToCharArray());

        if (string.IsNullOrEmpty(e.Text))
        {
            // Do not filter the point type for the time being - just display 'Any'.
            ds = facPoint.GetAllWithAddress(ePointType.Any, "", "", noOfRowsToReturn);
        }
        else if (filterString.Length == 1)
        {
            // Do not filter the point type for the time being - just display 'Any'.
            ds = facPoint.GetAllWithAddress(ePointType.Any, filterString[0], "", noOfRowsToReturn);
        }
        else if (filterString.Length > 1)
        {
            // Do not filter the point type for the time being - just display 'Any'.
            ds = facPoint.GetAllWithAddress(ePointType.Any, filterString[0], filterString[1], noOfRowsToReturn);
        }

        DataTable dt = ds.Tables[0];

        Telerik.Web.UI.RadComboBoxItem rcItem = null;

        foreach (DataRow row in dt.Rows)
        {
            rcItem = new Telerik.Web.UI.RadComboBoxItem();
            PointComboItem comboItem = new PointComboItem(row);

            rcItem.DataItem = comboItem;
            rcItem.Text     = comboItem.SingleLineText;
            rcItem.Value    = row["IdentityId"].ToString() + "," + row["PointId"];

            cboDefaultAttemptedDeliveryReturnPoint.Items.Add(rcItem);
        }
    }
Exemplo n.º 14
0
    void cboPointOwner_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        //cboDeliveryPointOwner.Items.Clear();


        // if this is being called by a client they can only access clients of their own for now.
        DataSet ds = null;

        if (this.ClientUserOrganisationIdentityID > 0)
        {
            Orchestrator.Facade.IOrganisation facOrganisation = new Orchestrator.Facade.Organisation();
            ds = facOrganisation.GetClientsForIdentityIdFiltered(this.ClientUserOrganisationIdentityID, e.Text);
        }
        else
        {
            Orchestrator.Facade.IReferenceData facReferenceData = new Orchestrator.Facade.ReferenceData();
            ds = facReferenceData.GetAllOrganisationsFiltered("%" + e.Text, false);
        }

        DataTable dt = ds.Tables[0];

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

        if (endOffset > dt.Rows.Count)
        {
            endOffset = dt.Rows.Count;
        }



        Telerik.Web.UI.RadComboBoxItem rcItem = null;
        for (int i = itemOffset; i < endOffset; i++)
        {
            rcItem       = new Telerik.Web.UI.RadComboBoxItem();
            rcItem.Text  = dt.Rows[i]["OrganisationName"].ToString();
            rcItem.Value = dt.Rows[i]["IdentityId"].ToString();
            cboPointOwner.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());
        }
    }
Exemplo n.º 15
0
        void cboTrailer_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            ((Telerik.Web.UI.RadComboBox)sender).Items.Clear();

            #region Get ControlArea and Traffic Area
            string[] clientArgs    = e.Context["FilterString"].ToString().Split(':');
            int      controlAreaId = 0;
            controlAreaId = int.Parse(clientArgs[0]);

            string[] taids        = clientArgs[1].Split(',');
            int[]    trafficAreas = new int[taids.Length];
            for (int i = 0; i < taids.Length; i++)
            {
                trafficAreas[i] = int.Parse(taids[i]);
            }
            #endregion

            Facade.IResource facResource = new Facade.Resource();
            DataSet          ds          = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Trailer, controlAreaId, trafficAreas, true);

            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]["ResourceId"].ToString();
                ((Telerik.Web.UI.RadComboBox)sender).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());
            }
        }
Exemplo n.º 16
0
    void cboTown_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        //cboTown.Items.Clear();
        int countryId = 1; //UK

        if (e.Context["FilterString"] != null && e.Context["FilterString"].ToString().ToLower().IndexOf("countryid=") > -1)
        {
            string countryIdString = e.Context["FilterString"].ToString().ToLower().Replace("countryid=", "");
            countryIdString = countryIdString.Substring(0, countryIdString.IndexOf(';'));
            countryId       = Convert.ToInt32(countryIdString);
        }

        Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData();
        DataSet ds = facRefData.GetTownForTownNameAndCountry(e.Text, countryId);

        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]["TownId"].ToString();
            cboClosestTown.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());
        }
    }
Exemplo n.º 17
0
        void cboDepotCode_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            ((Telerik.Web.UI.RadComboBox)sender).Items.Clear();
            System.Data.DataTable reader = null;
            if (Cache["__depotCodes"] == null)
            {
                Facade.IReferenceData facResource = new Facade.ReferenceData();
                reader = facResource.GetAllDepotCodes();
                Cache.Add("__depotCodes", reader, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
            }
            else
            {
                reader = (DataTable)Cache["__depotCodes"];
            }

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

            if (endOffset > reader.Rows.Count)
            {
                endOffset = reader.Rows.Count;
            }

            DataTable dt = reader;

            Telerik.Web.UI.RadComboBoxItem rcItem = null;
            for (int i = itemOffset; i < endOffset; i++)
            {
                rcItem       = new Telerik.Web.UI.RadComboBoxItem();
                rcItem.Text  = dt.Rows[i]["DepotCode"].ToString();
                rcItem.Value = dt.Rows[i]["DepotCode"].ToString();
                ((Telerik.Web.UI.RadComboBox)sender).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());
            }
        }
Exemplo n.º 18
0
        public void rcbMultiTrunk_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            List <Entities.MultiTrunk> multiTrunks = null;

            Orchestrator.Facade.MultiTrunk facMultiTrunk = new Orchestrator.Facade.MultiTrunk();
            int noOfRowsToReturn = 20;

            multiTrunks = facMultiTrunk.GetForDescriptionFiltered(e.Text, true, noOfRowsToReturn);

            Telerik.Web.UI.RadComboBoxItem rcItem = null;

            foreach (Entities.MultiTrunk mt in multiTrunks)
            {
                rcItem = new Telerik.Web.UI.RadComboBoxItem();

                rcItem.DataItem = mt;
                rcItem.Text     = mt.Description;
                rcItem.Value    = mt.MultiTrunkId.ToString();

                rcbMultiTrunk.Items.Add(rcItem);
            }
        }
Exemplo n.º 19
0
        void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            ((Telerik.Web.UI.RadComboBox)sender).Items.Clear();
            Telerik.Web.UI.RadComboBoxItem rcItem = new Telerik.Web.UI.RadComboBoxItem();

            DataSet ds = null;

            string[] clientArgs = e.Context["FilterString"].ToString().Split(':');
            if (e.Context["FilterString"] != null)
            {
                if (clientArgs[0] == "true")
                {
                    // Get the Drivers usual vehicle
                    Facade.IDriver  facDriver = new Facade.Resource();
                    Entities.Driver driver    = facDriver.GetDriverForResourceId(int.Parse(clientArgs[1]));

                    Entities.Vehicle vehicle = ((Facade.IVehicle)facDriver).GetForVehicleId(driver.AssignedVehicleId);
                    if (vehicle != null)
                    {
                        rcItem.Text     = vehicle.RegNo;
                        rcItem.Value    = vehicle.ResourceId.ToString();
                        rcItem.Selected = true;
                        ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem);
                    }
                }
                else
                {
                    int   controlAreaId = 0;
                    int[] trafficAreas  = new int[clientArgs.Length - 1];
                    controlAreaId = int.Parse(clientArgs[0]);

                    for (int i = 1; i < clientArgs.Length; i++)
                    {
                        trafficAreas[i - 1] = int.Parse(clientArgs[i]);
                    }

                    Facade.IResource facResource = new Facade.Resource();
                    ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, controlAreaId, trafficAreas, true);
                }
            }
            else
            {
                Facade.IResource facResource = new Facade.Resource();
                ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, false);
            }

            if (ds != null)
            {
                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];
                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]["ResourceId"].ToString();
                    ((Telerik.Web.UI.RadComboBox)sender).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());
                }
            }
        }
Exemplo n.º 20
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());
            }
        }
        public void ProblemClassAssignedToProviderSelection_OnItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            // GET REFERENCE TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECT RAD COMBO BOX THROUGH SENDER ARGUMENT

            Telerik.Web.UI.RadComboBox currentProblemClassAssignedToProviderSelection = (Telerik.Web.UI.RadComboBox)sender;

            // DEFAULT CURRENT MEMBER CASE PROBLEM CLASS ID TO 0

            Int64 currentMemberCaseProblemClassId = 0;

            // SET MEMBER CASE PROBLEM CLASS ID TO ZERO INDEX OF SLPIT STRING OF VALUE OF FZERO INDEX ITEM OF CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION (GETS ID FROM VALUE OF NOT ASSIGNED ITEM)

            currentMemberCaseProblemClassId = Convert.ToInt64(currentProblemClassAssignedToProviderSelection.Items[0].Value.Split('|')[1]);

            // EVALUATE IF ENTERED TEXT IS GREATER THAN 3 IN LENGTH (HANDLED IN "ON CLIENT ITEM REQUESTING" CLIENT-SIDE EVENT)

            if (e.Text.Length >= 3)
            {
                // CREATE REFERENCE TO SEARCH RESULTS PROVIDER RESPONSE OBJECT

                Mercury.Server.Application.SearchResultsProviderResponse providerSearchResponse;

                // GET PROVIDER SEARCH RESPONSE THROUGH SEARCH PROVIDER METHOD

                providerSearchResponse = MercuryApplication.SearchProvider(e.Text, e.Text);

                // EVALUATE IF PROVIDER SEARCH RESPONSE HAS EXCEPTION, IF SO ADD RAD COMBO BOX ITEM TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX TO INFORM USER OF EXCEPTION

                if (providerSearchResponse.HasException)
                {
                    // ADD RAD COMBO BOX ITEM TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX TO INFORM USER OF EXCEPTION

                    currentProblemClassAssignedToProviderSelection.Items.Add(new Telerik.Web.UI.RadComboBoxItem(("alert ('" + providerSearchResponse.Exception.Message.Replace("'", "''") + "');"), "0"));
                }

                // IF PROVIDER SEARCH RESPONSE DOES NOT HAVE EXCEPTION, THAN ADD RAD COMBO BOX ITEMS TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX

                else
                {
                    // GET AND SET SEARCH RESULTS PROVIDERS ARRAY AS RESULTS OF PROVIDER SEARCH RESPONSE

                    Mercury.Server.Application.SearchResultProvider[] searchResultProviders = providerSearchResponse.Results;

                    // IF COUNT OF SEARCH RESULT PROVIDERS IS GREATER THAN OR EQUAL TO 1 AND LESS THAN OR EQUAL TO 25, THEN ADD RAD COMBO BOX ITEMS FOR EACH PROVIDER IN SEARCH RESULT PROVIDERS

                    if ((searchResultProviders.Count() >= 1) && (searchResultProviders.Count() <= 25))
                    {
                        // LOOP THROUGH EACH SEARCH RESULT PROVIDER IN SEARCH RESULTS PROVIDERS, THEN ADD RAD COMBO BOX ITEMS FOR EACH PROVIDER INTO ITEMS OF CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX

                        foreach (Mercury.Server.Application.SearchResultProvider currentSearchResultProvider in searchResultProviders)
                        {
                            // CREATE REFERENCE TO NEW RAD COMBO BOX ITEM WITH TEXT AS NAME OF CURRENT PROVIDER AND VALUE AS PROVIDER ID OF CURRENT PROVIDER

                            Telerik.Web.UI.RadComboBoxItem newRadComboBoxItem = new Telerik.Web.UI.RadComboBoxItem(currentSearchResultProvider.Name, currentSearchResultProvider.ProviderId.ToString() + "|" + currentMemberCaseProblemClassId);

                            // ADD NEW RAD COMBO BOX ITEMS TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX

                            currentProblemClassAssignedToProviderSelection.Items.Add(newRadComboBoxItem);
                        } /* END FOREACH */
                    }

                    // IF COUNT OF SEARCH RESULT PROVIDERS IS GREATER THAN 25, THEN ADD RAD COMBO BOX ITEM THAT INDICATES TO USER THAT TOO MANY PROVIDERS WERE RETURNED

                    else if (searchResultProviders.Count() > 25)
                    {
                        // CREATE REFERENCE TO NEW RAD COMBO BOX ITEM WITH TEXT AS EXPLANATION TO USER THAT TOO MANY PROVIDERS WERE RETURNED AND VALUE AS 0

                        Telerik.Web.UI.RadComboBoxItem newRadComboBoxItem = new Telerik.Web.UI.RadComboBoxItem("**Too many providers returned (" + searchResultProviders.Count().ToString() + ". Please narrow search by entering more letters.", "0|0");

                        // ADD NEW RAD COMBO BOX ITEMS TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX

                        currentProblemClassAssignedToProviderSelection.Items.Add(newRadComboBoxItem);
                    }

                    // IF COUNT OF SEARCH RESULT PROVIDERS IS EQUAL TO 0, THEN ADD RAD COMBO BOX ITEM THAT INDICATES TO USER THAT NO PROVIDERS WERE RETURNED

                    else if (searchResultProviders.Count() == 0)
                    {
                        // CREATE REFERENCE TO NEW RAD COMBO BOX ITEM WITH TEXT AS EXPLANATION TO USER THAT NO PROVIDERS WERE RETURNED AND VALUE AS 0

                        Telerik.Web.UI.RadComboBoxItem newRadComboBoxItem = new Telerik.Web.UI.RadComboBoxItem("**No providers returned. Please widen search by entering fewer letters.", "0|0");

                        // ADD NEW RAD COMBO BOX ITEMS TO CURRENT PROBLEM CLASS ASSIGNED TO PROVIDER SELECTION RAD COMBO BOX

                        currentProblemClassAssignedToProviderSelection.Items.Add(newRadComboBoxItem);
                    }
                }
            }

            return;
        }