Example #1
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 #2
0
        public IActionResult FetchLookup([FromRoute] string ApiKey, [FromBody] LookupObj Param)
        {
            IActionResult  response;
            LookupResponse resp = new LookupResponse();

            try
            {
                #region Call Get_Data_Set

                LookupDAO ObjResponseDAO = new LookupDAO(_ConStr);
                DataSet   ds             = ObjResponseDAO.FetchLookup(ApiKey, Param);

                #endregion

                var lookups = (from r in ds.Tables[0].AsEnumerable()
                               select new Lookup()
                {
                    lookup_id = r.Field <int>("lookup_id"),
                    lookup_code = r.Field <string>("lookup_code"),
                    lookup_description = r.Field <string>("lookup_description"),
                    lookup_name = r.Field <string>("lookup_name")
                }).ToList();


                resp.statuscode = (int)Common.ResponseStatusCode.Success;
                resp.message    = "success";
                resp.rows       = lookups;

                response = Ok(resp);
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "BodyController";
                exobj.page_url  = "api/Body/List";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Example #3
0
        private void populateStoreDDL()
        {
            LookupDAO lkp = new LookupDAO();

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

            List <KeyValuePair <Int16, string> > storesconcat = new List <KeyValuePair <Int16, string> >();

            foreach (KeyValuePair <string, string> store in stores)
            {
                Int16 storeid = Int16.Parse(store.Key);
                KeyValuePair <Int16, string> listItem = new KeyValuePair <short, string>(storeid, (store.Key + " - " + store.Value));
                storesconcat.Add(listItem);
            }

            rcbStore.DataSource     = storesconcat;
            rcbStore.DataTextField  = "value";
            rcbStore.DataValueField = "key";
        }