Asp.net源码专业站
首页->商务办公->Asp.net简单网络选课系统源码>>Login.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net简单网络选课系统源码
当前文件:文件类型 MyElectCourse/Login.aspx.cs[3K,2009-6-12 11:48:09]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12//该源码下载自www.51aspx.com(51aspx.com) 13 14public partial class Login : System.Web.UI.Page 15{ 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 19 } 20 protected void imgbtnLogin_Click(object sender, ImageClickEventArgs e) 21 { 22 //接收用户输入的参数 23 string userName = txtUserName.Text.ToString().Trim(); 24 string userPwd = txtPwd.Text.ToString().Trim(); 25 string userRole = rblClass.SelectedValue.Trim(); 26 string selectStr = ""; 27 switch (userRole) 28 { 29 case "0": //身份为教师时 30 selectStr = "Select * from Teacher where teaID = '" + userName + "'"; 31 break; 32 case "1": //身份为学生时 33 selectStr = "Select * from Student where stuID = '" + userName + "'"; 34 break; 35 case "2": //身份为管理员时 36 selectStr = "Select * from Users where adminName = '" + userName + "'"; 37 break; 38 } 39 SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); 40 SqlCommand cmd = new SqlCommand(selectStr,conn); 41 try 42 { 43 conn.Open(); //打开连接 44 SqlDataReader sdr = cmd.ExecuteReader(); //执行查询 45 if (sdr.Read()) //如果该用户存在 46 { 47 if (sdr.GetString(1) == userPwd) //密码正确 48 { 49 Session["userName"] = userName; 50 Session["userRole"] = userRole; 51 conn.Close(); 52 switch (userRole) 53 { 54 case "0": //身份为教师时 55 Response.Redirect("TeacherQueryElect.aspx"); 56 break; 57 case "1": //身份为学生时 58 Response.Redirect("StudentElect.aspx"); 59 break; 60 case "2": //身份为管理员时 61 Response.Redirect("Main.aspx"); 62 break; 63 } 64 } 65 else //密码错误,给出提示信息! 66 { 67 lblMessage.Text = "您输入的密码错误,请检查后重新输入!"; 68 } 69 } 70 else //用户不存在或用户名输入错误 71 { 72 lblMessage.Text = "该用户不存在或用户名输入错误,请检查后重新输入!"; 73 } 74 } 75 catch (Exception ee) 76 { 77 Response.Write("<script language=javascript>alert('" + ee.Message.ToString() + "')</script>"); 78 } 79 finally 80 { 81 conn.Close(); 82 } 83 } 84} 85
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Asp.net简单网络选课系统源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146