📄 bookstores.java
字号:
package booksys;
import java.sql.*;
import java.io.*;
import java.util.*;
public class bookstores{
public int id;
public int bookid;
public int allcount;
public int borrowcount;
public int currentcount;
public int lowlimit;
public int storeid;
BufferedReader in;
public boolean status;
public bookstores(){
}
public bookstores(int id,int bookid,int allcount,int borrowcount,int currentcount,int lowlimit,int storeid){
this.id = id;
this.bookid = bookid;
this.allcount = allcount;
this.borrowcount = borrowcount;
this.currentcount = currentcount;
this.lowlimit = lowlimit;
this.storeid = storeid;
}
public static bookstores getid(int bookid,int storeid) throws Exception{
bookstores store1 = new bookstores();
dbconn.conn();
String sql = "select * from bookstores where bookid="+bookid+" and storeid="+storeid;
ResultSet rs = dbconn.dbquery(sql);
if(rs.next()){
store1 = new bookstores(rs.getInt(1),rs.getInt(2),rs.getInt(3),rs.getInt(4),rs.getInt(5),rs.getInt(6),rs.getInt(7));
}
return store1;
}
public static int getid() throws Exception{
int count = 0;
dbconn.conn();
String sql = "select * from bookstores";
ResultSet rs=dbconn.dbquery(sql);
while(rs.next()){
count=rs.getInt(1);
}
return count+1;
}
//增加书库信息
public boolean addbookstores() throws Exception{
int s=0;
boolean result = false;
if(this.currentcount>this.lowlimit) s = 1;
else s = 0;
dbconn.conn();
String sql = "insert into bookstores values("+this.id+","+this.bookid+","+this.allcount+","+this.borrowcount+","+this.currentcount+","+this.lowlimit+","+this.storeid+")";
int count=dbconn.dbinsert(sql);
if(count>0) result=true;
return result;
//return true;
}
public boolean updatebookstores(int id) throws Exception{
boolean result = false;
dbconn.conn();
String sql = "update bookstores set allcount="+allcount+", borrowcount="+borrowcount+",currentcount="+currentcount+", lowlimit="+lowlimit+" where id="+id;
int upcount = dbconn.dbupdate(sql);
if(upcount>0) result = true;
dbconn.dbclose();
return result;
}
public boolean updatebookstores(int bookid,int storeid) throws Exception{
boolean result = false;
in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入新增的数量:");
int count = Integer.parseInt(in.readLine());
int allcount = this.allcount+count;
int currentcount = this.currentcount+count;
if(this.currentcount>this.lowlimit) this.status = true;
else this.status = false;
dbconn.conn();
String sql = "update bookstores set allcount="+allcount+",currentcount="+currentcount+" where bookid="+bookid+" and storeid="+storeid;
int upcount = dbconn.dbupdate(sql);
if(upcount>0) result = true;
dbconn.dbclose();
return result;
}
public static bookstores searchcount(int bookid) throws Exception{
bookstores store1=new bookstores();
dbconn.conn();
String sql="select * from bookstores where bookid="+bookid;
ResultSet rs=dbconn.dbquery(sql);
if(rs.next()){
store1=new bookstores(rs.getInt(1),rs.getInt(2),rs.getInt(3),rs.getInt(4),rs.getInt(5),rs.getInt(6),rs.getInt(7));
}
return store1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -