コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int LocationID = 0;
                GlobalAdminManager _GlobalAdminManager = new GlobalAdminManager();
                System.Collections.Specialized.NameValueCollection forms = context.Request.Form;
                HttpRequest  request  = context.Request;
                HttpResponse response = context.Response;

                string strOperation   = forms.Get("oper");
                string _search        = request["_search"];
                string textSearch     = request["txtSearch"] ?? "";
                int?   numberOfRows   = Convert.ToInt32(request["rows"]);
                int?   pageIndex      = Convert.ToInt32(request["page"]);
                string sortColumnName = request["sidx"];
                string sortOrderBy    = request["sord"];
                if (Convert.ToInt32(request["id"]) != 0)
                {
                    long?id = Convert.ToInt32(request["id"]);
                    //obj_StaffUserBusiness.Deleteuser(id);
                }
                ObjectParameter paramTotalRecords = new ObjectParameter("TotalRecords", typeof(int));
                var             ListLocation      = _GlobalAdminManager.ListAllLocation(LocationID, pageIndex, numberOfRows, sortColumnName, sortOrderBy, textSearch, paramTotalRecords);
                if (ListLocation.Count() > 0)
                {
                    string output = BuildJQGridResults(ListLocation, Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), Convert.ToInt32(paramTotalRecords.Value));
                    response.Write(output);
                }
                else
                {
                    JQGridResults    result = new JQGridResults();
                    List <JQGridRow> rows   = new List <JQGridRow>();
                    result.rows    = rows.ToArray();
                    result.page    = 0;
                    result.total   = 0;
                    result.records = 0;
                    response.Write(new JavaScriptSerializer().Serialize(result));
                }
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #2
0
        public JsonResult GetListLocation(string _search, long?UserId, int?locationId, int?rows = 20, int?page = 1, int?TotalRecords = 10, string sord = null, string txtSearch = null, string sidx = null, string UserType = null)
        {
            eTracLoginModel    ObjLoginModel       = null;
            GlobalAdminManager _GlobalAdminManager = new GlobalAdminManager();

            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
                //if (locationId == null)
                //{
                //    locationId = Convert.ToInt32(ObjLoginModel.LocationID);
                //}
                UserId = ObjLoginModel.UserId;
            }

            JQGridResults    result  = new JQGridResults();
            var              result1 = new List <ListLocationModel>();
            List <JQGridRow> rowss   = new List <JQGridRow>();

            sord      = string.IsNullOrEmpty(sord) ? "desc" : sord;
            sidx      = string.IsNullOrEmpty(sidx) ? "LocationId" : sidx;
            txtSearch = string.IsNullOrEmpty(txtSearch) ? "" : txtSearch;             //UserType = Convert.ToInt64(Helper.UserType.ITAdministrator);
            try
            {
                ObjectParameter paramTotalRecords = new ObjectParameter("TotalRecords", typeof(int));
                var             data = _GlobalAdminManager.ListAllLocation(locationId, page, rows, sidx, sord, txtSearch, paramTotalRecords);

                foreach (var locList in data)
                {
                    //Convert Id to Encrypted data
                    var id = Cryptography.GetEncryptedData(locList.LocationId.ToString(), true);
                    locList.Id = id;
                    result1.Add(locList);
                }
                //This is for JSGrid
                var tt = result1.ToArray();
                //foreach (var locList in result1)
                //{
                //    JQGridRow row = new JQGridRow();
                //    row.id = Cryptography.GetEncryptedData(locList.LocationId.ToString(), true);
                //    row.cell = new string[11];
                //    row.cell[0] = locList.LocationName;
                //    row.cell[1] = locList.Address + "," + locList.City + ", " + locList.State + ", " + locList.ZipCode + "," + locList.Country;
                //    row.cell[2] = locList.LocationAdministrator;
                //    row.cell[3] = locList.LocationManager;
                //    row.cell[4] = locList.LocationEmployee;
                //    row.cell[5] = locList.City;
                //    row.cell[6] = locList.State;
                //    row.cell[7] = locList.Country;
                //    row.cell[8] = locList.PhoneNo + " / " + locList.Mobile;
                //    row.cell[9] = locList.Description;
                //    row.cell[10] = Convert.ToString(locList.QRCID);
                //    rowss.Add(row);
                //}
                result.rows    = rowss.ToArray();
                result.page    = Convert.ToInt32(page);
                result.total   = (int)Math.Ceiling((decimal)Convert.ToInt32(TotalRecords.Value) / rows.Value);
                result.records = Convert.ToInt32(TotalRecords.Value);
                return(Json(tt, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            { return(Json(ex.Message, JsonRequestBehavior.AllowGet)); }
        }