public RadComboBoxData GetCompanyNames(RadComboBoxContext context)
    {
        List<ComboBoxItemData> data = GetData(context.Text);

        RadComboBoxData comboData = new RadComboBoxData();
        int itemOffset = context.NumberOfItems;
        int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Count);
        comboData.EndOfItems = endOffset == data.Count;

        List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(endOffset - itemOffset);

        for (int i = itemOffset; i < endOffset; i++)
        {
            RadComboBoxItemData itemData = new RadComboBoxItemData();
            itemData.Text = data[i].CompanyName;
            itemData.Value = data[i].CompanyId.ToString();
            itemData.Attributes["Branch"] = data[i].BranchName;
            itemData.Attributes["Site"] = data[i].SiteName;

            result.Add(itemData);
        }

        comboData.Message = GetStatusMessage(endOffset, data.Count);

        comboData.Items = result.ToArray();
        return comboData;
    }
    public RadComboBoxData GetCompanyNames(RadComboBoxContext context)
    {
        List <ComboBoxItemData> data = GetData(context.Text);

        RadComboBoxData comboData  = new RadComboBoxData();
        int             itemOffset = context.NumberOfItems;
        int             endOffset  = Math.Min(itemOffset + ItemsPerRequest, data.Count);

        comboData.EndOfItems = endOffset == data.Count;

        List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(endOffset - itemOffset);

        for (int i = itemOffset; i < endOffset; i++)
        {
            RadComboBoxItemData itemData = new RadComboBoxItemData();
            itemData.Text  = data[i].CompanyName;
            itemData.Value = data[i].CompanyId.ToString();
            itemData.Attributes["Branch"] = data[i].BranchName;
            itemData.Attributes["Site"]   = data[i].SiteName;

            result.Add(itemData);
        }

        comboData.Message = GetStatusMessage(endOffset, data.Count);

        comboData.Items = result.ToArray();
        return(comboData);
    }
Example #3
0
        public RadComboBoxData FillRadComboData4AssignPartner(RadComboBoxContext context, string strClientCode)
        {
            RadComboBoxData comboData = new RadComboBoxData();

            DataTable dtPartnerData = GetPartner4AssignPartnerCombo(context["PartnerCode"].ToString(), context.Text.ToString(), strClientCode).Tables[0];

            if (dtPartnerData != null)
            {
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > dtPartnerData.Rows.Count)
                    {
                        endOffset = dtPartnerData.Rows.Count;
                    }
                    if (endOffset == dtPartnerData.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>();

                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();

                        String itemText = dtPartnerData.Rows[i]["PartnerCode"].ToString().Trim() + " " + dtPartnerData.Rows[i]["PartnerName"].ToString();
                        itemData.Text  = itemText;
                        itemData.Value = dtPartnerData.Rows[i]["PartnerCode"].ToString().Trim();
                        itemData.Attributes["PartnerCode"]     = dtPartnerData.Rows[i]["PartnerCode"].ToString().Trim();
                        itemData.Attributes["PartnerName"]     = dtPartnerData.Rows[i]["PartnerName"].ToString().Trim();
                        itemData.Attributes["PartnerTypeCode"] = dtPartnerData.Rows[i]["PartnerTypeCode"].ToString().Trim();

                        result.Add(itemData);
                    }

                    if (dtPartnerData.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dtPartnerData.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }
                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }
            return(comboData);
        }
        public RadComboBoxData GetComboItems([FromBody]RadComboBoxContext context)
        {
            string text = "";
            int numberOfItems = 0;

            foreach (var item in context)
            {
                JToken token = JObject.Parse(item.Value.ToString());
                text = (string)token.SelectToken("Text");
                numberOfItems = (int)token.SelectToken("NumberOfItems");
            }

            List<Product> products = GetProducts(text);

            RadComboBoxData comboData = new RadComboBoxData();
            int itemOffset = numberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, products.Count);
            comboData.EndOfItems = endOffset == products.Count;

            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>();

            for (int i = itemOffset; i < endOffset; i++)
            {
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text = products[i].Name;
                itemData.Value = products[i].Id.ToString();

                result.Add(itemData);
            }

            comboData.Message = GetStatusMessage(endOffset, products.Count);

            comboData.Items = result.ToArray();
            return comboData;
        }
Example #5
0
        public RadComboBoxItemData[] GetProductsByModel(RadComboBoxContext context)
        {
            List <RadComboBoxItemData> suggestions = new List <RadComboBoxItemData>(context.NumberOfItems);

            if (context != null && !string.IsNullOrEmpty(context.Text))
            {
                var products = new ProductRepository().GetByModel(context.Text);

                RadComboBoxData data = new RadComboBoxData();
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > products.Count)
                    {
                        endOffset = products.Count;
                    }
                    if (endOffset == products.Count)
                    {
                        data.EndOfItems = true;
                    }
                    else
                    {
                        data.EndOfItems = false;
                    }
                    suggestions = new List <RadComboBoxItemData>(endOffset - itemOffset);
                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        itemData.Text  = products[i].PartNumber;
                        itemData.Value = products[i].ID.ToString();

                        suggestions.Add(itemData);
                    }

                    if (products.Count > 0)
                    {
                        data.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), products.Count.ToString());
                    }
                    else
                    {
                        data.Message = "No matches";
                    }
                }
                catch (Exception e)
                {
                    data.Message = e.Message;
                }

                data.Items = suggestions.ToArray();
                return(data.Items);
            }
            return(suggestions.ToArray());
        }
Example #6
0
        public RadComboBoxData LoadStoreDDL(RadComboBoxContext context)
        {
            //The RadComboBoxData object contains all required information for load on demand:
            // - the items
            // - are there more items in case of paging
            // - status message to be displayed (which is optional)
            RadComboBoxData result = new RadComboBoxData();

            LookupDAO lkp = new LookupDAO();

            List <KeyValuePair <string, string> > stores = lkp.GetStore();

            //Get all items from the Customers table. This query will not be executed untill the ToArray method is called.
            var allStores = from store in stores
                            orderby store.Key, store.Value
                select new RadComboBoxItemData
            {
                Text  = store.Key + " - " + store.Value,
                Value = store.Key
            };


            //In case the user typed something - filter the result set
            string text = context.Text;

            if (!String.IsNullOrEmpty(text))
            {
                allStores = allStores.Where(item => item.Text.StartsWith(text));
            }
            //Perform the paging
            // - first skip the amount of items already populated
            // - take the next 10 items
            int numberOfItems = context.NumberOfItems;
            var storelist     = allStores.Skip(numberOfItems).Take(10);

            //This will execute the database query and return the data as an array of RadComboBoxItemData objects
            result.Items = storelist.ToArray();


            int endOffset  = numberOfItems + storelist.Count();
            int totalCount = allStores.Count();

            //Check if all items are populated (this is the last page)
            if (endOffset == totalCount)
            {
                result.EndOfItems = true;
            }

            //Initialize the status message
            result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>",
                                           endOffset, totalCount);

            return(result);
        }
Example #7
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);
        }
    }
 public RadComboBoxData GetCoworker(RadComboBoxContext context)
 {
     if (context.Text.Length > 1)
     {
         RadComboBoxData            comboData = new RadComboBoxData();
         List <RadComboBoxItemData> result    = new List <RadComboBoxItemData>();
         string searchterm = context.Text.ToLower();
         foreach (v_ad_user_creation pos in repo.Query.Where(p => p.Fullname.ToLower().Substring(0, searchterm.Length).Equals(searchterm) && p.User_fk != null))
         {
             RadComboBoxItemData item = new RadComboBoxItemData();
             item.Text  = pos.Fullname + " -- " + pos.Orgunit + " -- " + pos.Position;
             item.Value = pos.samaccount;
             result.Add(item);
         }
         comboData.Items = result.ToArray();
         return(comboData);
     }
     return(null);
 }
 public RadComboBoxData GetEmployee(RadComboBoxContext context)
 {
     if (context.Text.Length > 1)
     {
         RadComboBoxData            comboData = new RadComboBoxData();
         List <RadComboBoxItemData> result    = new List <RadComboBoxItemData>();
         string searchterm = context.Text.ToLower(); //p.User_fk == null &&
         foreach (v_ad_user_creation pos in repo.Query.Where(p => p.User_fk == null && p.Fullname.ToLower().Substring(0, searchterm.Length).Equals(searchterm)))
         {
             RadComboBoxItemData item = new RadComboBoxItemData();
             item.Text  = pos.Fullname + " -- " + pos.Orgunit + " -- " + pos.Position + " -- MedNR: " + pos.Opus_id;
             item.Value = pos.Opus_id.ToString();
             result.Add(item);
         }
         comboData.Items = result.ToArray();
         return(comboData);
     }
     return(null);
 }
        public RadComboBoxData GetComboItems([FromBody] RadComboBoxContext context)
        {
            string text          = "";
            int    numberOfItems = 0;

            foreach (var item in context)
            {
                JToken token = JObject.Parse(item.Value.ToString());
                text          = (string)token.SelectToken("Text");
                numberOfItems = (int)token.SelectToken("NumberOfItems");
            }

            List <Product> products = GetProducts(text);

            RadComboBoxData comboData  = new RadComboBoxData();
            int             itemOffset = numberOfItems;
            int             endOffset  = Math.Min(itemOffset + ItemsPerRequest, products.Count);

            comboData.EndOfItems = endOffset == products.Count;

            List <RadComboBoxItemData> result = new List <RadComboBoxItemData>();

            for (int i = itemOffset; i < endOffset; i++)
            {
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text  = products[i].Name;
                itemData.Value = products[i].Id.ToString();

                result.Add(itemData);
            }

            comboData.Message = GetStatusMessage(endOffset, products.Count);

            comboData.Items = result.ToArray();
            return(comboData);
        }
Example #11
0
        public RadComboBoxData GetExerciseListOnDemand(RadComboBoxContext context)
        {
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
            RadComboBoxData comboData = new RadComboBoxData();
            try
            {
                int itemsPerRequest = 15;
                int itemOffset = context.NumberOfItems;
                int endOffset = itemOffset + itemsPerRequest;

                aqufitEntities entities = new aqufitEntities();

                IQueryable<Exercise> erercisesQuery = string.IsNullOrEmpty(context.Text) ?
                        entities.Exercises.OrderBy(e => e.Name) :
                        entities.Exercises.Where(e => e.Name.ToLower().StartsWith(context.Text)).OrderBy(e => e.Name);
                int length = erercisesQuery.Count();
                Exercise[] exercises = erercisesQuery.Skip(itemOffset).Take(itemsPerRequest).ToArray();
                foreach (Exercise exer in exercises)
                {
                    RadComboBoxItemData item = new RadComboBoxItemData();
                    item.Text = exer.Name;
                    item.Value = "" + exer.Id;
                    result.Add(item);
                }
                if (endOffset > length)
                {
                    endOffset = length;
                }
                if (endOffset == length)
                {
                    comboData.EndOfItems = true;
                }
                else
                {
                    comboData.EndOfItems = false;
                }
                if (length > 0)
                {
                    comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length);
                }
                else
                {
                    comboData.Message = "No matches";
                }
                comboData.Items = result.ToArray();
            }
            catch (Exception ex)
            {
                comboData.Message = ex.Message;
            }
            return comboData;
        }
        public RadComboBoxData FillRadComboData(RadComboBoxContext context, string strClientCode)
        {
            RadComboBoxData comboData = new RadComboBoxData();

            DataTable dtMaterialData = GetSalesOrderDetail4Combo(context.Text.ToString(), context["SODocCode"].ToString().Trim(), strClientCode).Tables[0];

            if (dtMaterialData != null)
            {
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > dtMaterialData.Rows.Count)
                    {
                        endOffset = dtMaterialData.Rows.Count;
                    }
                    if (endOffset == dtMaterialData.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>();

                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();

                        String itemText = dtMaterialData.Rows[i]["MaterialCode"].ToString() + " " + dtMaterialData.Rows[i]["MatDesc"].ToString();

                        itemData.Text  = itemText;
                        itemData.Value = dtMaterialData.Rows[i]["SOItemNo"].ToString().Trim();
                        itemData.Attributes["MatDesc"]          = dtMaterialData.Rows[i]["MatDesc"].ToString();
                        itemData.Attributes["MaterialTypeCode"] = dtMaterialData.Rows[i]["MaterialTypeCode"].ToString().Trim();
                        itemData.Attributes["MatGroup1Code"]    = dtMaterialData.Rows[i]["MatGroup1Code"].ToString().Trim();
                        itemData.Attributes["MatGroup2Code"]    = dtMaterialData.Rows[i]["MatGroup2Code"].ToString().Trim();
                        itemData.Attributes["UOMCode"]          = dtMaterialData.Rows[i]["UOMCode"].ToString();
                        itemData.Attributes["ValClassType"]     = dtMaterialData.Rows[i]["ValClassType"].ToString();
                        itemData.Attributes["NetWeight"]        = dtMaterialData.Rows[i]["NetWeight"].ToString();
                        itemData.Attributes["GrossWeight"]      = dtMaterialData.Rows[i]["GrossWeight"].ToString();
                        itemData.Attributes["NetPriceperQty"]   = dtMaterialData.Rows[i]["PriceUnit"].ToString();

                        result.Add(itemData);
                    }

                    if (dtMaterialData.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dtMaterialData.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }
                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }
            return(comboData);
        }
Example #13
0
        public RadComboBoxData GetStudentsMobileDept(RadComboBoxContext context)
        {
            string searchtext = string.Empty;

            searchtext = Convert.ToString(context.Text);

            RadComboBoxData comboData = new RadComboBoxData();


            if (HttpContext.Current.Session["GlobalValueKey"] != null)
            {
                DataTable data = new DataTable();

                using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["GlobalValueKey"])))
                {
                    using (SqlCommand CMD = new SqlCommand())
                    {
                        //Last Name,First Name,Status
                        string strqry = string.Empty;
                        strqry          = strqry + " select  S.StudentID,S.LastName+', '+ S.FirstName  as FullName,convert(varchar(50), S.StudentNo) as StudentNo,  ";
                        strqry          = strqry + " (Select StudentStatus from StudentStatus where StudentStatusID=S.StudentStatusID) as StudentStatus  ";
                        strqry          = strqry + "  ,S.MobilePhone from Students AS S  ";
                        strqry          = strqry + " where  ( S.MobilePhone is not null and  S.MobilePhone<>'') and (S.LastName+', '+ S.FirstName  like '" + searchtext + "%' ";
                        strqry          = strqry + " or (Select StudentStatus from StudentStatus where StudentStatusID=S.StudentStatusID) like '" + searchtext + "%' or  S.MobilePhone  like '" + searchtext + "%') ";
                        strqry          = strqry + "   ORDER BY S.LastName+', '+ S.FirstName ";
                        CMD.Connection  = connection;
                        CMD.CommandType = System.Data.CommandType.Text;
                        CMD.CommandText = strqry;
                        CMD.Prepare();
                        SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD);
                        DataAdapter.Fill(data);
                    }
                }
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > data.Rows.Count)
                    {
                        endOffset = data.Rows.Count;
                    }
                    if (endOffset == data.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>(endOffset - itemOffset);


                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        //  itemData.Text = Convert.ToString(data.Rows[i]["FullName"]);
                        string itemtext = string.Empty;
                        itemtext       = itemtext + "<ul>";
                        itemtext       = itemtext + "<li class='SMScol1'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["FullName"]) + "</li>";
                        itemtext       = itemtext + "<li class='SMScol2'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["MobilePhone"]) + "</li>";
                        itemtext       = itemtext + "<li class='SMScol3'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["StudentStatus"]) + "</li>   ";
                        itemtext       = itemtext + "</ul>";
                        itemData.Text  = itemtext;
                        itemData.Value = Convert.ToString(data.Rows[i]["MobilePhone"]);

                        result.Add(itemData);
                    }



                    if (data.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }

                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }

            return(comboData);
        }
Example #14
0
        public RadComboBoxData FillRadComboData(RadComboBoxContext context, string strClientCode)
        {
            RadComboBoxData comboData = new RadComboBoxData();

            DataTable dtCustData = GetCustomer4Combo(context.Text.ToString(), context["SalesOfficeCode"].ToString().Trim(), strClientCode).Tables[0];

            if (dtCustData != null)
            {
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > dtCustData.Rows.Count)
                    {
                        endOffset = dtCustData.Rows.Count;
                    }
                    if (endOffset == dtCustData.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>();

                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();

                        String itemText = dtCustData.Rows[i]["CustomerCode"].ToString() + " " + dtCustData.Rows[i]["Name1"].ToString();
                        itemData.Text  = itemText;
                        itemData.Value = dtCustData.Rows[i]["CustomerCode"].ToString();
                        itemData.Attributes["CustomerCode"]          = dtCustData.Rows[i]["CustomerCode"].ToString();
                        itemData.Attributes["Name1"]                 = dtCustData.Rows[i]["Name1"].ToString();
                        itemData.Attributes["StateCode"]             = dtCustData.Rows[i]["StateCode"].ToString();
                        itemData.Attributes["SalesDistrictCode"]     = dtCustData.Rows[i]["SalesDistrictCode"].ToString();
                        itemData.Attributes["SalesRegionCode"]       = dtCustData.Rows[i]["SalesRegionCode"].ToString();
                        itemData.Attributes["SalesOfficeCode"]       = dtCustData.Rows[i]["SalesOfficeCode"].ToString();
                        itemData.Attributes["SalesGroupCode"]        = dtCustData.Rows[i]["SalesGroupCode"].ToString();
                        itemData.Attributes["VATNo"]                 = dtCustData.Rows[i]["VATNo"].ToString();
                        itemData.Attributes["IsTaxExempted"]         = dtCustData.Rows[i]["IsTaxExempted"].ToString();
                        itemData.Attributes["SalesOrganizationCode"] = dtCustData.Rows[i]["SalesOrganizationCode"].ToString();
                        itemData.Attributes["DistChannelCode"]       = dtCustData.Rows[i]["DistChannelCode"].ToString();
                        itemData.Attributes["DivisionCode"]          = dtCustData.Rows[i]["DivisionCode"].ToString();
                        itemData.Attributes["CurrencyCode"]          = dtCustData.Rows[i]["CurrencyCode"].ToString();
                        result.Add(itemData);
                    }

                    if (dtCustData.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dtCustData.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }
                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }
            return(comboData);
        }
Example #15
0
        public RadComboBoxData GetStandardWorkoutsOnDemand(RadComboBoxContext context)
        {
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
            RadComboBoxData comboData = new RadComboBoxData();
            try
            {
                int itemsPerRequest = 10;
                int itemOffset = context.NumberOfItems;
                int endOffset = itemOffset + itemsPerRequest;

                long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]);
                aqufitEntities entities = new aqufitEntities();

                UserSettings UserSettings = entities.UserSettings.FirstOrDefault(u => u.Id == ProfileUserSettingsId);
                IQueryable<WOD> wods = entities.WODs.Where(w => w.Standard > 0);
                wods.Select(w => w.WODType).ToArray();  // hydrate WODTypes

                string lowerTxt = context.Text.ToLower();
                if (!string.IsNullOrWhiteSpace(context.Text))
                {
                    wods = wods.Where(w => w.Name.ToLower().Contains(lowerTxt) || w.WODSchedules.Where(ws => ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0).Any(ws => ws.HiddenName.ToLower().Contains(lowerTxt))).OrderBy(w => w.Name);
                }
                else
                {
                    wods = wods.OrderByDescending(w => w.CreationDate);
                }
                int length = wods.Count();
                wods = wods.Skip(itemOffset).Take(itemsPerRequest);
                WOD[] wodList = wods.ToArray();
                for (int i = 0; i < wodList.Length; i++)
                {
                    WOD w = wodList[i];
                    if (w.WODSchedules != null && w.WODSchedules.Count > 0)
                    {
                        WODSchedule ws = w.WODSchedules.OrderByDescending(s => s.HideTillDate).First();
                        if (ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0)
                        {
                            if (string.IsNullOrWhiteSpace(context.Text))
                            {
                                result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                                if (w.Standard > 0 || w.WODSchedules.Count > 1)
                                {   // CA - here is what is going on here.  If the workout is suppost to be hidden until a date (common for crossfit gyms) then we just put a date name like up
                                    // top.  But if it is a standard WOD (or a wod that they have done before (w.WODSchedules.Count > 1) then we still need to add the WOD
                                    result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                                }
                            }
                            else if (ws.HiddenName.ToLower().StartsWith(lowerTxt))
                            {
                                result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                            }
                        }
                        else
                        {
                            result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                        }
                    }
                    else
                    {
                        result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                    }
                }
                if (endOffset > length)
                {
                    endOffset = length;
                }
                if (endOffset == length)
                {
                    comboData.EndOfItems = true;
                }
                else
                {
                    comboData.EndOfItems = false;
                }
                if (length > 0)
                {
                    comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length);
                }
                else
                {
                    comboData.Message = "No matches";
                }
                comboData.Items = result.ToArray();
            }
            catch (Exception ex)
            {
                comboData.Message = ex.Message;
            }
            return comboData;
        }
Example #16
0
        public RadComboBoxData GetLeadsMobileDept(RadComboBoxContext context)
        {
            string searchtext = string.Empty;

            searchtext = Convert.ToString(context.Text);

            RadComboBoxData comboData = new RadComboBoxData();


            if (HttpContext.Current.Session["GlobalValueKey"] != null)
            {
                DataTable data = new DataTable();

                using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["GlobalValueKey"])))
                {
                    using (SqlCommand CMD = new SqlCommand())
                    {
                        //Last Name,First Name,Status
                        string strqry = string.Empty;
                        strqry = strqry + " SELECT    ";
                        strqry = strqry + " (L.LName + ', ' + L.FName + CASE WHEN LEN(L.MInitial) > 0 Then ' ' + L.MInitial Else '' End) As FullName ,  ";
                        strqry = strqry + " ISNULL(L.StatusCode,'') AS Status,L.PhoneMobile as   MobilePhone ";
                        strqry = strqry + " FROM Lead AS L LEFT JOIN LeadStatus AS LS ON L.StatusCode = LS.StatusCode   LEFT JOIN Employees AS E  ";
                        strqry = strqry + " ON L.EmpID = E.EmpID    ";
                        strqry = strqry + " where (L.PhoneMobile is not null and L.PhoneMobile<>'') and ( L.LName + ', ' + L.FName like '" + searchtext + "%' or L.StatusCode like  '" + searchtext + "%' or L.PhoneMobile like  '" + searchtext + "%')      ";
                        strqry = strqry + " ORDER BY L.LName + ', ' + L.FName    ";

                        CMD.Connection  = connection;
                        CMD.CommandType = System.Data.CommandType.Text;
                        CMD.CommandText = strqry;
                        CMD.Prepare();
                        SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD);
                        DataAdapter.Fill(data);
                    }
                }
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > data.Rows.Count)
                    {
                        endOffset = data.Rows.Count;
                    }
                    if (endOffset == data.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>(endOffset - itemOffset);

                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        //  itemData.Text = Convert.ToString(data.Rows[i]["FullName"]);
                        string itemtext = string.Empty;
                        itemtext       = itemtext + "<ul>";
                        itemtext       = itemtext + "<li class='SMScol1'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["FullName"]) + "</li>";
                        itemtext       = itemtext + "<li class='SMScol2'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["MobilePhone"]) + "</li>";
                        itemtext       = itemtext + "<li class='SMScol3'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["Status"]) + "</li>   ";
                        itemtext       = itemtext + "</ul>";
                        itemData.Text  = itemtext;
                        itemData.Value = Convert.ToString(data.Rows[i]["MobilePhone"]);

                        result.Add(itemData);
                    }



                    if (data.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }

                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }

            return(comboData);
        }
Example #17
0
        public RadComboBoxData GetGroupSearch(RadComboBoxContext context)
        {
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
            RadComboBoxData comboData = new RadComboBoxData();
            if (!string.IsNullOrWhiteSpace(context.Text))
            {
                try
                {
                    const int TAKE = 15;
                    aqufitEntities entities = new aqufitEntities();
                    int itemOffset = context.NumberOfItems;
                    IQueryable<Group> friends = entities.UserSettings.OfType<Group>().OrderBy(w => w.UserName);
                    friends = friends.Where(w => w.UserName.ToLower().Contains(context.Text) || w.UserFirstName.ToLower().Contains(context.Text));
                    int length = friends.Count();
                    friends = friends.Skip(itemOffset).Take(TAKE);
                    Group[] groups = friends.ToArray();

                    foreach (Group g in groups)
                    {
                        RadComboBoxItemData item = new RadComboBoxItemData();
                        item.Text = g.UserFirstName;
                        item.Value = " { 'Address': '', 'GroupKey':" + g.Id + ", 'Lat':" + g.DefaultMapLat + ", 'Lng':" + g.DefaultMapLng + " , 'Name':'" + g.UserFirstName + "', 'UserName':'******'", "") + "', 'UserKey':" + g.UserKey + ", 'ImageId':0, 'Description':'' }";
                        //   item.ImageUrl = ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?u=" + g.UserKey + "&p=" + g.PortalKey;
                        result.Add(item);
                    }
                    int endOffset = Math.Min(itemOffset + TAKE + 1, length);
                    if (endOffset > length)
                    {
                        endOffset = length;
                    }
                    if (endOffset == length)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    if (length > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length);
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                    comboData.Items = result.ToArray();
                }
                catch (Exception ex)
                {
                    comboData.Message = ex.Message;
                }
            }
            else
            {
                comboData.Message = "Type to search";
            }
            return comboData;
        }
Example #18
0
        public RadComboBoxData GetRoutesOnDemand(RadComboBoxContext context)
        {
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
            RadComboBoxData comboData = new RadComboBoxData();
            try
            {
                int itemsPerRequest = 10;
                int itemOffset = context.NumberOfItems;
                int endOffset = itemOffset + itemsPerRequest;

                long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]);
                aqufitEntities entities = new aqufitEntities();

                UserSettings UserSettings = entities.UserSettings.FirstOrDefault(u => u.Id == ProfileUserSettingsId);
                IQueryable<MapRoute> mapRoutesQuery = string.IsNullOrEmpty(context.Text) ?
                        entities.User2MapRouteFav.Include("MapRoutes").Where(r => r.UserSettingsKey == ProfileUserSettingsId).Select(r => r.MapRoute).OrderBy(w => w.Name) :
                        entities.User2MapRouteFav.Include("MapRoutes").Where(r => r.UserSettingsKey == ProfileUserSettingsId).Select(r => r.MapRoute).Where(r => r.Name.ToLower().StartsWith(context.Text)).OrderBy(r => r.Name);
                int length = mapRoutesQuery.Count();
                MapRoute[] mapRoutes = mapRoutesQuery.Skip(itemOffset).Take(itemsPerRequest).ToArray();
                string mapIcon = ResolveUrl("~/DesktopModules/ATI_Base/resources/images/iMap.png");
                if (itemOffset == 0)
                {
                    RadComboBoxItemData item = new RadComboBoxItemData();
                    item.Text = "<img src=\"" + mapIcon + "\" /> Add New Map";
                    item.Value = "{'Id':0, 'Dist':'0'}";
                    result.Add(item);
                }
                Affine.Utils.UnitsUtil.MeasureUnit unit = UserSettings.DistanceUnits != null ? Affine.Utils.UnitsUtil.ToUnit(Convert.ToInt32(UserSettings.DistanceUnits)) : Affine.Utils.UnitsUtil.MeasureUnit.UNIT_MILES;
                string unitName = Affine.Utils.UnitsUtil.unitToStringName(unit);
                foreach (MapRoute mr in mapRoutes)
                {
                    double dist = Affine.Utils.UnitsUtil.systemDefaultToUnits(mr.RouteDistance, unit);
                    dist = Math.Round(dist, 2);
                    RadComboBoxItemData item = new RadComboBoxItemData();
                    item.Text = "<img src=\"" + Affine.Utils.ImageUtil.GetGoogleMapsStaticImage(mr, 200, 150) + "\" />" + Affine.Utils.Web.WebUtils.FromWebSafeString(mr.Name) + " (" + dist + " " + unitName + ")";
                    item.Value = "{ 'Id':" + mr.Id + ", 'Dist':" + mr.RouteDistance + "}";
                    result.Add(item);
                }
                if (endOffset > length)
                {
                    endOffset = length;
                }
                if (endOffset == length)
                {
                    comboData.EndOfItems = true;
                }
                else
                {
                    comboData.EndOfItems = false;
                }
                if (length > 0)
                {
                    comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length);
                }
                else
                {
                    comboData.Message = "No matches";
                }
                comboData.Items = result.ToArray();
            }
            catch (Exception ex)
            {
                comboData.Message = ex.Message;
            }
            return comboData;
        }
Example #19
0
        public RadComboBoxData GetFlexFWDSearch(RadComboBoxContext context)
        {
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
            RadComboBoxData comboData = new RadComboBoxData();
            if (!string.IsNullOrWhiteSpace(context.Text))
            {
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset = context.NumberOfItems;
                    int endOffset = itemOffset + itemsPerRequest;

                    long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]);
                    aqufitEntities entities = new aqufitEntities();

                    //UserSettings profileSettings = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.UserKey == PortalSettings.Current.UserId && u.PortalKey == PortalSettings.Current.PortalId);
                    IQueryable<UserSettings> friends = entities.UserSettings.Where(u => u.PortalKey == PortalSettings.Current.PortalId).OrderBy(w => w.UserName);
                    friends = friends.Where(w => w.UserName.ToLower().StartsWith(context.Text) || w.UserFirstName.ToLower().StartsWith(context.Text) || w.UserLastName.ToLower().StartsWith(context.Text));
                    int length = friends.Count();
                    var users = friends.Skip(itemOffset).Take(itemsPerRequest).Select(u => new {Id = u.Id, Type = (u is User ? "User" : "Group"), UserKey = u.UserKey, PortalKey = u.PortalKey, UserFirstName = u.UserFirstName, UserLastName = u.UserLastName, UserName = u.UserName }).ToArray();
                    foreach (var u in users)
                    {
                        RadComboBoxItemData item = new RadComboBoxItemData();
                        if (u.Type == "User")
                        {
                            item.Text = "<img style=\"float: left;\" src=\"" + StreamService.ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?u=" + u.UserKey + "&p=" + u.PortalKey + "\" /><span class=\"atiTmItem\">" + u.UserName + "<br /> (" + u.UserFirstName + " " + u.UserLastName + ")</span>";
                            item.Value = "{ Type:'USER', Val:'" + u.UserName + "'}";
                        }
                        else
                        {
                            item.Text = "<img style=\"float: left;\" src=\"" + StreamService.ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?us=" + u.Id + "\" /><span class=\"atiTmItem\">" + u.UserFirstName + "</span>";
                            item.Value = "{ Type:'GROUP', Val:'" + u.UserName + "'}";
                        }
                        result.Add(item);
                    }

                    if (endOffset > length)
                    {
                        endOffset = length;
                    }
                    if (endOffset == length)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    if (length > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length);
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                    comboData.Items = result.ToArray();
                }
                catch (Exception ex)
                {
                    comboData.Message = ex.Message;
                }
            }
            else
            {
                comboData.Message = "Type to search";
            }
            return comboData;
        }
Example #20
0
        public static RadComboBoxData GetFieldNames(RadComboBoxContext context)
        {
            var fields = new List<string>();
            if (HttpContext.Current.Session["Fields"] != null)
            {
                fields = (List<string>) HttpContext.Current.Session["Fields"];
            }
            var data = (from f in fields where f.ToLower().Contains(context.Text.ToLower()) select f).ToList();
            var comboData = new RadComboBoxData();
            var itemOffset = context.NumberOfItems;
            var endOffset = Math.Min(itemOffset + 10, data.Count);
            comboData.EndOfItems = endOffset == data.Count;

            var result = new List<RadComboBoxItemData>(endOffset - itemOffset);

            for (var i = itemOffset; i < endOffset; i++)
            {
                var itemData = new RadComboBoxItemData {Text = data.ElementAt(i), Value = data.ElementAt(i)};

                result.Add(itemData);
            }

            comboData.Message = GetStatusMessage(endOffset, data.Count);

            comboData.Items = result.ToArray();
            return comboData;
        }
Example #21
0
        public RadComboBoxData GetWorkoutsOnDemand(RadComboBoxContext context)
        {
            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
            RadComboBoxData comboData = new RadComboBoxData();
            try
            {
                int itemsPerRequest = 10;
                int itemOffset = context.NumberOfItems;
                int endOffset = itemOffset + itemsPerRequest;

                long ProfileUserSettingsId = Convert.ToInt64(context["UserSettingsId"]);
                aqufitEntities entities = new aqufitEntities();

                UserSettings UserSettings = entities.UserSettings.FirstOrDefault(u => u.Id == ProfileUserSettingsId);
                if (itemOffset == 0)
                {
                    RadComboBoxItemData item = new RadComboBoxItemData();
                    item.Text = "Create a New Workout";
                    item.Value = "{'Id':0, 'Type':'0'}";
                    result.Add(item);
                }
                IQueryable<WOD> wods = entities.User2WODFav.Where(w => w.UserSetting.Id == UserSettings.Id).Select(w => w.WOD);
                wods = wods.Union<WOD>(entities.WODs.Where(w => w.Standard > 0));
                wods.Select(w => w.WODType).ToArray();  // hydrate WODTypes

                long[] groupIds = null;
                groupIds = entities.UserFriends.Where(f => (f.SrcUserSettingKey == UserSettings.Id || f.DestUserSettingKey == UserSettings.Id) && f.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(f => f.SrcUserSettingKey == UserSettings.Id ? f.DestUserSettingKey : f.SrcUserSettingKey).ToArray();
                // OK this is a bit of a trick... this query hydrates only the "WODSchedule" in the above WOD query.. so we will get the wods we are looking for..
                IEnumerable<WODSchedule>[] workoutSchedule = entities.UserSettings.OfType<Group>().Where(LinqUtils.BuildContainsExpression<UserSettings, long>(us => us.Id, groupIds)).Select(g => g.WODSchedules.Where(ws => ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0)).ToArray();

                string lowerTxt = context.Text.ToLower();
                if (!string.IsNullOrWhiteSpace(context.Text))
                {
                    wods = wods.Where(w => w.Name.ToLower().Contains(lowerTxt) || w.WODSchedules.Where(ws => ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0).Any(ws => ws.HiddenName.ToLower().Contains(lowerTxt))).OrderBy(w => w.Name);
                }
                else
                {
                    wods = wods.OrderByDescending(w => w.CreationDate);
                }
                int length = wods.Count();
                wods = wods.Skip(itemOffset).Take(itemsPerRequest);
                WOD[] wodList = wods.ToArray();
                for (int i = 0; i < wodList.Length; i++)
                {
                    WOD w = wodList[i];
                    if (w.WODSchedules != null && w.WODSchedules.Count > 0)
                    {
                        WODSchedule ws = w.WODSchedules.OrderByDescending(s => s.HideTillDate).First();
                        if (ws.HideTillDate.HasValue && DateTime.Now.CompareTo(ws.HideTillDate.Value) < 0)
                        {
                            if (string.IsNullOrWhiteSpace(context.Text))
                            {
                                result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                                if (w.Standard > 0 || w.WODSchedules.Count > 1)
                                {   // CA - here is what is going on here.  If the workout is suppost to be hidden until a date (common for crossfit gyms) then we just put a date name like up
                                    // top.  But if it is a standard WOD (or a wod that they have done before (w.WODSchedules.Count > 1) then we still need to add the WOD
                                    result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                                }
                            }
                            else if (ws.HiddenName.ToLower().StartsWith(lowerTxt))
                            {
                                result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(ws.HiddenName), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                            }
                        }
                        else
                        {
                            result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                        }
                    }
                    else
                    {
                        result.Add(new RadComboBoxItemData() { Text = Affine.Utils.Web.WebUtils.FromWebSafeString(w.Name), Value = "{ 'Id':" + w.Id + ", 'Type':" + w.WODType.Id + "}" });
                    }
                }
                if (endOffset > length)
                {
                    endOffset = length;
                }
                if (endOffset == length)
                {
                    comboData.EndOfItems = true;
                }
                else
                {
                    comboData.EndOfItems = false;
                }
                if (length > 0)
                {
                    comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), length);
                }
                else
                {
                    comboData.Message = "No matches";
                }
                comboData.Items = result.ToArray();
            }
            catch (Exception ex)
            {
                comboData.Message = ex.Message;
            }
            return comboData;
        }
Example #22
0
        public RadComboBoxData GetSwitchLeads(RadComboBoxContext context)
        {
            string searchtext = string.Empty;

            searchtext = Convert.ToString(context.Text);
            RadComboBoxData comboData = new RadComboBoxData();

            if (HttpContext.Current.Session["Switchcampusconstring"] != null)
            {
                DataTable data = new DataTable();

                using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["Switchcampusconstring"])))
                {
                    using (SqlCommand CMD = new SqlCommand())
                    {
                        string strqry = string.Empty;


                        strqry          = strqry + "  SELECT    L.LeadsID as LeadsID,  ";
                        strqry          = strqry + " Lead = L.LName + ', ' + L.FName + CASE WHEN LEN(L.MInitial) > 0 Then ' ' + L.MInitial Else '' End ,  ";
                        strqry          = strqry + " ISNULL(L.StatusCode,'') AS LeadStatus, AdRep = E.LName + ', ' + E.FName, L.City, L.State, L.Zip, L.SSN  ";
                        strqry          = strqry + " FROM Lead AS L LEFT JOIN LeadStatus AS LS ON L.StatusCode = LS.StatusCode  ";
                        strqry          = strqry + " LEFT JOIN Employees AS E ON L.EmpID = E.EmpID  ";
                        strqry          = strqry + " where  L.LName + ', ' + L.FName like '" + searchtext + "%' or L.StatusCode like '" + searchtext + "%' ";
                        strqry          = strqry + " or E.LName + ', ' + E.FName like '" + searchtext + "%' or L.City like '" + searchtext + "%' or ";
                        strqry          = strqry + " L.State like '" + searchtext + "%' or L.Zip like '" + searchtext + "%' or L.SSN like '" + searchtext + "%' ";
                        strqry          = strqry + " ORDER BY L.LName + ', ' + L.FName + ' ' + ISNULL(L.MInitial,'')  ";
                        CMD.Connection  = connection;
                        CMD.CommandType = System.Data.CommandType.Text;
                        CMD.CommandText = strqry;
                        CMD.Prepare();
                        SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD);
                        DataAdapter.Fill(data);
                    }
                }
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);

                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > data.Rows.Count)
                    {
                        endOffset = data.Rows.Count;
                    }
                    if (endOffset == data.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>(endOffset - itemOffset);

                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        string itemtext = string.Empty;
                        itemtext       = itemtext + "<ul style='z-index:100'>";
                        itemtext       = itemtext + "<li class='Lcol1'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["Lead"]);
                        itemtext       = itemtext + "</li>";
                        itemtext       = itemtext + "<li class='Lcol2'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["LeadsID"]);
                        itemtext       = itemtext + "<li class='Lcol3'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["LeadStatus"]);
                        itemtext       = itemtext + "<li class='Lcol4'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["AdRep"]);
                        itemtext       = itemtext + "<li class='Lcol5'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["City"]);
                        itemtext       = itemtext + "<li class='Lcol6'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["State"]);
                        itemtext       = itemtext + "<li class='Lcol7'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["Zip"]);
                        itemtext       = itemtext + "</ul>";
                        itemData.Text  = itemtext;
                        itemData.Value = Convert.ToString(data.Rows[i]["LeadsID"]);

                        result.Add(itemData);
                    }

                    if (data.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }

                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }
            return(comboData);
        }
