コード例 #1
0
ファイル: Database.cs プロジェクト: llorch19/erp-aspnet
        public static int GetPageData(out DataTable tb, string tableName, string keyField, int PageSize, int PageIndex, string queryCondition, string sortExp, string fieldList)
        {
            /*
             *  @table nvarchar(50),
             *  @keyField nvarchar(50),
             *  @sortExp nvarchar(50),
             *  @fieldList nvarchar(255),
             *  @queryCondition nvarchar(255),
             *  @PageSize int,
             *  @PageIndex int,
             *  @recsCount int OUTPUT
             */
            SqlParameter[] prams =
            {
                SqlParameterHelper.MakeInParam("@table",          SqlDbType.NVarChar, 0, tableName),
                SqlParameterHelper.MakeInParam("@keyField",       SqlDbType.NVarChar, 0, keyField),

                SqlParameterHelper.MakeInParam("@sortExp",        SqlDbType.NVarChar, 0, sortExp),
                SqlParameterHelper.MakeInParam("@fieldList",      SqlDbType.NVarChar, 0, fieldList),
                SqlParameterHelper.MakeInParam("@queryCondition", SqlDbType.NVarChar, 0, queryCondition),

                SqlParameterHelper.MakeInParam("@PageSize",       SqlDbType.Int,      0, PageSize),
                SqlParameterHelper.MakeInParam("@PageIndex",      SqlDbType.Int,      0, PageIndex),
                SqlParameterHelper.MakeParam("@recsCount",        SqlDbType.Int,      0, ParameterDirection.Output, null)
            };

            DataSet ds;

            Database.RunProc("pageList", prams, out ds);
            tb = ds.Tables[0];

            int recCount = Convert.ToInt32(prams[prams.Length - 1].Value);

            return(recCount);
        }
コード例 #2
0
ファイル: DataStat.cs プロジェクト: llorch19/erp-aspnet
        /// <summary>
        /// 获取数据搜索的分页数据
        /// </summary>
        /// <param name="tb">输出的数据表</param>
        /// <param name="PageSize">页尺寸</param>
        /// <param name="PageIndex">页索引</param>
        /// <param name="queryCondition">查询条件</param>
        /// <param name="sortExp">排序表达式如: ID ASC</param>
        /// <param name="fieldList">查询的字段列表</param>
        /// <returns>记录总数</returns>
        public int GetPageData(out DataTable tb, int PageSize, int PageIndex, string queryCondition, string sortExp, string fieldList)
        {
            /*
             *  @fields varchar(512),
             *  @where varchar(200),
             *  @OrderExp varchar(50),
             *  @pageIndex int,
             *  @pageSize int,
             *  @RecsCount int output
             */
            SqlParameter[] prams =
            {
                SqlParameterHelper.MakeInParam("@OrderExp",  SqlDbType.NVarChar, 0, sortExp),
                SqlParameterHelper.MakeInParam("@fields",    SqlDbType.NVarChar, 0, fieldList),
                SqlParameterHelper.MakeInParam("@where",     SqlDbType.NVarChar, 0, queryCondition),

                SqlParameterHelper.MakeInParam("@pageSize",  SqlDbType.Int,      0, PageSize),
                SqlParameterHelper.MakeInParam("@pageIndex", SqlDbType.Int,      0, PageIndex),
                SqlParameterHelper.MakeParam("@RecsCount",   SqlDbType.Int,      0, ParameterDirection.Output, null)
            };

            DataSet ds;

            Database.RunProc("[statdba].[datastat_GetPageData]", prams, out ds);
            tb = ds.Tables[0];

            int recCount = Convert.ToInt32(prams[prams.Length - 1].Value);

            return(recCount);
        }