📄 frame8.java~28~
字号:
package test1;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: 图书管理系统</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2007</p> * <p>Company: </p> * @author koma * @version 1.0 */public class Frame8 extends JFrame { JLabel jLabel1 = new JLabel(); JTextField jTextField1 = new JTextField(); JLabel jLabel2 = new JLabel(); JTextField jTextField2 = new JTextField(); JButton jButton1 = new JButton(); public Frame8() { this.setTitle("借书"); this.setSize(300,300); this.setLocation(460,250); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("DialogInput", 0, 20)); jLabel1.setText("证件号"); jLabel1.setBounds(new Rectangle(22, 36, 92, 36)); this.getContentPane().setLayout(null); jTextField1.setFont(new java.awt.Font("DialogInput", 0, 20)); jTextField1.setText(""); jTextField1.setBounds(new Rectangle(129, 35, 211, 38)); jLabel2.setFont(new java.awt.Font("DialogInput", 0, 20)); jLabel2.setText("图书编号"); jLabel2.setBounds(new Rectangle(21, 99, 89, 38)); jTextField2.setFont(new java.awt.Font("DialogInput", 0, 20)); jTextField2.setText(""); jTextField2.setBounds(new Rectangle(131, 98, 227, 34)); jButton1.setBounds(new Rectangle(91, 218, 119, 43)); jButton1.setFont(new java.awt.Font("DialogInput", 0, 20)); jButton1.setText("确定"); jButton1.addActionListener(new Frame8_jButton1_actionAdapter(this)); this.getContentPane().add(jLabel1, null); this.getContentPane().add(jLabel2, null); this.getContentPane().add(jTextField2, null); this.getContentPane().add(jButton1, null); this.getContentPane().add(jTextField1, null); } void jButton1_actionPerformed(ActionEvent e) { String userNo=jTextField1.getText(); String bkNo=jTextField2.getText(); String bkBorrow="insert into userInfo (证件号,图书编号) values('"+userNo+"','"+bkNo+"')"; PreparedStatement pst=Application1.pst1; //ResultSet rst1=Application1.rst1;// Application1.rst2=Application1.smt.executeQuery("select * from book"); // ResultSet rst2=Application1.rst2; boolean bl=true; try{ //Application1.rst2=Application1.smt.executeQuery("select * from book"); ResultSet rst2=Application1.smt.executeQuery("select * from book"); // ResultSet rst=Application1.smt.executeQuery("select * from user1"); while(rst1.next()) while(rst2.next()){ if (rst2.getString(1).equals(bkNo)){ System.out.println("koma"); pst.executeUpdate(bkBorrow); break; } } }catch(Exception e1){} }}class Frame8_jButton1_actionAdapter implements java.awt.event.ActionListener { Frame8 adaptee; Frame8_jButton1_actionAdapter(Frame8 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -