parent
f32810d714
commit
a29f823ac0
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>借阅者登录页面</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
|
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
|
||||||
|
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||||
|
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||||
|
<!-- 可选的 Bootstrap 主题文件(一般不用引入) -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="./public/css/animate.css">
|
||||||
|
<link rel="stylesheet" href="./public/css/login.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container main">
|
||||||
|
<div id="login" class="contain animated fadeInDown">
|
||||||
|
<h1>工作人员登录</h1>
|
||||||
|
<form method="post">
|
||||||
|
<input type="text" name="user" class="form-control my_input" placeholder="请输入账号" required="required">
|
||||||
|
<input type="password" name="psw" class="form-control my_input" placeholder="请输入密码" required="required">
|
||||||
|
<input type="submit" class="form-control" value="登录" onclick="javascript:void(0);">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="./public/js/layer/layer.js"></script>
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
//登录
|
||||||
|
$("input[type=submit]").click(function(){
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "./managerLogin",
|
||||||
|
type: "post",
|
||||||
|
data: $("form").serialize(),
|
||||||
|
dataType: "json",
|
||||||
|
success: function( data ){
|
||||||
|
if(data.code == 0){
|
||||||
|
layer.msg("登录成功", {
|
||||||
|
icon: 6,
|
||||||
|
time: 1000
|
||||||
|
}, function(){
|
||||||
|
location.href = data.url;
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
layer.open({
|
||||||
|
title: "登录失败",
|
||||||
|
content: data.msg,
|
||||||
|
icon: 5,
|
||||||
|
anim: 6
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,121 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||||
|
<script src="../public/layui/layui.js"></script>
|
||||||
|
<style>
|
||||||
|
.layui-form-label{
|
||||||
|
margin-left:20%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div align="center" style=" margin-top: 2%;"><h1>借阅图书</h1></div>
|
||||||
|
<div align="center"
|
||||||
|
style="margin-left:30%; margin-top: 5%; width: 40%;">
|
||||||
|
|
||||||
|
<form class="layui-form layui-form-pane" action="03borrowSus.jsp">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">借阅证号</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="userid" lay-verify="required"
|
||||||
|
placeholder="请输入借阅证号" autocomplete="off" class="layui-input"><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">图书编号</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="bookid" lay-verify="required"
|
||||||
|
placeholder="请输入图书编号" autocomplete="off" class="layui-input"><br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">借阅日期</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="date1" id="date1" autocomplete="off"
|
||||||
|
class="layui-input"><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">截止日期</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="date2" lay-verify="required" id="date2" autocomplete="off"
|
||||||
|
class="layui-input"><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item" align="center">
|
||||||
|
<button class="layui-btn" lay-submit="" lay-filter="demo2">借阅</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
layui
|
||||||
|
.use(
|
||||||
|
[ 'form', 'layedit', 'laydate' ],
|
||||||
|
function() {
|
||||||
|
var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
|
||||||
|
//日期
|
||||||
|
laydate.render({
|
||||||
|
elem : '#date1',
|
||||||
|
type : 'datetime',
|
||||||
|
format : 'yyyy-M-d H:m:s',
|
||||||
|
value: new Date()
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem : '#date2',
|
||||||
|
type : 'datetime',
|
||||||
|
format : 'yyyy-M-d H:m:s'
|
||||||
|
});
|
||||||
|
|
||||||
|
//创建一个编辑器
|
||||||
|
var editIndex = layedit
|
||||||
|
.build('LAY_demo_editor');
|
||||||
|
|
||||||
|
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(demo1)', function(data) {
|
||||||
|
layer.alert(JSON.stringify(data.field), {
|
||||||
|
title : '最终的提交信息'
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
//表单赋值
|
||||||
|
layui.$('#LAY-component-form-setval').on(
|
||||||
|
'click', function() {
|
||||||
|
form.val('example', {
|
||||||
|
"username" : "贤心" // "name": "value"
|
||||||
|
,
|
||||||
|
"password" : "123456",
|
||||||
|
"interest" : 1,
|
||||||
|
"like[write]" : true //复选框选中状态
|
||||||
|
,
|
||||||
|
"close" : true //开关状态
|
||||||
|
,
|
||||||
|
"sex" : "女",
|
||||||
|
"desc" : "我爱 layui"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//表单取值
|
||||||
|
layui.$('#LAY-component-form-getval').on(
|
||||||
|
'click', function() {
|
||||||
|
var data = form.val('example');
|
||||||
|
alert(JSON.stringify(data));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,77 @@
|
|||||||
|
<%@ page import="java.sql.*"%>
|
||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<jsp:useBean id="borrow" scope="session" class="javabean.JDBCBean"></jsp:useBean>
|
||||||
|
<%
|
||||||
|
String user = request.getParameter("userid");
|
||||||
|
String book = request.getParameter("bookid");
|
||||||
|
String date1 = request.getParameter("date1");
|
||||||
|
String date2 = request.getParameter("date2");
|
||||||
|
String sql1 = "select * from borrow_card where ID =" + user;
|
||||||
|
|
||||||
|
ResultSet rs1 = borrow.executeQuery(sql1);
|
||||||
|
|
||||||
|
if (rs1.next()) {
|
||||||
|
String sql2 = "select * from books where ID =" + book;
|
||||||
|
ResultSet rs2 = borrow.executeQuery(sql2);
|
||||||
|
|
||||||
|
if(rs2.next()){
|
||||||
|
//out.println(psw1 + " " + psw2);
|
||||||
|
//String id = session.getAttribute("manager").toString();
|
||||||
|
|
||||||
|
String sql = "insert borrow_books(CARD_ID,BOOK_ID,BORROW_DATE,END_DATE)values('" + user + "','" + book
|
||||||
|
+ "','" + date1 + "','" + date2 + "');";
|
||||||
|
try {
|
||||||
|
int i = borrow.executeUpdate(sql);
|
||||||
|
if (i == 1) {
|
||||||
|
%>
|
||||||
|
<script>
|
||||||
|
alert('修改成功!');
|
||||||
|
window.location.href = "02borrow.jsp";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<%
|
||||||
|
} else {
|
||||||
|
%>
|
||||||
|
<script>
|
||||||
|
alert('修改未成功!');
|
||||||
|
window.location.href = "02borrow.jsp";
|
||||||
|
</script>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
%>
|
||||||
|
<script>
|
||||||
|
alert('修改未成功!');
|
||||||
|
window.location.href = "02borrow.jsp";
|
||||||
|
</script>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
%>
|
||||||
|
<script>
|
||||||
|
alert('该图书不存在!');
|
||||||
|
window.location.href = "02borrow.jsp";
|
||||||
|
</script>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
%>
|
||||||
|
<script>
|
||||||
|
alert('用户不存在!');
|
||||||
|
window.location.href = "02borrow.jsp";
|
||||||
|
</script>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Binary file not shown.
Binary file not shown.
@ -1,5 +1,32 @@
|
|||||||
package javabean;
|
package javabean;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Manager {
|
public class Manager {
|
||||||
|
@SuppressWarnings("null")
|
||||||
|
public String login(String user, String psw) throws ClassNotFoundException, SQLException {
|
||||||
|
|
||||||
|
if (user == null || user.trim().equals("")) {
|
||||||
|
return "账号不能为空";
|
||||||
|
} else if (psw == null || psw.trim().equals("")) {
|
||||||
|
return "密码不能为空";
|
||||||
|
}
|
||||||
|
Connection connection = null;
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
System.out.println("????");
|
||||||
|
String sql = "select * from manager where ACCOUNT=? and PASSWORD=?";
|
||||||
|
connection = Base.getConnection();
|
||||||
|
pstmt = (PreparedStatement) connection.prepareStatement(sql);
|
||||||
|
pstmt.setString(1, user);
|
||||||
|
pstmt.setString(2, psw);
|
||||||
|
resultSet = pstmt.executeQuery();
|
||||||
|
if (resultSet.next()) {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
return "账号或密码错误";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,61 @@
|
|||||||
package servlet.manager;
|
package servlet.manager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import javabean.Manager;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
@WebServlet("/managerLogin")
|
@WebServlet("/managerLogin")
|
||||||
public class ManagerLogin extends HttpServlet {
|
public class ManagerLogin extends HttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
response.getWriter().append("Served at: ").append(request.getContextPath());
|
response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
// 设置头文件
|
||||||
doGet(request, response);
|
response.setContentType("application/json; charset=utf8");
|
||||||
|
PrintWriter out = response.getWriter();
|
||||||
|
// 获取账号密码
|
||||||
|
String user = request.getParameter("user");
|
||||||
|
String psw = request.getParameter("psw");
|
||||||
|
// 设置响应map
|
||||||
|
HashMap<String, Object> hashMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
Manager manager = new Manager();
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
result = manager.login(user, psw);
|
||||||
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (result.equals("1")) {
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
session.setAttribute("manager", user);
|
||||||
|
session.setAttribute("manager_first", "1"); // 登录
|
||||||
|
hashMap.put("code", 0);
|
||||||
|
hashMap.put("msg", "登录成功");
|
||||||
|
hashMap.put("url", request.getContextPath() + "/manager/01nav.jsp");
|
||||||
|
} else {
|
||||||
|
hashMap.put("code", 1);
|
||||||
|
hashMap.put("msg", result);
|
||||||
|
}
|
||||||
|
// response.sendRedirect(request.getContextPath() +"/test.jsp");
|
||||||
|
JSONObject json = JSONObject.fromObject(hashMap);
|
||||||
|
out.write(json.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue