You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
library_manage_system/WebContent/admin/cardborrow.jsp

91 lines
4.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@page import="javabean.Util"%> <!-- 导入Util类用于处理日期等工具类 -->
<%@page import="java.sql.PreparedStatement"%> <!-- 导入PreparedStatement类用于执行SQL语句 -->
<%@page import="java.sql.Connection"%> <!-- 导入Connection类用于建立数据库连接 -->
<%@page import="javabean.Base"%> <!-- 导入Base类可能包含数据库连接的获取方法 -->
<%@page import="java.sql.ResultSet"%> <!-- 导入ResultSet类用于存储查询结果 -->
<%@page import="javabean.JDBCBean"%> <!-- 导入JDBCBean类用于数据库操作未使用可能是冗余 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> <!-- 设置页面语言为Java字符编码为UTF-8,设置页面的字符编码为UTF-8 -->
<!DOCTYPE html> <!-- 声明文档类型为HTML5 -->
<html> <!-- 开始HTML文档 -->
<head>
<meta charset="UTF-8"> <!-- 设置页面字符编码为UTF-8 -->
<title>借阅证借阅记录</title> <!-- 设置页面标题为“借阅证借阅记录” -->
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all"> <!-- 引入layui的CSS文件 -->
<script src="../public/layui/layui.js" charset="utf-8"></script> <!-- 引入layui的JS文件 -->
<style>
.layui-table,.layui-table-view{ <!-- 定义表格样式 -->
margin: 0 0px; <!-- 设置表格的外边距为0 -->
}
</style>
</head>
<body>
<%
// 获取请求参数"id"(即借阅证号)
String id = request.getParameter("id");
// 获取数据库连接
Connection connection = (Connection)Base.getConnection();
// 定义SQL查询语句查询借阅记录和对应书籍信息
String sql = "select * from borrow_books,books where card_id=? and borrow_books.book_id = books.id";
// 创建PreparedStatement对象准备执行查询语句
PreparedStatement pstmt = connection.prepareStatement(sql);
// 设置SQL语句中的占位符参数
pstmt.setString(1, id);
// 执行查询,获取结果集
ResultSet resultSet = null;
resultSet = pstmt.executeQuery();
%>
<div class="layui-form">
<table class="layui-table"> <!-- 创建layui样式的表格 -->
<colgroup> <!-- 设置列宽 -->
<col width="150">
<col width="150">
<col width="200">
<col width="200">
<col width="200">
<col width="200">
<col width="220">
<col width="200">
<col> <!-- 最后一列自动调整宽度 -->
</colgroup>
<thead>
<tr>
<th>ID</th> <!-- 列标题ID -->
<th>书籍ID</th> <!-- 列标题书籍ID -->
<th>书籍名</th> <!-- 列标题:书籍名 -->
<th>借阅时间</th> <!-- 列标题:借阅时间 -->
<th>截止时间</th> <!-- 列标题:截止时间 -->
<th>归还时间</th> <!-- 列标题:归还时间 -->
<th>违规信息</th> <!-- 列标题:违规信息 -->
<th>处理人</th> <!-- 列标题:处理人 -->
</tr>
</thead>
<tbody>
<%
// 输出当前时间,用于调试
System.out.println(Util.getCurrentTimeString());
%>
<% while(resultSet.next()){ %> <!-- 循环遍历查询结果集 -->
<%-- 判断借阅书籍是否超期,且未归还 --%>
<%if(Util.getFormatDateTime(resultSet.getString("end_date")).compareTo(Util.getCurrentTimeString()) < 0 && resultSet.getString("return_date") == null){ %> <!-- 如果借阅截止时间早于当前时间且未归还 -->
<tr style="color:#FF5722;"> <!-- 高亮显示,设置行文字颜色为橙色 -->
<%} else{ %>
<tr> <!-- 正常显示,不做样式修改 -->
<%} %>
<td><%=resultSet.getString("card_id") %></td> <!-- 显示借阅证ID -->
<td><%=resultSet.getString("book_id") %></td> <!-- 显示书籍ID -->
<td><%=resultSet.getString("books.name") %></td> <!-- 显示书籍名称 -->
<td><%=Util.getFormatDateTime(resultSet.getString("borrow_date")) %></td> <!-- 显示借阅日期 -->
<td><%=Util.getFormatDateTime(resultSet.getString("end_date"))%></td> <!-- 显示借阅截止日期 -->
<td><%=resultSet.getString("return_date")!=null?Util.getFormatDateTime(resultSet.getString("return_date")) : "未归还" %></td> <!-- 如果归还日期不为空,则显示归还日期,否则显示“未归还” -->
<td><%=resultSet.getString("illegal")!=null?resultSet.getString("illegal"):""%></td> <!-- 显示违规信息,如果为空则显示空字符串 -->
<td><%=resultSet.getString("manager_id")!=null?resultSet.getString("manager_id"):"" %></td> <!-- 显示处理人ID如果为空则显示空字符串 -->
</tr>
<%} %> <!-- 循环结束 -->
</tbody>
</table>
</div>
</body>
</html>