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

📄 updatedriver.java~39~

📁 出租车管理系统,为本人毕业设计. 还请大家多多指教了
💻 JAVA~39~
📖 第 1 页 / 共 2 页
字号:
        this.getContentPane().add(jLabel6, new XYConstraints(322, 322, 88, 31));
        this.getContentPane().add(tel_t, new XYConstraints(411, 321, 97, 31));
        this.getContentPane().add(idcard_t, new XYConstraints(412, 269, 97, 31));
        this.getContentPane().add(jLabel10, new XYConstraints(322, 269, 88, 31));
        this.getContentPane().add(jLabel8, new XYConstraints(35, 270, 98, 31));
        this.getContentPane().add(jLabel2, new XYConstraints(35, 218, 98, 31));
        this.getContentPane().add(jComboBox3,
                                  new XYConstraints(412, 218, 97, 31));
        this.getContentPane().add(jLabel3, new XYConstraints(322, 218, 88, 31));
        this.getContentPane().add(jComboBox4,
                                  new XYConstraints(135, 169, 104, 29));
        this.getContentPane().add(jLabel11, new XYConstraints(35, 169, 98, 29));
        jPanel1.add(jButton1, new XYConstraints(376, 8, 114, 34));
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel1.setText("请输入驾驶员驾证号:");
        this.setVisible(true) ;
        this.setSize(546,521) ;
        this.setLocation(170, 50);

        addWindowListener(new WindowAdapter() {
            public void WindowClosing(WindowEvent e) {
                if(db!=null)
                db.closeConnection();
                dispose();
            }
        });

    }
    DataBaseManager db=null;
    ResultSet r;
    JPanel jPanel1 = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    Border border1 = BorderFactory.createEtchedBorder(Color.white,
            new Color(165, 163, 151));
    JLabel jLabel1 = new JLabel();
    XYLayout xYLayout2 = new XYLayout();
    JTextField finddriverid_t = new JTextField();
    JButton jButton1 = new JButton(new ImageIcon("find.gif"));
    JLabel jLabel2 = new JLabel();
    JTextField address_t = new JTextField();
    JButton jButton2 = new JButton();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField idcard_t = new JTextField();
    JLabel jLabel7 = new JLabel();
    JTextField driveid_t = new JTextField();
    JLabel jLabel8 = new JLabel();
    JComboBox jComboBox1 = new JComboBox();
    JTextField getdate_t = new JTextField();
    JButton jButton4 = new JButton();
    JTextField tel_t = new JTextField();
    JTextField drivername_t = new JTextField();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    JComboBox jComboBox2 = new JComboBox();
    JButton jButton5 = new JButton(new ImageIcon("back.gif"));
    JLabel jLabel3 = new JLabel();
    JComboBox jComboBox3 = new JComboBox();
    JLabel jLabel11 = new JLabel();
    JComboBox jComboBox4 = new JComboBox();
    public void jButton5_actionPerformed(ActionEvent e) {
        if (db != null)
            db.closeConnection();
        this.dispose();
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        db = new DataBaseManager();
        try {
            String str1 = "select * from driver where 驾驶证号='" +
                          finddriverid_t.getText().trim() + "'";
            if (finddriverid_t.getText().trim().equals(""))
                JOptionPane.showMessageDialog(null, "请输入驾驶证号!");
            else if (!db.getResult(str1).first()) {
                String s = "没有编号为" + finddriverid_t.getText().trim() +
                           "的驾驶员,请重新输入驾驶证号。";
                JOptionPane.showMessageDialog(null, s);
                finddriverid_t.setText("");
            } else {
                String str = "select * from driver where 驾驶证号='" +
                             finddriverid_t.getText().trim() + "'";
                r = db.getResult(str);
                r.first();
                driveid_t.setText(finddriverid_t.getText());
                drivername_t.setText(r.getString("驾驶员姓名"));
                jComboBox1.setSelectedItem(r.getString("性别"));
                jComboBox3.setSelectedItem(r.getString("民族"));
                jComboBox4.setSelectedItem(r.getString("文化程度"));
                getdate_t.setText(r.getString("驾证初领日"));
                idcard_t.setText(r.getString("身份证号"));
                address_t.setText(r.getString("住址"));
                tel_t.setText(r.getString("联系电话"));
                jComboBox2.setSelectedItem(r.getString("准驾类型"));
            }
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        try { //驾驶证号,驾驶员姓名,性别,民族,文化程度,驾证初领日,身份证号,住址,联系电话,准驾类型,照片
            String strSQL = "update driver set 驾驶证号='" +
                            driveid_t.getText().trim() + "',驾驶员姓名='" +
                            drivername_t.getText().trim() + "',性别='" +
                            jComboBox1.getSelectedItem() + "',民族='" +
                            jComboBox3.getSelectedItem() + "',文化程度='" +
                            jComboBox4.getSelectedItem() + "',驾证初领日='" +
                            getdate_t.getText().trim() + "',身份证号='" +
                            idcard_t.getText().trim() + "',住址='" +
                            address_t.getText().trim() + "',联系电话='" +
                            tel_t.getText().trim() + "',准驾类型='" +
                            jComboBox2.getSelectedItem() +
                            "' where 驾驶证号='" + finddriverid_t.getText().trim() +
                            "'";
            if (db.updateSql(strSQL)) {
                JOptionPane.showMessageDialog(null, "信息修改成功!");
            } else {
                JOptionPane.showMessageDialog(null, "信息修改失败!");
            }
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }

    public void jButton4_actionPerformed(ActionEvent e) {
        try {
            String str2 = "delete from driver where 驾驶证号='" +
                          finddriverid_t.getText().trim() + "'";
            String q = "确定要删除吗?";
            int ok = JOptionPane.showConfirmDialog(null, q, "确认",
                                                   JOptionPane.YES_NO_OPTION,
                                                   JOptionPane.QUESTION_MESSAGE);
            if (ok == JOptionPane.YES_OPTION) {
                if (db.updateSql(str2))
                    JOptionPane.showMessageDialog(null,
                                                  "删除成功!");
                else
                    JOptionPane.showMessageDialog(null,
                                                  "删除失败!");
            }
            //  }catch(SQLException sqle){System.out.println(sqle.toString());
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }

    public void finddriverid_t_focusLost(FocusEvent focusEvent) {
        if (finddriverid_t.getText().trim().equals(""))
                  JOptionPane.showMessageDialog(null,
                                          "关键字不能为空!");
    }

    public void getdate_t_focusLost(FocusEvent e) {

    }
}


class Updatedriver_jButton5_actionAdapter implements ActionListener {
    private Updatedriver adaptee;
    Updatedriver_jButton5_actionAdapter(Updatedriver adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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