package com.action;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.dao.*;
import com.actionForm.*;
public class Borrow extends Action {
/******************在构造方法中实例化Borrow类中应用的持久层类的对象**************************/
private BorrowDAO borrowDAO = null;
private ReaderDAO readerDAO=null;
private BookDAO bookDAO=null;
private ReaderForm readerForm=new ReaderForm();
public Borrow() {
this.borrowDAO = new BorrowDAO();
this.readerDAO=new ReaderDAO();
this.bookDAO=new BookDAO();
}
/******************************************************************************************/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
BorrowForm borrowForm = (BorrowForm) form;
String action =request.getParameter("action");
if(action==null||"".equals(action)){
request.setAttribute("error","您的操作有误!");
return mapping.findForward("error");
}else if("bookBorrowSort".equals(action)){
return bookBorrowSort(mapping,form,request,response);
}else if("bookborrow".equals(action)){
return bookborrow(mapping,form,request,response); //图书借阅
}else if("bookrenew".equals(action)){
return bookrenew(mapping,form,request,response); //图书续借
}else if("bookback".equals(action)){
return bookback(mapping,form,request,response); //图书归还
}else if("Bremind".equals(action)){
return bremind(mapping,form,request,response); //借阅到期提醒
}else if("borrowQuery".equals(action)){
return borrowQuery(mapping,form,request,response); //借阅信息查询
}
request.setAttribute("error","操作失败!");
return mapping.findForward("error");
}
/*********************图书借阅排行***********************/
private ActionForward bookBorrowSort(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
request.setAttribute("bookBorrowSort",borrowDAO.bookBorrowSort());
return mapping.findForward("bookBorrowSort");
}
/*********************图书借阅查询***********************/
private ActionForward borrowQuery(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
String str=null;
String flag[]=request.getParameterValues("flag");
if (flag!=null){
String aa = flag[0];
if ("a".equals(aa)) {
if (request.getParameter("f") != null) {
str = request.getParameter("f") + " like '%" +
request.getParameter("key") + "%'";
}
}
if ("b".equals(aa)) {
String sdate = request.getParameter("sdate");
String edate = request.getParameter("edate");
if (sdate != null && edate != null) {
str = "borrowTime between '" + sdate + "' and '" + edate +
"'";
}
System.out.println("日期" + str);
}
//同时选择日期和条件进行查询
if (flag.length == 2) {
if (request.getParameter("f") != null) {
str = request.getParameter("f") + " like '%" +
request.getParameter("key") + "%'";
}
System.out.println("日期和条件");
String sdate = request.getParameter("sdate");
String edate = request.getParameter("edate");
String str1 = null;
if (sdate != null && edate != null) {
str1 = "borrowTime between '" + sdate + "' and '" + edate +
"'";
}
str = str + " and borr." + str1;
System.out.println("条件和日期:" + str);
}
}
request.setAttribute("borrowQuery",borrowDAO.borrowQuery(str));
System.out.print("条件查询图书借阅信息时的str:"+str);
return mapping.findForward("borrowQuery");
}
/*********************到期提醒***********************/
private ActionForward bremind(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
request.setAttribute("Bremind",borrowDAO.bremind());
return mapping.findForward("Bremind");
}
/*********************图书借阅***********************/
private ActionForward bookborrow(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
//查询读者信息
//ReaderForm readerForm=(ReaderForm)form; //此处一定不能使用该语句进行转换
readerForm.setBarcode(request.getParameter("barcode"));
ReaderForm reader = (ReaderForm) readerDAO.queryM(readerForm);
request.setAttribute("readerinfo", reader);
//查询读者的借阅信息
request.setAttribute("borrowinfo",borrowDAO.borrowinfo(request.getParameter("barcode")));
//完成借阅
String f = request.getParameter("f");
String key = request.getParameter("inputkey");
if (key != null && !key.equals("")) {
String operator = request.getParameter("operator");
BookForm bookForm=bookDAO.queryB(f, key);
if (bookForm!=null){
int ret = borrowDAO.insertBorrow(reader, bookDAO.queryB(f, key),
operator);
if (ret == 1) {
request.setAttribute("bar", request.getParameter("barcode"));
return mapping.findForward("bookborrowok");
} else {
request.setAttribute("error", "添加借阅信息失败!");
return mapping.findForward("error");
}
}else{
request.setAttribute("error", "没有该图书!");
return mapping.findForward("error");
}
}
return mapping.findForward("bookborrow");
}
/*********************图书继借***********************/
private ActionForward bookrenew(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
//查询读者信息
readerForm.setBarcode(request.getParameter("barcode"));
ReaderForm reader = (ReaderForm) readerDAO.queryM(readerForm);
request.setAttribute("readerinfo", reader);
//查询读者的借阅信息
request.setAttribute("borrowinfo",borrowDAO.borrowinfo(request.getParameter("barcode")));
if(request.getParameter("id")!=null){
int id = Integer.parseInt(request.getParameter("id"));
if (id > 0) { //执行继借操作
int ret = borrowDAO.renew(id);
if (ret == 0) {
request.setAttribute("error", "图书继借失败!");
return mapping.findForward("error");
} else {
request.setAttribute("bar", request.getParameter("barcode"));
return mapping.findForward("bookrenewok");
}
}
}
return mapping.findForward("bookrenew");
}
/*********************图书归还***********************/
private ActionForward bookback(ActionMapping mappin
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件) java期末大作业 基于Java+JSP实现的图书馆管理系统源码(含SQL数据库文件)
资源推荐
资源详情
资源评论































收起资源包目录





































































































共 179 条
- 1
- 2

柯晓楠
- 粉丝: 2w+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 该项目为一个集数据抓取与展示一体的ACM队员数据系统,基于Django、python实现。.zip
- 辅助背单词软件,基于艾宾浩斯记忆曲线(其实背啥都行)的Python重构版,增加在线查词与翻译等功能.zip
- 基于C开发的命令行输入输出流重定向与实时分析工具_支持快捷按键和文本框输入实时过滤计算分析多格式结果呈现文本提示弹窗曲线表格支持批量测试和日志抓取_用于开发调试协议分.zip
- 各种有用的web api 基于Golang, Python(tornado django scrapy gevent).zip
- 华南理工大学找到卷王,基于 Python 的综测系统数据爬虫.zip
- 湖南大学(HNU)数据库系统课程大作业 ATM系统 前端基于Python的PyQt5,后端基于MySQL.zip
- (新闻爬虫),基于python+Flask+Echarts,实现首页与更多新闻页面爬取
- 基于 Flask + Requests 的全平台音乐接口 Python 版.zip
- 基于 FFmpeg ,使用 Python 开发的批量媒体文件格式转换器。.zip
- 基于 CAI 的 OneBot Python 实现.zip
- 基于 nonebot2 开发的消息交互式 Python 解释器,依赖 docker SDK.zip
- 基于 Python 3 + Django 2 开发的用于适配手机的简单 Jenkins 构建平台.zip
- Python 语言的爬楼梯问题实现-计算爬到第 n 级台阶的方法数
- 基于 Napcat, NcatBot, JMComic-Crawler-Python 的 QQ 机器人。.zip
- 基于 Python Tornado 的博客程序 (练习).zip
- 基于 Python 3.5 + Django 2.0 开发的简单个人博客.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
- 3
前往页