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

📄 smainmenu.java~626~

📁 管理系统
💻 JAVA~626~
📖 第 1 页 / 共 5 页
字号:
                    jLabel11.setForeground(Color.yellow);
                    return;
                }
                char[] ch = tf4.toCharArray(); //转换客户类型以做判断
                for (int i = 0; i < ch.length; i++) {
                    if (Character.isDigit(ch[i])) {
                        jLabel5.setForeground(Color.yellow);
                        jLabel11.setText("    客户类型不能为数字!");
                        jLabel11.setForeground(Color.yellow);
                        return;
                    }
                }
            }
            sql = "insert into cclass values('" + tf1 + "','" + tf4 +
                          "','" + tf9 + "')";
            sql2 = "select * from cclass";
            if(!isLetter(tf9,sql,sql2,v_cclass)){
                return;
            }
            break;
        case 5:
            sql = "select id from state where id = '" + tf1 + "'";
            if(!isIdTrue(tf1,sql)){
                return;
            }
            if (tf5.length() == 0) { //判断状态是否为空
                jLabel6.setForeground(Color.yellow);
                jLabel11.setText("  状态未填写,请填写状态!");
                jLabel11.setForeground(Color.yellow);
                return;
            }
            if(tf5.length() > 20){
                jLabel6.setForeground(Color.yellow);
                jLabel11.setText("  状态长度不得超过20位!");
                jLabel11.setForeground(Color.yellow);
                return;
            }else {
                sql = "select states from state where states = '" + tf5 +
                              "'";
                if (!SDBManager.getOne(sql).isEmpty()) {
                    jLabel6.setForeground(Color.yellow);
                    jLabel11.setText("     状态已存在!");
                    jLabel11.setForeground(Color.yellow);
                    return;
                }
                char[] ch = tf5.toCharArray(); //转换状态以做判断
                for (int i = 0; i < ch.length; i++) {
                    if (Character.isDigit(ch[i])) {
                        jLabel6.setForeground(Color.yellow);
                        jLabel11.setText("    状态不能为数字!");
                        jLabel11.setForeground(Color.yellow);
                        return;
                    }
                }
            }
            sql = "insert into state values('" + tf1 + "','" + tf5 +
                          "','" + tf9 + "')";
            sql2 = "select * from state";
            if(!isLetter(tf9,sql,sql2,v_state)){
                return;
            }
            break;
        case 6:
            sql = "select id from step where id = '" + tf1 + "'";
            if(!isIdTrue(tf1,sql)){
                return;
            }
            if (tf6.length() == 0) { //判断职务类型文本框是否为空
                jLabel7.setForeground(Color.yellow);
                jLabel11.setText("  职务未填写,请填写职务!");
                jLabel11.setForeground(Color.yellow);
                return;
            }
            if(tf6.length() > 20){
                jLabel7.setForeground(Color.yellow);
                jLabel11.setText("  职务长度不得超过20位!");
                jLabel11.setForeground(Color.yellow);
                return;
            }else {
                sql = "select steps from step where steps = '" + tf6 +
                              "'";
                if (!SDBManager.getOne(sql).isEmpty()) {
                    jLabel7.setForeground(Color.yellow);
                    jLabel11.setText("     职务已存在!");
                    jLabel11.setForeground(Color.yellow);
                    return;
                }
                char[] ch = tf6.toCharArray(); //转换职务类型以做判断
                for (int i = 0; i < ch.length; i++) {
                    if (Character.isDigit(ch[i])) {
                        jLabel7.setForeground(Color.yellow);
                        jLabel11.setText("    职务不能为数字!");
                        jLabel11.setForeground(Color.yellow);
                        return;
                    }
                }
            }
            sql = "insert into step values('" + tf1 + "','" + tf6 +
                          "','" + tf9 + "')";
            sql2 = "select * from step";
            if(!isLetter(tf9,sql,sql2,v_step)){
                return;
            }
            break;
        }
    }

    public void tableClick(MouseEvent e) { //自动获取JTable表单值
        jTable1.setSelectionBackground(Color.GREEN);
        int row = jTable1.getSelectedRow();
        int col = jTable1.getSelectedColumn();
        if (row > -1 && choose == 1) {
            jTextField4.setText(jTable1.getValueAt(row, 0).toString());
            jTextField5.setText(jTable1.getValueAt(row, 1).toString());
            jTextField12.setText(jTable1.getValueAt(row, 2).toString());
        }
        if (row > -1 && choose == 2) {
            jTextField4.setText(jTable1.getValueAt(row, 0).toString());
            jTextField6.setText(jTable1.getValueAt(row, 1).toString());
            jTextField12.setText(jTable1.getValueAt(row, 2).toString());
        }
        if (row > -1 && choose == 3) {
            jTextField4.setText(jTable1.getValueAt(row, 0).toString());
            jTextField11.setText(jTable1.getValueAt(row, 1).toString());
            jTextField10.setText(jTable1.getValueAt(row, 2).toString());
        }
        if (row > -1 && choose == 4) {
            jTextField4.setText(jTable1.getValueAt(row, 0).toString());
            jTextField7.setText(jTable1.getValueAt(row, 1).toString());
            jTextField12.setText(jTable1.getValueAt(row, 2).toString());
        }
        if (row > -1 && choose == 5) {
            jTextField4.setText(jTable1.getValueAt(row, 0).toString());
            jTextField8.setText(jTable1.getValueAt(row, 1).toString());
            jTextField12.setText(jTable1.getValueAt(row, 2).toString());
        }
        if (row > -1 && choose == 6) {
            jTextField4.setText(jTable1.getValueAt(row, 0).toString());
            jTextField9.setText(jTable1.getValueAt(row, 1).toString());
            jTextField12.setText(jTable1.getValueAt(row, 2).toString());
        }
    }

    public void deleteLog(String sq1, String sql2, String sql3) { //删除事务
        if (SDBManager.getOne(sq1).isEmpty()) {
            jLabel2.setForeground(Color.yellow);
            jLabel11.setText("    没有可删除的记录!");
            jLabel11.setForeground(Color.yellow);
            status();
            return;
        } else {
            String tf1 = jTextField10.getText();
            if (choose == 3) {
                String sql4 = "select bigs from big where bigs = '" + tf1 + "'";
                if (SDBManager.getOne(sql4).isEmpty()) {
                    jLabel8.setForeground(Color.yellow);
                    jLabel11.setText("   没有可删除的大类记录!");
                    jLabel11.setForeground(Color.yellow);
                    status();
                    return;
                }
            }
            int option = JOptionPane.showConfirmDialog(this, "是否确定要删除?", "删除?",
                    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null);
            if (option == JOptionPane.NO_OPTION) {
                return;
            }
            SDBManager.dbUpdate("delete from big where bigs = '" + tf1 + "'"); //先删除大类
            if (SDBManager.dbUpdate(sql2)) {
                clearFont();
                JOptionPane.showMessageDialog(this, "恭喜!删除成功!");
                jTable1.setModel(new DefaultTableModel(SDBManager.getAll(sql3),
                        v_step));
                clear();
                status();
            } else {
                JOptionPane.showMessageDialog(this,
                                              "不好意思!删除失败!请检查:" + sql2 + "");
            }
        }
    }

