using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class New_Info : System.Web.UI.Page
{
    BLL.News news = new BLL.News(); 
    int nID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["nid"] != null)
        {
            Title = "欢迎光临大气象学习园地！";
            nID = Int32.Parse(Request.Params["nid"].ToString());
            if (!Page.IsPostBack)
            {
                if (nID > 0)
                {
                    this.Bind();
                    news.updatepointnum(int.Parse(this.Request.QueryString["nid"].ToString()));
                }
                else
                {
                    Response.Write("<script>alert('请选择数据');history.back(1);</script>");
                    Response.End();
                }
            }
        }
        else
        {
            Response.Write("<script>alert('请选择数据');history.back(1);</script>");
            Response.End();
        }
    }
    protected void Bind()
    {
        nID = int.Parse(this.Request.QueryString["nid"].ToString());
        DataRow dr = news.getoneNews(nID);
        this.Title_2.Text = dr["Title"].ToString();
        this.Author.Text = dr["Author"].ToString();
        this.Updatatime.Text = dr["UpdateTime"].ToString();
        this.Content.Text = dr["Content"].ToString();

        //绑定上一篇,下一篇
        if (news.getpreNews(nID) != "")
        {
            this.Hl_pre.NavigateUrl = "New_Info.aspx?nid=" + news.getpreNews(nID);
        }
        else
            this.Hl_pre.Text = "没有上一篇";
        if (news.getnextNews(nID) != "")
        {
            this.Hl_next.NavigateUrl = "New_Info.aspx?nid=" + news.getnextNews(nID);
        }
        else
            this.Hl_next.Text = "没有下一篇";
    }
}
