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

📄 pmainmenu.java

📁 管理系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public void jComboBox2_actionPerformed(ActionEvent e) {
        this.getTime();
        this.txtDate.setEditable(false);
        if(this.jComboBox2.getSelectedItem().equals("修改")){
           txtName.setEnabled(false);
           this.txtSex.setEnabled(false);
           this.txtAge.setEnabled(false);
        }
       if(this.jComboBox2.getSelectedItem().equals("增加")){
           this.txtAge.setEnabled(true);

           this.txtDate.setEnabled(false);
           this.txtId.setEnabled(false);
           this.txtName.setEnabled(true);

           this.txtAdd.setEnabled(true);
           this.txtPhone.setEnabled(true);
           this.txtSex.setEnabled(true);

       }

    }

        public void jComboBox2_mouseClicked(MouseEvent e) {
      }


      //jTable2单击事件
    public void jTable2_mouseClicked(MouseEvent e) {
        jTable2.setSelectionBackground(Color.green );

            String id = null;  // 编号
            String name = null; //姓名
            String sex = null; //性别
            String age = null; //年龄
            String duty = null; //职务
            String phone = null; //电话
            String add = null; //地址
            String stat = null; //状态
            String time = null; //时间

        id = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 0).toString();
        name = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 1).toString();
        sex = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 2).toString();
        age = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 3).toString();
        duty = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 4).toString();
        phone = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 5).toString();
        add = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 6).toString();
        stat = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 7).toString();
        time = this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 8).toString();

        this.txtId.setText(id);
        this.txtName.setText(name);
        this.txtDate.setText(time);
        this.txtSex.setText(sex);
        this.txtAge.setText(age);
        this.txtPhone.setText(phone);
        this.txtAdd.setText(add);
    }

    /**
     * 删除按钮点击事件
     * @param e ActionEvent
     * @throws SQLException
     */

    public void jButton11_actionPerformed(ActionEvent e) throws SQLException {
        SPerControl sp = new SPerControl();
        if(this.jComboBox1.getSelectedItem().equals("编号")){
            String id = txtTiao.getText(); //获得选择的编号
            if (id.equals("")) {
                JOptionPane.showMessageDialog(this, "请输入该条件的文本值");
                return;
            }
            int arraylist = sp.amend1(id);
            if (arraylist ==  0) {
                JOptionPane.showMessageDialog(this, "没有此编号");
            } else {
                JOptionPane.showMessageDialog(this, "删除成功");
                this.jbInit1();
            }
        }
        if(this.jComboBox1.getSelectedItem().equals("姓名")){
            String name = txtTiao.getText(); //获得姓名
            if (name.equals("")) {
                JOptionPane.showMessageDialog(this, "请输入该条件的文本值");
                return;
            }
           int arraylist = sp.amend2(name);
           if (arraylist == 0) {
               JOptionPane.showMessageDialog(this, "没有此姓名");
           } else {
               JOptionPane.showMessageDialog(this, "删除成功");
               this.jbInit1();
            }
        }
        if(this.jComboBox1.getSelectedItem().equals("性别")){
            String sex = txtTiao.getText(); //获得性别
            if(sex.equals("")){
                JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
                return;
            }
            if(!(sex.equals("女"))&&!(sex.equals("男"))){
               JOptionPane.showMessageDialog(this, "性别输入不对");
               return;
           }
            int arraylist = sp.amend3(sex);
            if (arraylist == 0) {
                JOptionPane.showMessageDialog(this, "没有此性别");
            } else {
                JOptionPane.showMessageDialog(this, "删除成功");
                this.jbInit1();
            }
        }
        if(this.jComboBox1.getSelectedItem().equals("年龄")){
            String age = txtTiao.getText();
            if(age.equals("")){
              JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
              return;
           }
           try {
               Integer.parseInt(txtTiao.getText());
           } catch (Exception ex) {
               JOptionPane.showMessageDialog(this, "年龄必须为整数");
               return;
           }
           if((Integer.parseInt(age)<18)||(Integer.parseInt(age)>60)){
               JOptionPane.showMessageDialog(this, "没有此段年龄的人员");
               return;
           }

            int arraylist = sp.amend4(age);
            if (arraylist == 0) {
               JOptionPane.showMessageDialog(this, "没有此年龄的人员");
           } else {
               JOptionPane.showMessageDialog(this, "删除成功");
               this.jbInit1();
            }
        }
        if(this.jComboBox1.getSelectedItem().equals("地址")){
            String add = txtTiao.getText();
            if(add.equals("")){
              JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
              return;
          }

            int arraylist = sp.amend5(add);
            if (arraylist == 0) {
               JOptionPane.showMessageDialog(this, "没有此地址的人员");
           } else {
               JOptionPane.showMessageDialog(this, "删除成功");
               this.jbInit1();
            }
        }
        if(this.jComboBox1.getSelectedItem().equals("职务")){
            String stat = txtTiao.getText();
            if(stat.equals("")){
              JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
              return;
          }
          if(!(stat.equals("经理"))&&!(stat.equals("主管"))&&!(stat.equals("职员"))){
              JOptionPane.showMessageDialog(this,"没有此职务的人员");
              return;
           }
            int arraylist = sp.amend6(stat);
            if (arraylist == 0) {
               JOptionPane.showMessageDialog(this, "没有此职务的人员");
           } else {
               JOptionPane.showMessageDialog(this, "删除成功");
               this.jbInit1();
            }
        }
        if(this.jComboBox1.getSelectedItem().equals("电话")){
            String phone = txtTiao.getText();
            if(phone.equals("")){
              JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
              return;
          }
          try {
             Float.parseFloat(txtTiao.getText());
         } catch (Exception ex) {
             JOptionPane.showMessageDialog(this, "电话号码必须为整数字的");
             return;
         }
         if(!(phone.length() == 11)){
             JOptionPane.showMessageDialog(this, "电话号码必须为11位正数字");
             return;
         }
         float num1;
         float num2;
         num1 = Float.parseFloat(phone.substring(0,2));
         num2 = Float.parseFloat(phone.substring(0,3));
         if(!(num1 == 13)&&!(num2 == 159)){
             JOptionPane.showMessageDialog(this, "电话号码输入有误");
             return;
         }
            int arraylist = sp.amend7(phone);
            if (arraylist == 0) {
              JOptionPane.showMessageDialog(this, "没有此电话的人员");
          } else {
              JOptionPane.showMessageDialog(this, "删除成功");
              this.jbInit1();
            }
        }
    }

    /**
     * 查询按钮点击事件
     * @param e ActionEvent
     * @throws SQLException
     */
    public void jButton12_actionPerformed(ActionEvent e) throws SQLException {
        SPerControl sp = new SPerControl();
        if(this.jComboBox1.getSelectedItem().equals("编号")){
            String id = txtTiao.getText();
            if(id.equals("")){
                JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
                return;
            }
            Vector ve = sp.query1(id);
            if(ve.size() == 0){
                JOptionPane.showConfirmDialog(this,"没有此编号");
                return;
            }
            SPerTitle spe = new SPerTitle();
            Vector vec = spe.titleName();

            JTable jTable2 = new JTable(ve,vec);
            jScrollPane2.getViewport().add(jTable2);
            jTable2.addMouseListener(new PMainMenu_jTable2_mouseAdapter(this));

        }
        if(this.jComboBox1.getSelectedItem().equals("姓名")){
            String name = txtTiao.getText();
            if(name.equals("")){
                JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
                return;
            }
            Vector ve = sp.query2(name);
            if (ve.size() == 0) {
                JOptionPane.showConfirmDialog(this, "没有此姓名的人员");
                return;
            }
            SPerTitle spe = new SPerTitle();
            Vector vec = spe.titleName();

            JTable jTable2 = new JTable(ve, vec);
            jScrollPane2.getViewport().add(jTable2);
            jTable2.addMouseListener(new PMainMenu_jTable2_mouseAdapter(this));
        }
        if(this.jComboBox1.getSelectedItem().equals("性别")){
            String sex = txtTiao.getText();
            if (sex.equals("")) {
                JOptionPane.showMessageDialog(this, "请输入该条件的文本值");
                return;
            }
            if(!(sex.equals("女"))&&!(sex.equals("男"))){
                JOptionPane.showMessageDialog(this, "性别输入不对");
                return;
            }
            Vector ve = sp.query3(sex);
            if (ve.size() == 0) {
                JOptionPane.showConfirmDialog(this, "没有此性别");
                return;
            }

            SPerTitle spe = new SPerTitle();
            Vector vec = spe.titleName();
            JTable jTable2 = new JTable(ve, vec);
            jScrollPane2.getViewport().add(jTable2);
            jTable2.addMouseListener(new PMainMenu_jTable2_mouseAdapter(this));
        }
        if(this.jComboBox1.getSelectedItem().equals("年龄")){
            String age = txtTiao.getText();
            if(age.equals("")){
              JOptionPane.showMessageDialog(this,"请输入该条件的文本值");
              return;
           }
           try {
               Integer.parseInt(txtTiao.getText());
           } catch (Exception ex) {
               JOptionPane.showMessageDialog(this, "年龄必须为整数");
               return;
           }
           if((Integer.parseInt(age)<18)||(Integer.parseInt(age)>60)){
               JOptionPane.showMessageDialog(this, "没有此段年龄的人员");
               return;
           }
            Vector ve = sp.query4(age);
            if (ve.size() == 0) {
                JOptionPane.showConfirmDialog(this, "没有此年龄的人员");
                return;
            }

            SPerTitle spe = new SPerTitle();
            Vector vec = spe.titleName();
            JTable jTable2 = new JTable(ve, vec);
            jScrollPane2.getViewport().add(jTable2);
            jTable2.addMouseListener(new PMainMenu_jTable2_mouseAdapter(this));
        }
        if(this.jComboBox1.getSelectedItem().equals("地址")){
            String add = txtTiao.getText();
            if (add.equals("")) {
                JOptionPane.showMessageDialog(this, "请输入该条件的文本值");
                return;
            }
            Vector ve = sp.query5(add);
            if (ve.size() == 0) {
                JOptionPane.showConfirmDialog(this, "没有此地址的人员");
                return;
            }

⌨️ 快捷键说明

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