Exemplo n.º 1
0
  public static RptCBpartnerData[] select(
      ConnectionProvider connectionProvider,
      String adLanguage,
      String cBpartnerId,
      int firstRegister,
      int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "        SELECT BP.C_BPARTNER_ID, BP.VALUE, AD_MESSAGE_GET2(BP.ISACTIVE, ?) AS ISACTIVE, TO_DATE(BP.CREATED) AS CREATED, TO_DATE(BP.UPDATED) AS UPDATED, "
            + "        BP.NAME, BP.NAME2, G.NAME AS GROUPNAME, BP.TAXID, '' AS ACCOUNTNO, AD_MESSAGE_GET2(BP.ISEMPLOYEE, ?) AS ISEMPLOYEE, AD_MESSAGE_GET2(BP.ISSALESREP, ?) AS ISSALESREP, "
            + "        ISCUSTOMER, ISVENDOR, '' AS SEQNO, '' AS CASCADE, '' AS DISCOUNT, '' AS QTY, '' AS CLASS_TREE"
            + "        FROM C_BPARTNER BP, C_BP_GROUP G"
            + "        WHERE BP.C_BP_GROUP_ID = G.C_BP_GROUP_ID";
    strSql =
        strSql
            + ((cBpartnerId == null || cBpartnerId.equals(""))
                ? ""
                : "           AND BP.C_BPARTNER_ID IN          " + cBpartnerId);

    ResultSet result;
    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
    PreparedStatement st = null;

    int iParameter = 0;
    try {
      st = connectionProvider.getPreparedStatement(strSql);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, adLanguage);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, adLanguage);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, adLanguage);
      if (cBpartnerId != null && !(cBpartnerId.equals(""))) {}

      result = st.executeQuery();
      long countRecord = 0;
      long countRecordSkip = 1;
      boolean continueResult = true;
      while (countRecordSkip < firstRegister && continueResult) {
        continueResult = result.next();
        countRecordSkip++;
      }
      while (continueResult && result.next()) {
        countRecord++;
        RptCBpartnerData objectRptCBpartnerData = new RptCBpartnerData();
        objectRptCBpartnerData.cBpartnerId = UtilSql.getValue(result, "c_bpartner_id");
        objectRptCBpartnerData.value = UtilSql.getValue(result, "value");
        objectRptCBpartnerData.isactive = UtilSql.getValue(result, "isactive");
        objectRptCBpartnerData.created = UtilSql.getDateValue(result, "created", "dd-MM-yyyy");
        objectRptCBpartnerData.updated = UtilSql.getDateValue(result, "updated", "dd-MM-yyyy");
        objectRptCBpartnerData.name = UtilSql.getValue(result, "name");
        objectRptCBpartnerData.name2 = UtilSql.getValue(result, "name2");
        objectRptCBpartnerData.groupname = UtilSql.getValue(result, "groupname");
        objectRptCBpartnerData.taxid = UtilSql.getValue(result, "taxid");
        objectRptCBpartnerData.accountno = UtilSql.getValue(result, "accountno");
        objectRptCBpartnerData.isemployee = UtilSql.getValue(result, "isemployee");
        objectRptCBpartnerData.issalesrep = UtilSql.getValue(result, "issalesrep");
        objectRptCBpartnerData.iscustomer = UtilSql.getValue(result, "iscustomer");
        objectRptCBpartnerData.isvendor = UtilSql.getValue(result, "isvendor");
        objectRptCBpartnerData.seqno = UtilSql.getValue(result, "seqno");
        objectRptCBpartnerData.cascade = UtilSql.getValue(result, "cascade");
        objectRptCBpartnerData.discount = UtilSql.getValue(result, "discount");
        objectRptCBpartnerData.qty = UtilSql.getValue(result, "qty");
        objectRptCBpartnerData.classTree = UtilSql.getValue(result, "class_tree");
        objectRptCBpartnerData.position = Long.toString(countRecord);
        objectRptCBpartnerData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectRptCBpartnerData);
        if (countRecord >= numberRegisters && numberRegisters != 0) {
          continueResult = false;
        }
      }
      result.close();
    } catch (SQLException e) {
      log4j.error("SQL error in query: " + strSql + "Exception:" + e);
      throw new ServletException(
          "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
    } catch (Exception ex) {
      log4j.error("Exception in query: " + strSql + "Exception:" + ex);
      throw new ServletException("@CODE=@" + ex.getMessage());
    } finally {
      try {
        connectionProvider.releasePreparedStatement(st);
      } catch (Exception ignore) {
        ignore.printStackTrace();
      }
    }
    RptCBpartnerData objectRptCBpartnerData[] = new RptCBpartnerData[vector.size()];
    vector.copyInto(objectRptCBpartnerData);
    return (objectRptCBpartnerData);
  }
Exemplo n.º 2
0
  public static RptCBpartnerData[] selectTemplate(
      ConnectionProvider connectionProvider,
      String adLanguage,
      String cBpartnerId,
      int firstRegister,
      int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "        SELECT AD_REF_LIST_V.VALUE AS VALUE, AD_REF_LIST_V.NAME AS NAME2, 'datawarehouseclose' AS CLASS_TREE"
            + "        FROM M_PRODUCT_TEMPLATE PT, AD_REF_LIST_V "
            + "        WHERE PT.TYPE_TEMPLATE = AD_REF_LIST_V.VALUE"
            + "        AND AD_REF_LIST_V.AD_LANGUAGE = ?"
            + "        AND AD_REF_LIST_V.AD_REFERENCE_ID = '800009'";
    strSql =
        strSql
            + ((cBpartnerId == null || cBpartnerId.equals(""))
                ? ""
                : "           AND PT.C_BPARTNER_ID IN          " + cBpartnerId);
    strSql = strSql + "        ORDER BY name2";

    ResultSet result;
    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
    PreparedStatement st = null;

    int iParameter = 0;
    try {
      st = connectionProvider.getPreparedStatement(strSql);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, adLanguage);
      if (cBpartnerId != null && !(cBpartnerId.equals(""))) {}

      result = st.executeQuery();
      long countRecord = 0;
      long countRecordSkip = 1;
      boolean continueResult = true;
      while (countRecordSkip < firstRegister && continueResult) {
        continueResult = result.next();
        countRecordSkip++;
      }
      while (continueResult && result.next()) {
        countRecord++;
        RptCBpartnerData objectRptCBpartnerData = new RptCBpartnerData();
        objectRptCBpartnerData.value = UtilSql.getValue(result, "value");
        objectRptCBpartnerData.name2 = UtilSql.getValue(result, "name2");
        objectRptCBpartnerData.classTree = UtilSql.getValue(result, "class_tree");
        objectRptCBpartnerData.position = Long.toString(countRecord);
        objectRptCBpartnerData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectRptCBpartnerData);
        if (countRecord >= numberRegisters && numberRegisters != 0) {
          continueResult = false;
        }
      }
      result.close();
    } catch (SQLException e) {
      log4j.error("SQL error in query: " + strSql + "Exception:" + e);
      throw new ServletException(
          "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
    } catch (Exception ex) {
      log4j.error("Exception in query: " + strSql + "Exception:" + ex);
      throw new ServletException("@CODE=@" + ex.getMessage());
    } finally {
      try {
        connectionProvider.releasePreparedStatement(st);
      } catch (Exception ignore) {
        ignore.printStackTrace();
      }
    }
    RptCBpartnerData objectRptCBpartnerData[] = new RptCBpartnerData[vector.size()];
    vector.copyInto(objectRptCBpartnerData);
    return (objectRptCBpartnerData);
  }