@Override public int delete(AbstractBean ab) { CompanyBean companyBean = (CompanyBean) ab; String query = "delete from tbl_crm_company where companyId = ?;"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setInt(1, companyBean.getCompanyId()); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in delete operation in CompanyHelper", e); } operationStatus = dbu.delete(preparedStatement); return operationStatus; }
@Override public int add(AbstractBean ab) { CompanyBean companyBean = (CompanyBean) ab; String query = "insert into tbl_crm_company values (?,?,?,?,?,?,?,?,?,?,?);"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setInt(1, companyBean.getCompanyId()); preparedStatement.setString(2, companyBean.getCompanyName()); preparedStatement.setString(3, companyBean.getCompanyAddress()); preparedStatement.setString(4, companyBean.getCompanyPhone()); preparedStatement.setString(5, companyBean.getCompanyFax()); preparedStatement.setString(6, companyBean.getCompanyEmail()); preparedStatement.setBoolean(7, companyBean.isStatus()); preparedStatement.setString(8, companyBean.getCreateBy()); preparedStatement.setTimestamp(9, new Timestamp(System.currentTimeMillis())); preparedStatement.setString(10, companyBean.getWriteBy()); preparedStatement.setTimestamp(11, new Timestamp(System.currentTimeMillis())); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in insert operation in CompanyHelper", e); } operationStatus = dbu.insert(preparedStatement); return operationStatus; }
@Override public int update(AbstractBean ab) { CompanyBean companyBean = (CompanyBean) ab; String query = "update tbl_crm_company set companyName = ?, companyAddress = ?, companyPhone = ?, companyFax = ?, companyEmail = ?, status = ?, writeBy = ?, writeDate = ? where companyId = ?;"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setString(1, companyBean.getCompanyName()); preparedStatement.setString(2, companyBean.getCompanyAddress()); preparedStatement.setString(3, companyBean.getCompanyPhone()); preparedStatement.setString(4, companyBean.getCompanyFax()); preparedStatement.setString(5, companyBean.getCompanyEmail()); preparedStatement.setBoolean(6, companyBean.isStatus()); preparedStatement.setString(7, companyBean.getWriteBy()); preparedStatement.setTimestamp(8, new Timestamp(System.currentTimeMillis())); preparedStatement.setInt(9, companyBean.getCompanyId()); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in update operation in CompanyHelper", e); } operationStatus = dbu.update(preparedStatement); return operationStatus; }
@Override public List<AbstractBean> getAllActiveRecords() { List<AbstractBean> retValue = new ArrayList<AbstractBean>(); String query = "select * from tbl_crm_company where status = ?;"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setBoolean(1, true); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in getting all active records in CompanyHelper", e); } ResultSet rs = dbu.select(preparedStatement); CompanyBean companyBean = null; try { while (rs.next()) { companyBean = new CompanyBean(); companyBean.setCompanyId(rs.getInt("companyId")); companyBean.setCompanyName(rs.getString("companyName")); companyBean.setCompanyAddress(rs.getString("companyAddress")); companyBean.setCompanyPhone(rs.getString("companyPhone")); companyBean.setCompanyFax(rs.getString("companyFax")); companyBean.setCompanyEmail(rs.getString("companyEmail")); companyBean.setStatus(rs.getBoolean("status")); companyBean.setCreateBy(rs.getString("createBy")); companyBean.setCreateDate(rs.getString("createDate")); companyBean.setWriteBy(rs.getString("writeBy")); companyBean.setWriteDate(rs.getString("writeDate")); retValue.add(companyBean); } } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in Company Helper Class", e); } return retValue; }
private CompanyBean getRecordFromResultSet(ResultSet rs) { CompanyBean companyBean = new CompanyBean(); try { while (rs.next()) { companyBean.setCompanyId(rs.getInt("companyId")); companyBean.setCompanyName(rs.getString("companyName")); companyBean.setCompanyAddress(rs.getString("companyAddress")); companyBean.setCompanyPhone(rs.getString("companyPhone")); companyBean.setCompanyFax(rs.getString("companyFax")); companyBean.setCompanyEmail(rs.getString("companyEmail")); companyBean.setStatus(rs.getBoolean("status")); companyBean.setCreateBy(rs.getString("createBy")); companyBean.setCreateDate(rs.getString("createDate")); companyBean.setWriteBy(rs.getString("writeBy")); companyBean.setWriteDate(rs.getString("writeDate")); } } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in Company Helper Class", e); } return companyBean; }