package com.action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import com.actionForm.BorrowBookForm;
import com.dao.BorrowBookDao;
import org.apache.struts.actions.DispatchAction;
import com.actionForm.BookForm;
import com.dao.BookDao;
import com.dao.ReaderDao;
import com.actionForm.ReaderForm;
import com.tool.ShowTime;
import java.util.List;
public class BorrowBookAction extends DispatchAction {
private BorrowBookDao borrowBookDao = new BorrowBookDao();
private ReaderDao readerDao = new ReaderDao();
private BookDao bookDao = new BookDao();
private ShowTime showTime = new ShowTime();
// 借书第一步
public ActionForward borrowBookLendOne(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
return mapping.findForward("BorrowBookLendOne");
}
// 借书第二步
public ActionForward borrowBookLendTwo(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String message = "";
ReaderForm readerForm = new ReaderForm();
readerForm.setBookCardMark(request.getParameter("readerCard"));
ReaderForm reader = readerDao.selectReader(readerForm);
if (reader == null) { // 判断借书证书是否已经存在以及判断是否已经过期
message = "您输入的借书人证号不存在!!!";
} else {
java.sql.Date currentTime = java.sql.Date.valueOf(showTime
.showCurrentTime());
java.sql.Date overTime = java.sql.Date
.valueOf(reader.getOverTime());
if (currentTime.after(overTime)) {
message = "您的借书人证件已经过期了,不能够再借书了!!!";
}
}
BorrowBookForm borrowBookForm = (BorrowBookForm) form;
borrowBookForm.setReaderCard(request.getParameter("readerCard"));
borrowBookForm.setLend("0");
BorrowBookForm borrowBook=borrowBookDao.selectBorrowBookGoOn(borrowBookForm);
if (borrowBook != null&& message.equals("")) { // 判断该用户是否已经借过书
message = "您已经借过一本书了,不能再借了!!!";
}
if (!message.equals("")) { // 主要的执行结果
request.setAttribute("message", message);
return mapping.findForward("BorrowBookLendOne");
}
return mapping.findForward("BorrowBookLendTwo");
}
// 借书第三步
public ActionForward borrowBookLendThree(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
BookForm bookForm = new BookForm();
bookForm.setLineNumber(request.getParameter("bookLink"));
BookForm book = bookDao.selectBook(bookForm);
// ===============
BorrowBookForm borrowBookForm = (BorrowBookForm) form;
borrowBookForm.setBooklink(Integer.parseInt(request
.getParameter("bookLink")));
borrowBookForm.setLend("0");
List borrowBookList = borrowBookDao
.selectBorrowBookNumber(borrowBookForm);
String message = "";
if (book == null) {
message = "您所要借的图书不存在!!!";
} else {
int mistake = book.getBookSum() - borrowBookList.size();
if (mistake < 3) {
message = "您所要借的图书在库存中不足3本,不能借了!!!";
}
}
// ===========
if (!message.equals("")) {
request.setAttribute("message", message);
return mapping.findForward("BorrowBookLendTwo");
}
ReaderForm readerForm = new ReaderForm();
readerForm.setBookCardMark(request.getParameter("readerCard"));
ReaderForm reader = readerDao.selectReader(readerForm);
request.setAttribute("bookForm", book);
request.setAttribute("readerForm", reader);
return mapping.findForward("borrowBookLendThree");
}
// 借书第四步
public ActionForward borrowBookLendFour(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
BorrowBookForm borrowBookForm = (BorrowBookForm) form;
borrowBookForm.setBookAuthor(borrowBookForm.getBookAuthor());
borrowBookForm.setBooklink(borrowBookForm.getBooklink());
borrowBookForm.setBookName(borrowBookForm.getBookName());
borrowBookForm.setBookPrice(borrowBookForm.getBookPrice());
borrowBookForm.setBookPunbilc(borrowBookForm.getBookPunbilc());
borrowBookForm.setLend("0");
borrowBookForm.setLendPrice(borrowBookForm.getLendPrice());
borrowBookForm.setOperation(borrowBookForm.getOperation());
borrowBookForm.setReaderCard(borrowBookForm.getReaderCard());
borrowBookForm.setStartTime(borrowBookForm.getStartTime());
borrowBookForm.setOverTime(borrowBookForm.getOverTime());
if (borrowBookDao.insertBorrowBook(borrowBookForm)) {
request.setAttribute("message", "图书借阅成功");
} else {
request.setAttribute("message", "图书借阅成功");
}
return mapping.findForward("BorrowBookLendOne");
}
// 图书继借第一步
public ActionForward borrowBookLendGoOne(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
return mapping.findForward("borrowBookLendGoOne");
}
// 图书继借第二步
public ActionForward borrowBookLendGoTwo(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
BorrowBookForm borrowBookForm = (BorrowBookForm) form;
borrowBookForm.setReaderCard(request.getParameter("readerCard"));
borrowBookForm.setLend("0");
BorrowBookForm borrowBook = borrowBookDao
.selectBorrowBookGoOn(borrowBookForm);
String message = "";
if (borrowBook == null) {
message = "您输入的借书人证号不存在!!!";
} else {
if(borrowBook.getLend().equals("1")){
request.setAttribute("message", "该图书已经归还!!!");
return mapping.findForward("borrowBookLendGoOne");
}
java.sql.Date currentTime = java.sql.Date.valueOf(showTime
.showCurrentTime());
java.sql.Date overTime = java.sql.Date.valueOf(borrowBook
.getOverTime());
if (currentTime.after(overTime)) {
message = "您输入的图书证号已经过期了。<br>请归还此书!!!";
}
}
// ===================
if (message.equals("")) {
request.setAttribute("form", borrowBook);
return mapping.findForward("borrowBookLendGoTwo");
} else {
request.setAttribute("message", message);
return mapping.findForward("borrowBookLendGoOne");
}
}
// 续借第三步
public ActionForward borrowBookLendGoThree(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
BorrowBookForm borrowBookForm = (BorrowBookForm) form;
borrowBookForm.setReaderCard(request.getParameter("readerCard"));
borrowBookForm.setStartTime(request.getParameter("startTime"));
borrowBookForm.setOverTime(request.getParameter("overTime"));
borrowBookForm.setOperation(request.getParameter("operation"));
if (borrowBookDao.updateBorrowBook(borrowBookForm)) {
request.setAttribute("message", "图书续借成功!!!");
} else {
request.setAttribute("message", "图书续借失败!!!");
}
return mapping.findForward("borrowBookLendGoOne");
}
// 图书归还第一步
public ActionForward lendBookOne(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("lendBookOne");
}
// 图书归还第二步
public ActionForward lendBookTwo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
BorrowBookForm borrowBookForm = (BorrowBookForm) form;
borrowBookForm.setReaderCard(request.getParameter("readerCard"));
borrowBookForm.setLend("0");
BorrowBookForm borrowBook = borrowBookDao
.selectBorrowBookGoOn(borrowBookForm);
if (borrowBook == null) {
request.setAttribute("message", "您输入的借书人证号不存在,请重新输入!!!");
return mapping.findForward("lendBookOne");
} else {
if(borrowBook.getLend().equals("1"
没有合适的资源?快使用搜索试试~ 我知道了~
基于struts和itabis的图书管理系统
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共174个文件
jsp:55个
class:30个
java:30个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 9 7 下载量 130 浏览量
2009-05-10
11:44:30
上传
评论
收藏 2.25MB RAR 举报
温馨提示
这是一个应用struts和itabis开发的图书馆管理系统,实现了图书的前台浏览与后台管理的相关操作。
资源推荐
资源详情
资源评论
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 174 条
- 1
- 2
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
naturalbo
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)