📄 jbook.java~26~
字号:
package jxm;
import java.awt.BorderLayout;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JTextField;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.*;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class jbook extends JFrame {
public jbook() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public jbook(String s1, String s2) {
try {
jbInit();
jTextField7.setText(s1);
jTextField3.setText(s2);
jTextField7.setEditable(false);
jTextField3.setEditable(false);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date dt = new Date();
String st = sdf.format(dt);
jTextField9.setText(st);
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel1.setText("读者姓名");
jLabel1.setBounds(new Rectangle(10, 8, 66, 28));
jTextField6.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField6.setText("jTextField6");
jTextField6.setBounds(new Rectangle(277, 66, 155, 29));
jTextField5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField5.setText("jTextField5");
jTextField5.setBounds(new Rectangle(75, 76, 244, 27));
jLabel7.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel7.setText("押金");
jLabel7.setBounds(new Rectangle(213, 63, 61, 34));
jLabel6.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel6.setText("联系电话");
jLabel6.setBounds(new Rectangle(9, 38, 56, 32));
jRadioButton2.setBackground(new Color(171, 171, 171));
jRadioButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jRadioButton2.setText("女");
jRadioButton2.setBounds(new Rectangle(321, 12, 56, 28));
jRadioButton1.setBackground(new Color(171, 171, 171));
jRadioButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jRadioButton1.setSelected(true);
jRadioButton1.setText("男");
jRadioButton1.setBounds(new Rectangle(276, 12, 45, 29));
jLabel5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel5.setText("性别");
jLabel5.setBounds(new Rectangle(233, 9, 45, 32));
jTextField4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField4.setText("jTextField4");
jTextField4.setBounds(new Rectangle(75, 62, 134, 33));
jTextField3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField3.setText("");
jTextField3.setBounds(new Rectangle(76, 13, 134, 33));
jTextField2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField2.setText("");
jTextField2.setBounds(new Rectangle(76, 43, 139, 27));
jTextField1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField1.setText("");
jTextField1.setBounds(new Rectangle(76, 10, 140, 25));
jLabel4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel4.setText("借阅期限");
jLabel4.setBounds(new Rectangle(6, 62, 66, 37));
jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel3.setText("借读书名");
jLabel3.setBounds(new Rectangle(8, 12, 66, 37));
jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton1.setBounds(new Rectangle(217, 339, 79, 31));
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton1.setSelectedIcon(null);
jButton1.setText("借出");
jButton1.addActionListener(new jbook_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(307, 339, 74, 32));
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton2.setText("重置");
jButton2.addActionListener(new jbook_jButton2_actionAdapter(this));
jButton3.setBounds(new Rectangle(388, 340, 74, 31));
jButton3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton3.setText("取消");
jButton3.addActionListener(new jbook_jButton3_actionAdapter(this));
jLabel8.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel8.setText("读者编号");
jLabel8.setBounds(new Rectangle(11, 186, 55, 34));
jTextField7.setText("");
jTextField7.setBounds(new Rectangle(84, 10, 139, 27));
jLabel9.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel9.setText("图书编号");
jLabel9.setBounds(new Rectangle(15, 8, 61, 32));
jTextField8.setText("jTextField8");
jTextField8.setBounds(new Rectangle(63, 187, 156, 30));
jPanel1.setBackground(new Color(171, 171, 171));
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setBounds(new Rectangle(11, 219, 491, 116));
jPanel1.setLayout(null);
jPanel2.setBackground(new Color(171, 171, 171));
jPanel2.setBorder(BorderFactory.createEtchedBorder());
jPanel2.setBounds(new Rectangle(10, 40, 491, 124));
jPanel2.setLayout(null);
this.getContentPane().setBackground(new Color(212, 208, 200));
jLabel10.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel10.setText("当前日期");
jLabel10.setBounds(new Rectangle(12, 336, 57, 30));
jTextField9.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jTextField9.setText("jTextField9");
jTextField9.setBounds(new Rectangle(70, 338, 131, 29));
jLabel11.setBorder(BorderFactory.createEtchedBorder());
jLabel11.setBounds(new Rectangle(11, 6, 491, 37));
jLabel12.setBorder(BorderFactory.createEtchedBorder());
jLabel12.setBounds(new Rectangle(10, 168, 491, 17));
jButton5.setBounds(new Rectangle(229, 189, 58, 26));
jButton5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton5.setText("确定");
jButton5.addActionListener(new jbook_jButton5_actionAdapter(this));
jPanel1.add(jLabel1);
jPanel1.add(jTextField5);
jPanel1.add(jTextField1);
jPanel1.add(jLabel2);
jPanel1.add(jLabel6);
jPanel1.add(jTextField2);
jPanel1.add(jLabel5);
jPanel1.add(jRadioButton1);
jPanel1.add(jRadioButton2);
this.getContentPane().add(jLabel8);
this.getContentPane().add(jTextField8);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
this.getContentPane().add(jButton3);
this.getContentPane().add(jLabel9);
this.getContentPane().add(jTextField7);
this.getContentPane().add(jPanel1);
this.getContentPane().add(jPanel2);
this.getContentPane().add(jTextField9);
this.getContentPane().add(jLabel10);
jPanel2.add(jLabel4);
jPanel2.add(jTextField4);
jPanel2.add(jTextField6);
jPanel2.add(jLabel7);
jPanel2.add(jLabel3);
jPanel2.add(jTextField3);
this.getContentPane().add(jLabel12);
this.getContentPane().add(jLabel11);
this.getContentPane().add(jButton5);
jLabel2.setText("地址");
jLabel2.setBounds(new Rectangle(10, 73, 66, 35));
buttonGroup1.add(jRadioButton1);
buttonGroup1.add(jRadioButton2);
}
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
JLabel jLabel5 = new JLabel();
ButtonGroup buttonGroup1 = new ButtonGroup();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JTextField jTextField5 = new JTextField();
JTextField jTextField6 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JLabel jLabel8 = new JLabel();
JTextField jTextField7 = new JTextField();
JLabel jLabel9 = new JLabel();
JTextField jTextField8 = new JTextField();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JLabel jLabel10 = new JLabel();
JTextField jTextField9 = new JTextField();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
JButton jButton5 = new JButton();
public void jButton5_actionPerformed(ActionEvent e) {
String str = "select * from duze where dnum='" + jTextField8.getText() +
"'";
cons con = new cons();
// Vector ve=new Vector();
ResultSet rs = null;
rs = con.getrs(str);
try {
if (rs.next()) {
jTextField1.setText(rs.getString(2));
jTextField2.setText(rs.getString(4));
jTextField5.setText(rs.getString(5));
if (rs.getString(3).trim().equals("女")) {
jRadioButton2.setSelected(true);
}
}
} catch (SQLException ex) {
}
}
public void jButton3_actionPerformed(ActionEvent e) {
this.dispose();
}
public void jButton2_actionPerformed(ActionEvent e) {
jTextField4.setText("");
jTextField6.setText("");
jTextField8.setText("");
jTextField1.setText("");
jTextField2.setText("");
jTextField5.setText("");
jRadioButton1.setSelected(true);
}
public void jButton1_actionPerformed(ActionEvent e) {
String str =
"insert into jhbook (bookid,userid,starttime,borrowtime,yamoney) values ('" +
jTextField7.getText() +
"','" + jTextField8.getText() + "','" +
jTextField9.getText() + "','" + jTextField4.getText() +
"','" + jTextField6.getText() + "')";
String str1 =
"update bookzt set ymount=ymount-1,nmount=nmount+1 where bname='" +
jTextField3.getText() + "'";
String str3 = "update books set bzt='0' where bnum='"+jTextField7.getText()+"'";
System.out.println(str3);
if (jTextField1.getText().equals("") && jTextField4.getText().equals("") &&
jTextField6.getText().equals("")) {
JOptionPane.showMessageDialog(this, "借书资料不完整", "错误",
JOptionPane.ERROR_MESSAGE);
} else {
cons con = new cons();
if (con.getblcc(str) && con.getblcc(str1) && con.getblcc(str3)) {
JOptionPane.showMessageDialog(this, "借书成功\n资料已入库", "成功借出",
JOptionPane.
INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "错误!\n图书资料可能已丢失", "错误",
JOptionPane.ERROR_MESSAGE);
}
}
}
}
class jbook_jButton1_actionAdapter implements ActionListener {
private jbook adaptee;
jbook_jButton1_actionAdapter(jbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class jbook_jButton2_actionAdapter implements ActionListener {
private jbook adaptee;
jbook_jButton2_actionAdapter(jbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class jbook_jButton3_actionAdapter implements ActionListener {
private jbook adaptee;
jbook_jButton3_actionAdapter(jbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
class jbook_jButton5_actionAdapter implements ActionListener {
private jbook adaptee;
jbook_jButton5_actionAdapter(jbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -