public void save(Connection con, JUser juser) throws Exception { PreparedStatement pstmt = null; java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis()); String sql = null; int idx = 1; if (JUtil.convertNull(this.getGroup_id()).equals("")) { sql = " insert into t_ym_book(group_id, group_name, inquire_date, group_no, contact," + " contact_phone, contact_handset, contact_fax, countries, countries_name, group_type, " + " memo, company_id, zxgw_id, zxgw_name, take_out, creater, createrName, created) " + " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "; pstmt = con.prepareStatement(sql); this.setGroup_id(JUtil.createUNID()); pstmt.setString(idx++, this.getGroup_id()); pstmt.setString(idx++, this.getGroup_name()); pstmt.setDate(idx++, this.getInquire_date()); pstmt.setString(idx++, this.getGroup_no()); pstmt.setString(idx++, this.getContact()); pstmt.setString(idx++, this.getContact_phone()); pstmt.setString(idx++, this.getContact_handset()); pstmt.setString(idx++, this.getContact_fax()); pstmt.setString(idx++, this.getCountries()); pstmt.setString(idx++, this.getCountries_name()); pstmt.setInt(idx++, this.getGroup_type()); pstmt.setString(idx++, this.getMemo()); pstmt.setString(idx++, this.getCompany_id()); pstmt.setString(idx++, this.getZxgw_id()); pstmt.setString(idx++, this.getZxgw_name()); pstmt.setString(idx++, this.getTake_out()); pstmt.setString(idx++, juser.getUserId()); pstmt.setString(idx++, juser.getUserName()); pstmt.setTimestamp(idx++, now); pstmt.executeUpdate(); pstmt.close(); } else { sql = " update t_ym_book set group_name = ?, inquire_date = ?, memo = ?, " + " group_no = ?, contact = ?, contact_phone = ?, contact_handset = ?, contact_fax = ?," + " countries = ?, countries_name = ?, zxgw_id = ?, zxgw_name = ?, take_out = ? " + " where group_id = ? "; pstmt = con.prepareStatement(sql); pstmt.setString(idx++, this.getGroup_name()); pstmt.setDate(idx++, this.getInquire_date()); pstmt.setString(idx++, this.getMemo()); pstmt.setString(idx++, this.getGroup_no()); pstmt.setString(idx++, this.getContact()); pstmt.setString(idx++, this.getContact_phone()); pstmt.setString(idx++, this.getContact_handset()); pstmt.setString(idx++, this.getContact_fax()); pstmt.setString(idx++, this.getCountries()); pstmt.setString(idx++, this.getCountries_name()); pstmt.setString(idx++, this.getZxgw_id()); pstmt.setString(idx++, this.getZxgw_name()); pstmt.setString(idx++, this.getTake_out()); pstmt.setString(idx++, this.getGroup_id()); pstmt.executeUpdate(); pstmt.close(); } }
public void save(Connection con) throws Exception { PreparedStatement pstmt = null; String sql = null; int index = 1; sql = "update t_team set team_code = ?, type_code = ? ,team_name = ?, team_desc = ?, team_manager_id = ?, team_manager_name = ? \n" + "where team_id = ? "; pstmt = con.prepareStatement(sql); ; pstmt.setString(index++, this.team_code.toUpperCase()); pstmt.setString(index++, this.type_code); pstmt.setString(index++, this.team_name); pstmt.setString(index++, this.team_desc); pstmt.setString(index++, this.team_manager_id); pstmt.setString(index++, this.team_manager_name); pstmt.setString(index++, this.team_id); int updateCount = pstmt.executeUpdate(); pstmt.close(); if (updateCount == 0) { sql = " insert into t_team(team_id, team_code, type_code, team_name, team_desc, team_manager_id, team_manager_name, creater, created ) \n " + " values( ?, ?, ?, ?, ?, ?, ?, ?, ?)"; pstmt = con.prepareStatement(sql); index = 1; this.team_id = JUtil.createUNID(); pstmt.setString(index++, this.team_id); pstmt.setString(index++, this.team_code.toUpperCase()); pstmt.setString(index++, this.type_code); pstmt.setString(index++, this.team_name); pstmt.setString(index++, this.team_desc); pstmt.setString(index++, this.team_manager_id); pstmt.setString(index++, this.team_manager_name); pstmt.setString(index++, this.creater); pstmt.setTimestamp(index++, this.created); pstmt.executeUpdate(); pstmt.close(); } }
/** * 保存修改 * * @param con * @throws Exception */ public static void saveWithOutApproval( Connection con, JUser juser, String approval_type, String approval_type_name, String con_id) throws Exception { PreparedStatement pstmt = null; ResultSet rs = null; String sql = null; int idx = 1; int approvalCount = 0; sql = " select count(*) count from t_ym_process_approval where con_id = ? and approval_type = ? "; pstmt = con.prepareStatement(sql); pstmt.setString(idx++, con_id); pstmt.setString(idx++, approval_type); rs = pstmt.executeQuery(); if (rs.next()) { approvalCount = rs.getInt("count"); } rs.close(); pstmt.close(); if (approvalCount > 0) return; idx = 1; sql = " insert into t_ym_process_approval(approval_id, con_id, approver, status, " + " approval_type, approval_type_name, creater, createrName, created) " + " values(?, ?, ?, 4, ?, ?, ?, ?, ?) "; pstmt = con.prepareStatement(sql); pstmt.setString(idx++, JUtil.createUNID()); pstmt.setString(idx++, con_id); pstmt.setString(idx++, "-1"); pstmt.setString(idx++, approval_type); pstmt.setString(idx++, approval_type_name); pstmt.setString(idx++, juser.getUserId()); pstmt.setString(idx++, juser.getUserName()); pstmt.setTimestamp(idx++, new java.sql.Timestamp(System.currentTimeMillis())); pstmt.executeUpdate(); pstmt.close(); }
/** * 保存修改 * * @param con * @throws Exception */ public void save(Connection con, JUser juser) throws Exception { PreparedStatement pstmt = null; String sql = null; int idx = 1; int updateCount = 0; if (JUtil.convertNull(this.getApproval_id()).length() > 0) { sql = " update t_ym_process_approval set approver = ?, status = 2 where approval_id = ? and status in(1, 3) "; pstmt = con.prepareStatement(sql); pstmt.setString(idx++, this.getApprover()); pstmt.setString(idx++, this.getApproval_id()); updateCount = pstmt.executeUpdate(); pstmt.close(); if (updateCount != 1) throw new Exception( "更新的记录不只一条approval_id=" + this.getApproval_id() + " con_id=" + this.getCon_id()); } else { sql = " insert into t_ym_process_approval(approval_id, con_id, approver, status, " + " approval_type, approval_type_name, creater, createrName, created) " + " values(?, ?, ?,2, ?, ?, ?, ?, ?) "; pstmt = con.prepareStatement(sql); this.setApproval_id(JUtil.createUNID()); pstmt.setString(idx++, this.getApproval_id()); pstmt.setString(idx++, this.getCon_id()); pstmt.setString(idx++, this.getApprover()); pstmt.setString(idx++, this.getApproval_type()); pstmt.setString(idx++, this.getApproval_type_name()); pstmt.setString(idx++, juser.getUserId()); pstmt.setString(idx++, juser.getUserName()); pstmt.setTimestamp(idx++, new java.sql.Timestamp(System.currentTimeMillis())); pstmt.executeUpdate(); pstmt.close(); } }