Exemplo n.º 1
0
        /// <summary>
        /// 分页查询,返回json数据
        /// </summary>
        /// <param name="strColumn">查询的字段列</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="currentPage">当前页数</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="orderBy">排序条件</param>
        /// <returns></returns
        public string GetAllByPage(string strColumn, int pageSize, int currentPage, string strWhere, string orderBy)
        {
            int pageCount   = 0;
            int recordCount = 0;

            if (strWhere == "")
            {
                strWhere = " 1=1 ";
            }
            if (strColumn == "")
            {
                strColumn = " * ";
            }
            if (orderBy == "")
            {
                orderBy = " ld desc ";
            }

            TSqlClient tSqlClient = new TSqlClient();

            tSqlClient.SetSqlConn(sqlConn);
            List <TModule> contList = tSqlClient.GetAllByPage(strColumn, pageSize, currentPage, strWhere, orderBy, out pageCount, out recordCount);
            StringBuilder  rStr     = new StringBuilder();

            rStr.Append("{\"total\":" + recordCount.ToString() + ",");
            if (contList != null)
            {
                rStr.Append("\"rows\":" + CFun.JsonToString <TModule>(contList));
            }
            else
            {
                rStr.Append("\"rows\":[]");
            }
            rStr.Append("}");
            return(rStr.ToString());
        }