?? user_maintain.java
字號(hào):
package imis_manager;
import java.io.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Hashtable;
import database.DBPoolManager;
public class user_maintain {
String organID;
String userID;
String userCode;
String userName;
String userPwd;
String remark;
String action;
byte temp[];
public void setOrganID(String value){
organID = ISOtoGB(value);
}
public void setUserID(String value){
userID = ISOtoGB(value);
}
public void setUserCode(String value){
userCode = ISOtoGB(value);
}
public void setUserName(String value){
userName = ISOtoGB(value);
}
public void setUserPwd(String value){
userPwd = ISOtoGB(value);
}
public void setRemark(String value){
remark = ISOtoGB(value);
}
public void setAction(String value){
action = ISOtoGB(value);
}
public String ISOtoGB(String in){
String out = "";
if (in == null){
return "";
}
else{
try {
out = new String(in.getBytes("iso-8859-1"),"gb2312");
return out;
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return out;
}
public String GBtoISO(String in){
String out = "";
if (in == null){
return "";
}
else{
try {
out = new String(in.getBytes("gb2312"),"iso-8859-1");
return out;
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return out;
}
public String processthis(){
String result= new String("執(zhí)行成功!");
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = null;
Statement stmt = dbpool.conn.createStatement();
ResultSet rest = null;
if (action.equals("changepwd")) {
sql="update staff set UserPwd='"+userPwd
+"', ModifyDate=sysdate "
+" where UserId="+userID;
stmt.executeUpdate(sql);
}
else if (action.equals("mod")) {
sql="update staff set UserCode='"+userCode
+"', UserName='"+userName
+"', UserPwd='"+userPwd +"', OrganID="+organID
+", ModifyDate=sysdate, Remark='"+remark
+"' where UserId="+userID;
stmt.executeUpdate(sql);
}
else if (action.equals("add")){
sql="select UserCode from staff where UserCode='"+userCode+"'";
rest = stmt.executeQuery(sql);
if (rest.next()) {
result = "該用戶工號(hào)已存在,不能增加!";
}
else{
sql="insert into staff(UserId, OrganID, UserCode, UserName, UserPwd, ModifyDate, Remark,USERFLAG)values(USERID.NextVal,'"+organID
+"','"+userCode
+"','"+userName
+"','"+userPwd
+"',sysdate,'"+remark
+"','1')";
stmt.close();
stmt = dbpool.conn.createStatement();
stmt.executeUpdate(sql);
}
rest.close();
}
else if (action.equals("del")){ //sql="delete from staff where UserId="+userID; sql="update staff set USERFLAG='0' where UserId="+userID; stmt.executeUpdate(sql);
}
stmt.close();
} catch (SQLException ex) {
result = "執(zhí)行出錯(cuò)!";
System.err.println("Get organ_maintain SQLException: " + ex.toString());
} finally {
dbpool.freeConnection();
}
return result;
} public String processthis(String UserId, String RoleID){
String result= new String("執(zhí)行成功!");
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = null;
Statement stmt = dbpool.conn.createStatement();
if (action.equals("add")){
sql="insert into staff_role(UserId,RoleID)values("+UserId
+","+RoleID+")";
stmt.executeUpdate(sql);
}
else if (action.equals("del")){ sql="delete from staff_role where UserId="+UserId +" and RoleID="+RoleID; stmt.executeUpdate(sql);
}
stmt.close();
} catch (SQLException ex) {
result = "執(zhí)行出錯(cuò)!";
System.err.println("Get organ_maintain SQLException: " + ex.toString());
} finally {
dbpool.freeConnection();
}
return result;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -