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()));
}
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);
}
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()));
}
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();
}
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;
}
Aggregations