asp.net中分页控件AspNetPager美化样式-阿里云开发者社区

开发者社区> 暖枫无敌> 正文

asp.net中分页控件AspNetPager美化样式

简介: 在asp.net开发中数据列表分页是再常见不过的功能了,相信大家使用AspNetPager的也很多,使用CSS可以让样式更好看,如下图: 新建一个名为content.
+关注继续查看

在asp.net开发中数据列表分页是再常见不过的功能了,相信大家使用AspNetPager的也很多,使用CSS可以让样式更好看,如下图:


新建一个名为content.css文件,如下:

/*分页控件*/
.paginator
{
    font: 11px Arial, Helvetica, sans-serif;
    padding: 0px 5px 0px 15px;
    margin: 0px;
    font-family:微软雅黑;
    font-size:13px;
}

/* 页面的背景以及字体*/
.paginator a
{
    padding: 1px 6px;
    border: solid 1px #7EC0EE;
    background:url(../Images/System/pages.png);
    text-decoration: none;
    margin-right: 2px;
    color:#436EEE;
}

.paginator a:visited
{
    padding: 1px 6px;
    border: solid 1px #99d6ff;
    background: #fff;
    text-decoration: none;
    color:#4cb8ff; 
}

.paginator .cpb
{
    padding: 1px 6px;
    font-weight: bold;
    font-size: 13px;
    border: none;
}

.paginator a:hover
{
    color:#EE4000;
    background: #ebf7ff;
    border-color: #99d6ff;
    text-decoration: none;
}

.paginator span
{
    color: #4cb8ff;
}


web系统中添加AspNetPager.dll引用,然后头部添加如下内容:

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>


引入css,如下:

<link href="../css/content.css" rel="stylesheet" type="text/css" />


 <webdiyer:AspNetPager ID="AspNetPager" runat="server" Width="90%" UrlPaging="true"
            ShowPageIndexBox="Always" AlwaysShow="True" PageIndexBoxType="DropDownList" TextBeforePageIndexBox="转到: "
            HorizontalAlign="Right" OnPageChanged="AspNetPager_PageChanged" EnableTheming="true"
            FirstPageText="首页" LastPageText="尾页" CssClass="paginator" NextPageText="下一页" PrevPageText="上一页">
 </webdiyer:AspNetPager>


    private int pageSize = int.Parse(CommonClass.GetContentFromWebConfig("PageSize"));
    int totalCount = 0;
    int totalPageCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindStateDropDownList();
            this.AspNetPager.PageSize = pageSize;
            BindGrid("");
            GetTotal();
        }
    }

    protected void btnQuery_Click(object sender, EventArgs e)
    {
        AspNetPager.CurrentPageIndex = 1;
        string where = getQueryString();
        BindGrid(where);
        GetTotal();
    }


    private void GetTotal()
    {
        AspNetPager.RecordCount = totalCount;
    }

    private void BindGrid(string where)
    {
        int start = AspNetPager.StartRecordIndex;
        int end = AspNetPager.EndRecordIndex;
        string region = getAuthorityRegionList();
        string corporation = getAuthorityCorporationList();
        DataSet ds = SqlHelper.PageList(SqlHelper.LocalSqlServer, "T_Persons", "*", "PersonneId", " 1=1 and TypeId in(" + region + ") and BrandId in ("+corporation+") " + where + "", " TypeID desc", 1, 0, pageSize, AspNetPager.CurrentPageIndex, ref totalCount, ref totalPageCount);
        this.RptData.DataSource = ds;
        this.RptData.DataBind();
    }


通用分页存储过程代码如下:

 create PROC P_viewPage

    /**//*
        nzperfect [no_mIss] 高效通用分页存储过程(双向检索)
        敬告:适用于单一主键或存在唯一值列的表或视图
        ps:Sql语句为8000字节,调用时请注意传入参数及sql总长度不要超过指定范围
           
    */

    @TableName VARCHAR(200),     --表名
    @FieldList VARCHAR(2000),    --显示列名,如果是全部字段则为*
    @PrimaryKey VARCHAR(100),    --单一主键或唯一值键
    @Where VARCHAR(2000),        --查询条件 不含'where'字符,如id>10 and len(userid)>9
    @Order VARCHAR(1000),        --排序 不含'order by'字符,如id asc,userid desc,必须指定asc或desc                                 
                                 --注意当@SortType=3时生效,记住一定要在最后加上主键,否则会让你比较郁闷
    @SortType INT,               --排序规则 1:正序asc 2:倒序desc 3:多列排序方法
    @RecorderCount INT,          --记录总数 0:会返回总记录
    @PageSize INT,               --每页输出的记录数
    @PageIndex INT,              --当前页数
    @TotalCount INT OUTPUT,      --记返回总记录
    @TotalPageCount INT OUTPUT   --返回总页数
