Ejemplo n.º 1
0
  public static DocInOutData[] selectRegistro(
      ConnectionProvider connectionProvider,
      String client,
      String id,
      int firstRegister,
      int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "        SELECT I.AD_CLIENT_ID, I.AD_ORG_ID, I.C_BPARTNER_ID, I.AD_ORGTRX_ID, I.C_PROJECT_ID,"
            + "        I.C_CAMPAIGN_ID, I.C_ACTIVITY_ID, I.USER1_ID, I.USER2_ID, I.C_COSTCENTER_ID, I.DOCUMENTNO, I.DATEACCT,"
            + "        I.C_DOCTYPE_ID, I.C_CHARGE_ID, I.CHARGEAMT, I.POSTED, I.MOVEMENTDATE, I.C_BPARTNER_LOCATION_ID"
            + "        FROM M_INOUT I"
            + "        WHERE AD_Client_ID=? "
            + "        AND M_INOUT_ID=?";

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

    int iParameter = 0;
    try {
      st = connectionProvider.getPreparedStatement(strSql);
      QueryTimeOutUtil.getInstance().setQueryTimeOut(st, SessionInfo.getQueryProfile());
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, client);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, id);

      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++;
        DocInOutData objectDocInOutData = new DocInOutData();
        objectDocInOutData.adClientId = UtilSql.getValue(result, "AD_CLIENT_ID");
        objectDocInOutData.adOrgId = UtilSql.getValue(result, "AD_ORG_ID");
        objectDocInOutData.cBpartnerId = UtilSql.getValue(result, "C_BPARTNER_ID");
        objectDocInOutData.adOrgtrxId = UtilSql.getValue(result, "AD_ORGTRX_ID");
        objectDocInOutData.cProjectId = UtilSql.getValue(result, "C_PROJECT_ID");
        objectDocInOutData.cCampaignId = UtilSql.getValue(result, "C_CAMPAIGN_ID");
        objectDocInOutData.cActivityId = UtilSql.getValue(result, "C_ACTIVITY_ID");
        objectDocInOutData.user1Id = UtilSql.getValue(result, "USER1_ID");
        objectDocInOutData.user2Id = UtilSql.getValue(result, "USER2_ID");
        objectDocInOutData.cCostcenterId = UtilSql.getValue(result, "C_COSTCENTER_ID");
        objectDocInOutData.documentno = UtilSql.getValue(result, "DOCUMENTNO");
        objectDocInOutData.dateacct = UtilSql.getDateValue(result, "DATEACCT", "dd-MM-yyyy");
        objectDocInOutData.cDoctypeId = UtilSql.getValue(result, "C_DOCTYPE_ID");
        objectDocInOutData.cChargeId = UtilSql.getValue(result, "C_CHARGE_ID");
        objectDocInOutData.chargeamt = UtilSql.getValue(result, "CHARGEAMT");
        objectDocInOutData.posted = UtilSql.getValue(result, "POSTED");
        objectDocInOutData.movementdate =
            UtilSql.getDateValue(result, "MOVEMENTDATE", "dd-MM-yyyy");
        objectDocInOutData.cBpartnerLocationId = UtilSql.getValue(result, "C_BPARTNER_LOCATION_ID");
        objectDocInOutData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectDocInOutData);
        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();
      }
    }
    DocInOutData objectDocInOutData[] = new DocInOutData[vector.size()];
    vector.copyInto(objectDocInOutData);
    return (objectDocInOutData);
  }
Ejemplo n.º 2
0
  public static DocInOutData[] select(
      ConnectionProvider connectionProvider, int firstRegister, int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "        SELECT '' AS M_INOUT_ID, '' AS AD_CLIENT_ID, '' AS AD_ORG_ID, '' AS ISACTIVE, '' AS CREATED,"
            + "        '' AS CREATEDBY, '' AS UPDATED, '' AS UPDATEDBY, '' AS ISSOTRX, '' AS DOCUMENTNO, '' AS DOCACTION,"
            + "        '' AS DOCSTATUS, '' AS POSTED, '' AS PROCESSING, '' AS PROCESSED, '' AS C_DOCTYPE_ID, '' AS DESCRIPTION,"
            + "        '' AS C_ORDER_ID, '' AS DATEORDERED, '' AS ISPRINTED, '' AS MOVEMENTTYPE, '' AS MOVEMENTDATE, '' AS DATEACCT,"
            + "        '' AS C_BPARTNER_ID, '' AS C_BPARTNER_LOCATION_ID, '' AS M_WAREHOUSE_ID, '' AS POREFERENCE, '' AS DELIVERYRULE,"
            + "        '' AS FREIGHTCOSTRULE, '' AS FREIGHTAMT, '' AS DELIVERYVIARULE, '' AS M_SHIPPER_ID, '' AS C_CHARGE_ID,"
            + "        '' AS CHARGEAMT, '' AS PRIORITYRULE, '' AS DATEPRINTED, '' AS C_INVOICE_ID, '' AS CREATEFROM, '' AS GENERATETO,"
            + "        '' AS SENDEMAIL, '' AS AD_USER_ID, '' AS SALESREP_ID, '' AS NOPACKAGES, '' AS PICKDATE, '' AS SHIPDATE,"
            + "        '' AS TRACKINGNO, '' AS AD_ORGTRX_ID, '' AS C_PROJECT_ID, '' AS C_CAMPAIGN_ID, '' AS C_ACTIVITY_ID, '' AS USER1_ID,"
            + "        '' AS USER2_ID, '' AS C_COSTCENTER_ID, '' AS UPDATELINES, '' AS M_COSTING_ID, '' AS stdprecision"
            + "        FROM DUAL";

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

    try {
      st = connectionProvider.getPreparedStatement(strSql);
      QueryTimeOutUtil.getInstance().setQueryTimeOut(st, SessionInfo.getQueryProfile());

      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++;
        DocInOutData objectDocInOutData = new DocInOutData();
        objectDocInOutData.mInoutId = UtilSql.getValue(result, "M_INOUT_ID");
        objectDocInOutData.adClientId = UtilSql.getValue(result, "AD_CLIENT_ID");
        objectDocInOutData.adOrgId = UtilSql.getValue(result, "AD_ORG_ID");
        objectDocInOutData.isactive = UtilSql.getValue(result, "ISACTIVE");
        objectDocInOutData.created = UtilSql.getValue(result, "CREATED");
        objectDocInOutData.createdby = UtilSql.getValue(result, "CREATEDBY");
        objectDocInOutData.updated = UtilSql.getValue(result, "UPDATED");
        objectDocInOutData.updatedby = UtilSql.getValue(result, "UPDATEDBY");
        objectDocInOutData.issotrx = UtilSql.getValue(result, "ISSOTRX");
        objectDocInOutData.documentno = UtilSql.getValue(result, "DOCUMENTNO");
        objectDocInOutData.docaction = UtilSql.getValue(result, "DOCACTION");
        objectDocInOutData.docstatus = UtilSql.getValue(result, "DOCSTATUS");
        objectDocInOutData.posted = UtilSql.getValue(result, "POSTED");
        objectDocInOutData.processing = UtilSql.getValue(result, "PROCESSING");
        objectDocInOutData.processed = UtilSql.getValue(result, "PROCESSED");
        objectDocInOutData.cDoctypeId = UtilSql.getValue(result, "C_DOCTYPE_ID");
        objectDocInOutData.description = UtilSql.getValue(result, "DESCRIPTION");
        objectDocInOutData.cOrderId = UtilSql.getValue(result, "C_ORDER_ID");
        objectDocInOutData.dateordered = UtilSql.getValue(result, "DATEORDERED");
        objectDocInOutData.isprinted = UtilSql.getValue(result, "ISPRINTED");
        objectDocInOutData.movementtype = UtilSql.getValue(result, "MOVEMENTTYPE");
        objectDocInOutData.movementdate = UtilSql.getValue(result, "MOVEMENTDATE");
        objectDocInOutData.dateacct = UtilSql.getValue(result, "DATEACCT");
        objectDocInOutData.cBpartnerId = UtilSql.getValue(result, "C_BPARTNER_ID");
        objectDocInOutData.cBpartnerLocationId = UtilSql.getValue(result, "C_BPARTNER_LOCATION_ID");
        objectDocInOutData.mWarehouseId = UtilSql.getValue(result, "M_WAREHOUSE_ID");
        objectDocInOutData.poreference = UtilSql.getValue(result, "POREFERENCE");
        objectDocInOutData.deliveryrule = UtilSql.getValue(result, "DELIVERYRULE");
        objectDocInOutData.freightcostrule = UtilSql.getValue(result, "FREIGHTCOSTRULE");
        objectDocInOutData.freightamt = UtilSql.getValue(result, "FREIGHTAMT");
        objectDocInOutData.deliveryviarule = UtilSql.getValue(result, "DELIVERYVIARULE");
        objectDocInOutData.mShipperId = UtilSql.getValue(result, "M_SHIPPER_ID");
        objectDocInOutData.cChargeId = UtilSql.getValue(result, "C_CHARGE_ID");
        objectDocInOutData.chargeamt = UtilSql.getValue(result, "CHARGEAMT");
        objectDocInOutData.priorityrule = UtilSql.getValue(result, "PRIORITYRULE");
        objectDocInOutData.dateprinted = UtilSql.getValue(result, "DATEPRINTED");
        objectDocInOutData.cInvoiceId = UtilSql.getValue(result, "C_INVOICE_ID");
        objectDocInOutData.createfrom = UtilSql.getValue(result, "CREATEFROM");
        objectDocInOutData.generateto = UtilSql.getValue(result, "GENERATETO");
        objectDocInOutData.sendemail = UtilSql.getValue(result, "SENDEMAIL");
        objectDocInOutData.adUserId = UtilSql.getValue(result, "AD_USER_ID");
        objectDocInOutData.salesrepId = UtilSql.getValue(result, "SALESREP_ID");
        objectDocInOutData.nopackages = UtilSql.getValue(result, "NOPACKAGES");
        objectDocInOutData.pickdate = UtilSql.getValue(result, "PICKDATE");
        objectDocInOutData.shipdate = UtilSql.getValue(result, "SHIPDATE");
        objectDocInOutData.trackingno = UtilSql.getValue(result, "TRACKINGNO");
        objectDocInOutData.adOrgtrxId = UtilSql.getValue(result, "AD_ORGTRX_ID");
        objectDocInOutData.cProjectId = UtilSql.getValue(result, "C_PROJECT_ID");
        objectDocInOutData.cCampaignId = UtilSql.getValue(result, "C_CAMPAIGN_ID");
        objectDocInOutData.cActivityId = UtilSql.getValue(result, "C_ACTIVITY_ID");
        objectDocInOutData.user1Id = UtilSql.getValue(result, "USER1_ID");
        objectDocInOutData.user2Id = UtilSql.getValue(result, "USER2_ID");
        objectDocInOutData.cCostcenterId = UtilSql.getValue(result, "C_COSTCENTER_ID");
        objectDocInOutData.updatelines = UtilSql.getValue(result, "UPDATELINES");
        objectDocInOutData.mCostingId = UtilSql.getValue(result, "M_COSTING_ID");
        objectDocInOutData.stdprecision = UtilSql.getValue(result, "STDPRECISION");
        objectDocInOutData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectDocInOutData);
        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();
      }
    }
    DocInOutData objectDocInOutData[] = new DocInOutData[vector.size()];
    vector.copyInto(objectDocInOutData);
    return (objectDocInOutData);
  }