📄 loancontroller.java
字号:
import java.sql.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.net.*;
import java.awt.event.*;
import java.util.*;
import java.util.Vector;
public class LoanController implements ActionListener{//,ListSelectionListener{
private SearchBookView sbv;
private Book book;
private CheckReaderView crv;
private Reader reader;
private LoanInfoView liv;
private Loan loan;
public LoanController(){
sbv = new SearchBookView(this);
book = new Book();
//crv = new CheckReaderView(this);
reader =new Reader();
//liv=new LoanInfoView(this);
loan=new Loan();
}
//实现表格中图书选择的监听,
//1把所选择的图书号放入Vector中,以供在创建load时,返回图书ID号;并把所选择的图书的书名合并成一个字符串作为返回值,以供"借阅模块"调用。
//2 或者把图书号和图书名都放入Vector当中
public void actionPerformed(ActionEvent e){
String cmd = ((JButton)e.getSource()).getText();
System.out.print("ss");
if("查找".equals(cmd)){
String key = sbv.getKey();
Vector books = book.serachBookByKey(key);
sbv.showResult(books);
}
if("借书".equals(cmd)){
crv = new CheckReaderView(this);
reader.checkReader(crv.getidKey(),crv.getpasswordKey());
}
if("确定".equals(cmd)){
Vector bookinfo;
String idkey = crv.getidKey();
String passwordKey = crv.getpasswordKey();
System.out.print("ddsss");
boolean istrue=reader.checkReader(idkey,passwordKey);
if(istrue){
bookinfo=sbv.getBookNames();
liv=new LoanInfoView(this,bookinfo);
}
}
if("确定借阅".equals(cmd)){
Vector bookIDs;
String readerID = crv.getidKey();
bookIDs = sbv.getBookIDs();
boolean createok;
createok=loan.createLoan(readerID,bookIDs);
if(createok){
JOptionPane.showMessageDialog(null,"借阅成功!");
//setVisible(false);
}
}
if("取消".equals(cmd)){
crv.setVisible(false);
liv.setVisible(false);
}
}
public static void main(String[] args){
new LoanController();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -