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

📄 pmainmenu.java

📁 管理系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                       JTextField jtf = (JTextField)vtxt.elementAt(i);
                       jtf.setForeground(Color.yellow);
                   }
               }
               if(node.toString().equals("蓝色")){
                   for (int i = 0; i < vtxt.size(); i++) {
                       JTextField jtf = (JTextField)vtxt.elementAt(i);
                       jtf.setForeground(Color.BLUE);
                   }
               }

               if(node.toString().equals("默认颜色")){
                   new PMainMenu();
                   this.dispose();
               }
               if(node.toString().equals("浅灰")){
                   for (int i = 0; i < vpnl.size(); i++) {
                       JPanel jab = (JPanel)vpnl.elementAt(i);
                       jab.setBackground(Color.lightGray);
                   }
               }
               if(node.toString().equals("深灰")){
                   for (int i = 0; i < vpnl.size(); i++) {
                       JPanel jab = (JPanel)vpnl.elementAt(i);
                       jab.setBackground(Color.GRAY);
                   }
               }
               if(node.toString().equals("白")){
                   for (int i = 0; i < vpnl.size(); i++) {
                       JPanel jab = (JPanel)vpnl.elementAt(i);
                       jab.setBackground(Color.WHITE);
                   }
               }
           }
       }
   }

    public void run(){ //线程设置
        while(true){
            SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss aaa");
            jTextField3.setText(SGetDate.getDate().concat(sdf.format(new Date())));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }
    }

    public void jbInit1() throws SQLException {
        Vector ve = sp.que();
        SPerTitle spe = new SPerTitle();
        Vector vec = spe.titleName();
        jTable2 = new JTable(ve,vec);
        jTable2.addMouseListener(new PMainMenu_jTable2_mouseAdapter(this));
        jScrollPane2.getViewport().add(jTable2);

        root.add(roota);
        roota.add(roota1);
        roota.add(roota2);

    }

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("菜单选项");
    DefaultMutableTreeNode roota = new DefaultMutableTreeNode("人员信息");
    DefaultMutableTreeNode roota1 = new DefaultMutableTreeNode("人员管理 1");
    DefaultMutableTreeNode roota2 = new DefaultMutableTreeNode("人员管理 2");
    JTree jTree1 = new JTree(root);
    TitledBorder titledBorder1 = new TitledBorder("");
    JMenuItem jMenuItem14 = new JMenuItem();
    JMenuItem jMenuItem21 = new JMenuItem();
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    GridLayout gridLayout2 = new GridLayout();
    JMenuItem jMenuItem22 = new JMenuItem();
    JScrollPane jScrollPane3 = new JScrollPane();
    JTree jTree2 = new JTree();
    JTextField txtnote = new JTextField();
    Border border1 = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.yellow);

    public void jPanel3_mouseClicked(MouseEvent e) {
        int num = (int)Math.round(Math.random()*9);
        ImageIcon image=new ImageIcon("/Jewelry/desktop/20050118xy001_("+num+").jpg");
    }

    public void jButton4_mouseClicked(MouseEvent e) {
    }

    public void jButton6_actionPerformed(ActionEvent e) {
        SMainMenu sm = new SMainMenu();
        Thread thr = new Thread(sm);
        thr.start();
        this.dispose();
    }

    public void jButton5_actionPerformed(ActionEvent e) {
        SMainMenu sm = new SMainMenu(); //
        sm.baseButton(e);  //
        Thread thr = new Thread(sm);
        thr.start();
        this.dispose();
    }

    public void jButton4_actionPerformed(ActionEvent e) {
        CSMainMenu cs = new CSMainMenu();
        Thread thr = new Thread(cs);
        thr.start();
        this.dispose();
    }
    public void getTime(){
        Date date = new Date();
        DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
        txtDate.setText(fmt.format(date));
    }

    public void jButton8_actionPerformed(ActionEvent e) throws SQLException {
        SPerControl sp = new SPerControl();

        if(this.jComboBox2.getSelectedItem().equals("--请选择--")){
            txtAdd.setText("");
            txtAge.setText("");
            txtId.setText("");
            txtName.setText("");
            txtPhone.setText("");
            txtSex.setText("");
            JOptionPane.showMessageDialog(this, "请选择填写的方式");
            return;
        }
        if(this.jComboBox2.getSelectedItem().equals("增加")){
            String id = txtId.getText();   //编号  //
            String name = txtName.getText(); //姓名 //
            String sex = txtSex.getText(); //性别 //
            String age = txtAge.getText(); //年龄 //
            String  duty= jComboBox3.getSelectedItem().toString(); //状态
            String phone = txtPhone.getText();  //电话 //
            String add = txtAdd.getText(); //地址
            String stat = this.jComboBox4.getSelectedItem().toString(); // 职务
            String time = this.txtDate.getText(); //时间

            //判断编号是否为空
            if(id.equals("")){
                JOptionPane.showMessageDialog(this, "编号不能为空");
                return;
            }
            //判断输入的编号是否以存在
            Vector ve = sp.query1(id);
            if (ve.size() != 0) {
                JOptionPane.showMessageDialog(this, "此编号已存在");
                return;
            }
            //判断姓名是否为空
            if(name.equals("")){
                JOptionPane.showMessageDialog(this, "姓名不能为空");
                return;
            }
            if(name.length() < 2 | name.length() > 4){
                JOptionPane.showMessageDialog(this, "姓名字符输入有误");
                return;
            }

            //判断性别是否为空
            if(!(sex.equals("男"))&& !(sex.equals("女"))){
                JOptionPane.showMessageDialog(this, "性别不能为空");
                return;
            }

            //判断输入的年龄是否为空
            if(age.equals("")){
                JOptionPane.showMessageDialog(this, "年龄不能为空");
                return;
            }
            //判断输入的年龄是否为整数字
            try {
                Integer.parseInt(txtAge.getText());
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, "年龄必须为整数");
                return;
            }
            //判断输入的年龄是否小于 18 岁
            if(Integer.parseInt(age) < 18 || Integer.parseInt(age) > 60){
                JOptionPane.showMessageDialog(this,""+ age +" 年龄输入不对");
                return;
            }
            //判断输入的电话是否为空
            if(phone.equals("")){
                JOptionPane.showMessageDialog(this, "电话号码不能为空");
                return;
            }
            //判断输入的电话号码是否为数字
            try {
                Float.parseFloat(this.txtPhone.getText());
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, "电话号码必须为数字");
                return;
            }

            //判断输入的电话号码是否以 13 获 159 开头
            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;
            }
            //判断输入的电话号码是否已存在
            Vector vec = sp.query7(phone);
            if(vec.size() != 0){
                JOptionPane.showMessageDialog(this, "此电话号码已存在");
                return;
            }

            ArrayList arraylist = sp.cont(id,name,sex,age,stat,phone,add,duty,time);
            if(arraylist == null){
                JOptionPane.showMessageDialog(this, "增加失败");
            }else{
                JOptionPane.showMessageDialog(this, "增加成功");
                this.jbInit1();
            }
    }else{

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


      id =  this.txtId.getText();
      name = this.txtName.getText();
      time =  this.txtDate.getText();
      sex = this.txtSex.getText();
      age = this.txtAge.getText();
      add = this.txtAdd.getText();
      phone = this.txtPhone.getText();
      stat = jComboBox3.getSelectedItem().toString();  //获得状态
      duty = this.jComboBox4.getSelectedItem().toString(); //职务
      ///////////////////////////////////////////////////////////////
      //判断编号是否为空
      if(id.equals("")){
          JOptionPane.showMessageDialog(this, "编号不能为空");
          return;
      }

      //判断姓名是否为空
      if(name.equals("")){
          JOptionPane.showMessageDialog(this, "姓名不能为空");
          return;
      }

      //判断性别是否为空
      if(!(sex.equals("男"))&& !(sex.equals("女"))){
          JOptionPane.showMessageDialog(this, "性别不能为空");
          return;
      }

      //判断输入的年龄是否为空
      if(age.equals("")){
          JOptionPane.showMessageDialog(this, "年龄不能为空");
          return;
      }
      //判断输入的年龄是否为整数字
      try {
          Integer.parseInt(txtAge.getText());
      } catch (Exception ex) {
          JOptionPane.showMessageDialog(this, "年龄必须为整数");
          return;
      }
      //判断输入的年龄是否小于 18 岁
      if(Integer.parseInt(age) < 18 || Integer.parseInt(age) > 60){
          JOptionPane.showMessageDialog(this,""+ age +" 年龄输入不对");
          return;
      }
      //判断输入的电话是否为空
      if(phone.equals("")){
          JOptionPane.showMessageDialog(this, "电话号码不能为空");
          return;
      }
      //判断输入的电话号码是否为数字
      try {
          Float.parseFloat(this.txtPhone.getText());
      } catch (Exception ex) {
          JOptionPane.showMessageDialog(this, "电话号码必须为数字");
          return;
      }

      //判断输入的电话号码是否以 13 获 159 开头
      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;
            }
      ///////////////////////////////////////////////////////////////
          ArrayList arraylist = sp.amend(id,name,time,sex,age,add,phone,stat,duty);
          if(arraylist == null){
              JOptionPane.showMessageDialog(this,"修改失败");
          }else{
              JOptionPane.showMessageDialog(this,"修改成功");
              this.jbInit1();
      }
    }
   }

⌨️ 快捷键说明

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