Esempio n. 1
0
        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <returns></returns>
        public string List(string CustomerName)
        {
            string where = "";
            if (!string.IsNullOrEmpty(CustomerName) && CommonHelper.filterSql(CustomerName))
            {
                where += "CustomerName like '%" + CustomerName + "%'";
            }
            int total      = BLL.GetRecordCount(where);
            int pageSize   = Convert.ToInt32(Request["rows"]);
            int pageNum    = Convert.ToInt32(Request["page"]);
            int startIndex = (pageNum - 1) * pageSize + 1;
            int endIndex   = pageNum * pageSize;

            if (total >= startIndex)
            {
                DataSet ds      = BLL.GetListByPage(where, " OrderBy asc", startIndex, endIndex);
                String  strJson = JsonHelper.GetJsonFromDataSet(ds, total);
                return(strJson);
            }
            else
            {
                String strJson = JsonHelper.GetJsonFromDataTable(null, total);
                return(strJson);
            }
        }