Beispiel #1
0
        private static IDataReader GetListPages_SPPT(DbHelperBase DB, string sTableName, int PageSize, int PageIndex, string strFields, string KeyField, string OrderBy, string strWhere, out int totalRecords, string TablePrefix)
        {
            DbHelperBase base2 = DB;

            sTableName = TablePrefix + sTableName;
            if (string.IsNullOrEmpty(strFields))
            {
                strFields = "*";
            }
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Tables", SqlDbType.VarChar, 0x3e8), new SqlParameter("@PrimaryKey", SqlDbType.VarChar, 10), new SqlParameter("@Sort", SqlDbType.VarChar, 200), new SqlParameter("@CurrentPage", SqlDbType.Int, 4), new SqlParameter("@PageSize", SqlDbType.Int, 4), new SqlParameter("@Fields", SqlDbType.VarChar, 0x3e8), new SqlParameter("@Filter", SqlDbType.VarChar, 0x3e8) };
            commandParameters[0].Value = sTableName;
            commandParameters[1].Value = KeyField;
            commandParameters[2].Value = OrderBy.Trim();
            commandParameters[3].Value = PageIndex;
            commandParameters[4].Value = PageSize;
            commandParameters[5].Value = strFields;
            commandParameters[6].Value = strWhere.Trim();
            IDataReader reader      = base2.ExecuteReader(CommandType.StoredProcedure, string.Format("{0}SplitPages", TablePrefix), commandParameters);
            string      commandText = string.Format("select count(*)  from {0}  {1} ", sTableName, string.IsNullOrEmpty(strWhere) ? "" : (" Where " + strWhere));
            object      objA        = base2.ExecuteScalar(CommandType.Text, commandText);

            totalRecords = 1;
            if (!object.Equals(objA, null))
            {
                totalRecords = int.Parse(objA.ToString());
            }
            return(reader);
        }
Beispiel #2
0
        public static IDataReader GetListPagesSql2005(DbHelperBase DB, string sTableName, int PageSize, int PageIndex, string Fileds, string strWhere, string oderby, out int RecordCount)
        {
            string commandText = string.Format("select count(*)  from {0}  {1} ", sTableName, string.IsNullOrEmpty(strWhere) ? "" : (" Where " + strWhere));
            object objA        = DB.ExecuteScalar(CommandType.Text, commandText);

            RecordCount = 1;
            if (!object.Equals(objA, null))
            {
                RecordCount = int.Parse(objA.ToString());
            }
            string str2 = GetListPagesSql2005(sTableName, PageIndex, PageSize, Fileds, strWhere, oderby);

            return(DB.ExecuteReader(CommandType.Text, str2));
        }