Example #1
0
  /** Descripción de Método */
  private void cmd_drill() {
    m_drillDown = comboDrill.getSelectedIndex() < 1; // -1 or 0

    if (m_drillDown) {
      setCursor(Cursor.getDefaultCursor());
    } else {
      setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
  } // cmd_drill
Example #2
0
 private void gridOK() {
   int mode = modeCombo.getSelectedIndex();
   //	Create PO
   if (mode == MODE_PO) {
     createPO();
     modeCombo.setSelectedIndex(MODE_VIEW);
     return;
   }
   //	Update Prices
   else if (mode == MODE_PRICE) {
     updatePrices();
     modeCombo.setSelectedIndex(MODE_VIEW);
     return;
   } else if (mode == MODE_VIEW) ;
   m_frame.dispose();
 } //	gridOK
Example #3
0
  /** Descripción de Método */
  private void deleteAttachmentEntry() {
    log.info("");

    int index = cbContent.getSelectedIndex();
    String fileName = getFileName(index);

    if (fileName == null) {
      return;
    }

    //

    if (ADialog.ask(m_WindowNo, this, "AttachmentDeleteEntry?", fileName)) {
      if (m_attachment.deleteEntry(index)) {
        cbContent.removeItemAt(index);
      }

      m_change = true;
    }
  } // deleteAttachment
Example #4
0
  /**
   * Descripción de Método
   *
   * @return
   */
  private boolean openAttachment() {
    int index = cbContent.getSelectedIndex();
    byte[] data = m_attachment.getEntryData(index);

    if (data == null) {
      return false;
    }

    try {
      String fileName = System.getProperty("java.io.tmpdir") + m_attachment.getEntryName(index);
      File tempFile = new File(fileName);

      m_attachment.getEntryFile(index, tempFile);

      if (isWindows()) {

        // Runtime.getRuntime().exec ("rundll32 url.dll,FileProtocolHandler " + url);

        Process p =
            Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \"" + tempFile + "\"");

        // p.waitFor();

        return true;
      } else if (isMac()) {
        String[] cmdArray = new String[] {"open", tempFile.getAbsolutePath()};
        Process p = Runtime.getRuntime().exec(cmdArray);

        // p.waitFor();

        return true;
      } else // other OS
      {
      }
    } catch (Exception e) {
      log.log(Level.SEVERE, "openFile", e);
    }

    return false;
  } // openFile
Example #5
0
  /** Descripción de Método */
  private void saveAttachmentToFile() {
    int index = cbContent.getSelectedIndex();

    log.info("index=" + index);

    if (m_attachment.getEntryCount() < index) {
      return;
    }

    String fileName = getFileName(index);
    String ext = fileName.substring(fileName.lastIndexOf("."));

    log.config("Ext=" + ext);

    JFileChooser chooser = new JFileChooser();

    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentSave"));

    File f = new File(fileName);

    chooser.setSelectedFile(f);

    // Show dialog

    int returnVal = chooser.showSaveDialog(this);

    if (returnVal != JFileChooser.APPROVE_OPTION) {
      return;
    }

    File saveFile = chooser.getSelectedFile();

    if (saveFile == null) {
      return;
    }

    log.config("Save to " + saveFile.getAbsolutePath());
    m_attachment.getEntryFile(index, saveFile);
  } // saveAttachmentToFile
  /**
   * ActionListener
   *
   * @param e ActionEvent
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
      if (fAddress1.isMandatory() && ((((String) fAddress1.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fAddress2.isMandatory() && ((((String) fAddress2.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fAddress3.isMandatory() && ((((String) fAddress3.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fPostal.isMandatory() && ((((String) fPostal.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else {
        action_OK();
        m_change = true;
        dispose();
      }
    } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
      m_change = false;
      dispose();
    } else if (e.getSource() == fCountry) {
      //	Country Changed - display in new Format
      //	Modifier for Mouse selection is 16  - for any key selection 0
      MCountry c = (MCountry) fCountry.getSelectedItem();
      m_location.setCountry(c);
      //	refrseh
      mainPanel.removeAll();
      initLocation();
      fCountry.requestFocus(); // 	allows to use Keybord selection
    }
    // Kenos
    else if (e.getSource() == fRegion) {
      //	Modifier for Mouse selection is 16  - for any key selection 0
      MRegion r = (MRegion) fRegion.getSelectedItem();
      m_location.setRegion(r);
      //	refrseh
      mainPanel.removeAll();
      initLocation();
      fRegion.requestFocus(); // 	allows to use Keybord selection
    }
    // Kenos
    else if (e.getSource() == toLink) {
      String urlString = GOOGLE_MAPS_URL_PREFIX + getGoogleMapsLocation(m_location);
      String message = null;

      try {
        new URL(urlString);
        Env.startBrowser(urlString);
      } catch (Exception ex) {
        message = ex.getMessage();
        ADialog.warn(0, this, "URLnotValid", message);
      }
    } else if (e.getSource() == toRoute) {
      int AD_Org_ID = Env.getAD_Org_ID(Env.getCtx());
      if (AD_Org_ID != 0) {
        MOrgInfo orgInfo = MOrgInfo.get(Env.getCtx(), AD_Org_ID, null);
        MLocation orgLocation = new MLocation(Env.getCtx(), orgInfo.getC_Location_ID(), null);

        String urlString =
            GOOGLE_MAPS_ROUTE_PREFIX
                + GOOGLE_SOURCE_ADDRESS
                + getGoogleMapsLocation(orgLocation)
                + // org
                GOOGLE_DESTINATION_ADDRESS
                + getGoogleMapsLocation(m_location); // partner
        String message = null;
        try {
          new URL(urlString);
          Env.startBrowser(urlString);
        } catch (Exception ex) {
          message = ex.getMessage();
          ADialog.warn(0, this, "URLnotValid", message);
        }
      }
    } else if (e.getSource() == getAddress) {
      if (fPostal != null && !fPostal.getText().equals("")) {
        if (!fAddress1.getText().equals("")
            || !fAddress2.getText().equals("")
            || !fAddress3.getText().equals("")
            || !fAddress4.getText().equals("")
            || fCity.getSelectedIndex() > 0) {
          String warningMsg = "O endereço atual será substituido. Deseja continuar?";
          String warningTitle = "Aviso";
          int response =
              JOptionPane.showConfirmDialog(
                  null, warningMsg, warningTitle, JOptionPane.YES_NO_OPTION);
          if (response == JOptionPane.NO_OPTION) return;
        }

        WebServiceCep cep = WebServiceCep.searchCep(fPostal.getText());
        if (cep.wasSuccessful()) {
          MRegion[] regions = MRegion.getRegions(Env.getCtx(), 139);
          for (MRegion r : regions)
            if (r.getName() != null && r.getName().equals(cep.getUf())) {
              fRegion.setSelectedItem(r);
              break;
            }
          fCity.setSelectedItem(cep.getCidade());
          fAddress1.setText(cep.getLogradouroType() + " " + cep.getLogradouro());
          fAddress3.setText(cep.getBairro());
          if (cep.getCep().length() == 8)
            fPostal.setText(cep.getCep().substring(0, 5) + "-" + cep.getCep().substring(5));
          else fPostal.setText(cep.getCep());
        } else if (cep.getResulCode() == 0)
          JOptionPane.showMessageDialog(null, "CEP não encontrado na base de dados.");
        else if (cep.getResulCode() == 14)
          JOptionPane.showMessageDialog(
              null, "Não foi possível fazer a busca. (Possível problema com a Internet).");
        else JOptionPane.showMessageDialog(null, "Erro ao fazer a busca.");
      } else JOptionPane.showMessageDialog(null, "Preencha o CEP.");
    }
  } //	actionPerformed
Example #7
0
  /**
   * Descripción de Método
   *
   * @param e
   */
  public void actionPerformed(ActionEvent e) {

    // log.config( "Attachment.actionPerformed - " + e.getActionCommand());
    // Save and Close

    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
      String newText = text.getText();

      if (newText == null) {
        newText = "";
      }

      String oldText = m_attachment.getTextMsg();

      if (oldText == null) {
        oldText = "";
      }

      if (!m_change) {
        m_change = !newText.equals(oldText);
      }

      if ((newText.length() > 0) || (m_attachment.getEntryCount() > 0)) {
        if (m_change) {
          // m_attachment.setTextMsg( text.getText());
          log.fine("Justo antes de guardar el registro, D_file_id=" + d_file_id);
          //	m_attachment.setD_File_Archive_ID(d_file_archive_id);
          m_attachment.setUploadedBy(Env.getContextAsInt(Env.getCtx(), "UploadedBy"));
          //	m_attachment.setD_File_ID(d_file_id);
          m_attachment.save();
        }
      } else {
        m_attachment.delete(true);
      }

      dispose();
    }

    // Cancel

    else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
      dispose();
    }

    // Delete Attachment

    else if (e.getSource() == bDeleteAll) {
      deleteAttachment();
      dispose();
    }

    // Delete individual entry and Return

    else if (e.getSource() == bDelete) {
      deleteAttachmentEntry();

      // Show Data

    } else if (e.getSource() == cbContent) {
      displayData(cbContent.getSelectedIndex());

      // Load Attachment

    } else if (e.getSource() == bLoad) {
      loadFile();

      // Open Attachment

    } else if (e.getSource() == bSave) {
      saveAttachmentToFile();

      // Open Attachment

    } else if (e.getSource() == bOpen) {
      if (!openAttachment()) {
        saveAttachmentToFile();
      }
    }
  } // actionPerformed
