private void applyButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_applyButtonActionPerformed

    try {
      LblAuditUser.setText(configuration.getField("system_user_name"));

      KDialogController.OKbuttonActionPerformed();

    } catch (KExceptionClass error) {

      // log error
      log.log(this, KMetaUtilsClass.getStackTrace(error));

      // show error message
      KMetaUtilsClass.showErrorMessageFromException(getOwner(), error);
    }
  } // GEN-LAST:event_applyButtonActionPerformed
  private void okButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okButtonActionPerformed

    // calculate
    // qtyneedLabel.setText(Long.toString( String.valueOf("s") ));
    // qtyneedLabel.setText((qtyLabel.getText() * compLabel.getText() * toleranceLabel.getText());

    try {
      LblAuditUser.setText(configuration.getField("system_user_name"));

      KDialogController.OKbuttonActionPerformed();

      setVisible(false);
      dispose();

    } catch (KExceptionClass error) {

      // log error
      log.log(this, KMetaUtilsClass.getStackTrace(error));

      // show error message
      KMetaUtilsClass.showErrorMessageFromException(getOwner(), error);
    }
  } // GEN-LAST:event_okButtonActionPerformed
Пример #3
0
  /** adds the databaseFieldName-criteria-operator fileds. Used by QBE screen */
  public void addCustomCriteria(java.util.List filters) throws KExceptionClass {
    if (filters.size() == 0) return;

    String criteria = "";

    // assemble each filter
    Iterator filterTrios = filters.iterator();
    while (filterTrios.hasNext()) {

      filterClass currentTrio = (filterClass) filterTrios.next();
      // find real field names.
      String fieldName = (String) getFullFieldName(currentTrio.name);

      // ==================================================================
      // column type is character.
      if (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_CHARACTER) {

        criteria += " UPPER( " + fieldName + " ) ";
        currentTrio.value = currentTrio.value.toUpperCase();
        if (currentTrio.value.startsWith("NOT")) {
          currentTrio.value = currentTrio.value.substring(3);
          currentTrio.value = currentTrio.value.trim();
          criteria += "NOT ";
        }

        criteria += "LIKE UPPER( ? ) ";

        // binding parameters
        customBindingParameterList.add(
            new boundParameterClass(
                ":x" + String.valueOf(BindingParameterNo), currentTrio.value + "%"));
        BindingParameterNo++;
      }

      // ==================================================================
      else if ((currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_NUMERICNOFORMAT)
          || (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_NUMERIC)
          || (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_NUMERIC2)
          || (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_CURRENCY)) {
        criteria += fieldName;
        if (currentTrio.value.startsWith("<")) {
          criteria += "< ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith(">")) {
          criteria += "> ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith("not") || currentTrio.value.startsWith("NOT")) {
          criteria += "<> ";
          currentTrio.value = currentTrio.value.substring(3);
          currentTrio.value = currentTrio.value.trim();
        } else criteria += "= ";

        criteria += "? ";

        // binding parameters
        customBindingParameterList.add(
            new boundParameterClass(":x" + String.valueOf(BindingParameterNo), currentTrio.value));

        BindingParameterNo++;
      }

      // ==================================================================
      else if (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_DATE) {
        criteria += fieldName;

        if (currentTrio.value.startsWith("=")) {
          criteria += " = ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();

        } else if (currentTrio.value.startsWith("<")) {
          criteria += "< ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith(">")) {
          criteria += "> ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith("not") || currentTrio.value.startsWith("NOT")) {
          criteria += "<> ";
          currentTrio.value = currentTrio.value.substring(3);
          currentTrio.value = currentTrio.value.trim();
        } else criteria += "= ";

        // MIH PEND criteria += " TO_DATE( :x" + String.valueOf( BindingParameterNo ) + ",
        // 'MM/DD/YYYY' ) ";
        // sql serVER criteria += " CONVERT( DATETIME, ? , 103 ) ";
        criteria += configuration.getField("date_parsing_sql");

        // binding parameters
        customBindingParameterList.add(
            new boundParameterClass(":x" + String.valueOf(BindingParameterNo), currentTrio.value));

        BindingParameterNo++;
      }

      // ==================================================================
      // column type is TIME.
      else if (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_TIME) {
        criteria += fieldName;

        if (currentTrio.value.startsWith("=")) {
          criteria += " = ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();

        } else if (currentTrio.value.startsWith("<")) {
          criteria += "< ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith(">")) {
          criteria += "> ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith("not") || currentTrio.value.startsWith("NOT")) {
          criteria += "<> ";
          currentTrio.value = currentTrio.value.substring(3);
          currentTrio.value = currentTrio.value.trim();
        } else criteria += "= ";

        // MIH criteria += " TO_DATE( :x" + String.valueOf( BindingParameterNo ) + ", 'HH:MI AM' ) "
        // ;
        // criteria += " CONVERT ( DATE, ?, 108 ) " ;  // Se requiere formatear el tiempo a
        // hh24:mi:ss DE 'HH:MI AM'
        // criteria += " CAST( ? AS TIME) ";
        criteria += configuration.getField("time_parsing_sql");

        // binding parameters
        customBindingParameterList.add(
            new boundParameterClass(":x" + String.valueOf(BindingParameterNo), currentTrio.value));

        BindingParameterNo++;
      }

      // ==================================================================
      // column type is currency.
      else if (currentTrio.type == KDataBrowserBaseClass.BROWSER_COLUMN_TYPE_CURRENCY) {
        criteria += fieldName;

        if (currentTrio.value.startsWith("=")) {
          criteria += " = ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();

        } else if (currentTrio.value.startsWith("<")) {
          criteria += "< ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith(">")) {
          criteria += "> ";
          currentTrio.value = currentTrio.value.substring(1);
          currentTrio.value = currentTrio.value.trim();
        } else if (currentTrio.value.startsWith("not") || currentTrio.value.startsWith("NOT")) {
          criteria += "<> ";
          currentTrio.value = currentTrio.value.substring(3);
          currentTrio.value = currentTrio.value.trim();
        } else criteria += "= ";

        criteria += "?";

        // binding parameters
        customBindingParameterList.add(
            new boundParameterClass(":x" + String.valueOf(BindingParameterNo), currentTrio.value));

        BindingParameterNo++;

        // ==================================================================

      } else {

        throw new KExceptionClass(
            "*** Could not set custom criteria ***\n" + "Invalid field type code\n", null);
      }
      ;

      if (filterTrios.hasNext()) criteria += " AND ";
    } // loop

    customCriteriaList.add(criteria);
  }