?? depot.java
字號:
person.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
new PersonInfo(Depot.frame);
}
});
}
return person;
}
/**
* This method initializes about
*
* @return javax.swing.JButton
*/
private JButton getAbout() {
if (about == null) {
about = new JButton();
about.setBounds(new Rectangle(542, 9, 101, 22));
about.setText("關(guān)于");
about.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
javax.swing.JOptionPane.showMessageDialog(null,"圖書館管理系統(tǒng)\n"+
"北京航空航天大學(xué)計算機(jī)學(xué)院 \n"+
"版本 1.0\n"+
"開源 使用請說明出處\n");
}
});
}
return about;
}
/**
* This method initializes isbn
*
* @return javax.swing.JTextField
*/
private JTextField getIsbn() {
if (isbn == null) {
isbn = new JTextField();
isbn.setBounds(new Rectangle(302, 57, 114, 22));
}
return isbn;
}
/**
* This method initializes bookname
*
* @return javax.swing.JTextField
*/
private JTextField getBookname() {
if (bookname == null) {
bookname = new JTextField();
bookname.setBounds(new Rectangle(535, 57, 137, 22));
}
return bookname;
}
/**
* This method initializes author
*
* @return javax.swing.JTextField
*/
private JTextField getAuthor() {
if (author == null) {
author = new JTextField();
author.setBounds(new Rectangle(302, 93, 114, 24));
}
return author;
}
/**
* This method initializes press
*
* @return javax.swing.JTextField
*/
private JTextField getPress() {
if (press == null) {
press = new JTextField();
press.setBounds(new Rectangle(535, 93, 137, 24));
}
return press;
}
/**
* This method initializes quantity
*
* @return javax.swing.JTextField
*/
private JTextField getQuantity() {
if (quantity == null) {
quantity = new JTextField();
quantity.setBounds(new Rectangle(302, 139, 114, 21));
}
return quantity;
}
/**
* This method initializes bookLocation
*
* @return javax.swing.JTextField
*/
private JTextField getBookLocation() {
if (bookLocation == null) {
bookLocation = new JTextField();
bookLocation.setBounds(new Rectangle(535, 139, 137, 21));
}
return bookLocation;
}
/**
* This method initializes confirm
*
* @return javax.swing.JButton
*/
private JButton getConfirm() {
if (confirm == null) {
confirm = new JButton();
confirm.setBounds(new Rectangle(527, 297, 85, 25));
confirm.setText("確認(rèn)");
confirm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
String isbn=Depot.this.getIsbn().getText();
String author=Depot.this.getAuthor().getText();
String bookname=Depot.this.getBookname().getText();
String quantity=Depot.this.getQuantity().getText();
String press=Depot.this.getPress().getText();
String place=Depot.this.getBookLocation().getText();
String abstracts=Depot.this.getJTextArea().getText();
String price=Depot.this.getPrice().getText();
//把入庫書籍的記錄添加到book表
String sql="insert into book(isbn,bookname,author,press," +
"abstract,remain_number,total_number,ruined_number,"+
"place,price,borrowed_times)values('"+isbn+"','"+
bookname+"','"+author+"','"+press+"','"+abstracts+"',"+
quantity+","+quantity+","+"0,'"+place+"',"+price+","+"0"+")";
// System.out.println(sql);
DataBase.execute(sql);
//把相應(yīng)的收貨單記為以入庫
DataBase.execute("update contract set store_or_not=1" +
" where contract_num='"+Depot.this.contractNum+"'");
Depot.paintJlist();
javax.swing.JOptionPane.showMessageDialog(null,"圖書館管理系統(tǒng)\n"+
"新書入庫成功\n");
}
});
}
return confirm;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setBounds(new Rectangle(302, 202, 134, 129));
jScrollPane.setViewportView(getJTextArea());
}
return jScrollPane;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
}
return jTextArea;
}
/**
* This method initializes jList1
*
* @return javax.swing.JList
*/
private JList getJList1() {
if (jList1 == null) {
jList1 = new JList();
jList1.setBounds(new Rectangle(37, 52, 163, 262));
jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//讓列表框響應(yīng)鼠標(biāo)單擊事件
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
Depot.this.contractNum=jList1.
getSelectedValue().toString();
Depot.this.initializeInfo();
}
};
jList1.addMouseListener(mouseListener);
}
return jList1;
}
//下面的方法用來更新list的顯示內(nèi)容
public static void paintJlist(){
Depot.defaultListModel.clear();
String sql="select contract_num from contract " +
"where real_deal_time>0 and store_or_not=0";
ResultSet result=DataBase.executeQuery(sql);
try{
while(result.next()){
Depot.defaultListModel.addElement((String)
result.getString("contract_num"));
}
}catch(Exception e){
System.out.println(e);
}
}
private void initializeInfo(){
String sql="select isbn,quantity,book_name,author,press " +
"from contract where contract_num='"+this.contractNum+"'";
ResultSet result=DataBase.executeQuery(sql);
try{
result.next();
this.getIsbn().setText((String)result.getString("isbn"));
this.getAuthor().setText((String)result.getString("author"));
this.getQuantity().setText((String)result.getString("quantity"));
this.getBookname().setText((String)result.getString("book_name"));
this.getPress().setText((String)result.getString("press"));
this.getPrice().setText("");
this.getBookLocation().setText("");
this.getJTextArea().setText("");
}catch(Exception e){
System.out.println(e);
}
}
private void getJContentPanefour() {
if (jContentPane == null) {
jLabel8 = new JLabel();
jLabel8.setBounds(new Rectangle(441, 173, 65, 22));
jLabel8.setText("單價");
jLabel9 = new JLabel();
jLabel9.setBounds(new Rectangle(41, 29, 77, 20));
jLabel9.setText("購買的新書");
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(212, 171, 67, 26));
jLabel7.setText("摘要");
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(441, 139, 66, 21));
jLabel6.setText("館藏地");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(213, 139, 67, 21));
jLabel5.setText("數(shù)量");
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(441, 93, 66, 24));
jLabel4.setText("出版社");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(213, 93, 67, 24));
jLabel3.setText("作者");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(441, 57, 66, 22));
jLabel2.setText("書名");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(213, 57, 67, 22));
jLabel1.setText("isbn");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(215, 29, 94, 20));
jLabel.setText("新書入庫");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(getPerson(), null);
jContentPane.add(getAbout(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(getIsbn(), null);
jContentPane.add(jLabel2, null);
jContentPane.add(getBookname(), null);
jContentPane.add(jLabel3, null);
jContentPane.add(getAuthor(), null);
jContentPane.add(jLabel4, null);
jContentPane.add(getPress(), null);
jContentPane.add(jLabel5, null);
jContentPane.add(getQuantity(), null);
jContentPane.add(jLabel6, null);
jContentPane.add(getBookLocation(), null);
jContentPane.add(jLabel7, null);
jContentPane.add(getConfirm(), null);
jContentPane.add(getJScrollPane(), null);
jContentPane.add(getJList1(), null);
jContentPane.add(jLabel9, null);
jContentPane.add(jLabel8, null);
jContentPane.add(getPrice(), null);
}
}
/**
* This method initializes price
*
* @return javax.swing.JTextField
*/
private JTextField getPrice() {
if (price == null) {
price = new JTextField();
price.setBounds(new Rectangle(537, 173, 132, 21));
}
return price;
}
private void getJContentPanefive() {
if (jContentPane == null) {
jLabel8 = new JLabel();
jLabel8.setBounds(new Rectangle(441, 173, 65, 22));
jLabel8.setText("單價");
jLabel9 = new JLabel();
jLabel9.setBounds(new Rectangle(41, 29, 77, 20));
jLabel9.setText("購買的新書");
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(212, 171, 67, 26));
jLabel7.setText("摘要");
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(441, 139, 66, 21));
jLabel6.setText("館藏地");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(213, 139, 67, 21));
jLabel5.setText("數(shù)量");
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(441, 93, 66, 24));
jLabel4.setText("出版社");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(213, 93, 67, 24));
jLabel3.setText("作者");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(441, 57, 66, 22));
jLabel2.setText("書名");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(213, 57, 67, 22));
jLabel1.setText("isbn");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(215, 29, 94, 20));
jLabel.setText("新書入庫");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(getPerson(), null);
jContentPane.add(getAbout(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(getIsbn(), null);
jContentPane.add(jLabel2, null);
jContentPane.add(getBookname(), null);
jContentPane.add(jLabel3, null);
jContentPane.add(getAuthor(), null);
jContentPane.add(jLabel4, null);
jContentPane.add(getPress(), null);
jContentPane.add(jLabel5, null);
jContentPane.add(getQuantity(), null);
jContentPane.add(jLabel6, null);
jContentPane.add(getBookLocation(), null);
jContentPane.add(jLabel7, null);
jContentPane.add(getConfirm(), null);
jContentPane.add(getJScrollPane(), null);
jContentPane.add(getJList1(), null);
jContentPane.add(jLabel9, null);
jContentPane.add(jLabel8, null);
jContentPane.add(getPrice(), null);
}
}
} // @jve:decl-index=0:visual-constraint="-9,-1"
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -