protected void Button1_Click(object sender, EventArgs e) { if (this.DropDownList1.SelectedValue == "学生") { BStudent bll = new BStudent(); bool affacted = bll.CheckUser(TextBox1.Text, TextBox2.Text); if (affacted) { Session["sname"] = TextBox1.Text.ToString(); Response.Write("<script>alert('登陆成功!');location='Student/Studentlogin.aspx'</script>"); } else { Response.Write("<script>alert('用户名或密码错误!请重试!');location='Login.aspx'</script>"); } } if (this.DropDownList1.SelectedValue == "教师") { BTeacher bll = new BTeacher(); bool affacted = bll.CheckUser(TextBox1.Text, TextBox2.Text); if (affacted) { Session["tname"] = TextBox1.Text.ToString(); Response.Write("<script>alert('登陆成功!');location='Teacher/Tusercenter.aspx'</script>"); } else { Response.Write("<script>alert('用户名或密码错误!请重试!');location='Login.aspx'</script>"); } } if (this.DropDownList1.SelectedValue == "管理员") { BAdmin bll = new BAdmin(); bool affacted = bll.CheckUser(TextBox1.Text, TextBox2.Text); if (affacted) { Session["aname"] = TextBox1.Text.ToString(); Response.Write("<script>alert('登陆成功!');location='Admin/UserCentre.aspx'</script>"); } else { Response.Write("<script>alert('用户名或密码错误!请重试!');location='Login.aspx'</script>"); } } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (this.DropDownList1.SelectedValue == "教师") { BTeacher bll = new BTeacher(); Teacher t = new Teacher( Convert.ToString(TextBox1.Text), Convert.ToString(TextBox2.Text), Convert.ToString(TextBox3.Text) ); if (Page.IsValid) { bll.InsertTeacher(t); Response.Write("<script>alert('添加成功!');</script>"); } else { Response.Write("<script>alert('添加失败!');</script>"); } } if (this.DropDownList1.SelectedValue == "管理员") { BAdmin bll = new BAdmin(); Admin t = new Admin( Convert.ToString(TextBox1.Text), Convert.ToString(TextBox2.Text), Convert.ToString(TextBox3.Text) ); if (Page.IsValid) { bll.InsertAdmin(t); Response.Write("<script>alert('添加成功!');</script>"); } else { Response.Write("<script>alert('添加失败!');</script>"); } } }