package com.dao;
import com.core.ConnDB;
import java.util.*;
import com.actionForm.BorrowForm;
import java.sql.*;
import com.actionForm.ReaderForm;
import com.actionForm.BookForm;
import java.util.Date;
public class BorrowDAO {
ConnDB conn = new ConnDB();
public int insert() {
String sql = "INSERT INTO tb_borrow (bookid) vlaues(1) ";
int ret = conn.executeUpdate(sql);
return ret;
}
//*****************************图书借阅******************************
public int insertBorrow(ReaderForm readerForm,BookForm bookForm,String operator){
//获取系统日期
Date dateU=new Date();
java.sql.Date date=new java.sql.Date(dateU.getTime());
String sql1="select t.days from tb_bookinfo b left join tb_booktype t on b.typeid=t.id where b.id="+bookForm.getId()+"";
ResultSet rs=conn.executeQuery(sql1);
int days=0;
try {
if (rs.next()) {
days = rs.getInt(1);
}
} catch (SQLException ex) {
}
//计算归还时间
String date_str=String.valueOf(date);
String dd = date_str.substring(8,10);
String DD = date_str.substring(0,8)+String.valueOf(Integer.parseInt(dd) + days);
java.sql.Date backTime= java.sql.Date.valueOf(DD);
String sql ="Insert into tb_borrow (readerid,bookid,borrowTime,backTime,operator) values("+readerForm.getId()+","+bookForm.getId()+",'"+date+"','"+backTime+"','"+operator+"')";
int falg = conn.executeUpdate(sql);
System.out.println("添加图书借阅信息的SQL:" + sql);
conn.close();
return falg;
}
//*************************************图书继借*********************************
public int renew(int id){
String sql0="SELECT bookid FROM tb_borrow WHERE id="+id+"";
ResultSet rs1=conn.executeQuery(sql0);
int flag=0;
try {
if (rs1.next()) {
//获取系统日期
Date dateU = new Date();
java.sql.Date date = new java.sql.Date(dateU.getTime());
String sql1 = "select t.days from tb_bookinfo b left join tb_booktype t on b.typeid=t.id where b.id=" +
rs1.getInt(1) + "";
ResultSet rs = conn.executeQuery(sql1);
int days = 0;
try {
if (rs.next()) {
days = rs.getInt(1);
}
} catch (SQLException ex) {
}
//计算归还时间
String date_str = String.valueOf(date);
String dd = date_str.substring(8, 10);
String DD = date_str.substring(0, 8) +
String.valueOf(Integer.parseInt(dd) + days);
java.sql.Date backTime = java.sql.Date.valueOf(DD);
String sql = "UPDATE tb_borrow SET backtime='" + backTime +
"' where id=" + id + "";
flag = conn.executeUpdate(sql);
}
} catch (Exception ex1) {}
conn.close();
return flag;
}
//*************************************图书归还*********************************
public int back(int id,String operator){
String sql0="SELECT readerid,bookid FROM tb_borrow WHERE id="+id+"";
ResultSet rs1=conn.executeQuery(sql0);
int flag=0;
try {
if (rs1.next()) {
//获取系统日期
Date dateU = new Date();
java.sql.Date date = new java.sql.Date(dateU.getTime());
int readerid=rs1.getInt(1);
int bookid=rs1.getInt(2);
String sql1="INSERT INTO tb_giveback (readerid,bookid,backTime,operator) VALUES("+readerid+","+bookid+",'"+date+"','"+operator+"')";
int ret=conn.executeUpdate(sql1);
if(ret==1){
String sql2 = "UPDATE tb_borrow SET ifback=1 where id=" + id +
"";
flag = conn.executeUpdate(sql2);
}else{
flag=0;
}
}
} catch (Exception ex1) {
}
conn.close();
return flag;
}
//*****************************查询图书借阅信息************************
public Collection borrowinfo(String str){
String sql="select borr.*,book.bookname,book.price,pub.pubname,bs.name bookcasename,r.barcode from (select * from tb_borrow where ifback=0) as borr left join tb_bookinfo book on borr.bookid=book.id join tb_publishing pub on book.isbn=pub.isbn join tb_bookcase bs on book.bookcase=bs.id join tb_reader r on borr.readerid=r.id where r.barcode='"+str+"'";
ResultSet rs=conn.executeQuery(sql);
Collection coll=new ArrayList();
BorrowForm form=null;
try {
while (rs.next()) {
form = new BorrowForm();
form.setId(Integer.valueOf(rs.getInt(1)));
form.setBorrowTime(rs.getString(4));
form.setBackTime(rs.getString(5));
form.setBookName(rs.getString(8));
form.setPrice(Float.valueOf(rs.getFloat(9)));
form.setPubName(rs.getString(10));
form.setBookcaseName(rs.getString(11));
coll.add(form);
}
} catch (SQLException ex) {
System.out.println("借阅信息:"+ex.getMessage());
}
conn.close();
return coll;
}
//*************************到期提醒******************************************
public Collection bremind(){
Date dateU = new Date();
java.sql.Date date = new java.sql.Date(dateU.getTime());
String sql="select borr.borrowTime,borr.backTime,book.barcode,book.bookname,r.name readername,r.barcode readerbarcode from tb_borrow borr join tb_bookinfo book on book.id=borr.bookid join tb_reader r on r.id=borr.readerid where borr.backTime <='"+date+"'";
ResultSet rs=conn.executeQuery(sql);
System.out.println("到时提醒的SQL:"+sql);
Collection coll=new ArrayList();
BorrowForm form=null;
try {
while (rs.next()) {
form = new BorrowForm();
form.setBorrowTime(rs.getString(1));
form.setBackTime(rs.getString(2));
form.setBookBarcode(rs.getString(3));
form.setBookName(rs.getString(4));
form.setReaderName(rs.getString(5));
form.setReaderBarcode(rs.getString(6));
coll.add(form);
System.out.println("图书条形码:"+rs.getString(3));
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
conn.close();
return coll;
}
//*************************图书借阅查询******************************************
public Collection borrowQuery(String strif){
String sql="";
if(strif!="all" && strif!=null && strif!=""){
sql="select * from (select borr.borrowTime,borr.backTime,book.barcode,book.bookname,r.name readername,r.barcode readerbarcode,borr.ifback from tb_borrow borr join tb_bookinfo book on book.id=borr.bookid join tb_reader r on r.id=borr.readerid) as borr where borr."+strif+"";
}else{
sql="select * from (select borr.borrowTime,borr.backTime,book.barcode,book.bookname,r.name readername,r.barcode readerbarcode,borr.ifback from tb_borrow borr join tb_bookinfo book on book.id=borr.bookid join tb_reader r on r.id=borr.readerid) as borr";
}
ResultSet rs=conn.executeQuery(sql);
System.out.println("图书借阅查询的SQL:"+sql);
Collection coll=new ArrayList();
BorrowForm form=null;
try {
while (rs.next()) {
form = new BorrowForm();
form.setBorrowTime(rs.getString(1));
form.setBackTime(rs.getString(2));
form.setBookBarcode(rs.
没有合适的资源?快使用搜索试试~ 我知道了~
基于JSP+Servlet+JavaBean+JDBC+DAO的Web图书管理架构设计该系统
共200个文件
java:64个
jsp:50个
class:32个
5星 · 超过95%的资源 需积分: 0 234 下载量 15 浏览量
2016-11-10
22:44:40
上传
评论 48
收藏 773KB RAR 举报
温馨提示
基于JSP+Servlet+JavaBean+JDBC+DAO的Web架构设计该系统,进一步了解并掌握如何对数据库进行操作,以及如何分析、设计一个应用系统。 需求要求: 该系统的基本需求是,系统要实现如下的基本管理功能: (1)用户分为两类:系统管理员,一般用户。
资源推荐
资源详情
资源评论
收起资源包目录
基于JSP+Servlet+JavaBean+JDBC+DAO的Web图书管理架构设计该系统 (200个子文件)
BorrowDAO.class 8KB
ManagerDAO.class 7KB
BookDAO.class 6KB
ReaderDAO.class 6KB
Borrow.class 6KB
Manager.class 6KB
Book.class 6KB
Reader.class 5KB
BorrowForm.class 5KB
ReaderType.class 4KB
BookType.class 4KB
BookCase.class 4KB
ReaderTypeDAO.class 4KB
BookTypeDAO.class 4KB
BookForm.class 4KB
BookCaseDAO.class 4KB
ReaderForm.class 3KB
ConnDB.class 3KB
Library.class 3KB
LibraryDAO.class 3KB
Parameter.class 2KB
LibraryForm.class 2KB
ManagerForm.class 2KB
ParameterDAO.class 2KB
CharacterEncodingFilter.class 2KB
PublishingDAO.class 1KB
ReaderTypeForm.class 1003B
BookTypeForm.class 999B
ParameterForm.class 938B
ChStr.class 864B
BookCaseForm.class 792B
PublishingForm.class 738B
.classpath 626B
org.eclipse.wst.common.component 444B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 3KB
Thumbs.db 35KB
程序使用说明书.doc 79KB
~$序使用说明书.doc 162B
top_bg.gif 51KB
main_booksort.gif 8KB
borrow_if.gif 7KB
borrowBackRenew_r.gif 7KB
borrowBackRenew.gif 7KB
borrowBackRenew_back.gif 7KB
search.gif 1KB
error_b.gif 1KB
main_readersort_1.gif 1KB
main_booksort_2.gif 701B
more.GIF 634B
item_over.gif 354B
item_out.gif 354B
main_booksort_1.gif 141B
navigation_bg.gif 133B
copyright_t.gif 96B
navigation_bg_bottom.gif 94B
refactorings.history 3KB
refactorings.history 1KB
refactorings.history 903B
refactorings.history 486B
refactorings.index 147B
refactorings.index 77B
refactorings.index 58B
refactorings.index 29B
mysql-connector-java-3.0.16-ga-bin.jar 231KB
BorrowDAO.java 10KB
BorrowDAO.java 10KB
Borrow.java 9KB
Borrow.java 9KB
ManagerDAO.java 9KB
ManagerDAO.java 9KB
Manager.java 8KB
Book.java 8KB
Manager.java 7KB
Reader.java 7KB
Book.java 7KB
ReaderDAO.java 7KB
Reader.java 6KB
BookDAO.java 6KB
BookDAO.java 6KB
ReaderType.java 5KB
ReaderDAO.java 5KB
ReaderType.java 5KB
BookType.java 5KB
BookCase.java 5KB
BookType.java 5KB
BookCase.java 4KB
BorrowForm.java 4KB
BorrowForm.java 4KB
BookForm.java 3KB
BookCaseDAO.java 3KB
BookCaseDAO.java 3KB
BookForm.java 3KB
ReaderTypeDAO.java 3KB
ReaderTypeDAO.java 3KB
BookTypeDAO.java 3KB
BookTypeDAO.java 3KB
ReaderForm.java 3KB
ReaderForm.java 3KB
ConnDB.java 3KB
共 200 条
- 1
- 2
资源评论
- yangyang54732023-07-1966666我举得还是客人要 #完美解决问题 #运行顺畅
- weixin_439478232019-10-1666666我举得还是客人要
- baozi2072017-06-08能不能把这个运行一下发个截图,我不太会看我君临天下2019-10-19可以啊
看我君临天下
- 粉丝: 83
- 资源: 363
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Serial Attach SCSI -5 protocal -SCSI 协议
- GitHub 是一个基于 Git 版本控制系统的在线代码托管平台,它不仅提供分布式版本控制,还提供了多种协作功能,使得软件开发者
- 车油口挡板开关闭合检测数据集VOC+YOLO格式138张2类别.zip
- 安装Linux操作系统是一个相对直接的过程,但需要根据您的具体需求和硬件配置来选择合适的发行版 以下是一份通用的Linux安装指
- 数据库SQL实战题目汇总.zip
- 基于深度学习实现驾驶员分心驾驶行为识别项目源码+数据集+模型+毕设论文
- 技术资料分享非常好的通俗易懂的开关电源原理与维修7.zip
- 数据库SQL实战题目汇总.zip
- NVM exporess 1.3 gold 文档
- linux操作系统基础命令.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功