package com.dao;
import com.core.ConnDB;
import java.text.SimpleDateFormat;
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);
//System.out.println("date_str="+date_str);
String dd = date_str.substring(8, 10);
//System.out.println("dd="+dd);
String DD = date_str.substring(0, 8)
+ String.valueOf(Integer.parseInt(dd) + days);
//System.out.println("DD="+DD);
//java.sql.Date backTime = java.sql.Date.valueOf(DD);
//用于计算归还的时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar ca=Calendar.getInstance();
ca.add(Calendar.DATE, days);
System.out.println(Calendar.DATE);
dateU=ca.getTime();
String backTime=format.format(dateU);
System.out.println("backtime"+backTime);
//System.out.println("backTime="+backTime);
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.getString(3));
form.setBookName(rs.getString(4));
form.setReaderName(rs.getString(5));
form.setReaderBarcode(rs.getString(6));
form.setIfBack(rs.getInt(7));
coll.add(form);
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
conn.close();
return coll;
}
// **********
没有合适的资源?快使用搜索试试~ 我知道了~
java图书馆借阅归还管理系统OA源码
共600个文件
gif:413个
jsp:52个
java:32个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 2 浏览量
2022-03-22
16:08:04
上传
评论
收藏 1.66MB ZIP 举报
温馨提示
1)用户登录图书馆管理系统后,可看到图书借阅排行榜,通过排行榜可以看出借阅图书的名称、图书类型、借阅次数等相关信息。(2)单击“系统设置”/“图书馆信息”命令,对图书馆信息进行设置操作。(3)单击“系统设置”/“管理员设置”命令,对管理员信息进行添加、权限设置、查询及删除操作。(4)单击“系统设置”/“参数设置”命令,对***费用及有效期限信息进行添加操作。(5)单击“系统设置”/“书架设置”命令,对书架信息进行添加、修改及删除操作。(6)单击“读者管理”/“读者类型管理”命令,对读者类型信息进行添加、修改及删除操作。(7)单击“读者管理”/“读者档案管理”命令,对读者信息进行添加、修改及删除操作。(8)单击“图书管理”/“图书类型设置”命令,对图书类型信息进行添加、修改及删除操作。(9)单击“图书管理”/“图书档案管理”命令,对图书信息进行添加、修改及删除操作。(10)单击“图书借还”/“图书借阅”命令,对图书借阅信息添加操作。(11)单击“图书借还”/“图书续借”命令,对图书续借信息进行添加操作。(12)单击“图书借还”/“图书归还”命令,对图书归还信息进行添加操作。
资源推荐
资源详情
资源评论
收起资源包目录
java图书馆借阅归还管理系统OA源码 (600个子文件)
BorrowDAO.class 9KB
ManagerDAO.class 7KB
BookDAO.class 7KB
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
BookCaseDAO.class 4KB
BookForm.class 4KB
ReaderForm.class 3KB
ConnDB.class 3KB
LibraryDAO.class 3KB
Library.class 3KB
Parameter.class 3KB
LibraryForm.class 2KB
ParameterDAO.class 2KB
ManagerForm.class 2KB
CharacterEncodingFilter.class 2KB
PublishingDAO.class 2KB
ReaderTypeForm.class 1003B
BookTypeForm.class 999B
ParameterForm.class 938B
ChStr.class 890B
BookCaseForm.class 792B
PublishingForm.class 738B
.classpath 850B
org.eclipse.wst.common.component 489B
org.eclipse.wst.jsdt.ui.superType.container 49B
amazeui.min.css 287KB
style.css 4KB
button.css 1KB
css.css 637B
程序使用说明书.doc 73KB
button_allbgs.gif 40KB
fw_top_bg.gif 30KB
main_booksort.gif 18KB
youqingtixing.gif 16KB
fw_top_bg_right.gif 14KB
fw_top_bg_left.gif 11KB
borrow_if (2).gif 8KB
win_operbar_bg_center.gif 7KB
main_operbar_bg.gif 7KB
login_05.gif 7KB
logo.gif 7KB
14.gif 6KB
09.gif 5KB
01.gif 5KB
fw_top_logo.gif 5KB
12.gif 5KB
11.gif 5KB
07.gif 5KB
18.gif 5KB
page_bar_bg.gif 5KB
21.gif 5KB
15.gif 5KB
16.gif 5KB
02.gif 5KB
17.gif 5KB
19.gif 5KB
20.gif 5KB
23.gif 5KB
08.gif 5KB
04.gif 5KB
borrowBackRenew1.gif 5KB
06.gif 5KB
10.gif 5KB
main_operbar_bg1.gif 5KB
borrowBackRenew1.gif 5KB
13.gif 5KB
03.gif 5KB
05.gif 4KB
borrowBackRenew_r.gif 4KB
borrowBackRenew.gif 4KB
input_bg_m.gif 4KB
borrowBackRenew_back.gif 4KB
fw_top_logo.gif 4KB
borrowBackRenew_back (2).gif 4KB
22.gif 4KB
wait.gif 4KB
wait.gif 4KB
search3.gif 4KB
login_04.gif 3KB
login_03.gif 3KB
main_bg.gif 2KB
face1.gif 2KB
progress_dialog.gif 2KB
face13.gif 2KB
fw_menu1_onmouseout.gif 2KB
face27.gif 2KB
logo_1.gif 2KB
fw_menu1_onmouseover.gif 2KB
login_dow.gif 2KB
login_06.gif 2KB
共 600 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- a4233035212022-04-25用户下载后在一定时间内未进行评价,系统默认好评。
办公模板库素材蛙
- 粉丝: 1660
- 资源: 2299
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功