📄 f4upbook.java~57~
字号:
package jxm;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.util.Vector;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class F4upbook extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
String strid;
String strname;
// String
/* public F4upbook(String str5) {
try {
this.strid = str5;
jbInit();
jButton1.setEnabled(false);
} catch (Exception exception) {
exception.printStackTrace();
}
}*/
public F4upbook() {
try {
jbInit();
jButton1.setEnabled(false);
} catch (Exception exception) {
exception.printStackTrace();
}
}
public F4upbook(Vector ve) {
try {
jbInit();
this.strid = (String) ve.get(0);
this.strname = (String) ve.get(1);
d1.setText((String) ve.get(0));
d2.setText((String) ve.get(1));
d6.setText((String) ve.get(2));
d3.setText((String) ve.get(3));
d4.setText((String) ve.get(4));
d8.setText((String) ve.get(5));
d7.setText((String) ve.get(6));
d5.setText((String) ve.get(7));
jButton4.setEnabled(false);
d2.setEditable(false);
d3.setEditable(false);
d4.setEditable(false);
d6.setEditable(false);
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jPanel1.setBounds(new Rectangle(17, 18, 59, 257));
jPanel1.setLayout(gridLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel1.setBorder(null);
jLabel1.setText("编号");
jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel2.setBorder(null);
jLabel2.setText("书名");
jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel3.setBorder(null);
jLabel3.setText("出版社");
jLabel4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel4.setBorder(null);
jLabel4.setText("页数");
d1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d1.setText("");
d1.setBounds(new Rectangle(82, 27, 89, 31));
d2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d2.setText("2");
d2.setBounds(new Rectangle(80, 74, 148, 31));
d3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d3.setText("jTextField3");
d3.setBounds(new Rectangle(79, 133, 148, 31));
d4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d4.setText("");
d4.setBounds(new Rectangle(80, 186, 148, 31));
d5.setText("jTextField5");
d5.setBounds(new Rectangle(82, 235, 148, 31));
jLabel5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel5.setText("存放位置");
jLabel6.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel6.setText("作者");
jLabel6.setBounds(new Rectangle(253, 70, 57, 34));
jLabel7.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel7.setText("类型");
jLabel7.setBounds(new Rectangle(252, 127, 60, 34));
jLabel8.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel8.setText("价格");
jLabel8.setBounds(new Rectangle(251, 179, 62, 34));
d6.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d6.setText("jTextField6");
d6.setBounds(new Rectangle(310, 74, 148, 32));
d7.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d7.setText("");
d7.setBounds(new Rectangle(310, 130, 148, 32));
d8.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
d8.setText("");
d8.setBounds(new Rectangle(310, 183, 148, 32));
jButton1.setBounds(new Rectangle(157, 298, 88, 31));
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton1.setText("更新");
jButton1.addActionListener(new F4upbook_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(253, 298, 88, 31));
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton2.setText("重置");
jButton2.addActionListener(new F4upbook_jButton2_actionAdapter(this));
jButton3.setBounds(new Rectangle(350, 297, 88, 31));
jButton3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton3.setText("取消");
jButton3.addActionListener(new F4upbook_jButton3_actionAdapter(this));
jButton4.setBounds(new Rectangle(60, 299, 84, 31));
jButton4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton4.setText("添加");
jButton4.addActionListener(new F4upbook_jButton4_actionAdapter(this));
jPanel1.add(jLabel1);
jPanel1.add(jLabel2);
jPanel1.add(jLabel3);
jPanel1.add(jLabel4);
jPanel1.add(jLabel5);
this.getContentPane().add(jPanel1);
this.getContentPane().add(d7);
this.getContentPane().add(d5);
this.getContentPane().add(d4);
this.getContentPane().add(d6);
this.getContentPane().add(jLabel6);
this.getContentPane().add(jLabel7);
this.getContentPane().add(jLabel8);
this.getContentPane().add(d2);
this.getContentPane().add(jButton3);
this.getContentPane().add(jButton2);
this.getContentPane().add(d3);
this.getContentPane().add(jButton4);
this.getContentPane().add(d1);
this.getContentPane().add(d8);
this.getContentPane().add(jButton1);
}
JPanel jPanel1 = new JPanel();
GridLayout gridLayout1 = new GridLayout(5, 1, 20, 20);
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JTextField d1 = new JTextField();
JTextField d2 = new JTextField();
JTextField d3 = new JTextField();
JTextField d4 = new JTextField();
JTextField d5 = new JTextField();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JTextField d6 = new JTextField();
JTextField d7 = new JTextField();
JTextField d8 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
public void jButton3_actionPerformed(ActionEvent e) { //退出
this.dispose();
}
public void jButton4_actionPerformed(ActionEvent e) { //增
String str = "insert into books values('" + d1.getText() + "','" +
d2.getText() + "','" + d6.getText() + "','" + d3.getText() +
"','" + d7.getText() + "','" + d8.getText() + "','" +
d4.getText() + "','" + d5.getText() + "','1')";
System.out.println(str);
String str2 = "select * from bookzt where bname='" + d2.getText() + "'";
String str3 =
"update bookzt set zmount=zmount+1,ymount=ymount+1 where bname='" +
d2.getText() + "'";
cons con = new cons();
if (con.getbl(str2)) { //查询此书名是否存在
if (con.getblcc(str) && con.getblcc(str3)) {
JOptionPane.showMessageDialog(this, "书已入库", "添加成功",
JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "添加失败", "错误",
JOptionPane.ERROR_MESSAGE);
}
} else {
String str4 = "insert into bookzt values ('" +
d2.getText() + "','1','0','1')";
// String s = "select * from books where bnum='" + d1.getText() + "'";
//if (con.getbl(s)) {
if (con.getblcc(str4) && con.getblcc(str)) {
JOptionPane.showMessageDialog(this, "新书已入库", "添加成功",
JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "添加失败", "错误",
JOptionPane.ERROR_MESSAGE);
}
// }
}
}
public void jButton1_actionPerformed(ActionEvent e) { //改
int ii = 0;
String str = "update books set bnum='" + d1.getText() + "', btype='" +
d7.getText() + "', baddress='" + d5.getText() +
"', bprice='" + d8.getText() + "' where bnum='" + strid +
"'";
String strjhbl = "select * from jhbook where bookid='" + strid + "'"; //1先到JMBOOK 表查询判断是否有 2 如有查询出来反倒稽核中
String strjh = "delete from jhbook where bookid='" + strid + "'"; //3 删除所有符合条件的行
//判断状态 1 执行str2 0执行str3
String strname = "select * from bookzt where bname='" + d2.getText() +
"'"; //4
String stradd;
cons con = new cons();
Vector ve = null;
ve = con.getjbkve(strjhbl);
con.getblcc(strjh);
{ //删除[jhbook]表中的数据关联
if (con.getblcc(str)) { //依次插入[books]表后改[bookzt]表中的数据关联
Vector v = null;
jbjhbook j;
for (int i = 0; i < ve.size(); i++) {
v = new Vector();
j = new jbjhbook();
j = (jbjhbook) ve.get(i);
v = getv(d1.getText(), j);
stradd = "insert into jhbook values('" + v.get(0) + "','" +
v.get(1) + "','" + v.get(2) + "','" + v.get(3) +
"','" + v.get(4) + "','" + v.get(5) + "','" +
v.get(6) + "')";
if (con.getblcc(stradd)) {
ii = 1;
} else {
ii = 0;
break;
}
}
}
if (ii == 1) {
JOptionPane.showMessageDialog(this, "图书资料已更新", "修改成功",
JOptionPane.
INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "修改失败", "错误",
JOptionPane.ERROR_MESSAGE);
}
}
}
public Vector getv(String str, jbjhbook j) {
Vector v = new Vector();
v.add(str);
v.add(j.getUserid());
v.add(j.getStarttime());
v.add(j.getEndtime());
v.add(j.getBorrowtime());
v.add(j.getYamoney());
v.add(j.getZumoney());
System.out.println(v);
return v;
}
public void jButton2_actionPerformed(ActionEvent e) {
d2.setText("");
d3.setText("");
d4.setText("");
d6.setText("");
d5.setText("");
d7.setText("");
d8.setText("");
if (d4.isEditable()) {} else {
d1.setText("");
}
}
}
class F4upbook_jButton2_actionAdapter implements ActionListener {
private F4upbook adaptee;
F4upbook_jButton2_actionAdapter(F4upbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class F4upbook_jButton1_actionAdapter implements ActionListener {
private F4upbook adaptee;
F4upbook_jButton1_actionAdapter(F4upbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class F4upbook_jButton4_actionAdapter implements ActionListener {
private F4upbook adaptee;
F4upbook_jButton4_actionAdapter(F4upbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton4_actionPerformed(e);
}
}
class F4upbook_jButton3_actionAdapter implements ActionListener {
private F4upbook adaptee;
F4upbook_jButton3_actionAdapter(F4upbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -