📄 return_dialog.java
字号:
package library;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import com.borland.dbswing.*;import java.awt.event.*;import com.borland.dx.sql.dataset.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Return_Dialog extends JDialog { private JPanel panel1 = new JPanel(); private JTextField jTextField2 = new JTextField(); private JLabel jLabel4 = new JLabel(); private JLabel jLabel2 = new JLabel(); private Database database1 = new Database(); private QueryDataSet queryDataSet1 = new QueryDataSet(); private JButton jButton1 = new JButton(); private JButton jButton2 = new JButton(); private TableScrollPane tableScrollPane1 = new TableScrollPane(); private JdbTable jdbTable1 = new JdbTable(); private GridBagLayout gridBagLayout1 = new GridBagLayout(); public Return_Dialog(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public Return_Dialog() { this(null, "", false); } private void jbInit() throws Exception { panel1.setLayout(gridBagLayout1); jTextField2.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(KeyEvent e) { jTextField2_keyReleased(e); } }); jLabel4.setFont(new java.awt.Font("DialogInput", 0, 12)); jLabel4.setText("例如:1001"); jLabel2.setFont(new java.awt.Font("DialogInput", 0, 12)); jLabel2.setText("图书编号:"); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select code as 编号,name as 书名, isBorrow as 是否借出 ,type as 类别,press " + "as 出版社,writer as 作者, reader_code as 借阅人编号 from bookInfo where code " + "= \'111111111111\'", null, true, Load.ALL)); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:lib", "", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); jButton1.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton1.setText("归还"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jButton2.setFont(new java.awt.Font("DialogInput", 0, 12)); jButton2.setText("返回"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jdbTable1.setDataSet(queryDataSet1); this.setTitle("还书"); getContentPane().add(panel1); panel1.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(26, 33, 0, 0), 0, 0)); panel1.add(jTextField2, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(26, 10, 0, 0), 90, 0)); panel1.add(jLabel4, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(26, 21, 0, 0), 0, 0)); panel1.add(jButton1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(22, 41, 44, 0), 0, 0)); panel1.add(jButton2, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(21, 109, 44, 179), 0, 0)); panel1.add(tableScrollPane1, new GridBagConstraints(0, 1, 4, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(29, 17, 0, 18), 122, -312)); tableScrollPane1.getViewport().add(jdbTable1, null); } void jTextField2_keyReleased(KeyEvent e) { if(queryDataSet1.isOpen()) queryDataSet1.close(); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select code as 编号,name as 书名, isBorrow as 是否借出 ,type as 类别,press as 出版社,writer as 作者,reader_code as 借阅人编号 from bookInfo where code =\'"+ jTextField2.getText()+"\'" , null, true, Load.ALL)); queryDataSet1.open(); } void jButton2_actionPerformed(ActionEvent e) { this.dispose(); } void jButton1_actionPerformed(ActionEvent e) { if(!queryDataSet1.isOpen())queryDataSet1.open(); if(queryDataSet1.getRowCount()==0) { JOptionPane.showMessageDialog(this,"您要还的图书不在书库中,请查证!","提示",JOptionPane.ERROR_MESSAGE); return; } if(!queryDataSet1.getBoolean("是否借出")) { JOptionPane.showMessageDialog(this,"您要还的图书不曾被借出,请查证!","提示",JOptionPane.ERROR_MESSAGE); return; } try { Statement sql = database1.createStatement() ; sql.executeUpdate("update bookInfo set isBorrow = false ,reader_code = \' \' where code =\'"+ jTextField2.getText()+"\'" ); JOptionPane.showMessageDialog(this,"图书归还成功!","提示",JOptionPane.INFORMATION_MESSAGE); queryDataSet1.refresh(); }catch(Exception ex) { JOptionPane.showMessageDialog(this,"图书归还失败!","提示",JOptionPane.INFORMATION_MESSAGE); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -