📄 circulatewindow.java
字号:
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("退出"))
{
ConfirmWindow x=new ConfirmWindow();
x.setVisible(true);
}
else if(e.getActionCommand().equals("入库"))
{
String s1=t1.getText(),s2="",s3="",s4="",s5="",s6="0",s7="";
if(s1.trim().equals("")){
JOptionPane.showMessageDialog(null, "输入内容不能为空!");
}
else{
DataBase_Sever d=new DataBase_Sever();
d.select("book", "where BookID='"+s1+"'");
int count=0;
try{
while(d.rs.next()){
s3=d.rs.getString("BookName");
s4=d.rs.getString("Author");
count++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
s5=Time.getCurrentFormatDate();
if(count==0)
{
JOptionPane.showMessageDialog(null, "图书不存在");
}
else
{
d.select("recorder", "where BookID='"+s1+"'");
int count1=0;
try{
while(d.rs.next()){
s2=d.rs.getString("ReaderID");
s7=d.rs.getString("OutDate");
count1++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
if(count1==0)
{
JOptionPane.showMessageDialog(null, "图书未借出");
t1.setText("");
}
else{
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
Date a,a1;long i=0,i1=0;
try {
a = f.parse(s7);
a1 = f.parse(s5);
i=(a1.getTime()-a.getTime())/(1000*3600*24);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
d.select("configuration", "where ID='"+s2+"'");
try{
while(d.rs.next()){
i1=Long.parseLong(d.rs.getString("MaxBLDays"));
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
if(i>i1){
s6= (new Double((i-i1)*0.1)).toString();
}
t2.setText(s2);
t3.setText(s3);
t4.setText(s4);
t5.setText(s5);
t6.setText(s6);
String ss="";ss=t1.getText();
d.delete("recorder"," WHERE BookID='"+ss+"'" );
d.update("book", "BookStatus='在库' where BookID='"+t1.getText()+"'");
JOptionPane.showMessageDialog(null, "入库成功");
}
}
}
}
else if(e.getActionCommand().equals("出库")){
String s1=t11.getText(),s2=t21.getText(),s3="",s4="",s5="",s6="";
int n1=0;
if(s1.trim().equals("")||s2.trim().equals("")){
JOptionPane.showMessageDialog(null, "输入内容不能为空!");
}
else{
DataBase_Sever d=new DataBase_Sever();
d.select("book", "where BookID='"+s1+"'");
int count=0;
try{
while(d.rs.next()){
s3=d.rs.getString("BookName");
s4=d.rs.getString("Author");
s6=d.rs.getString("Class");
count++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
s5=Time.getCurrentFormatDate();
if(count==0)
{
JOptionPane.showMessageDialog(null, "图书不存在");
t11.setText("");
t21.setText("");
}
else
{
d.select("configuration", "where ID='"+s2+"'");
int count2=0;
String reader="";
try{
while(d.rs.next()){
reader=d.rs.getString("MaxBLNum");
count2++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
if(count2==0)
{
JOptionPane.showMessageDialog(null, "读者不存在");
}
else{
d.select("recorder", "where BookID='"+s1+"'");
int count1=0;
try{
while(d.rs.next()){
count1++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
if(count1==1)
{
JOptionPane.showMessageDialog(null, "图书已借出");
}
else{
d.select("reader", "where ReaderID='"+s2+"'");
int count4=0;
try{
while(d.rs.next()){
n1=Integer.parseInt(d.rs.getString("ReaderLevel"));
count4++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
if(s6.trim().equals("藏书")&&n1!=1){
JOptionPane.showMessageDialog(null, "读者权限不足,不能借阅藏书");
}
else{
d.select("recorder", "where ReaderID='"+s2+"'");
int count3=0;
try{
while(d.rs.next()){
count3++;
}
d.rs.close();
}catch(SQLException ex1){}
d.closeDB();
if(count3>=Integer.parseInt(reader)){
JOptionPane.showMessageDialog(null, "该读者借书已达上限");
}
else{
t13.setText(s3);
t14.setText(s4);
t15.setText(s5);
String ss=t11.getText();
d.insert("recorder (BookID,ReaderID,OutDate)", "('" +t11.getText() + "','" +t21.getText()+ "','" +t15.getText()+"')");
d.update("book", "BookStatus='不在库' where BookID='"+t11.getText()+"'");
JOptionPane.showMessageDialog(null, "出库成功");
}
}
}
}
}
}
}
else if(e.getActionCommand().equals("锁定屏幕"))
{
frame.show();
}
else if(e.getActionCommand().equals("返回主界面"))
{MainWindow x=new MainWindow();
x.setVisible(true);
dispose();
}
else if(e.getActionCommand().equals("确定"))
{
String s1="",s2="";
if (t111.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null, "请先输入管理员帐号");
}
else {
s1=t111.getText().trim();
s2=t211.getText().trim();
if(!s1.equals(Main.manager))
{
JOptionPane.showMessageDialog(null, "帐号错误");
t111.setText("");
t211.setText("");
}
else
{
if(s2.equals(Main.pass)){
frame.dispose();
}
else{
JOptionPane.showMessageDialog(null, "密码错误");
t111.setText("");
t211.setText("");
}
}
}
}
else
System.out.println("Error!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -