一个按钮就可以有这么多代码了
private void Button1_Click(object sender, System.EventArgs e)
{
string stringconn="server=127.0.0.1;uid=sa;pwd=sa;database=teacher";
SqlConnection conn=new SqlConnection(stringconn);
string strSQL="select * from teacher where id = '"+textBox1.Text+"'";
SqlDataAdapter sqlDataAdapter= new SqlDataAdapter(strSQL,conn);
DataSet ds = new DataSet();
sqlDataAdapter.Fill(ds,"teacher");
if (ds.Tables["useradmin"].Rows.Count>0)
{
DataRow myDR=ds.Tables["teacher"].Rows[0];
if (textBox2.Text==myDR["pwd"].ToString().Trim())
{
Response.Write("<script>window.open('user.aspx','contents');</script>");
chuandi c=new chuandi();
c.setchuan(textBox1.Text);
Response.Write("<script>window.open('logo.htm','main');</script>");
}
else Response.Write("<script>window.open('error.htm','main');</script>");
}else Response.Write("<script>window.open('error.htm','main');</script>");
} |