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

📄 clubuserdel.java

📁 特色说明: 1.沿袭今晚在线论坛独有的双风格分桢形式 2.社区最多可进行3级分类
💻 JAVA
字号:
/* * Created on 2005年2月2日, 下午9:24 * 今晚制造 www.GamVan.com */package com.gamvan.club.user;import com.gamvan.conn.*;import com.gamvan.tools.*;import com.gamvan.club.ClubUsers;import com.gamvan.club.topic.ClubTopicManage;import java.sql.*;public class ClubUserDel {    String act = "0", message=""; //判断删除类型 1逻辑删除 2物理删除    int noListTopic=0, delTopic=0;    ConnClub bridge = new ConnClub();    ClubUsers cu = new ClubUsers();    ClubTopicManage ctm = new ClubTopicManage();    public void userDel(String userids[]) throws Exception{        boolean bea = false;        String uid = new String();        uid = "0";        int userid = 0;        int topicid = 0;        String userName = new String();        for (int i = 0; i < userids.length; i++) {            uid += "," + userids[i]; //将取得的用户ID数组转换成,分割的字符串数组            // 取得每个ID的用户名开始            userid = Integer.parseInt(userids[i]);            cu.userSelect(userid);            userName = cu.getUserName();            userTopicID(userName);        }         //判断动作        if(act.equals("1")){            bea = delUsers1(uid, 1);//逻辑删除        }else if(act.equals("2")){            bea = delUsers2(uid);//物理删除用户        }else{            message = "系统遭遇一个美丽的错误,您没有选择要操作的类型!";        }        //如果删除动作执行成功则开始对该用户主题进行屏毕或删除        if(bea){             message="所选用户已被成功删除!";        }else{            message = "系统遭遇一个美丽的错误,您操作被意外中断!";        }    }    // 循环取出用户所属文章ID    public void userTopicID(String username) throws Exception{        String sqlCommand = "";        Connection con = bridge.getConnection();        int topicid=0;        try{            ResultSet rs;            sqlCommand = "Select * From GVclubTopic where userName = ? order by topicID";            PreparedStatement pps = con.prepareStatement(sqlCommand);            pps.setString(1,username);            rs = pps.executeQuery();            while(rs.next()){                topicid = rs.getInt(1);                if(delTopic==1){                    ctm.topicInfoUpdate(topicid,4,0); //删除发言                }else{                    if(noListTopic==1){                        ctm.topicInfoUpdate(topicid,5,0); //屏闭发言                    }                }            }            rs.close();            pps.close();                   }catch(Exception e){            con.close();        }finally{            con.close();        }//    }    //逻辑删除用户    public boolean delUsers1(String userids, int isor) throws Exception{        boolean bea = false;        String sqlCommand = "";        Connection con = bridge.getConnection();        try{            sqlCommand = "Update GVclubUsers set userIsDel=? where userID in ("+ userids +")";             PreparedStatement pps = con.prepareStatement(sqlCommand);             pps.setInt(1,isor);             pps.executeUpdate();             pps.close();             bea = true;        }catch(Exception e){            con.close();        }finally{            try{                con.close();            }catch(Exception e){                bea = false;                message = "数据库关闭出错!";            }        }        return bea;    }    //物理删除用户    public boolean delUsers2(String userids) throws Exception{        boolean bea = false;        String sqlCommand = "";        Connection con = bridge.getConnection();        try{            sqlCommand = "Delete From GVclubUsers where userID in ("+ userids +")";             PreparedStatement pps = con.prepareStatement(sqlCommand);             pps.executeUpdate();             pps.close();             bea = true;        }catch(Exception e){            con.close();        }finally{            try{                con.close();            }catch(Exception e){                bea = false;                message = "数据库关闭出错!";            }        }        return bea;    }    public String getMessage(){        return this.message;    }    public void setAct(String act){        this.act = act;    }    public void setNoListTopic(String noListTopic){        if(noListTopic==null){            this.noListTopic = 0;        }else{            this.noListTopic = Integer.parseInt(noListTopic);        }    }    public void setDelTopic(String delTopic){        if(delTopic==null){            this.delTopic = 0;        }else{            this.delTopic = Integer.parseInt(delTopic);        }    }}

⌨️ 快捷键说明

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