// ����û�? public boolean addUnitUser(String strUserId, String[] arryUnitId) { String strSql = ""; try { // ����Ϣд����ݿ�? strSql = "INSERT INTO " + strTableName2 + " (strUserId, strUnitId, intSort, strCreator, dtCreatTime) VALUES (?,?,?,?,str_to_date(?,'%Y-%m-%d %T'))"; if (arryUnitId != null && arryUnitId.length > 0) for (int i = 0; i < arryUnitId.length; i++) { db.prepareStatement(strSql); db.setString(1, strUserId); db.setString(2, arryUnitId[i]); db.setInt(3, creatSort(arryUnitId[i])); // intSort db.setString(4, globa.loginName); db.setString(5, Format.getDateTime()); db.executeUpdate(); } return true; } catch (Exception e) { System.out.println("增加单位用户映射时出错!!"); e.printStackTrace(); return false; } }
// �� public boolean update(String tStrUserId) { try { String strSql = "UPDATE " + strTableName + " SET strName = ?, intError = ?, intState = ?, dBirthday = ?, strSex = ?, strIntro = ?, intType = ?, " + "strUnitId = ?, strUnitCode = ?,strNation = ?, strMobile = ?, strEmail = ?, strMsnQQ = ?, strOPhone = ?, strHPhone = ?, strDuty = ?, strStation = ?, " + " strCaNO = ?, strDepart = ?, strLinkAdd = ?, strCreator = ?, dtCreatTime = str_to_date(?,'%Y-%m-%d %T') ,strCssType=? WHERE strUserId=? "; db.prepareStatement(strSql); db.setString(1, strName); db.setInt(2, 0); db.setInt(3, intState); db.setString(4, dBirthday); db.setString(5, strSex); db.setString(6, strIntro); db.setInt(7, intType); db.setString(8, strUnitId); db.setString(9, ""); // "strUnitCode db.setString(10, strNation); db.setString(11, strMobile); db.setString(12, strEmail); db.setString(13, strMsnQQ); db.setString(14, strOPhone); db.setString(15, strHPhone); db.setString(16, strDuty); db.setString(17, strStation); db.setString(18, strCaNO); db.setString(19, strDepart); db.setString(20, strLinkAdd); db.setString(21, globa.loginName); db.setString(22, Format.getDateTime()); db.setString(23, strCssType); db.setString(24, tStrUserId); db.executeUpdate(); Globa.logger0( "修改用户信息", globa.loginName, globa.loginIp, strSql, "用户管理", globa.userSession.getStrDepart()); System.out.println("true"); return true; } catch (Exception e) { System.out.println("修改用户信息时出错:" + e); System.out.println("false"); return false; } }
// 修改领导密码用户密码 public boolean setPassword(String pwd) { try { String strSql = "update " + strTableName + " set strDepart='" + Format.enPass(pwd) + "' where strUserId='" + globa.loginName + "'"; db.executeUpdate(strSql); UserSession userSession = globa.userSession; userSession.setStrPWD(pwd); globa.session.setAttribute(com.ejoysoft.common.Constants.USER_KEY, userSession); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
// 增加用户 public boolean add(String strUserId) { String strSql = ""; strId = UID.getID(); try { // 把用户信息写入数据库 strSql = "INSERT INTO " + strTableName + " (strId, strUserId, strPWD, strName, intError, intState, dBirthday, strSex, strIntro,intType, strUnitId, strUnitCode," + " strNation, strMobile, strEmail, strMsnQQ,strOPhone, strHPhone, strDuty, strStation, intLoginNum, dLatestLoginTime,fOnlineTime, strCaNO, " + "strDepart, strCssType, strLinkAdd, strCreator, dtCreatTime,intUserType) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,str_to_date(?,'%Y-%m-%d %T'),?,?,?,?,?,?,str_to_date(?,'%Y-%m-%d %T'),?)"; db.prepareStatement(strSql); db.setString(1, strId); db.setString(2, strUserId.replaceAll(" ", "")); db.setString(3, MD5.getMD5ofString(Constants.resetPass)); // strPWD db.setString(4, strName); db.setInt(5, 0); db.setInt(6, 0); db.setString(7, dBirthday); db.setString(8, strSex); db.setString(9, strIntro); db.setInt(10, intType); db.setString(11, strUnitId); db.setString( 12, ""); // strUnitCode new Unit(globa, false).retFieldValue("strUnitCode", // strUnitId) db.setString(13, strNation); db.setString(14, strMobile); db.setString(15, strEmail); db.setString(16, strMsnQQ); db.setString(17, strOPhone); db.setString(18, strHPhone); db.setString(19, strDuty); db.setString(20, strStation); db.setInt(21, intLoginNum); db.setString(22, Format.getDateTime()); db.setDouble(23, 0); db.setString(24, strCaNO); db.setString(25, strDepart); db.setString(26, strCssType); db.setString(27, strLinkAdd); db.setString(28, globa.loginName); db.setString(29, Format.getDateTime()); db.setInt(30, intUserType); if (db.executeUpdate() > 0) { Globa.logger0( "增加用户信息", globa.loginName, globa.loginIp, strSql, "用户管理", globa.userSession.getStrDepart()); return true; } else return false; } catch (Exception e) { System.out.println("增加用户信息时出错!!"); e.printStackTrace(); return false; } }