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//这个是 声明一个 Login类,继承自System.Web.UI.Page,它是一个公共部分类
{
protected void Page_Load(object sender, EventArgs e)//页面加载事件,
{
if (!IsPostBack)
{
cx.Items.Add("管理员");
cx.Items.Add("考生");
}
}
protected void btLogin_Click(object sender, ImageClickEventArgs e)
{
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (TextBox2.Text.ToString().Trim() == "" || TextBox1.Text.ToString().Trim() == "")
{
Response.Write("<script>javascript:alert('请输入完整');history.back();</script>");
Response.End();
}
string sql;
if (cx.SelectedItem.ToString().Trim() == "管理员")
{
sql = "select * from allusers where username='" + TextBox2.Text.ToString().Trim() + "' and pwd='" + TextBox1.Text.ToString().Trim() + "'";
}
else
{
sql = "select * from kaosheng where xh='" + TextBox2.Text.ToString().Trim() + "' and pwd='" + TextBox1.Text.ToString().Trim() + "'";
}
DataSet result = new DataSet();
result = new Class1().hsggetdata(sql);
// result = new TestOnline.Class1().hsggetdata(sql);
if (result != null)
{
if (result.Tables[0].Rows.Count > 0)
{
Session["username"] = TextBox2.Text.ToString().Trim();
Session["role"] = cx.SelectedItem.ToString().Trim();
Response.Redirect("default.htm");
}
else
{
Response.Write("<script>javascript:alert('对不起,用户名或密码不正确!');</script>");
}
}
else
{
Response.Write("<script>javascript:alert('对不起,系统错误,请不要越权操作!');</script>");
}
}
}