FR#2538335 Swing POS: terminal selection
Refactoring to debug and solve easier. Issue is rs returns only POS_IDs. Why? Anyone knows? https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2538335&group_id=176962
This commit is contained in:
parent
7945180cc1
commit
4896450966
|
@ -18,7 +18,7 @@ package org.compiere.model;
|
|||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import java.util.List;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
|
@ -49,6 +49,23 @@ public class MPOS extends X_C_POS
|
|||
return retValue;
|
||||
} // get
|
||||
|
||||
/**
|
||||
* Get POSes for passed argument
|
||||
* @param ctx context
|
||||
* @param C_POS_ID id
|
||||
* @return POSes
|
||||
*/
|
||||
public static MPOS[] getAll (Properties ctx, String field, int ID)
|
||||
{
|
||||
String whereClause = field+"=?";
|
||||
List<MPOS> list = new Query(ctx, Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{ID})
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy(COLUMNNAME_Name)
|
||||
.list();
|
||||
return list.toArray(new MPOS[list.size()]);
|
||||
} // get
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MPOS> s_cache = new CCache<Integer,MPOS>("C_POS", 20);
|
||||
|
||||
|
|
|
@ -294,44 +294,16 @@ public class PosPanel extends CPanel
|
|||
*/
|
||||
private MPOS[] getPOSs (int SalesRep_ID)
|
||||
{
|
||||
ArrayList<MPOS> list = new ArrayList<MPOS>();
|
||||
String sql = "SELECT * FROM C_POS WHERE SalesRep_ID=?";
|
||||
if (SalesRep_ID == 0)
|
||||
sql = "SELECT * FROM C_POS WHERE AD_Client_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
if (SalesRep_ID != 0)
|
||||
pstmt.setInt (1, m_SalesRep_ID);
|
||||
else
|
||||
pstmt.setInt (1, Env.getAD_Client_ID(m_ctx));
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
list.add(new MPOS(m_ctx, rs, null));
|
||||
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;
|
||||
}
|
||||
MPOS[] retValue = new MPOS[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
String pass_field = "SalesRep_ID";
|
||||
int pass_ID = 0;
|
||||
if (SalesRep_ID==0)
|
||||
{
|
||||
pass_field = "AD_Client_ID";
|
||||
pass_ID = Env.getAD_Client_ID(m_ctx);
|
||||
}
|
||||
MPOS[] allPOSes = MPOS.getAll(m_ctx, pass_field, pass_ID);
|
||||
return allPOSes;
|
||||
} // getPOSs
|
||||
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
|
|
Loading…
Reference in New Issue