package com.library.model;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Calendar;
import com.library.common.Dbconn;
import com.library.view.BookVo;
import com.library.view.BrBookVo;
import com.library.view.Error;
public class BrBookModel {
Dbconn dbc;
String fakuan;
long s;
public void YueJieBook(String kahao,int id){
dbc=new Dbconn();
Connection con=dbc.getCon();
try {
Statement stmt=con.createStatement();
String sql1="select bianma from books_info where id="+id;
ResultSet rs=stmt.executeQuery(sql1);
String bianma=null;
while(rs.next()){
bianma=rs.getString("bianma");
}
String sql="insert into books_br(con,bon,flag) values("+kahao+",'"+bianma+"',0"+")";
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public ArrayList SelectYuJieBooks(String kahao){
ArrayList a=new ArrayList();
dbc = new Dbconn();
Connection con = dbc.getCon();
Statement stmt;
try {
stmt = con.createStatement();
String sql = "select books_br.id,bianma,bookname,author,bookkind,fakuan from books_info,books_br,card_info where card_no=con and card_no="+kahao+"and bianma=bon and flag=0";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
int id=rs.getInt("id");
String bianma=rs.getString("bianma");
String name=rs.getString("bookname");
String author=rs.getString("author");
String kind=rs.getString("bookkind");
String fakuan=rs.getString("fakuan");
BrBookVo bbv=new BrBookVo();
bbv.setId(id);
bbv.setBianma(bianma);
bbv.setBookname(name);
bbv.setAuthor(author);
bbv.setBookkind(kind);
bbv.setFakuan(fakuan);
a.add(bbv);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return a;
}
public void DeleteYuJieBook(int id){
dbc=new Dbconn();
Connection con=dbc.getCon();
try {
Statement stmt=con.createStatement();
String sql="delete from books_br where id="+id;
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void BorrowBook(int id){
dbc=new Dbconn();
Date d=new Date(new java.util.Date().getTime());
int a=d.getYear();
int c=d.getDate();
int b=d.getMonth();
String time=null;
if(b+2==13){
time=(a+1+1900)+"-01"+"-"+c;
}else{
time=(a+1900)+"-"+(b+2)+"-"+c;
}
Connection con=dbc.getCon();
try {
Statement stmt=con.createStatement();
String sql="update books_br set flag=1,bdate='"+d+"',rdate='"+time+"' where id="+id;
stmt.executeUpdate(sql);
String sql1="select con,bon from books_br where id="+id;
ResultSet rs=stmt.executeQuery(sql1);
String bianma=null;
int card_no=0;
while(rs.next()){
bianma=rs.getString("bon");
card_no=rs.getInt("con");
}
String sql2="update books_info set shuliang=shuliang-1 where bianma='"+bianma+"'";
stmt.executeUpdate(sql2);
String sql3="update card_info set maxborrow=maxborrow-1 where card_no="+card_no;
stmt.executeUpdate(sql3);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//判断还有没有书
public boolean BookSubtract(int id){
boolean bool=false;
dbc=new Dbconn();
Connection con=dbc.getCon();
try {
Statement stmt=con.createStatement();
String sql="select bon from books_br where id="+id;
ResultSet rs=stmt.executeQuery(sql);
String bianma=null;
while(rs.next()){
bianma=rs.getString("bon");
}
String sql1="select shuliang from books_info where bianma='"+bianma+"'";
ResultSet rs1=stmt.executeQuery(sql1);
int shuliang = 0;
while(rs1.next()){
shuliang=rs1.getInt("shuliang");
}
if(shuliang>0){
bool=true;
}
else{
bool=false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bool;
}
//判断借阅卡的最多借阅次数
public boolean SelectMaxBorrow(int id){
boolean bool=false;
dbc=new Dbconn();
Connection con=dbc.getCon();
Statement stmt;
try {
stmt = con.createStatement();
String sql="select con from books_br where id="+id;
ResultSet rs=stmt.executeQuery(sql);
int card_no=0;
while(rs.next()){
card_no=rs.getInt("con");
}
String sql2="select maxborrow from card_info where card_no="+card_no;
ResultSet rs2=stmt.executeQuery(sql2);
int maxborrow=0;
while(rs2.next()){
maxborrow=rs2.getInt("maxborrow");
}
if(maxborrow>0){
bool=true;
}
else{
bool=false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bool;
}
//查看已经借的书
public ArrayList SelectYiJieBooks(String kahao){
ArrayList a=new ArrayList();
dbc = new Dbconn();
Connection con = dbc.getCon();
Statement stmt;
try {
stmt = con.createStatement();
String sql = "select books_br.id,bianma,bookname,author,bookkind,fakuan from books_info,books_br,card_info where card_no=con and card_no="+kahao+"and bianma=bon and flag=1";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
int id=rs.getInt("id");
String bianma=rs.getString("bianma");
String name=rs.getString("bookname");
String author=rs.getString("author");
String kind=rs.getString("bookkind");
String fakuan=rs.getString("fakuan");
BrBookVo bbv=new BrBookVo();
bbv.setId(id);
bbv.setBianma(bianma);
bbv.setBookname(name);
bbv.setAuthor(author);
bbv.setBookkind(kind);
bbv.setFakuan(fakuan);
a.add(bbv);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return a;
}
//归还书籍
public boolean ReturnBook(int id){
dbc=new Dbconn();
boolean bool=false;
Connection con=dbc.getCon();
try {
Statement stmt=con.createStatement();
String sql1="select con,bon,rdate from books_br where id="+id;
ResultSet rs=stmt.executeQuery(sql1);
int card_no=0;
String bianma=null;
Date rdate=null;
while(rs.next()){
card_no=rs.getInt("con");
bianma=rs.getString("bon");
rdate=rs.getDate("rdate");
}
String sql2="update card_info set maxborrow=maxborrow+1 where card_no="+card_no;
stmt.executeUpdate(sql2);
String sql3="update books_info set shuliang=shuliang+1 where bianma='"+bianma+"'";
stmt.executeUpdate(sql3);
String sql="delete from books_br where id="+id;
stmt.executeUpdate(sql);
if(new Date(new java.util.Date().getTime()).before(rdate)){
bool=true;
}
else{
Date d=new Date(new java.util.Date().getTime());
Calendar cl=Calendar.getInstance();
cl.setTime(d);
Calendar c2=Calendar.getInstance();
c2.setTime(rdate);
s=(cl.getTimeInMillis()-c2.getTimeInMillis())/(1000*60*60*24);
String sql4="select fakuan from books_info where bianma='"+bianma+"'";
ResultSet rs1=stmt.executeQuery(sql4);
while(rs1.next()){
fakuan=rs1.getString("fakuan");
}
bool=false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bool;
}
public Error A(){
Error e=new Error();
e.setFakuan(faku
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
图书馆管理系统(jsp jsf ajax j2ee) (211个子文件)
BrBookModel.class 7KB
UserModel.class 5KB
BookModel.class 5KB
LikeBookModel.class 4KB
LoginModel.class 3KB
UserVo.class 2KB
BookVo.class 2KB
BrBookVo.class 1KB
LoginVo.class 1KB
Dbconn.class 1KB
trans.class 845B
LikeBookVo.class 733B
Error.class 720B
.classpath 910B
css.css 2KB
css.css 2KB
myweb.css 2KB
text.css 2KB
text.css 2KB
Style.css 497B
Style.css 497B
Thumbs.db 39KB
Thumbs.db 21KB
1_r1_c1.gif 39KB
1_r3_c3.gif 14KB
admin_07.gif 8KB
2-1_r3_c2.gif 7KB
admin_02.gif 6KB
menu_bg.gif 5KB
logo_02.gif 4KB
admin_11.gif 4KB
logo.gif 4KB
logo_01.gif 3KB
1_r2_c1.gif 3KB
1_r4_c1.gif 3KB
1_r5_c1.gif 3KB
admin_09.gif 3KB
admin_05.gif 2KB
1_r2_c2.gif 2KB
1_r6_c1.gif 2KB
admin_left_1.gif 2KB
admin_left_9.gif 2KB
admin_left_1.gif 2KB
admin_left_9.gif 2KB
admin_left_5.gif 2KB
admin_left_5.gif 2KB
admin_left_4.gif 2KB
admin_left_4.gif 2KB
admin_left_3.gif 2KB
admin_left_3.gif 2KB
title_bg_quit.gif 2KB
title_bg_quit.gif 2KB
top1.gif 2KB
top1.gif 2KB
top1.gif 2KB
menuup.gif 2KB
menuup.gif 2KB
menudown.gif 2KB
menudown.gif 2KB
student.gif 2KB
user.gif 2KB
student.gif 2KB
user.gif 2KB
1_r8_c1.gif 2KB
teacher.gif 2KB
teacher.gif 2KB
admin.gif 1KB
admin.gif 1KB
kemu.gif 1KB
kemu.gif 1KB
logo_bg.gif 1KB
clip_image001.gif 1KB
background.gif 1KB
background.gif 1KB
background.gif 1KB
top3.gif 1KB
top3.gif 1KB
top3.gif 1KB
admin_left_6.gif 1KB
admin_left_6.gif 1KB
admin_left_8.gif 1KB
admin_left_8.gif 1KB
leftxia.gif 1KB
leftxia.gif 1KB
login_bg.gif 1KB
admin_left_7.gif 1KB
admin_left_7.gif 1KB
admin_left_2.gif 1KB
admin_left_2.gif 1KB
bg.gif 1KB
stu_2.gif 919B
stu_2.gif 919B
dian.gif 907B
dian.gif 907B
admin_08.gif 800B
left_background1.gif 659B
left_background1.gif 659B
main_top_bg.gif 545B
end3.gif 496B
end3.gif 496B
共 211 条
- 1
- 2
- 3
资源评论
- ml3938466712012-09-05还可以吧,不过有点不符合正常逻辑
- 伊黑2013-04-15还不错的资源,功能有点乱。
a383063671
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功