Exemplo n.º 1
0
        public RadComboBoxItemData[] GetVehicles(RadComboBoxContext context)
        {
            List <RadComboBoxItemData> result = new List <RadComboBoxItemData>();

            // If the context contains a "TopItemText" key then add to a the top of the result list an item containing this text (for example "- all -" or "- select -")
            // But only if the list is currently empty. If they have clicked the ShowMoreResultsBox arrow, we don't want to add another "- all -"
            bool hasTopItemText = false;
            var  topItemText    = context.ContainsKey("TopItemText") ? context["TopItemText"].ToString() : string.Empty;

            hasTopItemText = !string.IsNullOrWhiteSpace(topItemText);

            if (hasTopItemText && context.NumberOfItems == 0)
            {
                result.Add(new Telerik.Web.UI.RadComboBoxItemData {
                    Text = topItemText
                });
            }

            string[] clientArgs = context["FilterString"].ToString().Split(':');
            int      depotID    = int.Parse(clientArgs[0]);

            var query = (context.ContainsKey("Text") && context.Text != topItemText) ? context.Text : string.Empty;

            Facade.IResource facResource = new Facade.Resource();
            DataSet          ds          = facResource.GetAllResourcesFiltered(query, eResourceType.Vehicle, depotID, false, true);

            int itemsPerRequest = 20;
            int itemOffset      = context.NumberOfItems;

            // If the list contains a Top Item (e.g. -All-) and the list is already populated (the ShowMoreResultsBox has been clicked), do not include the Top Item or the offset will skip a vehicle.
            if (hasTopItemText && context.NumberOfItems > 0)
            {
                itemOffset--;
            }

            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.RadComboBoxItemData rcItem = null;
            for (int i = itemOffset; i < endOffset; i++)
            {
                rcItem       = new Telerik.Web.UI.RadComboBoxItemData();
                rcItem.Text  = dt.Rows[i]["Description"].ToString();
                rcItem.Value = dt.Rows[i]["ResourceId"].ToString();
                result.Add(rcItem);
            }

            return(result.ToArray());
        }
Exemplo n.º 2
0
        public RadComboBoxItemData[] GetClients(RadComboBoxContext context)
        {
            List <RadComboBoxItemData> result = new List <RadComboBoxItemData>();

            // If the context contains a "TopItemText" key then add to a the top of the result list an item containing this text (for example "- all -" or "- select -")
            var topItemText = context.ContainsKey("TopItemText") ? context["TopItemText"].ToString() : string.Empty;

            if (!string.IsNullOrWhiteSpace(topItemText))
            {
                result.Add(new Telerik.Web.UI.RadComboBoxItemData {
                    Text = topItemText
                });
            }

            bool includeSuspended = false;

            if (context.ContainsKey("DisplaySuspended"))
            {
                includeSuspended = context["DisplaySuspended"] == null ? false : context["DisplaySuspended"].ToString() == "False" ? false : true;
            }

            var query = (context.ContainsKey("Text") && context.Text != topItemText) ? context.Text : string.Empty;

            Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData();
            DataSet ds = facRefData.GetAllClientsFiltered(query, includeSuspended);

            int itemsPerRequest = 20;
            int itemOffset      = context.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.RadComboBoxItemData rcItem = null;
            for (int i = itemOffset; i < endOffset; i++)
            {
                rcItem       = new Telerik.Web.UI.RadComboBoxItemData();
                rcItem.Text  = dt.Rows[i]["OrganisationName"].ToString();
                rcItem.Value = dt.Rows[i]["IdentityId"].ToString();
                result.Add(rcItem);
            }

            return(result.ToArray());
        }
Exemplo n.º 3
0
        public RadComboBoxItemData[] GetAllDrivers(RadComboBoxContext context)
        {
            List <RadComboBoxItemData> result = new List <RadComboBoxItemData>();

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

            var itemsPerRequest = context.ContainsKey("ItemsPerRequest") ? (int)context["ItemsPerRequest"] : 20;

            DataTable dt        = ds.Tables[0];
            var       itemCount = dt.Rows.Count;

            int itemOffset = context.NumberOfItems;
            int endOffset  = itemsPerRequest == 0 ? itemCount : itemOffset + itemsPerRequest;

            if (endOffset > itemCount)
            {
                endOffset = itemCount;
            }

            for (int i = itemOffset; i < endOffset; i++)
            {
                var rcItem = new Telerik.Web.UI.RadComboBoxItemData();
                rcItem.Text  = dt.Rows[i]["Description"].ToString();
                rcItem.Value = dt.Rows[i]["ResourceId"].ToString();
                result.Add(rcItem);
            }

            return(result.ToArray());
        }
Exemplo n.º 4
0
    public static RadComboBoxData GetEmployeeList(RadComboBoxContext context)
    {
        RadComboBoxData comboData = new RadComboBoxData();

        try
        {
            string keyword  = context.Text;
            int    pageFrom = context.NumberOfItems;
            int    pageSize = 10;

            int?departmentId = null;
            if (context.ContainsKey("DepartmentId") && context["DepartmentId"] != null)
            {
                departmentId = Convert.ToInt32(context["DepartmentId"]);
            }

            var employees = EmployeeManager.GetEmployees(pageFrom, pageSize, departmentId, context.Text, null, true);

            if (employees != null)
            {
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>();

                foreach (var item in employees)
                {
                    RadComboBoxItemData itemData = new RadComboBoxItemData();
                    itemData.Text  = item.EmployeeName;
                    itemData.Value = Convert.ToString(item.EmployeeId);
                    result.Add(itemData);
                }

                int totalCount = employees[0].TotalCount;
                int itemOffset = context.NumberOfItems;
                int endOffset  = itemOffset + totalCount;
                comboData.EndOfItems = totalCount < pageSize;
                //comboData.Message = GetStatusMessagecustom(endOffset);
                comboData.Items = result.ToArray();
            }
            return(comboData);
        }
        catch (Exception ex)
        {
            return(comboData);
        }
    }