/// <summary>
        /// 将传入SQL语句按PageInfo对象生成Select分页语句。并填充相关信息到PageInfo对象。
        /// 注:1 SQL必须是Select语句。
        ///     2 必须有Order By子句。
        /// </summary>
        private static string BuildSelectWithPage(string sql, PageInfo pageinfo, SqlParameter[] cmdParam)
        {
            int PageSize = pageinfo.PageSize;
            int PageNum  = pageinfo.CurrentPage;

            string OrderBy   = sql.Substring(sql.ToLower().IndexOf("order by"));
            string SelectSql = sql.Substring(0, sql.ToLower().IndexOf("order by"));
            string sb        = "select * from ( select row_number() over ({0}) as rowid,* from ({1}) t )t where t.rowid>={2} and t.rowid<={3}";
            string ret       = string.Format(sb.ToString(), OrderBy, SelectSql, PageSize * (PageNum - 1) + 1, PageNum * PageSize);

            //计算分页信息。
            string SelectCountSql = SelectSql.Replace("*", "count(*)");

            pageinfo.TotalRecords = (int)DbHelperSQL.ExecuteSqlScalar(SelectCountSql, cmdParam);
            pageinfo.CalculatePages();

            return(ret);
        }