Example #1
0
        /// <summary>
        /// 获取easyui datagrid 所需要的JSON数据
        /// </summary>
        /// <param name="fields">字段列表,以逗号隔开</param>
        /// <param name="pageindex">第几页</param>
        /// <param name="pagesize">每页记录数</param>
        /// <param name="keyfield">主键字段名</param>
        /// <param name="where">条件</param>
        /// <param name="sort">排序字段</param>
        /// <param name="tablename">表名</param>
        /// <returns></returns>
        public static string GetJsonForEasyuiDatagrid(string fields, int pageindex, int pagesize, string keyfield, string where, string sort, string tablename)
        {
            int recordcount = 0;

            DataTable dt = SqlEasy.GetDataByPager2000(fields, tablename, where, sort, keyfield, pageindex, pagesize, out recordcount);

            string s = FormatJSONForEasyuiDataGrid(recordcount, ToJson(dt));

            return(s);
        }
Example #2
0
        /// <summary>
        /// 获取指定表的数据,并转换为jqgrid 的JSON格式。适用于sql2000 以上版本
        /// </summary>
        /// <param name="fields">要选取的列,以逗号隔开</param>
        /// <param name="pageindex">当前第几页</param>
        /// <param name="pagesize">每页记录条数</param>
        /// <param name="orderfield">排序</param>
        /// <param name="key">关键字</param>
        /// <param name="where">条件</param>
        /// <param name="tbname">表名或视图名</param>
        /// <returns></returns>
        public static string GetJsonforjQgrid(string fields, int pageindex, int pagesize, string orderfield, string key, string where, string tbname)
        {
            int recordcount = 0;


            DataTable dt        = SqlEasy.GetDataByPager2000(fields, tbname, where, orderfield, key, pageindex, pagesize, out recordcount);
            int       pagecount = SqlEasy.GetDataPages(pagesize, recordcount);

            string json = FormatJSONForJQgrid(pagecount, pageindex, recordcount, dt);

            return(json);
        }