您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->明日网络考试系统源码>>Default.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:明日网络考试系统源码
当前文件:文件类型 NetExam/Default.aspx.cs打开代码结构图
普通视图
		            
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 13public partial class Default : System.Web.UI.Page 14{ 15 Datacon dataconn = new Datacon(); 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 Session["StuName"] = this.txtUserName.Text; 19 if (!IsPostBack) 20 { 21 Random rnd = new Random(); 22 //生成验证码 23 this.labValidate.Text = rnd.Next(1000,9999).ToString(); 24 } 25 } 26 //==============================找回密码========================= 27 protected void Button3_Click(object sender, EventArgs e) 28 { 29 Page.Response.Redirect("InfoPwd.aspx"); 30 } 31 //==============================新学生注册========================= 32 protected void Button2_Click(object sender, EventArgs e) 33 { 34 Page.Response.Redirect("zhuce.aspx"); 35 } 36 //==============================登录按钮========================= 37 protected void Button1_Click(object sender, EventArgs e) 38 { 39 if (txtValidate.Text != labValidate.Text) 40 { 41 Response.Write("<script lanuage=javascript>alert('验证码错误');location='javascript:history.go(-1)'</script>"); 42 } 43 else 44 { 45 if (cblAdminLog.Items[0].Selected == true) 46 { 47 this.getcom(1); 48 } 49 else 50 { 51 this.getcom(2); 52 } 53 } 54 } 55 //==============================登录控制============================ 56 private void getcom(int i) 57 { 58 SqlConnection con = dataconn.getcon(); 59 con.Open(); 60 SqlCommand com=con.CreateCommand(); 61 switch (i) 62 { 63 case 1: 64 com.CommandText = "select count(*) from tb_Administrator where Name='" + txtUserName.Text + "' and PWD='" + txtPwd.Text + "'"; 65 int count1 = Convert.ToInt32(com.ExecuteScalar());//获取SQL语句的值 强制转换成数值类型 66 if (count1 > 0) 67 { 68 Application["Name"] = txtUserName.Text;//成功 69 Application["PWD"] = txtPwd.Text;//成功 70 Page.Response.Redirect("HouAdmin/admin.aspx"); 71 } 72 else 73 { 74 Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); 75 return; 76 } 77 break; 78 case 2: 79 com.CommandText = "select count(*) from tb_Student where ID='" + txtUserName.Text + "' and PWD='" + txtPwd.Text + "'"; 80 int count2 = Convert.ToInt32(com.ExecuteScalar()); 81 if (count2 > 0) 82 { 83 Application["ID"] = txtUserName.Text; 84 Application["PWD"] = txtPwd.Text; 85 Page.Response.Redirect("QianUser/zaixian_kaoshi.aspx"); 86 } 87 else 88 { 89 Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); 90 return; 91 } 92 break; 93 } 94 con.Close(); 95 } 96} 97
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:明日网络考试系统源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号