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

📄 newweizhang.java~34~

📁 出租车管理系统,为本人毕业设计. 还请大家多多指教了
💻 JAVA~34~
📖 第 1 页 / 共 2 页
字号:
        db.closeConnection() ;
        this.dispose();
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        db=new DataBaseManager();
        String str = "select * from car where 车牌号='"+breakcarid_t.getText().trim()+"'";
                       try {
                           if (!db.getResult(str).first()) {
                               JOptionPane.showMessageDialog(null,
                                       "该车辆不存在!");
                               breakcarid_t.setText("");
                               drivername_t.setText("");
                               breaklowaddress_t.setText("");
                               breakdate_t.setText("");
                               penaltymoney_t.setText("");
                               unit_t.setText("");
                               breaklowreason_a.setText("");

                           } else {
                               str = "insert into weizhang(违章车号,驾驶员,违章日期,违章地点,罚款金额,处理单位,违章原因) values('" +
                                     breakcarid_t.getText().trim() + "','" +
                                     drivername_t.getText().trim() + "','" +
                                     breakdate_t.getText().trim() + "','" +
                                     breaklowaddress_t.getText().trim() + "','" +
                                     penaltymoney_t.getText().trim() + "','" +
                                     unit_t.getText() .trim()  + "','" +
                                     breaklowreason_a.getText().trim() + "'" + ")";
                               if (db.updateSql(str)) {
                                   JOptionPane.showMessageDialog(null,
                                           "添加信息成功!");
                                   String strSQL = "update car set 违章次数=违章次数+1" +
                                           " where 车牌号='" +
                                           breakcarid_t.getText().trim() +
                                           "'";
                                   if (db.updateSql(strSQL))
                                       ;

                                   breakcarid_t.setText("");
                                   drivername_t.setText("");
                                   breaklowaddress_t.setText("");
                                   breakdate_t.setText("");
                                   penaltymoney_t.setText("");
                                   unit_t.setText("");
                                   breaklowreason_a.setText("");
                               } else {
                                   JOptionPane.showMessageDialog(null, "添加信息失败!");
                               }
                           }
                       } catch (HeadlessException ex) {
                       } catch (SQLException ex) {
       }
    }

    public void breakcarid_t_focusLost(FocusEvent e) {
         if (breakcarid_t.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "车牌号不能为空!");
    }

    public void drivername_t_focusLost(FocusEvent e) {
        if (drivername_t.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "驾驶员姓名不能为空!");
    }

    public void breakdate_t_focusLost(FocusEvent e) {
        if (breakdate_t.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "违章日期不能为空!");
        else {
            String s = breakdate_t.getText().trim() + "!";

            char date[] = new char[20];
            int i;
            date = s.toCharArray();
            for (i = 0; date[i] != '!'; i++)
                if ((date[i] >= '0' && date[i] <= '9') || date[i] == '.')
                    ;
                else {
                    JOptionPane.showMessageDialog(null,
                                                  "您输入的日期非法或您输入的日期格式不正确,请以“.”为分隔符!");
                    breakdate_t.setText("");
                    breakdate_t.setFocusable(true);
                    break;
                }
        }


    }

    public void breaklowaddress_t_focusLost(FocusEvent e) {
        if (breaklowaddress_t.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "违章地点不能为空!");
    }

    public void penaltymoney_t_focusLost(FocusEvent e) {
        if (penaltymoney_t.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "罚款金额不能为空!");
    }

    public void unit_t_focusLost(FocusEvent e) {
        if (unit_t.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "处理单位不能为空!");
    }

    public void breaklowreason_a_focusLost(FocusEvent e) {
        if (breaklowreason_a.getText().trim().equals(""))
            JOptionPane.showMessageDialog(null, "违章原因不能为空!");
    }

    public void breaklowreason_a_keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
            db=new DataBaseManager();
       String str = "select * from car where 车牌号='"+breakcarid_t.getText().trim()+"'";
                      try {
                          if (!db.getResult(str).first()) {
                              JOptionPane.showMessageDialog(null,
                                      "该车辆不存在!");
                              breakcarid_t.setText("");
                              drivername_t.setText("");
                              breaklowaddress_t.setText("");
                              breakdate_t.setText("");
                              penaltymoney_t.setText("");
                              unit_t.setText("");
                              breaklowreason_a.setText("");

                          } else {
                              str = "insert into weizhang(违章车号,驾驶员,违章日期,违章地点,罚款金额,处理单位,违章原因) values('" +
                                    breakcarid_t.getText().trim() + "','" +
                                    drivername_t.getText().trim() + "','" +
                                    breakdate_t.getText().trim() + "','" +
                                    breaklowaddress_t.getText().trim() + "','" +
                                    penaltymoney_t.getText().trim() + "','" +
                                    unit_t.getText() .trim()  + "','" +
                                    breaklowreason_a.getText().trim() + "'" + ")";
                              if (db.updateSql(str)) {
                                  JOptionPane.showMessageDialog(null,
                                          "添加信息成功!");
                                  String strSQL = "update car set 违章次数=违章次数+1" +
                                          " where 车牌号='" +
                                          breakcarid_t.getText().trim() +
                                          "'";
                                  if (db.updateSql(strSQL))
                                      ;

                                  breakcarid_t.setText("");
                                  drivername_t.setText("");
                                  breaklowaddress_t.setText("");
                                  breakdate_t.setText("");
                                  penaltymoney_t.setText("");
                                  unit_t.setText("");
                                  breaklowreason_a.setText("");
                              } else {
                                  JOptionPane.showMessageDialog(null, "添加信息失败!");
                              }
                          }
                      } catch (HeadlessException ex) {
                      } catch (SQLException ex) {
      }

        }
    }
}


class Newweizhang_breakcarid_t_focusAdapter extends FocusAdapter {
    private Newweizhang adaptee;
    Newweizhang_breakcarid_t_focusAdapter(Newweizhang adaptee) {
        this.adaptee = adaptee;
    }

    public void focusLost(FocusEvent e) {

        adaptee.breakcarid_t_focusLost(e);
    }
}


class Newweizhang_jButton3_actionAdapter implements ActionListener {
    private Newweizhang adaptee;
    Newweizhang_jButton3_actionAdapter(Newweizhang adaptee) {
        this.adaptee = adaptee;
    }

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


class Newweizhang_jButton1_actionAdapter implements ActionListener {
    private Newweizhang adaptee;
    Newweizhang_jButton1_actionAdapter(Newweizhang adaptee) {
        this.adaptee = adaptee;
    }

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


class Newweizhang_jButton2_actionAdapter implements ActionListener {
    private Newweizhang adaptee;
    Newweizhang_jButton2_actionAdapter(Newweizhang adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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