Search in sources :

Example 71 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class InOutGen method executeQuery.

/**
	 *  Query Info
	 */
public void executeQuery(KeyNamePair docTypeKNPair, IMiniTable miniTable) {
    log.info("");
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    String sql = "";
    if (docTypeKNPair.getKey() == MRMA.Table_ID) {
        sql = getRMASql();
    } else {
        sql = getOrderSQL();
    }
    log.fine(sql);
    //  reset table
    int row = 0;
    miniTable.setRowCount(row);
    //  Execute
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
        pstmt.setInt(1, AD_Client_ID);
        ResultSet rs = pstmt.executeQuery();
        //
        while (rs.next()) {
            //  extend table
            miniTable.setRowCount(row + 1);
            //  set values
            //  C_Order_ID
            miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0);
            //  Org
            miniTable.setValueAt(rs.getString(2), row, 1);
            //  DocType
            miniTable.setValueAt(rs.getString(3), row, 2);
            //  Doc No
            miniTable.setValueAt(rs.getString(4), row, 3);
            //  BPartner
            miniTable.setValueAt(rs.getString(5), row, 4);
            //  DateOrdered
            miniTable.setValueAt(rs.getTimestamp(6), row, 5);
            //  TotalLines
            miniTable.setValueAt(rs.getBigDecimal(7), row, 6);
            //  prepare next
            row++;
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql.toString(), e);
    }
    //
    miniTable.autoSize();
//	statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 72 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class InvoiceGen method saveSelection.

//  executeQuery
/**
	 *	Save Selection & return selecion Query or ""
	 *  @return where clause like C_Order_ID IN (...)
	 */
public void saveSelection(IMiniTable miniTable) {
    log.info("");
    //  Array of Integers
    ArrayList<Integer> results = new ArrayList<Integer>();
    setSelection(null);
    //	Get selected entries
    int rows = miniTable.getRowCount();
    for (int i = 0; i < rows; i++) {
        //  ID in column 0
        IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
        //	log.fine( "Row=" + i + " - " + id);
        if (id != null && id.isSelected())
            results.add(id.getRecord_ID());
    }
    if (results.size() == 0)
        return;
    log.config("Selected #" + results.size());
    setSelection(results);
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) ArrayList(java.util.ArrayList)

Example 73 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class InvoiceGen method executeQuery.

/**
	 *  Query Info
	 */
public void executeQuery(KeyNamePair docTypeKNPair, IMiniTable miniTable) {
    log.info("");
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    //  Create SQL
    String sql = "";
    if (docTypeKNPair.getKey() == MOrder.Table_ID) {
        sql = getOrderSQL();
    } else {
        sql = getRMASql();
    }
    //  reset table
    int row = 0;
    miniTable.setRowCount(row);
    //  Execute
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
        pstmt.setInt(1, AD_Client_ID);
        ResultSet rs = pstmt.executeQuery();
        //
        while (rs.next()) {
            //  extend table
            miniTable.setRowCount(row + 1);
            //  set values
            //  C_Order_ID
            miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0);
            //  Org
            miniTable.setValueAt(rs.getString(2), row, 1);
            //  DocType
            miniTable.setValueAt(rs.getString(3), row, 2);
            //  Doc No
            miniTable.setValueAt(rs.getString(4), row, 3);
            //  BPartner
            miniTable.setValueAt(rs.getString(5), row, 4);
            //  DateOrdered
            miniTable.setValueAt(rs.getTimestamp(6), row, 5);
            //  TotalLines
            miniTable.setValueAt(rs.getBigDecimal(7), row, 6);
            //  prepare next
            row++;
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql.toString(), e);
    }
    //
    miniTable.autoSize();
//	statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 74 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class PaySelect method calculateSelection.

//  loadTableInfo
/**
	 *  Calculate selected rows.
	 *  - add up selected rows
	 */
public String calculateSelection(IMiniTable miniTable) {
    m_noSelected = 0;
    m_sum = new BigDecimal(0.0);
    int rows = miniTable.getRowCount();
    if (rows > 0) {
        for (// Count the rest - this will remove de-selections
        int i = 0; // Count the rest - this will remove de-selections
        i < rows; // Count the rest - this will remove de-selections
        i++) {
            IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
            BigDecimal amt = (BigDecimal) miniTable.getValueAt(i, 10);
            if (id.isSelected()) {
                amt = (BigDecimal) miniTable.getValueAt(i, 10);
                if (amt != null)
                    m_sum = m_sum.add(amt);
                m_noSelected++;
            }
        }
    }
    //  Information
    BigDecimal remaining = m_bankBalance.subtract(m_sum);
    StringBuffer info = new StringBuffer();
    info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" - ");
    info.append(m_format.format(m_sum)).append(", ");
    info.append(Msg.getMsg(Env.getCtx(), "Remaining")).append(" ").append(m_format.format(remaining));
    return info.toString();
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) BigDecimal(java.math.BigDecimal)

Example 75 with IDColumn

use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.

the class Browser method selectedRows.

// saveSelection
/**
	 * FR [ 245 ]
	 */
public void selectedRows(IBrowserTable browserTable) {
    int topIndex = browserTable.isShowTotals() ? 2 : 1;
    int rows = browserTable.getRowCount();
    if (isAllSelected) {
        for (int row = 0; row <= rows - topIndex; row++) {
            Object data = browserTable.getValueAt(row, m_keyColumnIndex);
            if (data instanceof IDColumn) {
                IDColumn dataColumn = (IDColumn) data;
                dataColumn.setSelected(true);
                browserTable.setValueAt(dataColumn, row, m_keyColumnIndex);
            }
        }
    } else {
        for (int row = 0; row <= rows - topIndex; row++) {
            Object data = browserTable.getValueAt(row, m_keyColumnIndex);
            if (data instanceof IDColumn) {
                IDColumn dataColumn = (IDColumn) data;
                dataColumn.setSelected(false);
                browserTable.setValueAt(dataColumn, row, m_keyColumnIndex);
            }
        }
    }
    isAllSelected = !isAllSelected;
}
Also used : IDColumn(org.compiere.minigrid.IDColumn)

Aggregations

IDColumn (org.compiere.minigrid.IDColumn)79 SQLException (java.sql.SQLException)25 BigDecimal (java.math.BigDecimal)20 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)20 ArrayList (java.util.ArrayList)16 KeyNamePair (org.compiere.util.KeyNamePair)13 Timestamp (java.sql.Timestamp)8 Vector (java.util.Vector)5 GridField (org.compiere.model.GridField)5 MBrowseField (org.adempiere.model.MBrowseField)4 ApplicationException (org.adempiere.webui.exception.ApplicationException)4 SimpleDateFormat (java.text.SimpleDateFormat)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 PO (org.compiere.model.PO)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 DecimalFormat (java.text.DecimalFormat)2 Date (java.util.Date)2 ChangeEvent (javax.swing.event.ChangeEvent)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2