62,074
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en">
<head>
<title>毕业设计系统登录</title><meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="Login/css/bootstrap.min.css" />
<link rel="stylesheet" href="Login/css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="Login/css/matrix-login.css" />
<link href="Login/css/font-awesome.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="loginbox">
<form id="loginform" class="form-vertical" action="../Login.ashx" method="post">
<input type="hidden" name="Login" value="true" />
<div class="control-group">
<div class="controls">
<div class="main_input_box">
<span class="add-on bg_lg"><i class="icon-user"></i></span><input type="text" name="Username" placeholder="用户名" required='required' oninvalid="setCustomValidity('请填写用户名!')" oninput="setCustomValidity('')" />
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="main_input_box">
<span class="add-on bg_ly"><i class="icon-lock"></i></span><input type="password" name="Password" placeholder="密码" required='required' oninvalid="setCustomValidity('请填写密码!')" oninput="setCustomValidity('')"/>
</div>
</div>
</div>
<div class="form-actions">
<span class="pull-left"><a href="#" class="flip-link btn btn-info" id="to-recover">忘记密码?</a></span>
<span class="pull-right"><input type="submit" value="登录" class="btn btn-success"/></span>
</div>
</form>
<form id="recoverform" action="#" class="form-vertical">
<p class="normal_text">请联系相关人员重置密码!</p>
<div class="form-actions">
<span class="pull-left"><a href="#" class="flip-link btn btn-success" id="to-login">« 返回登录</a></span>
</div>
</form>
</div>
<script src="Login/js/jquery.min.js"></script>
<script src="Login/js/matrix.login.js"></script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using System.Data;
using System.Data.SqlClient;
namespace thesis
{
/// <summary>
/// 登录界面
/// </summary>
public class Login : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
string filename="~/Login";
string template="login.html";
context.Session.Clear(); //清除Session的所有信息(记录用户的一些基本信息)
if (context.Request["Login"] != null)
{
bool login = Convert.ToBoolean(context.Request["Login"]);
if (login)
{
string usr = context.Request["Username"];
string pwd = context.Request["Password"];
dynamic login_data = CommonHelper.Login(usr, pwd); //登录类
if (login_data.error == 0) //判断用户是否登录成功!
{
//将用户的基本信息存入Session
context.Session["ID"] = login_data.id; //用户ID
context.Session["ROLE"] = login_data.role; //用户角色类型(学生,教师)
context.Session["NAME"] = login_data.name; //用户姓名
if (string.Equals("teacher", login_data.role)) //判断用户是教师
{
context.Session["ISLEADER"] = login_data.isleader; //该教师是否具有管理能力
context.Session["LEADERLV"] = login_data.leaderLv; //管理能力的等级
}
context.Response.Redirect("index.ashx"); //重定向到主页
}
else
{
switch ((int)login_data.error)
{
case -1:
CommonHelper.YesOrNo(context, false, "", "用户名输入有误", "Login.ashx");
break;
case -2:
CommonHelper.YesOrNo(context, false, "", "无此用户", "Login.ashx");
break;
case -3:
CommonHelper.YesOrNo(context, false, "", "密码输入错误,请重新输入", "Login.ashx");
break;
default:
CommonHelper.YesOrNo(context, false, "", "错误信息不明", "Login.ashx");
break;
}
}
}
else
{
string html=CommonHelper.GetHtml(filename,template,null);
context.Response.Write(html);
}
}
else
{
string html=CommonHelper.GetHtml(filename, template, null);
context.Response.Write(html);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
if (context.Request["Login"] != null)
{
bool login = Convert.ToBoolean(context.Request["Login"]);
if (login)