예제 #1
0
        public static int GetPaginationCount(QueryParam qp)
        {
            int RecordCount = 0;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlParameter[] parameters = { new SqlParameter("@Tables",    SqlDbType.VarChar,  255),
                                              new SqlParameter("@Fields",    SqlDbType.VarChar, 1000),
                                              new SqlParameter("@Filter",    SqlDbType.VarChar, 1500),
                                              new SqlParameter("@PageSize",  SqlDbType.Int),
                                              new SqlParameter("@PageIndex", SqlDbType.Int),
                                              new SqlParameter("@OrderName", SqlDbType.VarChar,  255),
                                              new SqlParameter("@OrderType", SqlDbType.Bit),
                                              new SqlParameter("@doCount",   SqlDbType.Bit) };
                // 设置参数
                parameters[0].Value = qp.Tables;
                parameters[1].Value = qp.Fields;
                parameters[2].Value = qp.Filter;
                parameters[3].Value = qp.PageSize;
                parameters[4].Value = qp.PageIndex;
                parameters[5].Value = qp.OrderName;
                parameters[6].Value = qp.OrderType;
                parameters[7].Value = 1;

                SqlDataReader Dr = RunProcedure("Pr_Pagination", parameters);

                if (Dr.Read())
                {
                    if (Dr[0].ToString() != "" || Dr[0].ToString() != null)
                    {
                        RecordCount = Convert.ToInt32(Dr[0].ToString());
                    }
                }
            }
            return(RecordCount);
        }
예제 #2
0
        /// <summary>
        /// 公共查询数据函数Sql存储过程版
        /// </summary>
        /// <param name="qp">参数对象</param>
        /// <returns>返回记录集SqlDataReader</returns>
        public static SqlDataReader GetListByParam(QueryParam qp)
        {
            SqlDataReader dr = null;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Tables",    SqlDbType.VarChar,  255),
                    new SqlParameter("@Fields",    SqlDbType.VarChar, 1000),
                    new SqlParameter("@Filter",    SqlDbType.VarChar, 1500),
                    new SqlParameter("@OrderName", SqlDbType.VarChar,  255),
                    new SqlParameter("@OrderType", SqlDbType.Bit)
                };
                parameters[0].Value = qp.Tables;
                parameters[1].Value = qp.Fields;
                parameters[2].Value = qp.Filter;
                parameters[3].Value = qp.OrderName;
                parameters[4].Value = qp.OrderType;

                dr = RunProcedure("Pr_Table_GetModel", parameters);
            }
            return(dr);
        }