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 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int nResult = -1;
        if (!Page.IsPostBack)
        {
            if (Request.Params["ShowID"] != null)
            {
                if (Int32.TryParse(Request.Params["ShowID"].ToString(), out nResult) == false) { return; }
                Showproduct(nResult);
                Adduptohit(nResult);
            }
           
        }
        
    }
    //显示产品
    private void Showproduct(int nParrentID)
    {
        INews Shownews = new Mynews();
        SqlDataReader dr = Shownews.Getproduct(nParrentID);
        if (dr.Read())
        {
            lblTitle.Text = dr["Title"].ToString();
            lblContent.Text = dr["Content"].ToString();
            lblHit.Text = dr["Hit"].ToString();
            lblDate.Text = dr["Mydate"].ToString();
            this.Title = System.Configuration.ConfigurationSettings.AppSettings["WebTitle"] +"--"+ lblTitle.Text;
            dr.Close();
          
        }
    }
    
    //产品点击加1
    private void Adduptohit(int nProductID)
    {
        INews shownews = new Mynews();
        shownews.Executeinfo("UPDATE Product SET Hit=Hit+1 WHERE ProductID=" + nProductID);
        
    }
    //关闭页面
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Response.Write("<Script>window.close()</Script>");
    }
}
