1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 15 16 public class s_editUserToSection extends StoredProcedure implements ProcedureInterface { 17 18 String in_userID; 20 21 String in_mappingCode; 22 23 String ifexists; 24 25 String in_director; 26 27 String ifnoneed; 28 29 public s_editUserToSection() { 30 } 31 32 public void init(HashMap initData, Connection con) { 33 super.init(initData, con); 35 in_userID = utils.getString(data, "USERID", ""); 37 in_mappingCode = utils.getString(data, "MAPPINGCODE", ""); 38 in_director = utils.getString(data, "DIRECTOR", ""); 39 action = utils.getString(data, "ACTION", ""); 40 } 41 42 public void checkAction() throws SQLException { 43 String qry = "SELECT count(0) as nb FROM tblpermusersection WHERE userID=" + in_userID + " AND mappingCode=" + in_mappingCode; 44 ifexists = execStatementToValue(qry); 45 close(); 46 } 47 48 public void checkParams() throws SQLException { 49 } 50 51 public void executeAction() throws SQLException { 52 if (ifexists.equals("0")) { 53 if (action.equals("1")) { 54 StringBuffer v_sb = new StringBuffer (); 55 v_sb.append("INSERT into tblpermusersection ").append(" values ('" + in_userID + "', '" + in_mappingCode + "', '" + in_director + "')"); 56 57 execStatement(v_sb.toString()); 58 } 59 if (action.equals("2")) { 60 StringBuffer v_sb = new StringBuffer (); 61 v_sb.append("INSERT into tblpermusersection ").append(" values ('" + in_userID + "', '" + in_mappingCode + "', '" + in_director + "')"); 62 63 execStatement(v_sb.toString()); 64 } 65 } else if (ifexists.equals("1")) { 66 if (action.equals("0")) { 67 StringBuffer v_sb = new StringBuffer (); 68 v_sb.append("DELETE FROM tblpermusersection ").append(" WHERE userID = " + in_userID + " ").append(" AND mappingCode = " + in_mappingCode); 69 70 execStatement(v_sb.toString()); 71 } 72 if ((action.equals("2")) || (action.equals("1"))) { 73 StringBuffer v_sb = new StringBuffer (); 74 v_sb.append("UPDATE tblpermusersection ").append(" SET manager = " + in_director + " ").append(" WHERE userID = " + in_userID + " ").append( 75 " AND mappingCode = " + in_mappingCode); 76 77 execStatement(v_sb.toString()); 78 } 79 80 } 81 execStatementToRS(queryResultOk); 82 } 83 } | Popular Tags |