using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;
public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
        SqlConnection con = new SqlConnection(ConStr);
        string SqlStr = "select  * from myuser where  sname = '" + TextBox1 .Text +"' and spwd = '" +TextBox2 .Text + "'";
        SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
        con.Open();
        DataSet ds = new DataSet();
        ada.Fill(ds);
        if (ds.Tables[0].Rows.Count > 0)
        {
            Session["username"] = TextBox1.Text;
            Response.Redirect("Default.aspx");
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误，请重新登录！')</script>");
        }

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Write("<script>window.close()</script>");
    }
}
