Ejemplo n.º 1
0
        /// <summary>
        /// 分页存储过程参数
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private SqlParameter[] PrepareParameters(PaginationRequest input)
        {
            SqlParameter[] Parameter ={
                            new SqlParameter("@Tables",input.Tables),
                            new SqlParameter("@PrimaryKey",input.PrimaryKey),
                            new SqlParameter("@Sort",input.Sort),
                            new SqlParameter("@CurrentPage",input.CurrentPage),
                            new SqlParameter("@PageSize",input.PageSize),
                            new SqlParameter("@Fields",input.Fields),
                            new SqlParameter("@Filter",input.Filter),
                            new SqlParameter("@Group",input.Group),
                            new SqlParameter("@TotalRecord",SqlDbType.Int,10),
                            new SqlParameter("@TotalPage",SqlDbType.Int,10)
                                     };
            Parameter[8].Direction = ParameterDirection.Output;
            Parameter[9].Direction = ParameterDirection.Output;

            return Parameter;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 分页通用方法
        /// </summary>
        /// <param name="input"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public PaginationResponse ProcessPagination(PaginationRequest input, SQLHelper sql)
        {
            const string CmdText = "Usp_PCustomer_V2_Pagination";
            PaginationResponse Response = null;
            SqlParameter[] Parameter = PrepareParameters(input);

            try
            {
                DataTable dt = sql.ExecuteDataTable(CommandType.StoredProcedure, CmdText, "", Parameter);
                Response = new PaginationResponse();
                Response.dt = dt;
                Response.TotalPage = ConvertHelper.ToInt32(Parameter[Parameter.Length - 1].Value.ToString());
                Response.TotalRecord = ConvertHelper.ToInt32(Parameter[Parameter.Length - 2].Value.ToString());
                return Response;
            }
            catch (Exception ex)
            {
                sql.CloseConnection();

            }

            return Response;
        }