⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dadduser.java~52~

📁 图书管理 问题描述:图书管理基本业务活动包括对一本书的采编入库、清除库存、借阅和归还等等。将上述业务活动借助于计算机系统完成。
💻 JAVA~52~
字号:
package jxm;

import java.awt.*;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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 Dadduser extends JDialog {
    JPanel panel1 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    JTextField jTextField4 = new JTextField();
    ButtonGroup buttonGroup1 = new ButtonGroup();
    JRadioButton jRadioButton1 = new JRadioButton();
    JRadioButton jRadioButton2 = new JRadioButton();
    JLabel jLabel6 = new JLabel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    //  Vector ve;
    String id;
    int N;
    public Dadduser(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public Dadduser() {
        this(new Frame(), "Dadduser", false);
        N = 1;
    }

    public Dadduser(Vector v) {
        this(new Frame(), "Dadduser", false);
        N = 0;
        //this.ve = v;
        this.id = (String) v.get(0);
        jTextField1.setText((String) v.get(0));
        jTextField2.setText((String) v.get(1));
        jTextField3.setText((String) v.get(3));
        jTextField4.setText((String) v.get(4));

        String st = new String((String) v.get(2));
        System.out.println(st);
        if (st.trim().equals("女")) {
            jRadioButton1.setSelected(false);
            jRadioButton2.setSelected(true);
        }
        jTextField2.setEditable(false);
        jRadioButton1.setEnabled(false);
        jRadioButton2.setEnabled(false);
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jLabel1.setText("编号");
        jLabel1.setBounds(new Rectangle(50, 23, 44, 27));
        jButton1.setBounds(new Rectangle(75, 235, 76, 30));
        jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jButton1.setText("确定");
        jButton1.addActionListener(new Dadduser_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(175, 235, 71, 30));
        jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jButton2.setText("重置");
        jButton2.addActionListener(new Dadduser_jButton2_actionAdapter(this));
        jButton3.setBounds(new Rectangle(264, 235, 61, 30));
        jButton3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jButton3.setText("取消");
        jButton3.addActionListener(new Dadduser_jButton3_actionAdapter(this));
        jLabel6.setBorder(BorderFactory.createEtchedBorder());
        jLabel6.setBounds(new Rectangle(312, 58, 63, 62));
        jRadioButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jRadioButton2.setText("女");
        jRadioButton2.setBounds(new Rectangle(322, 88, 42, 26));
        jRadioButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jRadioButton1.setSelected(true);
        jRadioButton1.setText("男");
        jRadioButton1.setBounds(new Rectangle(319, 63, 46, 25));
        jTextField4.setText("");
        jTextField4.setBounds(new Rectangle(113, 139, 181, 23));
        jTextField3.setText("");
        jTextField3.setBounds(new Rectangle(113, 100, 122, 24));
        jTextField2.setText("");
        jTextField2.setBounds(new Rectangle(113, 59, 115, 25));
        jTextField1.setText("");
        jTextField1.setBounds(new Rectangle(112, 25, 115, 24));
        jLabel5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jLabel5.setText("联系地址");
        jLabel5.setBounds(new Rectangle(46, 133, 72, 32));
        jLabel4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jLabel4.setText("联系电话");
        jLabel4.setBounds(new Rectangle(47, 99, 50, 29));
        jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jLabel3.setText("性别");
        jLabel3.setBounds(new Rectangle(268, 56, 42, 29));
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jLabel6);
        this.getContentPane().add(jRadioButton1);
        this.getContentPane().add(jRadioButton2);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(jTextField2);
        this.getContentPane().add(jTextField3);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jLabel1, null);
        this.getContentPane().add(jLabel4);
        this.getContentPane().add(jLabel5);
        this.getContentPane().add(jTextField1);
        this.getContentPane().add(jTextField4);
        this.getContentPane().add(jLabel7);
        this.getContentPane().add(jLabel8);
        this.getContentPane().add(jLabel9);
        this.getContentPane().add(jLabel10);
        this.getContentPane().add(jButton3);
        this.getContentPane().add(jButton2);
        jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        jLabel2.setText("姓名");
        jLabel2.setBounds(new Rectangle(48, 53, 55, 31));
        jLabel7.setBorder(BorderFactory.createEtchedBorder());
        jLabel7.setBounds(new Rectangle(13, 3, 405, 19));
        jLabel8.setBorder(BorderFactory.createEtchedBorder());
        jLabel8.setBounds(new Rectangle(13, 20, 18, 210));
        jLabel9.setBorder(BorderFactory.createEtchedBorder());
        jLabel9.setBounds(new Rectangle(29, 213, 389, 17));
        jLabel10.setBorder(BorderFactory.createEtchedBorder());
        jLabel10.setBounds(new Rectangle(401, 20, 17, 195));
        buttonGroup1.add(jRadioButton1);
        buttonGroup1.add(jRadioButton2);

    }

    public void jButton1_actionPerformed(ActionEvent e) {
        if (N == 1) {
            tianjia();
        } else {
            updata();
        }
    }

    public void tianjia() {
        String s;
        if (jRadioButton1.isSelected()) {
            s = jRadioButton1.getText().trim();
        } else {
            s = jRadioButton2.getText().trim();
        }
        String str = "insert into duze values('" + jTextField1.getText() +
                     "','" + jTextField2.getText() + "','" + s + "','" +
                     jTextField3.getText() + "','" + jTextField4.getText() +
                     "')";
        cons con = new cons();
        if (con.getblcc(str)) {
            JOptionPane.showMessageDialog(this, "添加成功", "消息",
                                          JOptionPane.INFORMATION_MESSAGE);

        } else {
            JOptionPane.showMessageDialog(this, "添加失败", "错误",
                                          JOptionPane.ERROR_MESSAGE);
        }

    }

    public void updata() {
        int ii = 0;
        String str = "update duze set dnum='" + jTextField1.getText() +
                     "' ,ddh='" + jTextField3.getText() + "',daddress='" +
                     jTextField4.getText() + "' where dnum='"+id+"'";
        String strjhbl = "select * from jhbook where userid='" + id + "'"; //1先到JMBOOK 表查询判断是否有 2 如有查询出来反倒稽核中
        String strjh = "delete from jhbook  where userid='" + id + "'"; //3 删除所有符合条件的行
        //判断状态 1 执行str2 0执行str3
        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(jTextField1.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;
                }
                System.out.println(ii);
            }
        }

        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(j.getBookid());
          v.add(str);
          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) {
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField3.setText("");
        jTextField4.setText("");
        jRadioButton1.setEnabled(true);
    }

    public void jButton3_actionPerformed(ActionEvent e) {
        this.dispose();
    }
}


class Dadduser_jButton3_actionAdapter implements ActionListener {
    private Dadduser adaptee;
    Dadduser_jButton3_actionAdapter(Dadduser adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class Dadduser_jButton2_actionAdapter implements ActionListener {
    private Dadduser adaptee;
    Dadduser_jButton2_actionAdapter(Dadduser adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class Dadduser_jButton1_actionAdapter implements ActionListener {
    private Dadduser adaptee;
    Dadduser_jButton1_actionAdapter(Dadduser adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -