Exemplo n.º 1
0
        public static Json <T> ToJqGridResult <T>(JqGridParameter gridPara, List <T> result, int?TotalRecord = null) where T : new()
        {
            int pageIndex    = Convert.ToInt32(gridPara.Page) - 1;
            int pageSize     = gridPara.Rows ?? result.Count();
            int totalRecords = TotalRecord ?? result.Count();
            int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            if (!string.IsNullOrEmpty(gridPara.Sidx))
            {
                try
                {
                    //--ถ้ามีการ order
                    //result = result.AsQueryable().OrderBy(gridPara.Sidx + " " + gridPara.Sord).ToList();
                }
                catch
                {
                }
            }

            return(new Json <T>
            {
                valid = true,
                total = totalPages,
                page = gridPara.Page,
                records = totalRecords,
                //data = result.Skip(pageIndex * pageSize).Take(pageSize).ToList<T>()
                data = result
            });
        }
Exemplo n.º 2
0
        public static Json <Model.M_Account> getAccount(Model.Criteria.M_AccountCriteria criteria, Helper.JqGridParameter gridParam)
        {
            BLL.ManageAccount _BLL = new BLL.ManageAccount();

            int rsTotalRecord = 0;

            var result = _BLL.getAccount(criteria, ref rsTotalRecord);

            //turn Helper.UtilityHelper.ToJqGridResult<Models.M_Department_SearchLv1>(gridParam, result, rsTotalRecord);
            return(Helper.Utility.ToJqGridResult <Model.M_Account>(gridParam, result));
        }