您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->在线考试系统源码及论文>>Default.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:在线考试系统源码及论文
当前文件:文件类型 OnlineTestSystem/Default.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Web.UI.WebControls.WebParts; 9using System.Web.UI.HtmlControls; 10using System.Data.OleDb; 11 12public partial class _Default : System.Web.UI.Page 13{ 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 17 } 18 19 protected void testlogbtn_Click(object sender, EventArgs e) 20 { 21 string username = usernametxt.Text.Trim(); 22 string password = pawtxt.Text.Trim(); 23 string connecionstring =(string)Application["connectstring"]; 24 OleDbConnection conn = new OleDbConnection(connecionstring); 25 try 26 { 27 bool flag=false; 28 conn.Open(); 29 string commandtext = "select distinct * from student where studentname='" + username + "' and paw='" + password + "'"; 30 OleDbCommand checkcommand = new OleDbCommand(commandtext, conn); 31 OleDbDataReader dr = checkcommand.ExecuteReader(); 32 flag = dr.HasRows; 33 if (flag) 34 { 35 Session.Add("username", username); 36 Session.Add("logintime", System.DateTime.Now.ToLongTimeString()); 37 conn.Close(); 38 Response.Redirect("test.aspx"); 39 } 40 else 41 { 42 lblmessage.Text = "用户名或密码错误,请重新登陆!"; 43 usernametxt.Text = ""; 44 pawtxt.Text = ""; 45 } 46 47 } 48 catch (Exception err) 49 { 50 Response.Write(err.Message); 51 //Response.Redirect("error.aspx"); 52 } 53 finally 54 { 55 if (conn.State == ConnectionState.Open) 56 conn.Close(); 57 } 58 59 } 60 61 protected void adminlogbtn_Click(object sender, EventArgs e) 62 { 63 string username = usernametxt.Text.Trim(); 64 string password = pawtxt.Text.Trim(); 65 string connecionstring = (string)Application["connectstring"]; 66 OleDbConnection conn = new OleDbConnection(connecionstring); 67 try 68 { 69 bool flag = false; 70 conn.Open(); 71 string commandtext = "select distinct * from admin where name='" + username + "' and password='" + password + "'"; 72 OleDbCommand checkcommand = new OleDbCommand(commandtext, conn); 73 OleDbDataReader dr = checkcommand.ExecuteReader(); 74 flag = dr.HasRows; 75 if (flag) 76 { 77 Session.Add("username", username); 78 Session.Add("logintime", System.DateTime.Now.ToLongTimeString()); 79 Session.Add("role", "adminstrator"); 80 conn.Close(); 81 Response.Redirect("guanli.aspx"); 82 } 83 else 84 { 85 lblmessage.Text = "用户名或密码错误,请重新登陆!"; 86 usernametxt.Text = ""; 87 pawtxt.Text = ""; 88 } 89 90 } 91 catch (Exception err) 92 { 93 Response.Write(err.Message); 94 //Response.Redirect("error.aspx"); 95 } 96 finally 97 { 98 if (conn.State == ConnectionState.Open) 99 conn.Close(); 100 } 101 } 102 103} 104
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:在线考试系统源码及论文
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号