Beispiel #1
0
        /*
         * /// <summary>
         * /// 分页获取数据列表
         * /// </summary>
         * public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         * {
         *  SqlParameter[] parameters = {
         *          new SqlParameter("@tblName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@fldName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@PageSize", SqlDbType.Int),
         *          new SqlParameter("@PageIndex", SqlDbType.Int),
         *          new SqlParameter("@IsReCount", SqlDbType.Bit),
         *          new SqlParameter("@OrderType", SqlDbType.Bit),
         *          new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
         *          };
         *  parameters[0].Value = "KeyWords";
         *  parameters[1].Value = "KID";
         *  parameters[2].Value = PageSize;
         *  parameters[3].Value = PageIndex;
         *  parameters[4].Value = 0;
         *  parameters[5].Value = 0;
         *  parameters[6].Value = strWhere;
         *  return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         * }*/

        #endregion  BasicMethod

        #region  ExtensionMethod
        /// <summary>
        /// 获得分页的数据
        /// </summary>
        /// <param name="pageSize">每页的条数</param>
        /// <param name="pageIndex">显示的第几页</param>
        /// <param name="strWhere">where条件</param>
        /// <param name="fieldOrder">排序字段【不可为空】</param>
        /// <param name="recordCount">返回记录的总条数</param>
        /// <returns></returns>
        public DataTable GetListByPage(int pageSize, int pageIndex, string strWhere, string fieldOrder, out int recordCount)
        {
            StringBuilder sbr = new StringBuilder();

            sbr.Append("select KID as 关键字ID,KeyWordsName 关键字 ,KeyWordsStatus 状态 FROM KeyWords");
            if (strWhere.Trim() != "")
            {
                sbr.Append("  where " + strWhere);
            }

            //统计记录的SQL语句
            string strCountSQL = PagingHelper.CreateCountingSQL(sbr.ToString());

            //统计的记录数
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(strCountSQL));

            //分页的SQL语句
            string strPageSQL = PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, sbr.ToString(), fieldOrder);

            return(DbHelperSQL.Query(strPageSQL).Tables[0]);
        }