using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace yn165.admin
{
	/// <summary>
	/// ad_addarticle 的摘要说明。
	/// </summary>
	public class ad_addarticle : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox title;
		protected System.Web.UI.WebControls.TextBox content;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.DropDownList art_class;
		protected System.Web.UI.WebControls.ImageButton ImageButton1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
				SqlConnection conn = new SqlConnection("server=211.155.254.117;database=yn165;uid=yn165;pwd=159753");
				conn.Open();
				//类别处理---------------------
				SqlDataAdapter cmd1= new SqlDataAdapter("Select * From class",conn);
				DataSet ds = new DataSet();
				cmd1.Fill(ds,"tab_class");
				this.art_class.DataSource=ds.Tables["tab_class"].DefaultView;
				this.art_class.DataTextField="class";
				this.art_class.DataValueField="class";
				this.art_class.DataBind();
				//时间标签
				this.Label1.Text=DateTime.Now.ToString();
			}
			
			
			// 在此处放置用户代码以初始化页面
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN：该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			SqlConnection conn = new SqlConnection("server=211.155.254.117;database=yn165;uid=yn165;pwd=159753");
			conn.Open();
			string sql="insert into server (title,class,content,record_date) values('" + this.title.Text + "','" + 
				this.art_class.SelectedItem.Text + "','" + this.content.Text + "','" + this.Label1.Text + "')";
			SqlCommand cmd = new SqlCommand(sql,conn);
			cmd.ExecuteNonQuery();
			conn.Close();
			Response.Redirect("007.aspx");

		}
	}
}
