Пример #1
0
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="TableViewName"></param>
        /// <param name="Key"></param>
        /// <param name="SelectStr"></param>
        /// <param name="Criteria"></param>
        /// <param name="Sort"></param>
        /// <param name="CurrentPage"></param>
        /// <param name="PageSize"></param>
        /// <param name="TotalCount"></param>
        /// <returns></returns>
        public DataTable GetListT(string TableViewName, string Key, string SelectStr, string Criteria, string Sort, ref long CurrentPage, long PageSize, ref long TotalCount)
        {
            DataTable dt = null;

            SqlParameter[] parameters =
            {
                new SqlParameter("@TableViewName",  SqlDbType.VarChar,  255),
                new SqlParameter("@Key",            SqlDbType.VarChar,   50),
                new SqlParameter("@SelectStr",      SqlDbType.VarChar,  500),
                new SqlParameter("@Criteria",       SqlDbType.VarChar, 8000),
                new SqlParameter("@Sort",           SqlDbType.VarChar,  255),
                new SqlParameter("@Page",           SqlDbType.BigInt),
                new SqlParameter("@CurrentPageRow", SqlDbType.BigInt),
                new SqlParameter("@TotalCount",     SqlDbType.BigInt)
            };

            parameters[0].Value     = TableViewName;
            parameters[1].Value     = Key;
            parameters[2].Value     = SelectStr;
            parameters[3].Value     = Criteria;
            parameters[4].Value     = Sort;
            parameters[5].Direction = ParameterDirection.InputOutput;
            parameters[5].Value     = CurrentPage;
            parameters[6].Value     = PageSize;
            parameters[7].Direction = ParameterDirection.InputOutput;

            DataSet ds = crm.RunProcedureShow("GetDataList", parameters, "ds");

            if (ds == null)
            {
                return(null);
            }
            dt = ds.Tables["ds"];
            if (dt != null)
            {
                if (PageSize > 0)
                {
                    TotalCount  = Convert.ToInt64(parameters[7].Value);
                    CurrentPage = Convert.ToInt64(parameters[5].Value);
                }
                else
                {
                    TotalCount = Convert.ToInt64(dt.Rows.Count);
                    if (TotalCount > 0)
                    {
                        CurrentPage = 1;
                    }
                    else
                    {
                        CurrentPage = 0;
                    }
                }
            }
            return(dt);
        }