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 free.bbs
{
	/// <summary>
	/// Summary description for guanlidenglu.
	/// </summary>
	public class guanlidenglu : System.Web.UI.Page
	{
		protected System.Web.UI.HtmlControls.HtmlInputButton denglu;
		protected System.Web.UI.HtmlControls.HtmlInputText password;
		protected System.Data.SqlClient.SqlConnection myconn;
		protected System.Web.UI.HtmlControls.HtmlInputText name;
		protected System.Data.SqlClient.SqlCommand mycomm;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.denglu.ServerClick += new System.EventHandler(this.denglu_ServerClick);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void denglu_ServerClick(object sender, System.EventArgs e)
		{
			string sql="select* from huiyuan where yonghuming=@name and mima=@mima";
			myconn=new SqlConnection(Session["str_connection"].ToString());
			mycomm= new SqlCommand(sql,myconn);
			mycomm.Parameters.Add(new SqlParameter("@name", SqlDbType.Char, 20));
			mycomm.Parameters["@name"].Value =name.Value ;

			mycomm.Parameters.Add(new SqlParameter("@mima", SqlDbType.Char, 20));
			mycomm.Parameters["@mima"].Value =password.Value;
			myconn.Open();	
			
			SqlDataReader dr=mycomm.ExecuteReader();
			if(dr.Read())
			{
				Response.Cookies["free_huiyuan"].Value =name.Value.Trim();
				dr.Close();
				Response.Redirect("guanli.aspx?ancestor_id="+Request.Params["ancestor_id"]+"");
			}
			else
			{
				dr.Close();
				Response.Redirect("error1.aspx");
			}			
			myconn.Close();   
		
		}
	}
}
