1 32 33 package com.knowgate.crm; 34 35 import java.sql.SQLException ; 36 import java.sql.Statement ; 37 import java.sql.PreparedStatement ; 38 import java.sql.CallableStatement ; 39 import java.sql.ResultSet ; 40 41 import com.knowgate.debug.DebugFile; 42 import com.knowgate.jdc.JDCConnection; 43 import com.knowgate.dataobjs.DB; 44 import com.knowgate.dataobjs.DBPersist; 45 import com.knowgate.acl.ACLUser; 46 47 53 public class SalesMan extends DBPersist { 54 55 private ACLUser oUser; 56 57 public SalesMan() { 58 super(DB.k_sales_men, "SalesMan"); 59 oUser=null; 60 } 61 62 66 public ACLUser getUser() { 67 return oUser; 68 } 69 70 77 public boolean load(JDCConnection oConn, Object [] PKVals) throws SQLException { 78 boolean bRetVal = super.load(oConn, PKVals); 79 if (bRetVal) 80 oUser = new ACLUser(oConn, getString(DB.gu_sales_man)); 81 return bRetVal; 82 } 83 84 91 public boolean store (JDCConnection oConn) throws SQLException { 92 boolean bRetVal = super.store(oConn); 93 if (oUser==null) 94 oUser = new ACLUser(oConn, getString(DB.gu_sales_man)); 95 return bRetVal; 96 } 97 98 102 public boolean delete(JDCConnection oConn) throws SQLException { 103 return SalesMan.delete(oConn, getString(DB.gu_sales_man)); 104 } 105 106 114 public static boolean delete(JDCConnection oConn, String sSalesManGUID) throws SQLException { 115 CallableStatement oCall; 116 Statement oStmt; 117 if (DebugFile.trace) { 118 DebugFile.writeln("Begin SalesMan.delete([Connection], " + sSalesManGUID + ")"); 119 DebugFile.incIdent(); 120 DebugFile.writeln("Connection.prepareCall({ call k_sp_del_sales_man('" + sSalesManGUID + "')}"); 121 } 122 switch (oConn.getDataBaseProduct()) { 123 case JDCConnection.DBMS_POSTGRESQL: 124 oStmt = oConn.createStatement(); 125 oStmt.executeQuery("SELECT k_sp_del_sales_man('" + sSalesManGUID + "')").close(); 126 oStmt.close(); 127 oStmt=null; 128 break; 129 default: 130 oCall = oConn.prepareCall("{ call k_sp_del_sales_man('" + sSalesManGUID + "')}"); 131 oCall.execute(); 132 oCall.close(); 133 oCall = null; 134 } 135 if (DebugFile.trace) { 136 DebugFile.decIdent(); 137 DebugFile.writeln("End SalesMan.delete()"); 138 } 139 140 return true; 141 } 143 151 public static boolean exists(JDCConnection oConn, String sSalesManGUID) throws SQLException { 152 PreparedStatement oStmt = oConn.prepareStatement("SELECT NULL FROM "+DB.k_sales_men+" WHERE "+DB.gu_sales_man+"=?", 153 ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 154 oStmt.setString(1, sSalesManGUID); 155 ResultSet oRSet = oStmt.executeQuery(); 156 boolean bExists = oRSet.next(); 157 oRSet.close(); 158 oStmt.close(); 159 return bExists; 160 } 161 162 165 public static final short ClassId = 97; 166 } 167 | Popular Tags |