/** Refresh Query */ private void refresh() { String sql = m_sql; int pos = m_sql.lastIndexOf(" ORDER BY "); if (!showAll.isSelected()) { sql = m_sql.substring(0, pos) + s_sqlWhereSameWarehouse; if (s_sqlMinLife.length() > 0) sql += s_sqlMinLife; sql += m_sql.substring(pos); } // log.finest(sql); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, m_M_Product_ID); if (!showAll.isSelected()) { pstmt.setInt(2, m_M_Warehouse_ID); } rs = pstmt.executeQuery(); m_table.loadTable(rs); } catch (Exception e) { log.log(Level.SEVERE, sql, e); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; } enableButtons(); }
/** * Fill the table using m_sql * * @param table table */ private static void tableLoad(MiniTable table) { // log.finest(m_sql + " - " + m_groupBy); String sql = MRole.getDefault() .addAccessSQL(m_sql.toString(), "tab", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO) + m_groupBy + m_orderBy; log.finest(sql); try { Statement stmt = DB.createStatement(); ResultSet rs = stmt.executeQuery(sql); table.loadTable(rs); stmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } } // tableLoad
/** Refresh Query */ private void refresh(Object obj, int M_Warehouse_ID, int M_PriceList_Version_ID) { // int M_Product_ID = 0; String sql = m_sqlWarehouse; // Add description to the query sql = sql.replace(" FROM", ", DocumentNote FROM"); log.finest(sql); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, null); pstmt.setString(1, (String) obj); rs = pstmt.executeQuery(); fieldDescription.setText(""); warehouseTbl.loadTable(rs); rs = pstmt.executeQuery(); if (rs.next()) if (rs.getString("DocumentNote") != null) fieldDescription.setText(rs.getString("DocumentNote")); } catch (Exception e) { log.log(Level.WARNING, sql, e); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; } m_M_Product_ID = getSelectedRowKey(); sql = m_sqlSubstitute; log.finest(sql); try { pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(2, M_PriceList_Version_ID); rs = pstmt.executeQuery(); substituteTbl.loadTable(rs); rs.close(); } catch (Exception e) { log.log(Level.WARNING, sql, e); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; } sql = m_sqlRelated; log.finest(sql); try { pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(2, M_PriceList_Version_ID); rs = pstmt.executeQuery(); relatedTbl.loadTable(rs); rs.close(); } catch (Exception e) { log.log(Level.WARNING, sql, e); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; } initAtpTab(M_Warehouse_ID); } // refresh