?? default.aspx.cs
字號:
using System;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session.RemoveAll();
}
protected void BtnLogin_Click(object sender, EventArgs e)
{
if (this.userName.Text.Trim() == "" || this.userPwd.Text.Trim() == ""||this.TextBox1.Text=="")
{
if (this.userName.Text.Trim() == "" && this.userPwd.Text.Trim() == ""&&this.TextBox1.Text.Trim()=="")
{
Response.Write("<script>alert('用戶名、密碼、驗證碼不能為空!')</script>");
}
else if (this.userName.Text.Trim() == "")
{
Response.Write("<script>alert('用戶名不能為空!')</script>");
}
else if (this.userPwd.Text.Trim() == "")
{
Response.Write("<script>alert('密碼不能為空!')</script>");
}
else {
Response.Write("<script>alert('驗證碼不能為空!')</script>");
}
}
else
{
if (String.Compare(Request.Cookies["CheckCode"].Value, this.TextBox1.Text, true) == 0)
{
int count = 0;
if (this.DDLtype.SelectedValue == "學(xué)生")
{
int exist;
exist = (new projClass()).ifStuExist(this.userName.Text);
if (exist == 1)
{
count = (new projClass()).getUser(this.userName.Text, this.userPwd.Text);
if (count == 1)
{
string stuId = this.userName.Text;
Session["stuId"] = stuId;
Response.Redirect("StudentInfo.aspx");
// Response.Redirect("userInfo.aspx?stuId="+stuId);
}
else Response.Write("<script>alert(\"密碼錯誤!請重新輸入\");</script>");
}
//else if(count==2)
//Response.Write("<script>alert(\"密碼錯誤!請重新輸入\");</script>");
else Response.Write("<script>alert(\"學(xué)號不存在!請確認(rèn)學(xué)號輸入正確\");</script>");
}
else if (this.DDLtype.SelectedValue == "管理員")
{
count = (new projClass()).getAdmin(this.userName.Text, this.userPwd.Text);
if (count > 0)
{
// Response.Write("<script>alert(\"登陸成功!\");</script>");
string adminId = this.userName.Text;
Session["adminId"] = adminId;
Response.Redirect("AdministratorInfo.aspx");
}
else Response.Write("<script>alert(\"登錄失敗!\");</script>");
}
else if (this.DDLtype.SelectedValue == "教師")
{
count = (new projClass()).getTeacher(this.userName.Text, this.userPwd.Text);
if (count > 0)
{
string teacherId = this.userName.Text;
Session["teacherId"] = teacherId;
Response.Redirect("TeacherInfo.aspx");
}
else Response.Write("<script>alert(\"登錄失敗!\");</script>");
}
}
else if (String.Compare(Request.Cookies["CheckCode"].Value, this.TextBox1.Text, true) != 0) {
Response.Write("<script>alert(\"驗證碼錯誤,請輸入正確的驗證碼!\");</script>");
return;
}
else{
Response.Write("<script>alert(\"您的瀏覽器設(shè)置已被禁用 Cookies,您必須設(shè)置瀏覽器允許使用 Cookies 選項后才能使用本系統(tǒng)!\");</script>");
return;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -