📄 clubuserop.java
字号:
/* * Made in GamVan * 社区用户管理员相关 */package com.gamvan.club;import com.gamvan.conn.*;import com.gamvan.tools.*;import java.sql.*;import java.util.*;import com.gamvan.club.ClubUsers;public class ClubUserop{ Gb clubgb = new Gb(); //中文编码 //格式化当前时间 java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private String now = isNow.format(new java.util.Date()); //声明所需变量 private String uoUser; private int uoGradeID, uoCID, uoID; private int uois; private String uoByUser, uoByip, uoByTime; ConnClub bridge = new ConnClub(); Connection con = bridge.getConnection();public boolean useropSelect(int uoid, String uouser) throws Exception{ boolean temp = false; String sqlCommand = new String(); Statement sta; ResultSet rs; Connection con = bridge.getConnection(); try{ sta = con.createStatement(); sqlCommand = "Select * From GVclubUserop where "; if(uoid>0){ sqlCommand += " uoID = " + uoid + ""; }else{ sqlCommand += " uoUser = '" + uouser + "'"; } PreparedStatement pps = con.prepareStatement(sqlCommand); rs = pps.executeQuery(); if(rs.next()){ uoID = rs.getInt(1); uoUser = rs.getString(2).trim(); uoGradeID = rs.getInt(3); uoCID = rs.getInt(4); uois = rs.getInt(5); uoByUser = rs.getString(6).trim(); uoByip = rs.getString(7).trim(); uoByTime = rs.getString(8).trim(); temp = true; } rs.close(); sta.close(); }catch(Exception e){ con.close(); //message= "系统发生意外错误,指令将不被执行,请重新尝试!"; }finally{ con.close(); } return temp; } public boolean useropDel(String[] uoIDs) throws Exception{ boolean temp = false; String sqlCommand = new String(); Statement sta; String uoids = new String(); try{ uoids = "0"; int i = 0; Connection con = bridge.getConnection(); sta = con.createStatement(); for (i = 0; i < uoIDs.length; i++) { uoids += "," + uoIDs[i]; } sqlCommand = "DELETE FROM GVclubUserop where uoID in ("+ uoids + ")"; sta.executeUpdate(sqlCommand); sta.close(); temp = true; }catch(Exception e){ con.close(); temp = false; }finally{ con.close(); } return temp; } public String useropEdit(String act) throws Exception{ String temp = new String(); ClubUsers cu = new ClubUsers(); String userName = uoUser; userName = clubgb.Gb(uoUser); boolean passUser = true; passUser = cu.userSelect(userName); if(passUser){ if(act.equals("add")){ temp = useropAdd(); }else{ temp = useropUpdate(); } }else{ temp = "用户“" + userName + "”尚未注册或已被删除!"; } return temp; } private String useropUpdate() throws Exception{ String sqlCommand = new String(); String temp = new String(""); try{ sqlCommand = "UPDATE GVclubUserop set uoUser=?, uoGradeID=?, uoCID=?, uoIs=?"; sqlCommand += ", uoByUser=?, uoByip=?, uoByTime=? where uoID=?"; PreparedStatement pps = con.prepareStatement(sqlCommand); pps.setString(1,clubgb.Gb(uoUser)); pps.setInt(2,uoGradeID); pps.setInt(3,uoCID); pps.setInt(4,uois); pps.setString(5, uoByUser); pps.setString(6, uoByip); pps.setString(7, now); pps.setInt(8,uoID); pps.executeUpdate(); temp = "信息更新成功!"; }catch(Exception e){ temp = "信息更新失败,请重新尝试!"; con.close(); }finally{ con.close(); } return temp; } public String useropAdd() throws Exception{ String sqlCommand = new String(); String temp = new String(); try{ sqlCommand = "Insert Into GVclubUserop(uoUser, uoGradeID, uoCID, uoIs"; sqlCommand += ", uoByUser, uoByip, uoByTime) Values(?,?,?,?,?,?,?)"; PreparedStatement pps = con.prepareStatement(sqlCommand); uoUser = clubgb.Gb(uoUser); pps.setString(1,uoUser); pps.setInt(2, uoGradeID); pps.setInt(3, uoCID); pps.setInt(4, uois); pps.setString(5, uoByUser); pps.setString(6, uoByip); pps.setString(7, now); pps.executeUpdate(); pps.close(); temp = "操作成功!"; }catch(Exception e){ temp = "遭遇意外,操作失败!请重新尝试!"; con.close(); }finally{ con.close(); } return temp; } public int getUoID(){ return this.uoID; } public void setUoID(int uoID){ this.uoID = uoID; } public void setUoUser(String uoUser){ this.uoUser = uoUser.trim(); } public String getUoUser(){ return this.uoUser.trim(); } public void setUois(String uois){ this.uois = Integer.parseInt(uois); } public int getUois(){ return this.uois; } public void setUoGradeID(String uoGradeID){ this.uoGradeID = Integer.parseInt(uoGradeID); } public int getUoGradeID(){ return this.uoGradeID; } public void setUoCID(String uoCID){ this.uoCID = Integer.parseInt(uoCID); } public int getUoCID(){ return this.uoCID; } public void setUoByUser(String uoByUser){ //uoByUser = clubgb.Gb(uoByUser); this.uoByUser = uoByUser; } public String getUoByUser(){ return this.uoByUser; } public void setUoByip(String uoByip){ this.uoByip = uoByip; } public String getUoByip(){ return this.uoByip; } public void setUoByTime(String uoByTime){ uoByTime = now; } public String getUoByTime(){ return this.uoByTime; } public void conClose() throws Exception{ con.close(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -