📄 killclass.java~26~
字号:
package bookmanager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class killclass {//控制类
Statement s1;
ResultSet s2;
dbconnection rd=new dbconnection();
public killclass() {
try {
jbInit();
s1 = rd.getconnection().createStatement();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public int rtu(borrownote j,int tr3)
{
int u1=0,u2=0,u3=0;
try {
String sr="insert into borrownote(notid,redid,notdata,nottada) values('"+j.getnotid()+
"','"+j.getredid()+"','"+j.getnotdata()+"','"+j.getnottada()+"')";
String rs="update bookinfo set onoutctrl='否' where bookid='"+j.getnotid()+"'";
String rt="update borrowinfo set amount=amount+"+tr3+" where borrowid='"+j.getredid()+"'";
u1=s1.executeUpdate(sr);
u2=s1.executeUpdate(rs);
u3=s1.executeUpdate(rt);
} catch (SQLException ex) {
}
return (u1+u2+u3);
}
public int readopen(readinfo r)
{
int up=0;
try {
String str="insert into readinfo(readid,readname,readsex,readtelephone,readaddress,readdatetime) values('"+
r.getreadid()+"','"+r.getreadname()+"','"+r.getsex()+"','"+r.getreadtelephone()+"','"+
r.getreadaddress()+"',"+r.getreaddatetime()+")";
up=s1.executeUpdate(str);
} catch (SQLException ex) {
}
return up;
}
public ArrayList checkbookinfo()
{
ArrayList list=new ArrayList();
try {
s2=s1.executeQuery("select bookid,bookname from bookinfo");
while(s2.next())
{
bookinfo info=new bookinfo();
info.setbookid(s2.getString(1));
info.setbookname(s2.getString(2));
list.add(info);
}
} catch (SQLException ex) {
}
return list;
}
public ArrayList checkreadinfo()
{
ArrayList list=new ArrayList();
try {
String uuu="select readid,readname,readdatetime from readinfo";
s2=s1.executeQuery(uuu);
while(s2.next())
{
readinfo info=new readinfo();
info.setreadid(s2.getString(1));
info.setreadname(s2.getString(2));
info.setreaddatetime(s2.getInt(3));
list.add(info);
}
} catch (SQLException ex) {
}
return list;
}
public void insertmodel(borrowinfo b)
{
try {
s1.executeUpdate("insert into borrowinfo(borrowid,borrowname,boamount,amount,moneyfee) values('"+
b.getborrowid()+"','"+b.getborrowname()+"',"+b.getboamount()+","+b.getamount()+","+b.getmoneyfee()+")");
} catch (SQLException ex) {
}
}
public ArrayList addrt(String rt)
{
ArrayList li=new ArrayList();
try {
s2 = s1.executeQuery("select notdata,nottada from borrownote where redid='" +
rt + "'");
while(s2.next())
{
borrownote note=new borrownote();
note.setnotdata(s2.getString(1));
note.setnottada(s2.getString(2));
li.add(note);
}
} catch (SQLException ex) {
}
return li;
}
public int adder(browbook b,String num)
{
int r1=0,r2=0,r3=0;
try {
r1=s1.executeUpdate(
"insert into browbook(browid,rdid,nota,tada,dataot) values('" +
b.getbrowid() + "','" + b.getrdid() + "','" + b.getnota() +
"','" + b.gettada() + "','"+b.getdataot()+"')");
r2=s1.executeUpdate("update borrowinfo set amount=amount-"+Integer.parseInt(num)
+" where borrowid='"+b.getrdid()+"'");
r3=s1.executeUpdate("update bookinfo set onoutctrl='是' where bookid='"+b.getbrowid()+"'");
String str1= b.gettada();
String str2=b.getdataot();
int f1=Integer.parseInt(str1.substring(0,4));
int f2=Integer.parseInt(str1.substring(5,7));
int f3=Integer.parseInt(str1.substring(8,10));
int num1=Integer.parseInt(str2.substring(0,4));
int num2=Integer.parseInt(str2.substring(5,7));
int num3=Integer.parseInt(str2.substring(8,10));
if((f1*365+f2*30+f3)>(num1*365+num2*30+num3))
{
s1.executeUpdate("update borrowinfo set moneyfee=moneyfee-10 where borrowid='"+b.getrdid()+"'");
}
} catch (SQLException ex) {
}
return (r1+r2+r3);
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -