1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 16 public class s_editUser extends StoredProcedure implements ProcedureInterface { 17 18 String in_userID; 20 21 String in_userName; 22 23 String in_userPassword; 24 25 String in_lastName; 26 27 String in_firstName; 28 29 String in_homepub; 30 31 String in_email; 32 33 String in_workPhone; 34 35 String in_cellPhone; 36 37 String include; 38 39 String in_pager; 40 41 String in_notes; 42 43 String duplicateUser; 44 45 String in_newuserid; 46 47 public s_editUser() { 48 49 } 50 51 public void init(HashMap initData, Connection con) { 52 super.init(initData, con); 54 in_userID = utils.getString(data, "USERID", ""); 56 in_userName = utils.getString(data, "USERNAME", ""); 57 in_userPassword = utils.getString(data, "USERPASSWORD", ""); 58 in_lastName = utils.getString(data, "LASTNAME", ""); 59 in_firstName = utils.getString(data, "FIRSTNAME", ""); 60 in_homepub = utils.getString(data, "HOMEPUB", ""); 61 in_email = utils.getString(data, "EMAIL", ""); 62 in_workPhone = utils.getString(data, "WORKPHONE", ""); 63 in_cellPhone = utils.getString(data, "CELLPHONE", ""); 64 in_pager = utils.getString(data, "PAGER", ""); 65 in_notes = utils.getString(data, "NOTES", ""); 66 } 67 68 public void checkParams() throws SQLException { 69 } 70 71 public void checkAction() throws SQLException { 72 if (in_userID.equals("0")) { 73 action = "insert"; 74 } else { 75 action = "update"; 76 } 77 } 78 79 public void executeAction() throws SQLException { 80 String v_select = ""; 81 v_select = "select " + in_userID + " as USERID"; 82 83 if (action.equals("update")) { 84 StringBuffer v_sb = new StringBuffer (); 85 v_sb.append("UPDATE tblpermusers ").append(" SET username = '" + in_userName + "',"); 86 if (!(in_userPassword.equals(""))) 87 v_sb.append(" userpassword = MD5('" + in_userName + ":" + in_userPassword + "'),"); 88 v_sb.append(" lastname = '" + in_lastName + "',").append(" firstname = '" + in_firstName + "',").append(" homepub = " + in_homepub + ",").append( 89 " email = '" + in_email + "',").append(" workphone = '" + in_workPhone + "',").append(" cellphone = '" + in_cellPhone + "',").append( 90 " pager = '" + in_pager + "',").append(" notes = '" + in_notes + "'").append(" WHERE userid = " + in_userID); 91 execStatement(v_sb.toString()); 92 93 } else if (action.equals("insert")) { 94 StringBuffer v_sbSelect = new StringBuffer (); 95 v_sbSelect.append("SELECT count(*) ").append(" FROM tblpermusers ").append(" WHERE userName = '" + in_userName + "'"); 96 97 duplicateUser = execStatementToValue(v_sbSelect.toString()); 98 99 if (Integer.parseInt(duplicateUser) > 0) { 100 duplicateUser = in_userName; 101 } else { 102 StringBuffer v_sbInsert = new StringBuffer (); 103 v_sbInsert.append("INSERT INTO tblpermusers ").append( 104 "(username, userpassword, lastname, firstname, homepub, email, workphone, cellphone, pager, notes)").append( 105 " VALUES ('" + in_userName + "', MD5('" + in_userName + ":" + in_userPassword + "'), '" + in_lastName + "', '" + in_firstName + "', " 106 + in_homepub + ", '" + in_email + "', '" + in_workPhone + "', '" + in_cellPhone + "', '" + in_pager + "', '" + in_notes + "')"); 107 108 synchronized (this) { 110 execStatement(v_sbInsert.toString()); 111 112 String new_userID = getMax("tblpermusers", "userid"); 114 v_select = "select " + new_userID + " as USERID"; 115 } 116 } 117 } 118 execStatementToRS(v_select); 119 } 120 } 121 | Popular Tags |