using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
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 value=this.DropDownList1.SelectedValue;
if ( value== "0")
{
Response.Write(
"<script language=javascript>alert('请选择您的级别!')</script>");
}
else
{
SQLHelper sqlHelper = new SQLHelper();
DataSet dt = new DataSet();
try
{
string strSql="";
if (value == "1")
{
strSql = "select * from admin where Admin_name='" +
this.TextBox1.Text + "' and Admin_pass='" +
StringHelper.EncryptCookie(this.TextBox2.Text) + "'";
}
if (value == "2")
{
strSql = "select * from teacher where tea_name='" +
this.TextBox1.Text + "' and tea_pass='" +
StringHelper.EncryptCookie(this.TextBox2.Text) + "'";
}
if (value == "3")
{
strSql = "select * from Users where UserName='" +
this.TextBox1.Text + "' and UserPwd='" +
this.TextBox2.Text + "'";
}
dt = sqlHelper.ExecuteDataSet(strSql);
if (dt.Tables[0].Rows.Count > 0)
{
Session["jibie"] = this.DropDownList1.SelectedItem.Text;
Session["name"] = this.TextBox1.Text;
if (value == "1")
{
Response.Redirect("Default.aspx");
}
if (value == "2")
{
Response.Redirect("Teacher\\main.aspx");
}
if (value == "3")
{
Session["userID"] = dt.Tables[0].Rows[0]["UserID"].ToString();//存储用户编号
Response.Redirect("Student\\Default.aspx");
}
}
else
{
Response.Write(
"<script language=javascript>alert('用户名或者密码错误!')</script>");
ValidateNum clear = new ValidateNum();
clear.cleanall(this.Page);
}
}
catch (Exception ex)
{
Response.Write("登录失败:" + ex);
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
ValidateNum clear = new ValidateNum();
clear.cleanall(this.Page);
}
}
如需定做或者获取更多资料,请联系QQ:375279829