Example #23
0
        public RadComboBoxData GetSwitchStudents(RadComboBoxContext context)
        {
            string searchtext = string.Empty;

            searchtext = Convert.ToString(context.Text);

            RadComboBoxData comboData = new RadComboBoxData();


            if (HttpContext.Current.Session["Switchcampusconstring"] != null)
            {
                DataTable data = new DataTable();

                using (SqlConnection connection = new SqlConnection(Convert.ToString(HttpContext.Current.Session["Switchcampusconstring"])))
                {
                    using (SqlCommand CMD = new SqlCommand())
                    {
                        string strqry = string.Empty;
                        strqry          = strqry + " select  S.StudentID,S.LastName+', '+ S.FirstName  as FullName,convert(varchar(50), S.StudentNo) as StudentNo,  ";
                        strqry          = strqry + " (Select StudentStatus from StudentStatus where StudentStatusID=S.StudentStatusID) as StudentStatus  ";
                        strqry          = strqry + " ,S.StudentStatusID,S.EMail,S.SSN from Students AS S  ";
                        strqry          = strqry + " where  S.LastName+', '+ S.FirstName  like '" + searchtext + "%' or S.StudentNo like '" + searchtext + "%' ";
                        strqry          = strqry + " or (Select StudentStatus from StudentStatus where StudentStatusID=S.StudentStatusID) like '" + searchtext + "%' ";
                        strqry          = strqry + " or S.EMail like '" + searchtext + "%' or S.SSN like '" + searchtext + "%'  ORDER BY S.LastName+', '+ S.FirstName ";
                        CMD.Connection  = connection;
                        CMD.CommandType = System.Data.CommandType.Text;
                        CMD.CommandText = strqry;
                        CMD.Prepare();
                        SqlDataAdapter DataAdapter = new SqlDataAdapter(CMD);
                        DataAdapter.Fill(data);
                    }
                }
                List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(context.NumberOfItems);
                try
                {
                    int itemsPerRequest = 10;
                    int itemOffset      = context.NumberOfItems;
                    int endOffset       = itemOffset + itemsPerRequest;
                    if (endOffset > data.Rows.Count)
                    {
                        endOffset = data.Rows.Count;
                    }
                    if (endOffset == data.Rows.Count)
                    {
                        comboData.EndOfItems = true;
                    }
                    else
                    {
                        comboData.EndOfItems = false;
                    }
                    result = new List <RadComboBoxItemData>(endOffset - itemOffset);

                    //=================================================================

                    /*List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
                     * foreach(row in rows)
                     * {
                     * RadComboBoxItemData itemData = new RadComboBoxItemData();
                     * itemData.Attributes.Add("HostName", row["HostName"].ToString());
                     * itemData.Value = row["ID"].ToString();
                     * result.Add(itemData);
                     * }
                     * return result;*/
                    //===================================================================
                    for (int i = itemOffset; i < endOffset; i++)
                    {
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        //  itemData.Text = Convert.ToString(data.Rows[i]["FullName"]);
                        string itemtext = string.Empty;
                        itemtext       = itemtext + "<ul style='z-index:100'>";
                        itemtext       = itemtext + "<li class='col1'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["FullName"]) + "</li>";
                        itemtext       = itemtext + "<li class='col2'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["StudentNo"]) + "</li>";
                        itemtext       = itemtext + "<li class='col3'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["StudentStatus"]) + "</li>   ";
                        itemtext       = itemtext + "<li class='col4'>";
                        itemtext       = itemtext + Convert.ToString(data.Rows[i]["EMail"]) + "</li>  ";
                        itemtext       = itemtext + "</ul>";
                        itemData.Text  = itemtext;
                        itemData.Value = Convert.ToString(data.Rows[i]["StudentNo"]);

                        result.Add(itemData);
                    }

                    if (data.Rows.Count > 0)
                    {
                        comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                    }
                    else
                    {
                        comboData.Message = "No matches";
                    }
                }

                catch (Exception e)
                {
                    comboData.Message = e.Message;
                }

                comboData.Items = result.ToArray();
            }

            return(comboData);
        }