using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
public partial class values : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            int pagenumber = 6; //页面显示的数量
            int mypage;
            if (Request["page"] != "" && Request["page"] != null)
                mypage = Convert.ToInt32(Request["page"].ToString());
            else 
                mypage = 1;

            PageConent(pagenumber, mypage); //输入出留言

        }
    }

    /// <summary>
    /// 获取分页数据
    /// </summary>
    /// <param name="pagenumber"></param>
    /// <param name="mypage"></param>
    public void PageConent(int pagenumber, int mypage)
    {
        int page;                     //当前页面变量
        string sql=string.Empty;      //sql语句

        if (mypage > 0)
            page = mypage;
        else
            page = 1;

        if (page == 1)
            sql = "select top " + pagenumber + " * from A_Message order by id desc";
        else
            sql = "select top " + pagenumber + " * from A_Message where id not in(select top " + pagenumber * (page - 1) + " id from A_Message) order by id desc";
        DataSet ds;
          if (ISDatabase.SelectDatebase() == 1)
              ds = DbHelp.Query(sql);
          else
              ds = DbHelperOleDb.Query(sql); 

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < ds.Tables[0].Rows.Count;i++) 
        {
                sb.Append("<div class=\"msglist\">");
                sb.Append("<div>留言编号:"  + ds.Tables[0].Rows[i]["id"].ToString() + "</div>");
                sb.Append("<div>留言标题：" + ds.Tables[0].Rows[i]["Title"].ToString() + "</div>");
                sb.Append("<div>留言内容：" + ds.Tables[0].Rows[i]["Contents"].ToString() + "</div>");
                sb.Append("<div>留言人："   + ds.Tables[0].Rows[i]["M_user"].ToString() + "</div>");
                sb.Append("<div>留言IP"     + ds.Tables[0].Rows[i]["M_Ip"].ToString() + "</div>");
                sb.Append("<div>添加时间：" + ds.Tables[0].Rows[i]["AddTime"].ToString() + "</div>");
                sb.Append("</div>");
        }
        Response.Write(sb.ToString());

    }








}