/************************删除删除删除删除删除删除删除删除删除删除删除删除删除删除删除删除*******************/
    public void jButton15_actionPerformed(ActionEvent e) { //删除按钮事件
        jTextField5.setEditable(false);
        jTextField6.setEditable(false);
        jTextField7.setEditable(false);
        jTextField8.setEditable(false);
        jTextField9.setEditable(false);
        jTextField10.setEditable(false);
        jTextField11.setEditable(false);
        jTextField12.setEditable(false);
        String tf1 = jTextField4.getText();
        String sql = null;
        String sql2 = null;
        String sql3 = null;
        switch (choose) {
        case 1:
            sql = "select id from style where id = '" + tf1 + "'";
            sql2 = "delete from style where id = '" + tf1 + "'";
            sql3 = "select * from style";
            deleteLog(sql, sql2, sql3); //调用删除事务
            break;
        case 2:
            sql = "select id from unit where id = '" + tf1 + "'";
            sql2 = "delete from unit where id = '" + tf1 + "'";
            sql3 = "select * from unit";
            deleteLog(sql, sql2, sql3);
            break;
        case 3:
            sql = "select id from small where id = '" + tf1 + "'";
            sql2 = "delete from small where id = '" + tf1 + "'";
            sql3 = "select * from small";
            deleteLog(sql, sql2, sql3);
            break;
        case 4:
            sql = "select id from cclass where id = '" + tf1 + "'";
            sql2 = "delete from cclass where id = '" + tf1 + "'";
            sql3 = "select * from cclass";
            deleteLog(sql, sql2, sql3);
            break;
        case 5:
            sql = "select id from state where id = '" + tf1 + "'";
            sql2 = "delete from state where id = '" + tf1 + "'";
            sql3 = "select * from state";
            deleteLog(sql, sql2, sql3);
            break;
        case 6:
            sql = "select id from step where id = '" + tf1 + "'";
            sql2 = "delete from step where id = '" + tf1 + "'";
            sql3 = "select * from step";
            deleteLog(sql, sql2, sql3);
            break;
        }
    }
    public boolean isModifiable(String str,String sql3,int col){//修改按纽事务
        if(col == 0){  //点中第1列
            if (!SDBManager.getOne(sql3).isEmpty()) {
                JOptionPane.showMessageDialog(this, "输入的编号,已存在,请重新输入!","编号错误",0);
                return false;
            }
            return true;
        }
        if(col == 1){  //点中第2列
            if (!SDBManager.getOne(sql3).isEmpty()) {
                JOptionPane.showMessageDialog(this, "输入的类型,已存在,请重新输入!","类型错误",0);
                return false;
            }
            if(choose >= 4 && choose <= 6){
                char[] ch = str.toCharArray();
                for (int i = 0; i < ch.length; i++) {
                    if (Character.isDigit(ch[i])) {
                        JOptionPane.showMessageDialog(this, "输入的类型不能为数字,请重新输入!","类型错误",0);
                        return false;
                    }
                }
                return true;
            }
        }
        if(col == 2){  //点中第3列
            if(choose == 3){ //类别按钮
                if(SDBManager.getOne("select bigs from big where bigs = '"+str+"'").isEmpty()){
                    JOptionPane.showMessageDialog(this, "输入的大类,不存在,请重新输入!","类型错误",0);
                    return false;
                }
            }
            char[] ch = str.toCharArray();
            for (int i = 0; i < ch.length; i++) {
                if (!Character.isLetter(ch[i])) {
                    JOptionPane.showMessageDialog(this,"输入的拼音码只能为字母,请重新输入!","拼音码错误",0);
                    return false;
                }
            }
            return true; //以防万一
        }
        return true;
    }
/*********修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改修改*******/
    public void jButton16_act

⌨️ 快捷键说明

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