AS
    SET NOCOUNT ON

    IF ISNULL(@TotalCount,'') = '' SET @TotalCount = 0
    SET @Order = RTRIM(LTRIM(@Order))
    SET @PrimaryKey = RTRIM(LTRIM(@PrimaryKey))
    SET @FieldList = REPLACE(RTRIM(LTRIM(@FieldList)),' ','')

    WHILE CHARINDEX(', ',@Order) > 0 OR CHARINDEX(' ,',@Order) > 0
    BEGIN
        SET @Order = REPLACE(@Order,', ',',')
        SET @Order = REPLACE(@Order,' ,',',')    
    END

    IF ISNULL(@TableName,'') = '' OR ISNULL(@FieldList,'') = '' 
        OR ISNULL(@PrimaryKey,'') = ''
        OR @SortType < 1 OR @SortType >3
        OR @RecorderCount  < 0 OR @PageSize < 0 OR @PageIndex < 0        
    BEGIN 
        PRINT('ERR_00')       
        RETURN
    END    

    IF @SortType = 3
    BEGIN
        IF (UPPER(RIGHT(@Order,4))!=' ASC' AND UPPER(RIGHT(@Order,5))!=' DESC')
        BEGIN PRINT('ERR_02') RETURN END
    END

    DECLARE @new_where1 VARCHAR(1000)
    DECLARE @new_where2 VARCHAR(1000)
    DECLARE @new_order1 VARCHAR(1000)   
    DECLARE @new_order2 VARCHAR(1000)
    DECLARE @new_order3 VARCHAR(1000)
    DECLARE @Sql VARCHAR(8000)
    DECLARE @SqlCount NVARCHAR(4000)

    IF ISNULL(@where,'') = ''
        BEGIN
            SET @new_where1 = ' '
            SET @new_where2 = ' WHERE  '
        END
    ELSE
        BEGIN
            SET @new_where1 = ' WHERE ' + @where 
            SET @new_where2 = ' WHERE ' + @where + ' AND '
        END

    IF ISNULL(@order,'') = '' OR @SortType = 1  OR @SortType = 2 
        BEGIN
            IF @SortType = 1 
            BEGIN 
                SET @new_order1 = ' ORDER BY ' + @PrimaryKey + ' ASC'
                SET @new_order2 = ' ORDER BY ' + @PrimaryKey + ' DESC'
            END
            IF @SortType = 2 
            BEGIN 
                SET @new_order1 = ' ORDER BY ' + @PrimaryKey + ' DESC'
                SET @new_order2 = ' ORDER BY ' + @PrimaryKey + ' ASC'
            END
        END
    ELSE
        BEGIN
            SET @new_order1 = ' ORDER BY ' + @Order
        END

    IF @SortType = 3 AND  CHARINDEX(','+@PrimaryKey+' ',','+@Order)>0
        BEGIN
            SET @new_order1 = ' ORDER BY ' + @Order
            SET @new_order2 = @Order + ','            
            SET @new_order2 = REPLACE(REPLACE(@new_order2,'ASC,','{ASC},'),'DESC,','{DESC},')            
            SET @new_order2 = REPLACE(REPLACE(@new_order2,'{ASC},','DESC,'),'{DESC},','ASC,')
            SET @new_order2 = ' ORDER BY ' + SUBSTRING(@new_order2,1,LEN(@new_order2)-1)            
            IF @FieldList <> '*'
                BEGIN            
                    SET @new_order3 = REPLACE(REPLACE(@Order + ',','ASC,',','),'DESC,',',')                              
                    SET @FieldList = ',' + @FieldList                    
                    WHILE CHARINDEX(',',@new_order3)>0
                    BEGIN
                        IF CHARINDEX(SUBSTRING(','+@new_order3,1,CHARINDEX(',',@new_order3)),','+@FieldList+',')>0
                        BEGIN 
                        SET @FieldList = 
                            @FieldList + ',' + SUBSTRING(@new_order3,1,CHARINDEX(',',@new_order3))                        
                        END
                        SET @new_order3 = 
                        SUBSTRING(@new_order3,CHARINDEX(',',@new_order3)+1,LEN(@new_order3))
                    END
                    SET @FieldList = SUBSTRING(@FieldList,2,LEN(@FieldList))                     
                END            
        END

    SET @SqlCount = 'SELECT @TotalCount=COUNT(*),@TotalPageCount=CEILING((COUNT(*)+0.0)/'
                    + CAST(@PageSize AS VARCHAR)+') FROM ' + @TableName + @new_where1
    
    IF @RecorderCount  = 0
        BEGIN
             EXEC SP_EXECUTESQL @SqlCount,N'@TotalCount INT OUTPUT,@TotalPageCount INT OUTPUT',
                               @TotalCount OUTPUT,@TotalPageCount OUTPUT
        END
    ELSE
        BEGIN
             SELECT @TotalCount = @RecorderCount            
        END

    IF @PageIndex > CEILING((@TotalCount+0.0)/@PageSize)
        BEGIN
            SET @PageIndex =  CEILING((@TotalCount+0.0)/@PageSize)
        END

    IF @PageIndex = 1 OR @PageIndex >= CEILING((@TotalCount+0.0)/@PageSize)
        BEGIN
            IF @PageIndex = 1 --返回第一页数据
                BEGIN
                    SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ' 
                               + @TableName + @new_where1 + @new_order1
                END
            IF @PageIndex >= CEILING((@TotalCount+0.0)/@PageSize)  --返回最后一页数据
                BEGIN
                    SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM (' 
                               + 'SELECT TOP ' + STR(ABS(@PageSize*@PageIndex-@TotalCount-@PageSize)) 
                               + ' ' + @FieldList + ' FROM '
                               + @TableName + @new_where1 + @new_order2 + ' ) AS TMP '
                               + @new_order1                    
                END        
        END    
    ELSE
        BEGIN
            IF @SortType = 1  --仅主键正序排序
                BEGIN
                    IF @PageIndex <= CEILING((@TotalCount+0.0)/@PageSize)/2  --正向检索
                        BEGIN
                            SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ' 
                                       + @TableName + @new_where2 + @PrimaryKey + ' > '
                                       + '(SELECT MAX(' + @PrimaryKey + ') FROM (SELECT TOP '
                                       + STR(@PageSize*(@PageIndex-1)) + ' ' + @PrimaryKey 
                                       + ' FROM ' + @TableName
                                       + @new_where1 + @new_order1 +' ) AS TMP) '+ @new_order1
                        END
                    ELSE  --反向检索
                        BEGIN
                            SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM (' 
                                       + 'SELECT TOP ' + STR(@PageSize) + ' ' 
                                       + @FieldList + ' FROM '
                                       + @TableName + @new_where2 + @PrimaryKey + ' < '
                                       + '(SELECT MIN(' + @PrimaryKey + ') FROM (SELECT TOP '
                                       + STR(@TotalCount-@PageSize*@PageIndex) + ' ' + @PrimaryKey 
                                       + ' FROM ' + @TableName
                                       + @new_where1 + @new_order2 +' ) AS TMP) '+ @new_order2 
                                       + ' ) AS TMP ' + @new_order1
                        END
                END
            IF @SortType = 2  --仅主键反序排序
                BEGIN
                    IF @PageIndex <= CEILING((@TotalCount+0.0)/@PageSize)/2  --正向检索
                        BEGIN
                            SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ' 
                                       + @TableName + @new_where2 + @PrimaryKey + ' < '
                                       + '(SELECT MIN(' + @PrimaryKey + ') FROM (SELECT TOP '
                                       + STR(@PageSize*(@PageIndex-1)) + ' ' + @PrimaryKey 
                                       +' FROM '+ @TableName
                                       + @new_where1 + @new_order1 + ') AS TMP) '+ @new_order1                               
                        END 
                    ELSE  --反向检索
                        BEGIN
                            SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM (' 
                                       + 'SELECT TOP ' + STR(@PageSize) + ' ' 
                                       + @FieldList + ' FROM '
                                       + @TableName + @new_where2 + @PrimaryKey + ' > '
                                       + '(SELECT MAX(' + @PrimaryKey + ') FROM (SELECT TOP '
                                       + STR(@TotalCount-@PageSize*@PageIndex) + ' ' + @PrimaryKey 
                                       + ' FROM ' + @TableName
                                       + @new_where1 + @new_order2 +' ) AS TMP) '+ @new_order2 
                                       + ' ) AS TMP ' + @new_order1
                        END  
                END                         
            IF @SortType = 3  --多列排序,必须包含主键,且放置最后,否则不处理
                BEGIN
                    IF CHARINDEX(',' + @PrimaryKey + ' ',',' + @Order) = 0 
                    BEGIN PRINT('ERR_02') RETURN END
                    IF @PageIndex <= CEILING((@TotalCount+0.0)/@PageSize)/2  --正向检索
                        BEGIN
                            SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ( '
                                       + 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ( '
                                       + ' SELECT TOP ' + STR(@PageSize*@PageIndex) + ' ' + @FieldList
                                       + ' FROM ' + @TableName + @new_where1 + @new_order1 + ' ) AS TMP '
                                       + @new_order2 + ' ) AS TMP ' + @new_order1    
                        END
                    ELSE  --反向检索
                        BEGIN
                            SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ( '  
                                       + 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM ( '
                                       + ' SELECT TOP ' + STR(@TotalCount-@PageSize*@PageIndex+@PageSize) + ' ' + @FieldList
                                       + ' FROM ' + @TableName + @new_where1 + @new_order2 + ' ) AS TMP '
                                       + @new_order1 + ' ) AS TMP ' + @new_order1
                        END
                END
        END
    PRINT(@Sql)
    EXEC(@Sql)

SqlHelper.cs数据库操作类代码如下:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Xml;


/// <summary>
/// 数据库访问抽象基类  (基于MS-SQLServer2005或以上版本)
/// 此类为抽象类 abstract ,不允许实例化,在应用时直接调用即可
/// </summary>
public abstract class SqlHelper
{
    //数据库连接字符串(web.config来配置),可以动态更改connectionString支持多数据库.		
    public static readonly string LocalSqlServer = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString();

    #region ===========通用分页存储过程===========
    /// <summary>
    /// 通用分页存储过程
    /// </summary>
    /// <param name="connectionString"></param>
    /// <param name="tblName"></param>
    /// <param name="strGetFields"></param>
    /// <param name="primaryKey"></param>
    /// <param name="strWhere"></param>
    /// <param name="strOrder"></param>
    /// <param name="sortType"></param>
    /// <param name="recordCount"></param>
    /// <param name="PageSize"></param>
    /// <param name="PageIndex"></param>
    /// <param name="totalCount"></param>
    /// <param name="totalPageCount"></param>
    /// <returns></returns>
    public static DataSet PageList(string connectionString, string tblName, string strGetFields, string primaryKey, string strWhere, string strOrder, int sortType, int recordCount,
        int PageSize, int PageIndex,ref int totalCount,ref int totalPageCount)
    {
        SqlParameter[] parameters ={ new SqlParameter("@TableName ",SqlDbType.VarChar,200),
                new SqlParameter("@FieldList",SqlDbType.VarChar,2000),
                new SqlParameter("@PrimaryKey",SqlDbType.VarChar,100),
                new SqlParameter("@Where",SqlDbType.VarChar,2000),
                new SqlParameter("@Order",SqlDbType.VarChar,1000),
                new SqlParameter("@SortType",SqlDbType.Int),
                new SqlParameter("@RecorderCount",SqlDbType.Int),
                new SqlParameter("@PageSize",SqlDbType.Int),
                new SqlParameter("@PageIndex",SqlDbType.Int),
                new SqlParameter("@TotalCount",SqlDbType.Int),
                new SqlParameter("@TotalPageCount",SqlDbType.Int)};

        parameters[0].Value = tblName;
        parameters[1].Value = strGetFields;
        parameters[2].Value = primaryKey;
        parameters[3].Value = strWhere;
        parameters[4].Value = strOrder;
        parameters[5].Value = sortType;
        parameters[6].Value = recordCount;
        parameters[7].Value = PageSize;
        parameters[8].Value = PageIndex;
        parameters[9].Value = totalCount;
        parameters[9].Direction = ParameterDirection.Output;
        parameters[10].Value = totalPageCount;
        parameters[10].Direction = ParameterDirection.Output;

        DataSet ds = RunProcedureDS(connectionString, "P_viewPage", parameters, "PageListTable");
        totalCount = int.Parse(parameters[9].Value.ToString());
        totalPageCount = int.Parse(parameters[10].Value.ToString());
        return ds;
    }
    #endregion

    #region ===========执行简单SQL语句============

    /// <summary>
    /// 获取表某个字段的最大值
    /// </summary>
    /// <param name="FieldName"></param>
    /// <param name="TableName"></param>
    /// <returns></returns>
    public static int GetMaxID(string connectionString, string FieldName, string TableName)
    {
        string strSql = "select max(" + FieldName + ") from " + TableName;
        DataSet ds = ExecuteDataSet(connectionString, strSql);
        if (ds.Tables[0].Rows[0][0] != DBNull.Value)
        {
            return int.Parse(ds.Tables[0].Rows[0][0].ToString());
        }
        else
        {
            return 0;
        }
    }

    /// <summary>
    ///  检测一个记录是否存在(SqlParameter语句方式)
    /// </summary>
    /// <param name="strSql"></param>
    /// <param name="cmdParms"></param>
    /// <returns></returns>
    public static bool ExistsRecord(string connectionString, string strSql, params SqlParameter[] cmdParms)
    {
        DataSet ds = RunProcedureDS(connectionString, strSql, cmdParms);
        return int.Parse(ds.Tables[0].Rows[0][0].ToString()) > 0;
    }


    /// <summary>
    ///执行查询,并将查询返回的结果集中第一行的第一列作为 .NET Framework 数据类型返回。忽略额外的列或行。返回查询结果(object)。
    /// </summary>
    /// <param name="SQLString">计算查询结果语句</param>
    /// <returns>查询结果(object)</returns>
    public static object GetSingle(string connectionString, string SQLString)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            using (SqlCommand cmd = new SqlCommand(SQLString, connection))
            {
                try
                {
                    connection.Open();
                    object obj = cmd.ExecuteScalar();
                    if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
                    {
                        return null;
                    }
                    else
                    {
                        return obj;
                    }
                }
                catch (System.Data.SqlClient.SqlException e)
                {
                    connection.Close();
                    throw new Exception(e.Message);
                }
            }
        }
    }

    #endregion 执行简单SQL语句

    #region StrSQL执行结果,返回执行后受影响的行数

    /*【公告】:ExecuteNonQuery()方法介绍
         *对于   UPDATE、INSERT   和   DELETE   语句,
         *返回值为该命令所影响的行数。对于所有其他类型的语句,
         *返回值为   -1。如果发生回滚,返回值也为   -1。
         */

    /// <summary>
    /// 执行SQL语句,返回影响的记录数,select类型的语句此方法不可行。
    /// 对于select方法应该通过Dataset.Tables[0].Rows.Count来判断
    /// </summary>
    /// <param name="SQLString">SQL语句</param>
    /// <returns>影响的记录数</returns>
    public static int ExecuteSql(string connectionString, string SQLString)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            using (SqlCommand cmd = new SqlCommand(SQLString, connection))
            {
                try
                {
                    connection.Open();
                    int rows = cmd.ExecuteNonQuery();
                    return rows;
                }
                catch (System.Data.SqlClient.SqlException E)
                {
                    connection.Close();
                    throw new Exception(E.Message);
                }
            }
        }
    }
    /// <summary>
    /// 方法重载,限定查询时间,返回影响的记录数
    /// 客观的多并发查询时,可限制用户查询时间,以免对服务器增加负担
    /// </summary>
    /// <param name="Times">等待命令执行的时间,默认值为 30 秒。</param>
    /// <returns>影响的记录数</returns>
    public static int ExecuteSql(string connectionString, string SQLstring, int Times)
    {
        using (SqlConnection conntion = new SqlConnection(connectionString))
        {
            using (SqlCommand cmd = new SqlCommand(SQLstring, conntion))
            {
                try
                {
                    conntion.Open();
                    cmd.CommandTimeout = Times;//默认值为 30 秒
                    int rows = cmd.ExecuteNonQuery();
                    return rows;
                }
                catch (System.Data.SqlClient.SqlException e)
                {
                    conntion.Close();
                    throw e;
                }
            }
        }
    }

    /// <summary>
    /// 执行SQL语句,返回记录的条数【注意是记录数】;
    /// 获取SQL字段第一行第一字段的数值,请不要用select
    /// </summary>
    /// <param name="SQLString">SQL语句</param>
    /// <returns>影响的记录数</returns>
    public static int ExecuteCountSql(string connectionString, string SQLString)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            using (SqlCommand cmd = new SqlCommand(SQLString, connection))
            {
                try
                {
                    connection.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    dr.Read();
                    int count = int.Parse(dr[0].ToString());
                    return count;

                }
                catch (System.Data.SqlClient.SqlException E)
                {
                    connection.Close();
                    throw new Exception(E.Message);
                }
            }
        }
    }

    /// <summary>
    /// 执行带一个存储过程参数的的SQL语句。
    /// </summary>
    /// <param name="SQLString">SQL语句</param>
    /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
    /// <returns>影响的记录数</returns>
    public static int ExecuteSql(string connectionString, string SQLString, string content)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            SqlCommand cmd = new SqlCommand(SQLString, connection);
            SqlParameter myParameter = new SqlParameter("@content", SqlDbType.NText);
            myParameter.Value = content;
            cmd.Parameters.Add(myParameter);
            try
            {
                connection.Open();
                int rows = cmd.ExecuteNonQuery();
                return rows;
            }
            catch (SqlException E)
            {
                throw new Exception(E.Message);
            }
            finally
            {
                cmd.Dispose();
            }
        }
    }

    /// <summary>
    /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
    /// </summary>
    /// <param name="strSQL">SQL语句</param>
    /// <param name="fs">图像字节,数据库的字段类型为image的情况</param>
    /// <returns>影响的记录数</returns>
    public static int ExecuteSqlInsertImg(string connectionString, string strSQL, byte[] fs)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            SqlCommand cmd = new SqlCommand(strSQL, connection);
            SqlParameter myParameter = new SqlParameter("@fs", SqlDbType.Image);
            myParameter.Value = fs;
            cmd.Parameters.Add(myParameter);
            try
            {
                connection.Open();
                int rows = cmd.ExecuteNonQuery();
                return rows;
            }
            catch (SqlException E)
            {
                throw new Exception(E.Message);
            }
            finally
            {
                cmd.Dispose();
            }
        }
    }

    /// <summary>
    /// 执行带参数的SQL语句,返回影响的记录数
    /// </summary>
    /// <param name="connectionString">连接字符串</param>
    /// <param name="SQLString">SQL语句</param>
    /// <param name="cmdParms">参数</param>
    /// <returns>影响的记录数</returns>
    public static int ExecuteSql(string connectionString, string SQLString, params SqlParameter[] cmdParms)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                try
                {
                    PrepareCommand(cmd, connection, null, SQLString, cmdParms);
                    int rows = cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();
                    return rows;
                }
                catch (System.Data.SqlClient.SqlException E)
                {
                    connection.Close();
                    throw new Exception(E.Message);
                }
            }
        }
    }

    /// <summary>
    /// 执行存储过程,返回Return值【这个方法还没看明白,- -  】
    /// </summary>
    /// <param name="storedProcName">存储过程名</param>
    /// <param name="parameters">存储过程参数</param>
    /// <param name="rowsAffected">影响的行数</param>
    /// <returns></returns>
    public static int RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, out int rowsAffected)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            int result;
            connection.Open();
            SqlCommand command = BuildIntCommand(connection, storedProcName, parameters);
            rowsAffected = command.ExecuteNonQuery();
            result = (int)command.Parameters["ReturnValue"].Value;
            connection.Close();
            return result;
        }
    }
    #endregion

    #region ============获取DataReader============

    /*【公告】下面的方法调用(先实例化一个dr)该方法后,
         * 一定要对SqlDataReader进行Close (对实例化的dr进行 dr.Close();
         * 如果不Close掉,则会保持read回话状态,加重数据库负荷) */

    /// <summary>
    /// 执行查询语句,返回SqlDataReader
    /// </summary>
    /// <param name="strSQL">查询语句</param>
    /// <returns>SqlDataReader</returns>
    public static SqlDataReader ExecuteReader(string connectionString, string strSQL)
    {
        SqlConnection connection = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand(strSQL, connection);
        try
        {
            connection.Open();
            SqlDataReader myReader = cmd.ExecuteReader();
            return myReader;
        }
        catch (System.Data.SqlClient.SqlException e)
        {
            throw new Exception(e.Message);
        }
        finally
        {
            connection.Close();
        }
    }

    /// <summary>
    /// 执行存储过程,返回SqlDataReader 
    /// </summary>
    /// <param name="storedProcName">存储过程名</param>
    /// <param name="parameters">存储过程参数</param>
    /// <returns>SqlDataReader</returns>
    public static SqlDataReader RunProcedureDR(string connectionString, string storedProcName, IDataParameter[] parameters)
    {
        SqlConnection connection = new SqlConnection(connectionString);
        SqlDataReader returnReader;
        try
        {
            connection.Open();
            SqlCommand command = BuildQueryCommand(connection, storedProcName, parameters);
            command.CommandType = CommandType.StoredProcedure;
            returnReader = command.ExecuteReader(CommandBehavior.CloseConnection);
        }
        catch (System.Data.SqlClient.SqlException e)
        {
            connection.Close();
            throw new Exception(e.Message);
        }
        return returnReader;
    }
    #endregion

    #region =============获取DataSet==============

    /// <summary>
    /// 执行查询语句,返回DataSet
    /// </summary>
    /// <param name="SQLString">查询语句</param>
    /// <returns>DataSet</returns>
    public static DataSet ExecuteDataSet(string connectionString, string SQLString)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            DataSet ds = new DataSet();
            try
            {
                connection.Open();

                SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
                command.Fill(ds);
            }
            catch (SqlException ex)
            {
                connection.Close();
                throw new Exception(ex.Message);
            }
            return ds;
        }
    }
    public static DataSet ExecuteDataSet(string connectionString, string strSQL, int Times)
    {
        using (SqlConnection conntion = new SqlConnection(connectionString))
        {
            DataSet ds = new DataSet();
            try
            {
                conntion.Open();
                SqlDataAdapter da = new SqlDataAdapter(strSQL, conntion);
                da.SelectCommand.CommandTimeout = Times;//限制查询时间
                da.Fill(ds);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                conntion.Close();
                throw new Exception(e.Message);
            }
            return ds;
        }
    }

    /// <summary>
    /// 执行查询语句,返回DataSet
    /// </summary>
    /// <param name="SQLString">查询语句</param>
    /// <returns>DataSet</returns>
    /// BU层得到对象实体用这个方法
    public static DataSet ExecuteDataSet(string connectionString, string SQLString, params SqlParameter[] cmdParms)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            SqlCommand cmd = new SqlCommand();
            PrepareCommand(cmd, connection, null, SQLString, cmdParms);
            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
            {
                DataSet ds = new DataSet();
                try
                {
                    da.Fill(ds);
                    cmd.Parameters.Clear();
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
                return ds;
            }
        }
    }

    //【调用方法】:
    //ArrayList arrayList = new ArrayList();
    //arrayList.Add("strsql1");
    //arrayList.Add("strsql2");
    //...
    //arrayList.Add("strsqln");
    //return DbHelperSQL.ExecuteManySqlDS(arrayList);         
    /// <summary>
    /// 执行多条SQL语句返回多个DataSet
    /// </summary>
    /// <param name="arrayList">arrayList对象集合</param>
    /// <returns>多个数据集</returns>
    public static DataSet ExecuteManySqlDS(string connectionString, ArrayList arrayList)
    {
        DataSet set = new DataSet();
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            string table = "table";
            SqlDataAdapter adapter = new SqlDataAdapter();

            for (int i = 0; i < arrayList.Count; ++i)
            {
                command.CommandText = arrayList[i].ToString();
                adapter.SelectCommand = command;
                adapter.Fill(set, table + i);// table + i 每个语句返回数据集的表名
            }
            return set;
        }
    }

    /// <summary>
    /// 执行存储过程返回DataSet
    /// </summary>
    /// <param name="storedProcName">存储过程名</param>
    /// <param name="parameters">存储过程参数</param>
    /// <param name="tableName">DataSet结果中的表名</param>
    /// <returns>DataSet</returns>
    public static DataSet RunProcedureDS(string connectionString, string storedProcName, IDataParameter[] parameters)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            DataSet dataSet = new DataSet();
            try
            {
                connection.Open();
                SqlDataAdapter sqlDA = new SqlDataAdapter();
                sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
                sqlDA.Fill(dataSet);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                connection.Close();
                throw new Exception(e.Message);
            }
            return dataSet;
        }
    }
    public static DataSet RunProcedureDS(string connectionString, string storedProcName, IDataParameter[] parameters, string tableName)
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            DataSet dataSet = new DataSet();
            connection.Open();
            SqlDataAdapter sqlDA = new SqlDataAdapter();
            sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
            sqlDA.Fill(dataSet, tableName);
            connection.Close();
            return dataSet;
        }
    }
    #endregion

    #region ============数据库事务处理============
    /// <summary>
    /// 执行多条SQL语句,实现数据库事务
    /// </summary>
    /// <param name="SQLStringList">多条SQL语句</param>
    /// <returns>执行事务影响的行数</returns>
    public static int ExecuteSqlTran(string connectionString, List<String> SQLStringList)
    {
        using (SqlConnection conntion = new SqlConnection(connectionString))
        {
            conntion.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conntion;

            SqlTransaction ts = conntion.BeginTransaction();
            cmd.Transaction = ts;
            try
            {
                int count = 0;
                for (int n = 0; n < SQLStringList.Count; n++)
                {
                    string strsql = SQLStringList[n];
                    if (strsql.Length > 1)
                    {
                        cmd.CommandText = strsql;
                        count += cmd.ExecuteNonQuery();
                    }
                }
                ts.Commit();//提交数据库事务
                return count;
            }
            catch
            {
                ts.Rollback();
                return 0;
            }
        }
    }

    /// <summary>
    ///  执行多条SQL语句,实现数据库事务
    /// </summary>
    /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[])</param>
    public static void ExecuteSqlTran(string connectionString, Hashtable SQLStringList)
    {
        using (SqlConnection conn = new SqlConnection(connectionString))
        {
            conn.Open();
            using (SqlTransaction trans = conn.BeginTransaction())
            {
                SqlCommand cmd = new SqlCommand();
                try
                {
                    //循环
                    foreach (DictionaryEntry myDY in SQLStringList)
                    {
                        string cmdText = myDY.Key.ToString();
                        SqlParameter[] parameter = (SqlParameter[])myDY.Value;
                        PrepareCommand(cmd, conn, trans, cmdText, parameter);
                        int result = cmd.ExecuteNonQuery();     //这里可以记录该事务的执行结果
                        cmd.Parameters.Clear();
                    }
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
            }
        }
    }

    #endregion

    #region 创建 SqlCommand 对象及创建执行命令参数

    /// <summary>
    /// 为执行命令准备参数
    /// </summary>
    /// <param name="cmd">SqlCommand 命令</param>
    /// <param name="conn">已经存在的数据库连接</param>
    /// <param name="trans">数据库事物处理</param>
    /// <param name="cmdText">SQL语句</param>
    /// <param name="cmdparams">返回带参数的命令</param>
    public static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, string cmdText, SqlParameter[] cmdparams)
    {
        if (conn.State != ConnectionState.Open)
        {//判断数据库连接状态
            conn.Open();
        }
        cmd.Connection = conn;
        cmd.CommandText = cmdText;
        if (trans != null)
        {//判断是否需要事物处理
            cmd.Transaction = trans;
        }
        cmd.CommandType = CommandType.Text;
        if (cmdparams != null)
        {
            foreach (SqlParameter parameter in cmdparams)
            {
                if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) && (parameter.Value == null))
                {
                    parameter.Value = DBNull.Value;
                }
                cmd.Parameters.Add(parameter);
            }
        }
    }

    /// <summary>
    /// 创建 SqlCommand 对象实例(用来返回一个整数值)	
    /// </summary>
    /// <param name="storedProcName">存储过程名</param>
    /// <param name="parameters">存储过程参数</param>
    /// <returns>SqlCommand 对象实例</returns>
    private static SqlCommand BuildIntCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
    {
        SqlCommand command = BuildQueryCommand(connection, storedProcName, parameters);
        command.Parameters.Add(new SqlParameter("ReturnValue",
            SqlDbType.Int, 4, ParameterDirection.ReturnValue,
            false, 0, 0, string.Empty, DataRowVersion.Default, null));
        return command;
    }
    /// <summary>
    /// 构建 SqlCommand 对象(用来返回一个结果集,而不是一个整数值)
    /// </summary>
    /// <param name="connection">数据库连接</param>
    /// <param name="storedProcName">存储过程名</param>
    /// <param name="parameters">存储过程参数</param>
    /// <returns>SqlCommand</returns>
    private static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
    {
        SqlCommand command = new SqlCommand(storedProcName, connection);
        command.CommandType = CommandType.StoredProcedure;
        foreach (SqlParameter parameter in parameters)
        {
            if (parameter != null)
            {
                // 检查未分配值的输出参数,将其分配以DBNull.Value.
                if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
                    (parameter.Value == null))
                {
                    parameter.Value = DBNull.Value;
                }
                command.Parameters.Add(parameter);
            }
        }

        return command;
    }

    #endregion

    #region ============构造语句常用类============
    /// <summary>
    /// Make input param.
    /// </summary>
    /// <param name="ParamName">Name of param.</param>
    /// <param name="DbType">Param type.</param>
    /// <param name="Size">Param size.</param>
    /// <param name="Value">Param value.</param>
    /// <returns>New parameter.</returns>
    public static SqlParameter MakeInParam(string ParamName, SqlDbType DbType, int Size, object Value)
    {
        return MakeParam(ParamName, DbType, Size, ParameterDirection.Input, Value);
    }
    public static SqlParameter MakeInParam(string ParamName, SqlDbType DbType, object Value)
    {
        return MakeParam(ParamName, DbType, 0, ParameterDirection.Input, Value);
    }

    /// <summary>
    /// Make input param.
    /// </summary>
    /// <param name="ParamName">Name of param.</param>
    /// <param name="DbType">Param type.</param>
    /// <param name="Size">Param size.</param>
    /// <returns>New parameter.</returns>
    public static SqlParameter MakeOutParam(string ParamName, SqlDbType DbType, int Size)
    {
        return MakeParam(ParamName, DbType, Size, ParameterDirection.Output, null);
    }

    /// <summary>
    /// 构建存储过程参数
    /// </summary>
    /// <param name="ParamName">参数名</param>
    /// <param name="DbType">参数类型(枚举)</param>
    /// <param name="Size">参数大小</param>
    /// <param name="Direction">DataSet 的参数类型(枚举)</param>
    /// <param name="Value">设置该参数的数值</param>
    /// <returns>New parameter.</returns>
    public static SqlParameter MakeParam(string ParamName, SqlDbType DbType, Int32 Size, ParameterDirection Direction, object Value)
    {
        SqlParameter param;
        if (Size > 0)
        {
            param = new SqlParameter(ParamName, DbType, Size);
        }
        else
        {
            param = new SqlParameter(ParamName, DbType);
        }
        param.Direction = Direction;
        if (!(Direction == ParameterDirection.Output && Value == null))
        {
            param.Value = Value;
        }
        return param;
    }
    #endregion 构造语句常用类

    #region =============由Object取值=============
    /// <summary>
    /// 取得Int值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static int GetInt(object obj)
    {
        if (obj.ToString() != "")
            return int.Parse(obj.ToString());
        else
            return 0;
    }

    /// <summary>
    /// 获得Long值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static long GetLong(object obj)
    {
        if (obj.ToString() != "")
            return long.Parse(obj.ToString());
        else
            return 0;
    }

    /// <summary>
    /// 取得Decimal值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static decimal GetDecimal(object obj)
    {
        if (obj.ToString() != "")
            return decimal.Parse(obj.ToString());
        else
            return 0;
    }

    /// <summary>
    /// 取得Guid值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static Guid GetGuid(object obj)
    {
        if (obj.ToString() != "")
            return new Guid(obj.ToString());
        else
            return Guid.Empty;
    }

    /// <summary>
    /// 取得DateTime值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static DateTime GetDateTime(object obj)
    {
        if (obj.ToString() != "")
            return DateTime.Parse(obj.ToString());
        else
            return DateTime.MinValue;
    }

    /// <summary>
    /// 取得bool值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static bool GetBool(object obj)
    {
        if (obj.ToString() == "1" || obj.ToString().ToLower() == "true")
            return true;
        else
            return false;
    }

    /// <summary>
    /// 取得byte[]
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static Byte[] GetByte(object obj)
    {
        if (obj.ToString() != "")
        {
            return (Byte[])obj;
        }
        else
            return null;
    }

    /// <summary>
    /// 取得string值
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static string GetString(object obj)
    {
        return obj.ToString();
    }
    #endregion

    #region ===========序列化与反序列化===========
    /// <summary>
    /// 序列化对象
    /// </summary>
    /// <param name="obj">要序列化的对象</param>
    /// <returns>返回二进制</returns>
    public static byte[] SerializeModel(Object obj)
    {
        if (obj != null)
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            MemoryStream ms = new MemoryStream();
            byte[] b;
            binaryFormatter.Serialize(ms, obj);
            ms.Position = 0;
            b = new Byte[ms.Length];
            ms.Read(b, 0, b.Length);
            ms.Close();
            return b;
        }
        else
            return new byte[0];
    }

    /// <summary>
    /// 反序列化对象
    /// </summary>
    /// <param name="b">要反序列化的二进制</param>
    /// <returns>返回对象</returns>
    public static object DeserializeModel(byte[] b, object SampleModel)
    {
        if (b == null || b.Length == 0)
            return SampleModel;
        else
        {
            object result = new object();
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            MemoryStream ms = new MemoryStream();
            try
            {
                ms.Write(b, 0, b.Length);
                ms.Position = 0;
                result = binaryFormatter.Deserialize(ms);
                ms.Close();
            }
            catch { }
            return result;
        }
    }
    #endregion

    #region ==========Model与XML互相转换==========
    /// <summary>
    /// Model转化为XML的方法
    /// </summary>
    /// <param name="model">要转化的Model</param>
    /// <returns></returns>
    public static string ModelToXML(object model)
    {
        XmlDocument xmldoc = new XmlDocument();
        XmlElement ModelNode = xmldoc.CreateElement("Model");
        xmldoc.AppendChild(ModelNode);

        if (model != null)
        {
            foreach (PropertyInfo property in model.GetType().GetProperties())
            {
                XmlElement attribute = xmldoc.CreateElement(property.Name);
                if (property.GetValue(model, null) != null)
                    attribute.InnerText = property.GetValue(model, null).ToString();
                else
                    attribute.InnerText = "[Null]";
                ModelNode.AppendChild(attribute);
            }
        }

        return xmldoc.OuterXml;
    }

    /// <summary>
    /// XML转化为Model的方法
    /// </summary>
    /// <param name="xml">要转化的XML</param>
    /// <param name="SampleModel">Model的实体示例,New一个出来即可</param>
    /// <returns></returns>
    public static object XMLToModel(string xml, object SampleModel)
    {
        if (string.IsNullOrEmpty(xml))
            return SampleModel;
        else
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(xml);

            XmlNodeList attributes = xmldoc.SelectSingleNode("Model").ChildNodes;
            foreach (XmlNode node in attributes)
            {
                foreach (PropertyInfo property in SampleModel.GetType().GetProperties())
                {
                    if (node.Name == property.Name)
                    {
                        if (node.InnerText != "[Null]")
                        {
                            if (property.PropertyType == typeof(System.Guid))
                                property.SetValue(SampleModel, new Guid(node.InnerText), null);
                            else
                                property.SetValue(SampleModel, Convert.ChangeType(node.InnerText, property.PropertyType), null);
                        }
                        else
                            property.SetValue(SampleModel, null, null);
                    }
                }
            }
            return SampleModel;
        }
    }
    #endregion
}