Example #8
0
  /**
   * Get Grid Element
   *
   * @param xValue X value
   * @param yValue Y value
   * @return Panel with Info
   */
  private CPanel getGridElement(MAttributeValue xValue, MAttributeValue yValue) {
    CPanel element = new CPanel();
    element.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
    element.setLayout(new BoxLayout(element, BoxLayout.Y_AXIS));

    String sql = "SELECT * FROM M_Product WHERE IsActive='Y'";
    //	Product Attributes
    if (xValue != null)
      sql +=
          " AND M_AttributeSetInstance_ID IN "
              + "(SELECT M_AttributeSetInstance_ID "
              + "FROM M_AttributeInstance "
              + "WHERE M_Attribute_ID="
              + xValue.getM_Attribute_ID()
              + " AND M_AttributeValue_ID="
              + xValue.getM_AttributeValue_ID()
              + ")";
    if (yValue != null)
      sql +=
          " AND M_AttributeSetInstance_ID IN "
              + "(SELECT M_AttributeSetInstance_ID "
              + "FROM M_AttributeInstance "
              + "WHERE M_Attribute_ID="
              + yValue.getM_Attribute_ID()
              + " AND M_AttributeValue_ID="
              + yValue.getM_AttributeValue_ID()
              + ")";
    sql = MRole.getDefault().addAccessSQL(sql, "M_Product", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    PreparedStatement pstmt = null;
    int noProducts = 0;
    try {
      pstmt = DB.prepareStatement(sql, null);
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {
        MProduct product = new MProduct(Env.getCtx(), rs, null);
        addProduct(element, product);
        noProducts++;
      }
      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      log.log(Level.SEVERE, sql, e);
    }
    try {
      if (pstmt != null) pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      pstmt = null;
    }

    int mode = modeCombo.getSelectedIndex();
    //	No Products
    if (noProducts == 0 && mode == MODE_VIEW) {
      //	CButton button = ConfirmPanel.createNewButton(true);
      //	button.addActionListener(this);
      //	element.add(button);
    } else //	Additional Elements
    {
      if (mode == MODE_PRICE) {
        //	Price Field
      } else if (mode == MODE_PO) {
        //	Qty Field
      }
    }
    return element;
  } //	getGridElement
Example #9
0
  /** Create Grid */
  private void createGrid() {
    if (attributeCombo1 == null || m_setting) return; // 	init
    int indexAttr1 = attributeCombo1.getSelectedIndex();
    int indexAttr2 = attributeCombo2.getSelectedIndex();
    if (indexAttr1 == indexAttr2) {
      log.warning("Same Attribute Selected");
      tabbedPane.setSelectedIndex(0);
      return;
    }
    m_setting = true;
    m_M_PriceList_Version_ID = 0;
    KeyNamePair pl = (KeyNamePair) pickPriceList.getSelectedItem();
    if (pl != null) m_M_PriceList_Version_ID = pl.getKey();
    m_M_Warehouse_ID = 0;
    KeyNamePair wh = (KeyNamePair) pickWarehouse.getSelectedItem();
    if (wh != null) m_M_Warehouse_ID = wh.getKey();

    //	x dimension
    int cols = 2;
    MAttributeValue[] xValues = null;
    if (indexAttr1 > 0) xValues = m_attributes[indexAttr1 - 1].getMAttributeValues();
    if (xValues != null) {
      cols = xValues.length;
      log.info("X - " + m_attributes[indexAttr1 - 1].getName() + " #" + xValues.length);
    }

    //	y dimension
    int rows = 2;
    MAttributeValue[] yValues = null;
    if (indexAttr2 > 0) yValues = m_attributes[indexAttr2 - 1].getMAttributeValues();
    if (yValues != null) {
      rows = yValues.length;
      log.info("Y - " + m_attributes[indexAttr2 - 1].getName() + " #" + yValues.length);
    }

    //
    gridPanel.removeAll();
    CPanel grid = new CPanel(new GridLayout(rows, cols, 5, 5));
    gridPanel.add(modePanel, BorderLayout.NORTH);
    gridPanel.add(new CScrollPane(grid), BorderLayout.CENTER);
    //
    log.info("Rows=" + rows + " - Cols=" + cols);
    for (int row = 0; row < rows; row++) {
      for (int col = 0; col < cols; col++) {
        MAttributeValue xValue = null;
        if (xValues != null) xValue = xValues[col];
        MAttributeValue yValue = null;
        if (yValues != null) yValue = yValues[row];
        //	log.fine("Row=" + row + " - Col=" + col);
        //
        if (row == 0 && col == 0) {
          CPanel descr = new CPanel(new GridLayout(2, 1, 0, 0));
          if (xValues != null)
            descr.add(new JLabel(m_attributes[indexAttr1 - 1].getName(), JLabel.TRAILING));
          if (yValues != null) descr.add(new JLabel(m_attributes[indexAttr2 - 1].getName()));
          grid.add(descr);
        } else if (row == 0) // 	column labels
        {
          if (xValue != null) {
            grid.add(new JLabel(xValue.getName(), JLabel.TRAILING));
          } else grid.add(new JLabel());
        } else if (col == 0) // 	row labels
        {
          if (yValue != null) grid.add(new JLabel(yValue.getName()));
          else grid.add(new JLabel());
        } else {
          grid.add(getGridElement(xValue, yValue));
        }
      }
    }
    //
    tabbedPane.setSelectedIndex(1);
    m_setting = false;
    m_frame.pack();
  } //	createGrid
  private void tableInit() {

    m_sql = new StringBuffer();
    m_sql2 = new StringBuffer();

    // Mostrar todos los ACC y AAP
    if (tableInit_option == 0) {
      m_sql.append(
          "select cb.value ||'-'|| cb.name vendor, co.name country, extract(month from cn.CREATED) month,"
              + " extract (year from cn.CREATED) year, NVL(round(sum(cn.XX_UNITPURCHASEPRICEBS),2),0) total,"
              + " dep.value || '-' || dep.name department, cat.value || '-' || cat.name category,"
              + " o.XX_VMR_DEPARTMENT_ID, o.XX_VMR_CATEGORY_ID, o.C_BPARTNER_ID vendorID"
              + " from  XX_CREDITNOTIFYRETURN cn, C_BPARTNER cb, C_COUNTRY co, C_ORDER o, XX_VMR_DEPARTMENT dep, XX_VMR_CATEGORY cat"
              + " where o.C_BPARTNER_ID=cb.C_BPARTNER_ID and co.C_COUNTRY_ID=o.C_COUNTRY_ID and"
              + " cn.XX_NOTIFICATIONTYPE='ACC'and cn.C_ORDER_ID=o.C_ORDER_ID and"
              + " dep.XX_VMR_DEPARTMENT_ID=o.XX_VMR_DEPARTMENT_ID and o.XX_VMR_CATEGORY_ID=cat.XX_VMR_CATEGORY_ID and o.AD_CLIENT_ID="
              + ctx.getAD_Client_ID()
              + " AND o.ISSOTRX = 'N'");

      m_groupBy =
          " group by cb.value ||'-'|| cb.name, co.name,  extract(month from cn.CREATED), extract (year from cn.CREATED), dep.value || '-' || dep.name,"
              + " cat.value || '-' || cat.name,o.XX_VMR_DEPARTMENT_ID, o.XX_VMR_CATEGORY_ID, o.C_BPARTNER_ID";

      m_sql2.append(
          "select cb.value ||'-'|| cb.name vendor, co.name country, det.XX_MONTH month,"
              + " det.XX_YEAR year, round(cn.XX_UNITPURCHASEPRICEBS,2) total, o.C_BPARTNER_ID vendorID,"
              + " o.XX_VMR_DEPARTMENT_ID, o.XX_VMR_CATEGORY_ID, cn.XX_CREDITNOTIFYRETURN_ID creditNotID, cn.XX_NOTIFICATIONTYPE tipo"
              + " from  XX_CREDITNOTIFYRETURN cn, C_BPARTNER cb, C_COUNTRY co, C_ORDER o, XX_VMR_DEPARTMENT dep, XX_VMR_CATEGORY cat, XX_VCN_DETAILADVICE det"
              + " where o.C_BPARTNER_ID=cb.C_BPARTNER_ID and co.C_COUNTRY_ID=o.C_COUNTRY_ID and cn.XX_NOTIFICATIONTYPE<>'ACC'"
              + " and cn.C_ORDER_ID=o.C_ORDER_ID and dep.XX_VMR_DEPARTMENT_ID=o.XX_VMR_DEPARTMENT_ID"
              + " and o.XX_VMR_CATEGORY_ID=cat.XX_VMR_CATEGORY_ID and det.XX_CREDITNOTIFYRETURN_ID=cn.XX_CREDITNOTIFYRETURN_ID and o.AD_CLIENT_ID="
              + ctx.getAD_Client_ID()
              + " AND o.ISSOTRX = 'N'");

      m_groupBy2 =
          " group by cb.value ||'-'|| cb.name, co.name,  det.XX_MONTH, det.XX_YEAR, cn.XX_UNITPURCHASEPRICEBS,"
              + " o.XX_VMR_DEPARTMENT_ID, o.XX_VMR_CATEGORY_ID, o.C_BPARTNER_ID, cn.XX_CREDITNOTIFYRETURN_ID, cn.XX_NOTIFICATIONTYPE";
      // Búsqueda por mes
      if (monthCombo.getSelectedIndex() != 0 && monthCombo.getSelectedItem() != null) {
        m_sql
            .append(" AND ")
            .append("extract(month from cn.created)=")
            .append(monthCombo.getSelectedIndex());
        m_sql2.append(" AND ").append("det.XX_MONTH=").append(monthCombo.getSelectedIndex());
      }
      // Búsqueda por año
      if (yearField.getValue() != null) {
        m_sql
            .append(" AND ")
            .append("extract(year from cn.created)=")
            .append(((BigDecimal) yearField.getValue()).intValue());
        m_sql2
            .append(" AND ")
            .append("det.XX_YEAR=")
            .append(((BigDecimal) yearField.getValue()).intValue());
      }
      // Búsqueda por proveedor
      if (comboBPartner.getSelectedIndex() != 0 && comboBPartner.getSelectedItem() != null) {
        if (((KeyNamePair) comboBPartner.getSelectedItem()).getKey() != 0) {
          int clave_vendor = ((KeyNamePair) comboBPartner.getSelectedItem()).getKey();
          m_sql.append(" AND ").append("o.C_BPartner_ID=").append(clave_vendor);
          m_sql2.append(" AND ").append("o.C_BPartner_ID=").append(clave_vendor);
        }
      }

      // agrego la categoria
      if (categoryCombo.getValue() != null) {
        KeyNamePair cat = (KeyNamePair) categoryCombo.getValue();
        if (cat.getKey() != -1) {
          m_sql.append(" AND o.XX_VMR_CATEGORY_ID = ").append(cat.getKey()).append(" ");
          m_sql2.append(" AND o.XX_VMR_CATEGORY_ID = ").append(cat.getKey()).append(" ");
        }
      }
      // agrego el departamento al query
      if (departmentCombo.getValue() != null) {
        KeyNamePair dep = (KeyNamePair) departmentCombo.getValue();
        if (dep.getKey() != -1) {
          m_sql.append(" AND o.XX_VMR_DEPARTMENT_ID = ").append(dep.getKey()).append(" ");
          m_sql2.append(" AND o.XX_VMR_DEPARTMENT_ID = ").append(dep.getKey()).append(" ");
        }
      }
    }

    String SQL = m_sql.toString() + m_groupBy;

    int i = 0;
    xTableACC.setRowCount(i);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(SQL, null);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        xTableACC.setRowCount(i + 1);
        // Proveedor
        xTableACC.setValueAt(rs.getString("vendor"), i, 0); // 1
        // País
        xTableACC.setValueAt(rs.getString("country"), i, 1);
        // Departamento
        xTableACC.setValueAt(rs.getString("department"), i, 2);
        // Categoría
        xTableACC.setValueAt(rs.getString("category"), i, 3);
        // Mes
        xTableACC.setValueAt(rs.getInt("month"), i, 4);
        // Año
        xTableACC.setValueAt(rs.getInt("year"), i, 5);
        // Compras hechas
        xTableACC.setValueAt(rs.getBigDecimal("total"), i, 6);

        // Se calculan los avisos cerrados(CER) de el mismo mes, año, proveedor, depto y categoría
        String SQL2 =
            "select nvl(round(sum(cn.XX_AMOUNT),2),0) totalDesc"
                + " from  XX_CREDITNOTIFYRETURN cn, C_BPARTNER cb, C_COUNTRY co, C_ORDER o, XX_VMR_DEPARTMENT dep, XX_VMR_CATEGORY cat"
                + " where o.C_BPARTNER_ID=cb.C_BPARTNER_ID and co.C_COUNTRY_ID=o.C_COUNTRY_ID"
                + " and cn.XX_NOTIFICATIONTYPE='ACC' and cn.C_ORDER_ID=o.C_ORDER_ID"
                + " and dep.XX_VMR_DEPARTMENT_ID=o.XX_VMR_DEPARTMENT_ID and o.XX_VMR_CATEGORY_ID=cat.XX_VMR_CATEGORY_ID"
                + " and XX_STATUS='CER' and extract(month from cn.CREATED)="
                + rs.getInt("month")
                + " and extract (year from cn.CREATED)="
                + rs.getInt("year")
                + " and o.C_BPARTNER_ID="
                + rs.getInt("vendorID")
                + " and o.AD_CLIENT_ID="
                + ctx.getAD_Client_ID()
                + " AND o.ISSOTRX = 'N'";
        PreparedStatement pstmt2 = null;
        ResultSet rs2 = null;

        try {
          pstmt2 = DB.prepareStatement(SQL2, null);
          rs2 = pstmt2.executeQuery();
          if (rs2.next()) xTableACC.setValueAt(rs2.getBigDecimal("totalDesc"), i, 7);
          else xTableACC.setValueAt(0, i, 7);
        } catch (SQLException e) {
          System.out.print(e.getMessage());
        } finally {
          DB.closeResultSet(rs2);
          DB.closeStatement(pstmt2);
        }

        // Se calculan los avisos pendientes(ACT) de el mismo mes, año, proveedor, depto y categoría
        String SQL3 =
            "select nvl(round(sum(cn.XX_AMOUNT),2),0) totalDesc"
                + " from  XX_CREDITNOTIFYRETURN cn, C_BPARTNER cb, C_COUNTRY co, C_ORDER o, XX_VMR_DEPARTMENT dep, XX_VMR_CATEGORY cat"
                + " where o.C_BPARTNER_ID=cb.C_BPARTNER_ID and co.C_COUNTRY_ID=o.C_COUNTRY_ID"
                + " and cn.XX_NOTIFICATIONTYPE='ACC' and cn.C_ORDER_ID=o.C_ORDER_ID"
                + " and dep.XX_VMR_DEPARTMENT_ID=o.XX_VMR_DEPARTMENT_ID and o.XX_VMR_CATEGORY_ID=cat.XX_VMR_CATEGORY_ID"
                + " and XX_STATUS='ACT' and extract(month from cn.CREATED)="
                + rs.getInt("month")
                + " and extract (year from cn.CREATED)="
                + rs.getInt("year")
                + " and o.C_BPARTNER_ID="
                + rs.getInt("vendorID")
                + " and o.AD_CLIENT_ID="
                + ctx.getAD_Client_ID()
                + " AND o.ISSOTRX = 'N'";
        PreparedStatement pstmt3 = null;
        ResultSet rs3 = null;
        try {
          pstmt3 = DB.prepareStatement(SQL3, null);
          rs3 = pstmt3.executeQuery();
          if (rs3.next()) xTableACC.setValueAt(rs3.getBigDecimal("totalDesc"), i, 8);
          else xTableACC.setValueAt(0, i, 8);
        } catch (SQLException e) {
          System.out.print(e.getMessage());
        } finally {
          DB.closeResultSet(rs3);
          DB.closeStatement(pstmt3);
        }

        i++;
      }

    } catch (SQLException e) {
      e.getMessage();
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }

    String sqlAAP = m_sql2.toString() + m_groupBy2;

    i = 0;
    xTableAAP.setRowCount(i);
    pstmt = null;
    rs = null;
    try {
      pstmt = DB.prepareStatement(sqlAAP, null);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        xTableAAP.setRowCount(i + 1);
        // Proveedor
        xTableAAP.setValueAt(
            new KeyNamePair(rs.getInt("vendorID"), rs.getString("vendor")), i, 0); // 1
        // País
        xTableAAP.setValueAt(
            new KeyNamePair(rs.getInt("creditNotID"), rs.getString("country")), i, 1);
        // Mes
        xTableAAP.setValueAt(rs.getInt("month"), i, 2);
        // Año
        xTableAAP.setValueAt(rs.getInt("year"), i, 3);
        // Tipo
        xTableAAP.setValueAt(rs.getString("tipo"), i, 4);
        // Compras hechas
        xTableAAP.setValueAt(rs.getBigDecimal("total"), i, 5);

        // Se calculan los avisos cerrados(CER) de el mismo mes, año, proveedor, depto y categoría
        String SQL2 =
            "select nvl(round(sum(cn.XX_AMOUNT),2),0) totalDesc"
                + " from  XX_CREDITNOTIFYRETURN cn, C_BPARTNER cb, C_COUNTRY co, C_ORDER o, XX_VMR_DEPARTMENT dep, XX_VMR_CATEGORY cat"
                + " where o.C_BPARTNER_ID=cb.C_BPARTNER_ID and co.C_COUNTRY_ID=o.C_COUNTRY_ID"
                + " and cn.XX_NOTIFICATIONTYPE<>'ACC' and cn.C_ORDER_ID=o.C_ORDER_ID"
                + " and dep.XX_VMR_DEPARTMENT_ID=o.XX_VMR_DEPARTMENT_ID and o.XX_VMR_CATEGORY_ID=cat.XX_VMR_CATEGORY_ID"
                + " and XX_STATUS='CER' and cn.XX_CREDITNOTIFYRETURN_ID="
                + rs.getInt("creditNotID")
                + " and o.C_BPARTNER_ID="
                + rs.getInt("vendorID")
                + " and o.AD_CLIENT_ID="
                + ctx.getAD_Client_ID()
                + " AND o.ISSOTRX = 'N'";
        PreparedStatement pstmt2 = null;
        ResultSet rs2 = null;

        try {
          pstmt2 = DB.prepareStatement(SQL2, null);
          rs2 = pstmt2.executeQuery();
          if (rs2.next()) xTableAAP.setValueAt(rs2.getBigDecimal("totalDesc"), i, 6);
          else xTableAAP.setValueAt(0, i, 6);
        } catch (SQLException e) {
          System.out.print(e.getMessage());
        } finally {
          DB.closeResultSet(rs2);
          DB.closeStatement(pstmt2);
        }

        // Se calculan los avisos pendientes(ACT) de el mismo mes, año, proveedor, depto y categoría
        String SQL3 =
            "select nvl(round(sum(cn.XX_AMOUNT),2),0) totalDesc"
                + " from  XX_CREDITNOTIFYRETURN cn, C_BPARTNER cb, C_COUNTRY co, C_ORDER o, XX_VMR_DEPARTMENT dep, XX_VMR_CATEGORY cat"
                + " where o.C_BPARTNER_ID=cb.C_BPARTNER_ID and co.C_COUNTRY_ID=o.C_COUNTRY_ID"
                + " and cn.XX_NOTIFICATIONTYPE<>'ACC' and cn.C_ORDER_ID=o.C_ORDER_ID"
                + " and dep.XX_VMR_DEPARTMENT_ID=o.XX_VMR_DEPARTMENT_ID and o.XX_VMR_CATEGORY_ID=cat.XX_VMR_CATEGORY_ID"
                + " and XX_STATUS='ACT' and cn.XX_CREDITNOTIFYRETURN_ID="
                + rs.getInt("creditNotID")
                + " and o.C_BPARTNER_ID="
                + rs.getInt("vendorID")
                + " and o.AD_CLIENT_ID="
                + ctx.getAD_Client_ID()
                + " AND o.ISSOTRX = 'N'";
        PreparedStatement pstmt3 = null;
        ResultSet rs3 = null;
        try {
          pstmt3 = DB.prepareStatement(SQL3, null);
          rs3 = pstmt3.executeQuery();
          if (rs3.next()) xTableAAP.setValueAt(rs3.getBigDecimal("totalDesc"), i, 7);
          else xTableAAP.setValueAt(0, i, 7);
        } catch (SQLException e) {
          System.out.print(e.getMessage());
        } finally {
          DB.closeResultSet(rs3);
          DB.closeStatement(pstmt3);
        }

        i++;
      }

    } catch (SQLException e) {
      e.getMessage();
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
  } //  tableInit
