IDEMPIERE-524 Product Info Windows, Description Tab does not show DocumentNote

This commit is contained in:
Carlos Ruiz 2012-12-20 11:26:15 -05:00
parent 506e1eb6fd
commit beeac4449a
2 changed files with 40 additions and 70 deletions

View File

@ -302,7 +302,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
/** Where Clause */ /** Where Clause */
String s_sqlWhere = "Value = ?"; String s_sqlWhere = "Value = ?";
m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V"); m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
m_sqlWarehouse += " Group By Warehouse, documentnote "; m_sqlWarehouse += " GROUP BY Warehouse";
warehouseTbl.setRowSelectionAllowed(true); warehouseTbl.setRowSelectionAllowed(true);
warehouseTbl.setMultiSelection(false); warehouseTbl.setMultiSelection(false);
warehouseTbl.addMouseListener(this); warehouseTbl.addMouseListener(this);
@ -368,7 +368,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceLimit", Double.class)); list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceLimit", Double.class));
ColumnInfo[] s_layoutProductPrice = new ColumnInfo[list.size()]; ColumnInfo[] s_layoutProductPrice = new ColumnInfo[list.size()];
list.toArray(s_layoutProductPrice); list.toArray(s_layoutProductPrice);
s_sqlFrom = "M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID"; s_sqlFrom = "M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON (pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID)";
s_sqlWhere = "pp.M_Product_ID = ? AND plv.IsActive = 'Y' AND pp.IsActive = 'Y'"; s_sqlWhere = "pp.M_Product_ID = ? AND plv.IsActive = 'Y' AND pp.IsActive = 'Y'";
m_sqlProductprice = productpriceTbl.prepareTable(s_layoutProductPrice, s_sqlFrom, s_sqlWhere, false, "pp") + " ORDER BY plv.ValidFrom DESC"; m_sqlProductprice = productpriceTbl.prepareTable(s_layoutProductPrice, s_sqlFrom, s_sqlWhere, false, "pp") + " ORDER BY plv.ValidFrom DESC";
productpriceTbl.setRowSelectionAllowed(false); productpriceTbl.setRowSelectionAllowed(false);
@ -427,8 +427,6 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
{ {
//int M_Product_ID = 0; //int M_Product_ID = 0;
String sql = m_sqlWarehouse; String sql = m_sqlWarehouse;
//Add description to the query
sql = sql.replace(" FROM", ", DocumentNote FROM");
log.finest(sql); log.finest(sql);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -450,27 +448,8 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
} }
m_M_Product_ID = getSelectedRowKey(); m_M_Product_ID = getSelectedRowKey();
sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID = ?;"; sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID=?";
fieldDescription.setText(DB.getSQLValueString(null, sql, m_M_Product_ID));
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
fieldDescription.setText("");
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;
}
sql = m_sqlSubstitute; sql = m_sqlSubstitute;
log.finest(sql); log.finest(sql);
@ -480,7 +459,6 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
pstmt.setInt(2, M_PriceList_Version_ID); pstmt.setInt(2, M_PriceList_Version_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
substituteTbl.loadTable(rs); substituteTbl.loadTable(rs);
rs.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, sql, e); log.log(Level.WARNING, sql, e);
} }
@ -498,7 +476,6 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
pstmt.setInt(2, M_PriceList_Version_ID); pstmt.setInt(2, M_PriceList_Version_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
relatedTbl.loadTable(rs); relatedTbl.loadTable(rs);
rs.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, sql, e); log.log(Level.WARNING, sql, e);
} }
@ -517,7 +494,6 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
productpriceTbl.loadTable(rs); productpriceTbl.loadTable(rs);
rs.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, sql, e); log.log(Level.WARNING, sql, e);
} }
@ -618,6 +594,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
pickPriceList.addItem(kn); pickPriceList.addItem(kn);
} }
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null; pstmt = null;
// Warehouse // Warehouse
SQL = MRole.getDefault().addAccessSQL ( SQL = MRole.getDefault().addAccessSQL (
@ -636,6 +613,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener
pickWarehouse.addItem(kn); pickWarehouse.addItem(kn);
} }
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null; pstmt = null;
// Product Category // Product Category
SQL = MRole.getDefault().addAccessSQL ( SQL = MRole.getDefault().addAccessSQL (

View File

@ -386,7 +386,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
/** Where Clause */ /** Where Clause */
String s_sqlWhere = "Value = ?"; String s_sqlWhere = "Value = ?";
m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V"); m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
m_sqlWarehouse += " Group By Warehouse, documentnote "; m_sqlWarehouse += " GROUP BY Warehouse";
warehouseTbl.setMultiSelection(false); warehouseTbl.setMultiSelection(false);
warehouseTbl.setShowTotals(true); warehouseTbl.setShowTotals(true);
warehouseTbl.autoSize(); warehouseTbl.autoSize();
@ -626,23 +626,27 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
log.finer(sqlCount); log.finer(sqlCount);
m_count = -1; m_count = -1;
PreparedStatement pstmt = null;
ResultSet rs = null;;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sqlCount, null); pstmt = DB.prepareStatement(sqlCount, null);
setParameters (pstmt, false); setParameters (pstmt, false);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
m_count = rs.getInt(1); m_count = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sqlCount, e); log.log(Level.SEVERE, sqlCount, e);
m_count = -2; m_count = -2;
} }
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
log.fine("#" + m_count + " - " + (System.currentTimeMillis()-start) + "ms"); log.fine("#" + m_count + " - " + (System.currentTimeMillis()-start) + "ms");
@ -663,8 +667,6 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
{ {
//int M_Product_ID = 0; //int M_Product_ID = 0;
String sql = m_sqlWarehouse; String sql = m_sqlWarehouse;
//Add description to the query
sql = sql.replace(" FROM", ", DocumentNote FROM");
log.finest(sql); log.finest(sql);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -686,27 +688,8 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
} }
m_M_Product_ID = getSelectedRowKey(); m_M_Product_ID = getSelectedRowKey();
sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID = ?;"; sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID=?";
fieldDescription.setText(DB.getSQLValueString(null, sql, m_M_Product_ID));
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
fieldDescription.setText("");
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;
}
sql = m_sqlSubstitute; sql = m_sqlSubstitute;
log.finest(sql); log.finest(sql);
@ -716,7 +699,6 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
pstmt.setInt(2, M_PriceList_Version_ID); pstmt.setInt(2, M_PriceList_Version_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
substituteTbl.loadTable(rs); substituteTbl.loadTable(rs);
rs.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, sql, e); log.log(Level.WARNING, sql, e);
} }
@ -734,7 +716,6 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
pstmt.setInt(2, M_PriceList_Version_ID); pstmt.setInt(2, M_PriceList_Version_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
relatedTbl.loadTable(rs); relatedTbl.loadTable(rs);
rs.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, sql, e); log.log(Level.WARNING, sql, e);
} }
@ -753,7 +734,6 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
productpriceTbl.loadTable(rs); productpriceTbl.loadTable(rs);
rs.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, sql, e); log.log(Level.WARNING, sql, e);
} }
@ -826,17 +806,19 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
// Add Access & Order // Add Access & Order
SQL = MRole.getDefault().addAccessSQL (SQL, "M_PriceList_Version", true, false) // fully qualidfied - RO SQL = MRole.getDefault().addAccessSQL (SQL, "M_PriceList_Version", true, false) // fully qualidfied - RO
+ " ORDER BY M_PriceList_Version.Name"; + " ORDER BY M_PriceList_Version.Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pickPriceList.appendItem("",new Integer(0)); pickPriceList.appendItem("",new Integer(0));
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
pickPriceList.appendItem(rs.getString(2),new Integer(rs.getInt(1))); pickPriceList.appendItem(rs.getString(2),new Integer(rs.getInt(1)));
} }
rs.close(); DB.close(rs, pstmt);
pstmt.close(); rs = null; pstmt = null;
// Warehouse // Warehouse
SQL = MRole.getDefault().addAccessSQL ( SQL = MRole.getDefault().addAccessSQL (
@ -852,8 +834,8 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
{ {
pickWarehouse.appendItem(rs.getString("ValueName"), new Integer(rs.getInt("M_Warehouse_ID"))); pickWarehouse.appendItem(rs.getString("ValueName"), new Integer(rs.getInt("M_Warehouse_ID")));
} }
rs.close(); DB.close(rs, pstmt);
pstmt.close(); rs = null; pstmt = null;
// Elaine 2008/11/21 // Elaine 2008/11/21
// Product Category // Product Category
@ -879,6 +861,11 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
setStatusLine(e.getLocalizedMessage(), true); setStatusLine(e.getLocalizedMessage(), true);
} }
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} // fillPicks } // fillPicks
/** /**
@ -951,24 +938,29 @@ public class InfoProductPanel extends InfoPanel implements EventListener<Event>
+ " AND pl.M_PriceList_ID=? " // 1 + " AND pl.M_PriceList_ID=? " // 1
+ "ORDER BY plv.ValidFrom DESC"; + "ORDER BY plv.ValidFrom DESC";
// find newest one // find newest one
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_PriceList_ID); pstmt.setInt(1, M_PriceList_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next() && retValue == 0) while (rs.next() && retValue == 0)
{ {
Timestamp plDate = rs.getTimestamp(2); Timestamp plDate = rs.getTimestamp(2);
if (!priceDate.before(plDate)) if (!priceDate.before(plDate))
retValue = rs.getInt(1); retValue = rs.getInt(1);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
Env.setContext(Env.getCtx(), p_WindowNo, "M_PriceList_Version_ID", retValue); Env.setContext(Env.getCtx(), p_WindowNo, "M_PriceList_Version_ID", retValue);
return retValue; return retValue;
} // findPLV } // findPLV