using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    int nResult = -1;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.Params["ShowID"] != null)
            {
                if (Int32.TryParse(Request.Params["ShowID"].ToString(), out nResult) == false) { return; }
                Addhit(nResult);
                ShownewsByID(nResult);
            }
           
        }
        
    }
    private void ShownewsByID(int nMynewsID)
    {
        INews shownews = new Mynews();
        SqlDataReader dr = shownews.GetnewsByID(nMynewsID);
        if (dr.Read())
        {
            lblLeibie.Text = dr["Leibie"].ToString();
            lblTitle.Text = dr["Title"].ToString();
            lblDate.Text = dr["Createdate"].ToString();
            lblChuchu.Text = dr["Chuchu"].ToString();
            lblAuthor.Text = dr["Author"].ToString();
            lblHit.Text = dr["Hit"].ToString();
            lblContent.Text = dr["Content"].ToString();
            this.Title = ConfigurationManager.AppSettings["WebTitle"].ToString() + "--" + lblTitle.Text.ToString();
        }
    }
    private void Addhit(int nMynews)
    {
        INews shownews = new Mynews();
        shownews.Executeinfo("UPDATE Mynews SET Hit=Hit+1 WHERE MynewsID=" + nMynews);
       
    }
    protected void closebtn_Click(object sender, EventArgs e)
    {
        Response.Write("<Script>window.close()</Script>");
    }
}