Example #11
0
  /**
   * Descripción de Método
   *
   * @param e
   * @param rightClick
   */
  private void mouse_clicked(MouseEvent e, boolean rightClick) {
    Point point = e.getPoint();

    log.info("Right=" + rightClick + " - " + point.toString());

    if (rightClick) {
      m_ddQ = m_viewPanel.getDrillDown(point);
      m_daQ = m_viewPanel.getDrillAcross(point);
      m_ddM = null;
      m_daM = null;

      if ((m_ddQ == null) && (m_daQ == null)) {
        return;
      }

      // Create Menu

      JPopupMenu pop = new JPopupMenu();
      Icon wi = Env.getImageIcon("mWindow.gif");

      if (m_ddQ != null) {
        m_ddM = new JMenuItem(m_ddQ.getDisplayName(Env.getCtx()), wi);
        m_ddM.setToolTipText(m_ddQ.toString());
        m_ddM.addActionListener(this);
        pop.add(m_ddM);
      }

      if (m_daQ != null) {
        m_daM = new JMenuItem(m_daQ.getDisplayName(Env.getCtx()), wi);
        m_daM.setToolTipText(m_daQ.toString());
        m_daM.addActionListener(this);
        pop.add(m_daM);
      }

      Point pp = e.getPoint();

      pop.show((Component) e.getSource(), pp.x, pp.y);

      return;
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    if (m_drillDown) {
      MQuery query = m_viewPanel.getDrillDown(point);

      if (query != null) {
        log.info("Drill Down: " + query.getWhereClause(true));
        executeDrill(query);
      }
    } else if ((comboDrill.getSelectedItem() != null) && (comboDrill.getSelectedIndex() > 0)) {
      MQuery query = m_viewPanel.getDrillAcross(point);

      if (query != null) {
        NamePair pp = (NamePair) comboDrill.getSelectedItem();

        query.setTableName(pp.getID());
        log.info("Drill Accross: " + query.getWhereClause(true));
        executeDrill(query);
      }
    }

    cmd_drill(); // setCursor
  } // mouse_clicked