allbook.jsp

    pageEncoding="UTF-8"%>

    <%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean>
<%
List<BookManage> list = dao.checkAll();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="menu.css"/>
</head>
<body>
<main>
<section class="glass">
<div>
<p class="tip">全部书籍</p>
</div>
<div class="dateshow">
<table>
<tr>
<th>编号</th>
<th>书名</th>
<th>作者</th>
<th>出版日期</th>
<th>类型</th>
<th>库存</th>
</tr>
<%for(BookManage book : list){
%>
<tr>
<td><%=book.getB_id() %></td>
<td><%=book.getB_name() %></td>
<td><%=book.getB_author() %></td>
<td><%=book.getB_date() %></td>
<td><%=book.getB_type() %></td>
<td><%=book.getB_stock() %></td>
</tr>
<%
}
%> </table>
</div>
<div class="foot1">
<a href="menu.jsp">返回首页</a>
</div>
</section>
</main>
</body>
<script type="text/javascript"> </script>
</html>

borrow.jsp

 pageEncoding="UTF-8"%>

 <%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean>
<%
List<BookManage> list = dao.checkAll();
int id = 0;
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="menu.css"/>
</head>
<body>
<main>
<section class="glass">
<div>
<p class="tip">请输入借出书籍的编号、书名,谢谢!</p>
</div>
<form action="onborrow.jsp" method="post">
<p>书籍编号:</p>
<input type="text" id="bnumber" name="bnumber"/>
<p>书籍名:</p>
<input type="text" id="bname" name="bname"/>
<input type="submit" id="submit" name="submit" value="借书"/>
</form>
<%
String jud = (String)session.getAttribute("jud");
if(jud == "true"){
%>
<script>
alert("借书成功!");
</script>
<%
session.setAttribute("jud", "");
}else if(jud == "false"){
%>
<script>
alert("借书失败!");
</script>
<%
session.setAttribute("jud", "");
}
%>
<div class="foot">
<a href="menu.jsp">返回首页</a>
</div>
</section>
</main>
</body>
<script type="text/javascript">
function judge(){
var nu = document.getElementById("bnumber");
var na = document.getElementById("bname");
if(parseInt(nu.value) !== null && na.value !== null){
return true;
}else{
return false;
}
}
</script> </html>

check.jsp

    pageEncoding="UTF-8"%>
<%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean> <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="menu.css"/>
</head>
<body>
<main>
<section class="glass">
<div>
<p class="tip">请输入要查询的书籍的编号、书名,谢谢!</p>
</div>
<form action="oncheck.jsp" method="post">
<p>书籍编号:</p>
<input type="text" id="bnumber" name="bnumber"/>
<p>书籍名:</p>
<input type="text" id="bname" name="bname"/>
<input type="submit" id="submit" name="submit" value="查询"/>
</form>
<div class="foot">
<a href="menu.jsp">返回首页</a>
</div>
</section>
</main>
</body>
<script type="text/javascript">
function judge(){
var nu = document.getElementById("bnumber");
var na = document.getElementById("bname");
if(parseInt(nu.value) !== null && na.value !== null){
return true;
}else{
return false;
}
}
</script> </html>

menu.css

*{
margin: 0;
padding: 0;
box-sizing: border-box;
} main{
min-height:100vh;
background:linear-gradient(to right top,#65dfc9,#6cdbeb);
display:flex;
align-items: center;
justify-content: center;
} .glass{
background: white;
min-height: 80vh;
width:60%;
background: linear-gradient(to right bottom,rgba(255,255,255,0.7),rgba(255,255,255,0.3));
border-radius: 2rem;
z-index: 2;
backdrop-filter: blur(2rem);
} .circle1,.circle2{
background:white;
background: linear-gradient(to right bottom,rgba(255,255,255,0.8),rgba(255,255,255,0.3));
height: 20rem;
width: 20rem;
position:absolute;
border-radius: 50%;
}
.circle1{
top: 5%;
right: 15%;
}
.circle2{
top: 60%;
left: 10%;
}
.title{
position: relative;
top: 50px;
}
.element{
height: 120px;
width: 120px;
float: left;
align-items: center;
margin: 20px;
}
.link{
background:rgb(109, 211, 236);
background: linear-gradient(to right bottom,rgba(255,255,255,0.8),rgba(255,255,255,0.3));
height: 120px;
width: 120px;
border-radius: 50%;
box-shadow: 5px 5px 5px rgba(0,0,0,0.2);
display: flex;
justify-content: center;
align-items: center; }
.links{
height: 60%;
width: 100%;
position: relative;
top: 130px;
display: flex;
justify-content: center;
align-items: center;
} img{
width: 80px;
height: 80px; }
a{
font-family:Georgia, 'Times New Roman', Times, serif;
position: relative;
display: flex;
justify-content: center;
align-items: center;
color: #26cce6;
text-decoration: none;
margin-top: 25px;
font-weight: 500;
border-radius: 20px;
background-color: rgba(255,255,255,0.2);
padding: 8px 20px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
}
h1{
text-align: center;
font-size: 60px;
color: #26cce6;
}
.tip{
position: relative;
top: 20px;
font-size: 20px;
color: #26cce6;
text-decoration: none;
margin-top: 25px;
font-weight: 500;
border-radius: 20px;
background-color: rgba(255,255,255,0.2);
padding: 8px 20px;
}
table{
width: 100%;
position: relative;
top: 50px;
text-align:center;
vertical-align:middle;
border-top: 1px solid #999;
border-left: 1px solid #999;
border-spacing: 0;/*去掉单元格间隙*/
}
table th{
border-bottom: 1px solid #999;
border-right: 1px solid #999;
}
table td{
border-bottom: 1px solid #999;
border-right: 1px solid #999;
}
.checkshow{
width: 100%;
position: relative;
top: 30px;
display: flex;
justify-content: center;
align-items: center;
}
.tab1{
width: 100%;
position: relative;
top: 20px;
text-align:center;
vertical-align:middle;
border-top: 1px solid #999;
border-left: 1px solid #999;
border-spacing: 0;/*去掉单元格间隙*/
}
.tab1>th{
border-bottom: 1px solid #999;
border-right: 1px solid #999;
}
.tad1>td{
border-bottom: 1px solid #999;
border-right: 1px solid #999;
}
form{
position: relative;
top: 130px;
display: flex;
justify-content: center;
align-items: center;
}
.foot{
width: 100%;
position: relative;
top: 430px;
right: 20px;
display: flex;
justify-content: flex-end;
align-items: flex-end;
}
.foot1{
width: 100%;
position: relative;
top: 330px;
right: 20px;
display: flex;
justify-content: flex-end;
align-items: flex-end;
}

menu.jsp

    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书管理系统</title>
<link rel="stylesheet" type="text/css" href="menu.css"/>
</head>
<body>
<main>
<section class="glass">
<div class="title">
<h1>图书管理系统</h1>
</div>
<div class="links">
<div class="element">
<div class="link">
<img src="./images/borrow1.png" alt=""/>
</div>
<a href="borrow.jsp">借阅</a>
</div>
<div class="element">
<div class="link">
<img src="./images/return1.png" alt=""/>
</div>
<a href="return.jsp">还书</a>
</div>
<div class="element">
<div class="link">
<img src="./images/check1.png" alt=""/>
</div>
<a href="check.jsp">查询</a>
</div>
<div class="element">
<div class="link">
<img src="./images/book1.png" alt=""/>
</div>
<a href="allbook.jsp">书库</a>
</div>
</div> </section>
</main>
<div class="circle1"></div>
<div class="circle2"></div>
</body>
</html>``` ##onborrow.jsp
```<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> <%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean>
<%
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("bnumber");
String name = request.getParameter("bname"); String i = "false"; int ids = Integer.valueOf(id);
if(dao.update(ids, name) != 0){
i = "true";
session.setAttribute("jud", i);
response.sendRedirect("borrow.jsp");
}else{
i = "false";
session.setAttribute("jud", i);
response.sendRedirect("borrow.jsp");
}
%> <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>```
##oncheck.jsp
```<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> <%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean>
<%
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("bnumber");
String name = request.getParameter("bname"); String i = "false"; int ids = Integer.valueOf(id);
List<BookManage> list = dao.check(ids,name);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="menu.css"/>
</head>
<body>
<main>
<section class="glass">
<div>
<p class="tip">查找到的信息</p>
</div>
<div class="checkshow">
<table class="tab1">
<tr>
<th>编号</th>
<th>书名</th>
<th>作者</th>
<th>出版日期</th>
<th>类型</th>
<th>库存</th>
</tr>
<%for(BookManage book : list){
%>
<tr>
<td><%=book.getB_id() %></td>
<td><%=book.getB_name() %></td>
<td><%=book.getB_author() %></td>
<td><%=book.getB_date() %></td>
<td><%=book.getB_type() %></td>
<td><%=book.getB_stock() %></td>
</tr>
<%
}
%> </table>
</div>
<div class="foot">
<a href="menu.jsp">返回首页</a>
</div>
</section>
</main>
</body>
<script type="text/javascript"> </script>
</html>

onreturn.jsp

    pageEncoding="UTF-8"%>

    <%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean>
<%
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("bnumber");
String name = request.getParameter("bname"); String i = "false"; int ids = Integer.valueOf(id);
if(dao.add(ids, name) != 0){
i = "true";
session.setAttribute("jud", i);
response.sendRedirect("return.jsp");
}else{
i = "false";
session.setAttribute("jud", i);
response.sendRedirect("return.jsp");
}
%> <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>

return.jsp

    pageEncoding="UTF-8"%>

    <%@ page import = "java.util.*" %>
<%@page import="com.book.service.*" %>
<%@page import="com.book.entity.*" %>
<%@page import="com.book.dao.*" %>
<jsp:useBean id="bse" class="com.book.service.BookService" scope="page"></jsp:useBean>
<jsp:useBean id="bm" class="com.book.entity.BookManage" scope="page"></jsp:useBean>
<jsp:useBean id="dao" class="com.book.dao.BookManageDao" scope="page"></jsp:useBean>
<%
int id = 0;
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="menu.css"/>
</head>
<body>
<main>
<section class="glass">
<div>
<p class="tip">请输入归还书籍的编号、书名,谢谢!</p>
</div>
<form action="onreturn.jsp" method="post">
<p>书籍编号:</p>
<input type="text" id="bnumber" name="bnumber"/>
<p>书籍名:</p>
<input type="text" id="bname" name="bname"/>
<input type="submit" id="submit" name="submit" value="还书"/>
</form>
<%
String jud = (String)session.getAttribute("jud");
if(jud == "true"){
%>
<script>
alert("还书成功!");
</script>
<%
session.setAttribute("jud", "");
}else if(jud == "false"){
%>
<script>
alert("还书失败!");
</script>
<%
session.setAttribute("jud", "");
}
%>
<div class="foot">
<a href="menu.jsp">返回首页</a>
</div>
</section>
</main>
</body>
<script type="text/javascript">
function judge(){
var nu = document.getElementById("bnumber");
var na = document.getElementById("bname");
if(parseInt(nu.value) !== null && na.value !== null){
return true;
}else{
return false;
}
}
</script> </html>

BookManageDao.java


import java.awt.print.Book;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List; import com.book.entity.BookManage; public class BookManageDao extends BaseDao{ //check *
public List<BookManage> checkAll() {
List<BookManage> list = new ArrayList<BookManage>();
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = getConnection();
//SQL code
String sql = "select * from bookinfo";
ps = conn.prepareStatement(sql);
//run
rs = ps.executeQuery();//rs is a from
while(rs.next()) {
//everyone is a object
BookManage b = new BookManage();
b.setB_id(rs.getInt(1));
b.setB_name(rs.getString(2));
b.setB_author(rs.getString(3));
b.setB_date(rs.getString(4));
b.setB_type(rs.getInt(5));
b.setB_stock(rs.getInt(6));
list.add(b);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally {
closeAll(conn, ps, null);
}
return list;
} //check query
public List<BookManage> check(int bid, String bname) {
List<BookManage> list = new ArrayList<BookManage>();
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = getConnection();
//SQL code
String sql = "select * from bookinfo where b_id=? and b_name=?";
ps = conn.prepareStatement(sql);
ps.setInt(1, bid);
ps.setString(2, bname);
//run
rs = ps.executeQuery();//rs is a from
while(rs.next()) {
//everyone is a object
BookManage b = new BookManage();
b.setB_id(rs.getInt(1));
b.setB_name(rs.getString(2));
b.setB_author(rs.getString(3));
b.setB_date(rs.getString(4));
b.setB_type(rs.getInt(5));
b.setB_stock(rs.getInt(6));
list.add(b);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally {
closeAll(conn, ps, null);
}
return list;
} //add
public int add(int bid, String bname) {
int i = 0;
Connection conn = null;
PreparedStatement ps = null; try {
//link
conn = getConnection();
//SQL code
String sql = "update bookinfo set b_stock=b_stock+1 where b_id=? and b_name=?";
//given ?
ps = conn.prepareStatement(sql);
ps.setInt(1, bid);
ps.setString(2, bname);
//run
i = ps.executeUpdate();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally {
closeAll(conn, ps, null);
} return i; } //update
public int update(int bid, String bname) {
int i = 0;
Connection conn = null;
PreparedStatement ps = null;
try {
//link
conn = getConnection();
//SQL code
String sql = "update bookinfo set b_stock=b_stock-1 where b_id=? and b_name=?";
//given ?
ps = conn.prepareStatement(sql);
ps.setInt(1, bid);
ps.setString(2, bname);
//run
i = ps.executeUpdate();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally {
closeAll(conn, ps, null);
} return i;
} }

BookManage.java


public class BookManage {
// b_id bigint not null auto_increment,
// b_name varchar(50) not null,
// b_author varchar(50) not null,
// b_date datetime not null,
// b_type int not null
// b_stock int(50) not null private int b_id;
private String b_name;
private String b_author;
private String b_date;
private int b_type;
private int b_stock; //空构造
public BookManage() {
super();
} // 构造
public BookManage(int b_id, String b_name, String b_author, String b_date, int b_type, int b_stock) {
super();
this.b_id = b_id;
this.b_name = b_name;
this.b_author = b_author;
this.b_date = b_date;
this.b_type = b_type;
this.b_stock = b_stock;
} public int getB_id() {
return b_id;
} public void setB_id(int b_id) {
this.b_id = b_id;
} public String getB_name() {
return b_name;
} public void setB_name(String b_name) {
this.b_name = b_name;
} public String getB_author() {
return b_author;
} public void setB_author(String b_author) {
this.b_author = b_author;
} public String getB_date() {
return b_date;
} public void setB_date(String b_date) {
this.b_date = b_date;
} public int getB_type() {
return b_type;
} public void setB_type(int b_type) {
this.b_type = b_type;
} public int getB_stock() {
return b_stock;
} public void setB_stock(int b_stock) {
this.b_stock = b_stock;
} }

BaseDao.java


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; public class BaseDao { //open connection
protected Connection getConnection(){
Connection conn = null; try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/book","root","root");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} return conn; } //close connection
protected void closeAll(Connection con,PreparedStatement ps,ResultSet rs) {
try {
if(rs != null) {
rs.close();
}
if(ps != null) {
ps.close();
}
if(con != null) {
con.close();
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
} }







最新文章

  1. c#设计模式-工厂方法
  2. codeforces 496B. Secret Combination 解题报告
  3. iOS开发之时间格式的转化
  4. json,serialze之格式
  5. jquery 提示插件 cluetip
  6. leaflet地图在选项卡中不正常显示
  7. chromium blog
  8. python 字典操作方法详解
  9. vueX、vue中transition的使用、axios
  10. PHP json_decode为什么将json字符串转成数组是对象格式?
  11. ActiveMQ(3)---ActiveMQ原理分析之消息持久化
  12. CSS圆角进化论
  13. [maven] dependency标签理解
  14. spring4.3.9 @ResponseBody中文乱码,全是问号
  15. SuperSocket.WebSocket.WebSocketServer.Setup无法启动
  16. 【Oracle+PHP】php连接oracle设定字符集,避免乱码
  17. Net分布式系统整体框架
  18. php中的PDO函数库详解
  19. IAsyncResult 接口
  20. Storm-源码分析- hook (backtype.storm.hooks)

热门文章

  1. Prime Distance
  2. 第六周作业-N67044-张铭扬
  3. 迁移virtualenv虚拟环境,复制,免安装
  4. Asp.NET core/net 5接口返回实体含有long/int64的属性序列后最后几位变为0的解决
  5. 基于Spring AOP切面实现请求入参出参加解密
  6. ap,路由器,交换机
  7. Server2008通过bat命令自动定时备份MySQL数据库
  8. python自动化-取消&quot;Chrome正受到自动软件的控制&quot;提示
  9. vscode plugin - jenkins jack使用方法
  10. 4、kubesphere环境安装