版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Linq配合AspNetPager高效分页
最近正在学习Linq,看到分页这里的时候感觉真的很简单,可是又担心学着学习就把知识混在一起,不知道大家在刚学的时候是不是跟我一样,因为他有的地主真的太像SQL了 分页方式: 获取数据总条数: var Count = db.
912 0
【开源】QuickPager ASP.NET2.0分页控件V2.0.0.7 增加了一个js函数的分页方式。
     昨天在csdn上看到一个人提出来了一种分页的需求,大致是分页控件只负责绘制总页数、上一页、下一页等信息,然后在用户翻页的时候可以触发一个js函数,然后自己实现这个js函数。并不需要提交表单,他想用ajax的方式来获取数据,但是又不想使用微软的ajax。
756 0
【开源】QuickPager ASP.NET2.0分页控件V2.0.0.4 增加了几个分页算法
================================ 欢迎转载,但是请注明出处。本文出自博客园 。谢谢合作! ================================                最近忙一个项目,没有太多的时间来升级分页控件。
816 0
阿里云服务器端口号设置
阿里云服务器初级使用者可能面临的问题之一. 使用tomcat或者其他服务器软件设置端口号后,比如 一些不是默认的, mysql的 3306, mssql的1433,有时候打不开网页, 原因是没有在ecs安全组去设置这个端口号. 解决: 点击ecs下网络和安全下的安全组 在弹出的安全组中,如果没有就新建安全组,然后点击配置规则 最后如上图点击添加...或快速创建.   have fun!  将编程看作是一门艺术,而不单单是个技术。
4615 0
【开源】QuickPager ASP.NET2.0分页控件 v2.0.0.2版本。
下载地址:http://files.cnblogs.com/jyk/Page2.0.0.2_080701.rar 这回只有 dll文件。请把包里的文件拷贝到bin目录下。 道歉。 由于v2.0.0.1有些地方没有说说清楚,给一些朋友带来了一些麻烦,在这里向大家道歉,对不住大家了。
889 0
.NET中的repeater简介及分页效果
  Repeater控件是一个数据绑定容器控件,它能够生成各个项的列表,并可以使用模板定义网页上各个项的布局。当该页运行时,该控件为数据源中的每个项重复此布局。     配合模板使用repeater控件    若要使用repeater控件,需创建定义控件内容布局的模板。
835 0
【开源】QuickPager ASP.NET2.0分页控件V2.0.0.6 修改了几个小bug,使用演示。
     由于项目里面还在使用vs2003,还没有使用新的分页控件,所以对新的分页控件的测试还很不到位,遗留了不少的bug,感谢网友试用提出宝贵意见。由于项目正在收尾中,时间也不是太充裕,所以使用说明也不够详细。
767 0
QuickPager asp.net 分页控件、表单控件等自定义控件下载 和介绍 【2009.09.07更新】
  最新下载地址: 自然框架的源代码、Demo、数据库、配置信息管理程序下载(2010.01.25更新)     QuickControl web控件集包含的控件 QuickControl web控件集——基本控件: 控件名称 说明 详细介绍 MyTextBox ...
951 0
Struts2获取easyUI datagrid 分页参数page和rows
Struts2获取easyUI datagrid 分页参数page和rows   用pageHelper分页时,只要是能够获取前台传来的两个参数page和rows基本就完成了很大一部分。 获取方法:定义两个变量page和rows,设置对应的getter,setter方法,在方法中直接获取就能打得。
1134 0
+关注
474
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
文娱运维技术
立即下载
《SaaS模式云原生数据仓库应用场景实践》
立即下载
《看见新力量:二》电子书
立即下载