@Override
  public String getSQLWhere() {
    StringBuffer sql = new StringBuffer();
    if (txtDocumentNo.getText().length() > 0) sql.append(" AND UPPER(o.DocumentNo) LIKE ?");
    if (txtDescription.getText().length() > 0) sql.append(" AND UPPER(o.Description) LIKE ?");
    if (txtOrderRef.getText().length() > 0) sql.append(" AND UPPER(o.POReference) LIKE ?");
    //
    if (editorBPartner.getValue() != null) sql.append(" AND o.C_BPartner_ID=?");
    //
    Date fromDate = null;
    Date toDate = null;
    try {
      fromDate = dateFrom.getValue();
    } catch (WrongValueException e) {

    }
    try {
      toDate = dateTo.getValue();
    } catch (WrongValueException e) {

    }
    if (fromDate == null && toDate != null) {
      sql.append(" AND TRUNC(o.DateOrdered) <= ?");
    } else if (fromDate != null && toDate == null) {
      sql.append(" AND TRUNC(o.DateOrdered) >= ?");
    } else if (fromDate != null && toDate != null) {
      sql.append(" AND TRUNC(o.DateOrdered) BETWEEN ? AND ?");
    }
    //
    Double fromAmount = null;
    Double toAmount = null;
    if (amountFrom.getText() != null && amountFrom.getText().trim().length() > 0) {
      try {
        fromAmount = Double.parseDouble(amountFrom.getText());
      } catch (NumberFormatException e) {

      }
    }
    if (amountTo.getText() != null && amountTo.getText().trim().length() > 0) {
      try {
        toAmount = Double.parseDouble(amountTo.getText());
      } catch (NumberFormatException e) {

      }
    }
    if (fromAmount == null && toAmount != null) {
      sql.append(" AND o.GrandTotal <= ?");
    } else if (fromAmount != null && toAmount == null) {
      sql.append(" AND o.GrandTotal >= ?");
    } else if (fromAmount != null && toAmount != null) {
      sql.append(" AND o.GrandTotal BETWEEN ? AND ?");
    }
    sql.append(" AND o.IsSOTrx=?");

    log.finer(sql.toString());
    return sql.toString();
  }
Esempio n. 2
0
 private void getDateAndTimeFrom(Calendar date) {
   Date dateFrom = fDateFrom.getValue();
   Date timeFrom = fTimeFrom.getValue();
   date.setTime(dateFrom);
   Calendar time = new GregorianCalendar();
   time.setTime(timeFrom);
   date.set(Calendar.HOUR, time.get(Calendar.HOUR));
   date.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
 }
Esempio n. 3
0
  /** Initialize component & values from m_mAssignment */
  private void setDisplay() {
    m_setting = true;

    //	Set Resource
    int S_Resource_ID = m_mAssignment.getS_Resource_ID();
    KeyNamePair[] resources = new KeyNamePair[m_lookup.size()];
    m_lookup.keySet().toArray(resources);
    for (int i = 0; i < resources.length; i++) {
      if (resources[i].getKey() == S_Resource_ID) {
        fResource.setSelectedIndex(i);
        break;
      }
    }
    ListItem listItem = fResource.getSelectedItem();
    KeyNamePair check = new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel());
    if (check == null || check.getKey() != S_Resource_ID) {
      if (m_mAssignment.getS_ResourceAssignment_ID() == 0) // 	new record select first
      fResource.setSelectedItem(fResource.getSelectedItem()); // 	initiates UOM display
      else log.log(Level.SEVERE, "Resource not found ID=" + S_Resource_ID);
    }

    //	Set Date, Qty
    fDateFrom.setValue(m_mAssignment.getAssignDateFrom());
    fTimeFrom.setValue(m_mAssignment.getAssignDateFrom());
    fQty.setValue(m_mAssignment.getQty());

    //	Name, Description
    fName.setValue(m_mAssignment.getName());
    fDescription.setValue(m_mAssignment.getDescription());

    //	Set Editor to R/O if confirmed
    boolean readWrite = true;
    if (m_mAssignment.isConfirmed()) readWrite = false;
    confirmPanel.getButton("Cancel").setVisible(readWrite);
    fResource.setEnabled(readWrite);
    fDateFrom.setReadonly(!readWrite);
    fQty.setEnabled(readWrite);

    m_setting = false;
  } //	dynInit
  /**
   * Get dynamic WHERE part of SQL To be overwritten by concrete classes
   *
   * @return WHERE clause
   */
  protected String getSQLWhere() {
    StringBuilder sql = new StringBuilder();

    Integer S_ResourceType_ID = (Integer) fieldResourceType.getValue();

    if (S_ResourceType_ID != null)
      sql.append(" AND rt.S_ResourceType_ID=").append(S_ResourceType_ID.intValue());

    Integer S_Resource_ID = (Integer) fieldResource.getValue();

    if (S_Resource_ID != null) sql.append(" AND r.S_Resource_ID=").append(S_Resource_ID.intValue());

    Date f = fieldFrom.getValue();
    Timestamp ts = f != null ? new Timestamp(f.getTime()) : null;

    if (ts != null) sql.append(" AND TRUNC(ra.AssignDateFrom)>=").append(DB.TO_DATE(ts, false));

    Date t = fieldTo.getValue();
    ts = t != null ? new Timestamp(t.getTime()) : null;

    if (ts != null) sql.append(" AND TRUNC(ra.AssignDateTo)<=").append(DB.TO_DATE(ts, false));

    return sql.toString();
  } // getSQLWhere
  /**
   * Static Setup - add fields to parameterPanel.
   *
   * <pre>
   * 		ResourceType	Resource	DateTimeFrom	DateTimeTo	New
   *  </pre>
   */
  private void statInit() {
    fieldFrom.setWidth("180px");
    fieldTo.setWidth("180px");

    bNew.addEventListener(Events.ON_CLICK, this);

    Grid grid = GridFactory.newGridLayout();

    Rows rows = new Rows();
    grid.appendChild(rows);

    Row row = new Row();
    rows.appendChild(row);
    row.appendChild(fieldResourceType.getLabel().rightAlign());
    row.appendChild(fieldResource.getLabel().rightAlign());
    row.appendChild(labelFrom.rightAlign());
    row.appendChild(labelTo.rightAlign());
    row.appendChild(new Label());

    row = new Row();
    rows.appendChild(row);
    row.appendChild(fieldResourceType.getComponent());
    row.appendChild(fieldResource.getComponent());
    Div div = new Div();
    div.setStyle("text-align: right;");
    div.appendChild(fieldFrom);
    row.appendChild(div);
    div = new Div();
    div.setStyle("text-align: right;");
    div.appendChild(fieldTo);
    row.appendChild(div);
    row.appendChild(bNew);

    layout = new Borderlayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    if (!isLookup()) {
      layout.setStyle("position: absolute");
    }
    this.appendChild(layout);

    North north = new North();
    layout.appendChild(north);
    north.appendChild(grid);

    Center center = new Center();
    layout.appendChild(center);
    div = new Div();
    div.appendChild(contentPanel);
    if (isLookup()) contentPanel.setWidth("99%");
    else contentPanel.setStyle("width: 99%; margin: 0px auto;");
    contentPanel.setVflex(true);
    div.setStyle("width :100%; height: 100%");
    center.appendChild(div);
    div.setVflex("1");
    div.setHflex("1");

    South south = new South();
    layout.appendChild(south);
    southBody = new Vbox();
    southBody.setWidth("100%");
    south.appendChild(southBody);
    southBody.appendChild(confirmPanel);
    southBody.appendChild(new Separator());
    southBody.appendChild(statusBar);
  }
  @Override
  protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException {
    int index = 1;
    if (txtDocumentNo.getText().length() > 0) pstmt.setString(index++, getSQLText(txtDocumentNo));
    if (txtDescription.getText().length() > 0) pstmt.setString(index++, getSQLText(txtDescription));
    if (txtOrderRef.getText().length() > 0) pstmt.setString(index++, getSQLText(txtOrderRef));
    //
    if (editorBPartner.getValue() != null) {
      Integer bp = (Integer) editorBPartner.getValue();
      pstmt.setInt(index++, bp.intValue());
      log.fine("BPartner=" + bp);
    }
    //

    Date fromD = null;
    Date toD = null;
    Timestamp from = null;
    Timestamp to = null;
    try {
      if (dateFrom.getValue() != null) {
        fromD = dateFrom.getValue();
        from = new Timestamp(fromD.getTime());
      }
    } catch (WrongValueException e) {

    }
    try {
      if (dateTo.getValue() != null) {
        toD = dateTo.getValue();
        to = new Timestamp(toD.getTime());
      }
    } catch (WrongValueException e) {

    }

    log.fine("Date From=" + from + ", To=" + to);
    if (from == null && to != null) {
      pstmt.setTimestamp(index++, to);
    } else if (from != null && to == null) {
      pstmt.setTimestamp(index++, from);
    } else if (from != null && to != null) {
      pstmt.setTimestamp(index++, from);
      pstmt.setTimestamp(index++, to);
    }

    //
    BigDecimal fromBD = null;
    BigDecimal toBD = null;
    Double fromAmt = null;
    Double toAmt = null;

    if (amountFrom.getText() != null && amountFrom.getText().trim().length() > 0) {
      try {
        fromAmt = Double.parseDouble(amountFrom.getText());
        fromBD = BigDecimal.valueOf(fromAmt);
      } catch (Exception e) {

      }
    }

    if (amountTo.getText() != null && amountTo.getText().trim().length() > 0) {
      try {
        toAmt = Double.parseDouble(amountTo.getText());
        toBD = BigDecimal.valueOf(toAmt);
      } catch (Exception e) {

      }
    }

    if (fromBD == null && toBD != null) {
      pstmt.setBigDecimal(index++, toBD);
    } else if (fromBD != null && toBD == null) {
      pstmt.setBigDecimal(index++, fromBD);
    } else if (fromBD != null && toBD != null) {
      pstmt.setBigDecimal(index++, fromBD);
      pstmt.setBigDecimal(index++, toBD);
    }

    pstmt.setString(index++, isSoTrx.isChecked() ? "Y" : "N");
  }
  private void initLayout() {
    txtDocumentNo.setWidth("100%");
    txtDescription.setWidth("100%");
    txtOrderRef.setWidth("100%");
    dateFrom.setWidth("165px");
    dateTo.setWidth("165px");
    amountFrom.getDecimalbox().setWidth("155px");
    amountTo.getDecimalbox().setWidth("155px");

    Grid grid = GridFactory.newGridLayout();

    Rows rows = new Rows();
    grid.appendChild(rows);

    Row row = new Row();
    rows.appendChild(row);
    row.appendChild(lblDocumentNo.rightAlign());
    row.appendChild(txtDocumentNo);
    row.appendChild(editorBPartner.getLabel().rightAlign());
    row.appendChild(editorBPartner.getComponent());
    row.appendChild(isSoTrx);

    row = new Row();
    row.setSpans("1, 1, 1, 2");
    rows.appendChild(row);
    row.appendChild(lblDescription.rightAlign());
    row.appendChild(txtDescription);
    row.appendChild(lblDateOrdered.rightAlign());
    Hbox hbox = new Hbox();
    hbox.appendChild(dateFrom);
    hbox.appendChild(new Label("-"));
    hbox.appendChild(dateTo);
    row.appendChild(hbox);

    row = new Row();
    row.setSpans("1, 1, 1, 2");
    rows.appendChild(row);
    row.appendChild(lblOrderRef.rightAlign());
    row.appendChild(txtOrderRef);
    row.appendChild(lblGrandTotal.rightAlign());
    hbox = new Hbox();
    hbox.appendChild(amountFrom);
    hbox.appendChild(new Label("-"));
    hbox.appendChild(amountTo);
    row.appendChild(hbox);

    layout = new Borderlayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    if (!isLookup()) {
      layout.setStyle("position: absolute");
    }
    this.appendChild(layout);

    North north = new North();
    layout.appendChild(north);
    north.appendChild(grid);

    Center center = new Center();
    layout.appendChild(center);
    center.setFlex(true);
    Div div = new Div();
    div.appendChild(contentPanel);
    if (isLookup()) contentPanel.setWidth("99%");
    else contentPanel.setStyle("width: 99%; margin: 0px auto;");
    contentPanel.setVflex(true);
    div.setStyle("width :100%; height: 100%");
    center.appendChild(div);

    South south = new South();
    layout.appendChild(south);
    southBody = new Vbox();
    southBody.setWidth("100%");
    south.appendChild(southBody);
    southBody.appendChild(confirmPanel);
    southBody.appendChild(new Separator());
    southBody.appendChild(statusBar);
  }