?? 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 + -