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

public partial class WebMain_news_newslist : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {            
        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        if (Request.QueryString["type"] == null)
        {   
            this.Panel1.Visible = true;
            this.Panel2.Visible = false;
            this.h4.Visible = true;
            this.h2.Visible = false;
            SqlCommand cmd = new SqlCommand("select * from news where id=" + Request.QueryString["id"], conn);
            SqlDataReader sdr = cmd.ExecuteReader();
            sdr.Read();
            this.title.Text = sdr.GetString(3);
            h3.Text = sdr.GetString(3);
            h4.Text = sdr.GetString(2);
            h4.NavigateUrl = "~/china/NewsGroup.aspx?id="+sdr.GetInt32(1);
            this.Author.Text = "作者：" + sdr.GetString(9);
            this.adddate.Text = "发布时间：" + Convert.ToString(sdr.GetDateTime(4));
            this.Source.Text = "来源：" + sdr.GetString(8);
            this.content.Text = Server.HtmlDecode(sdr.GetString(6)).Replace("http://127.0.0.1/", "../");
            this.times.Text = "已有" + Convert.ToString(sdr.GetInt32(7)) + "位网友关注此文章";
            sdr.Close();
            Doadmin.Exec("update news set times=times+1 where id="+Request.QueryString["id"]);
        }
        else
        {
            this.Panel1.Visible = false;
            this.Panel2.Visible = true;
            SqlCommand cmd2 = new SqlCommand("select title,Content from newsSole where id=" + Request.QueryString["id"], conn);
            SqlDataReader sdr2 = cmd2.ExecuteReader();
            sdr2.Read();
            this.Label1.Text = sdr2.GetString(0);
            this.h3.Text = sdr2.GetString(0);
            this.content2.Text = Server.HtmlDecode(sdr2.GetString(1)).Replace("http://127.0.0.1/","../");
            sdr2.Close();
           
        } 
        conn.Close();
    }
}
