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.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.List;
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
@ -49,6 +49,23 @@ public class MPOS extends X_C_POS
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get
|
} // 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 */
|
/** Cache */
|
||||||
private static CCache<Integer,MPOS> s_cache = new CCache<Integer,MPOS>("C_POS", 20);
|
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)
|
private MPOS[] getPOSs (int SalesRep_ID)
|
||||||
{
|
{
|
||||||
ArrayList<MPOS> list = new ArrayList<MPOS>();
|
String pass_field = "SalesRep_ID";
|
||||||
String sql = "SELECT * FROM C_POS WHERE SalesRep_ID=?";
|
int pass_ID = 0;
|
||||||
if (SalesRep_ID == 0)
|
if (SalesRep_ID==0)
|
||||||
sql = "SELECT * FROM C_POS WHERE AD_Client_ID=?";
|
{
|
||||||
PreparedStatement pstmt = null;
|
pass_field = "AD_Client_ID";
|
||||||
try
|
pass_ID = Env.getAD_Client_ID(m_ctx);
|
||||||
{
|
}
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
MPOS[] allPOSes = MPOS.getAll(m_ctx, pass_field, pass_ID);
|
||||||
if (SalesRep_ID != 0)
|
return allPOSes;
|
||||||
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;
|
|
||||||
} // getPOSs
|
} // getPOSs
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Visible
|
* Set Visible
|
||||||
|
|
Loading…
Reference in New Issue