public static boolean isCategory(int M_Product_Category_ID,int M_Product_ID){
  if (M_Product_ID == 0 || M_Product_Category_ID == 0)   return false;
  Integer product=new Integer(M_Product_ID);
  Integer category=(Integer)s_products.get(product);
  if (category != null)   return category.intValue() == M_Product_Category_ID;
  String sql="SELECT M_Product_Category_ID FROM M_Product WHERE M_Product_ID=?";
  PreparedStatement pstmt=null;
  try {
    pstmt=DB.prepareStatement(sql,null);
    pstmt.setInt(1,M_Product_ID);
    ResultSet rs=pstmt.executeQuery();
    if (rs.next())     category=new Integer(rs.getInt(1));
    rs.close();
    pstmt.close();
    pstmt=null;
  }
 catch (  Exception e) {
    s_log.log(Level.SEVERE,sql,e);
  }
  try {
    if (pstmt != null)     pstmt.close();
    pstmt=null;
  }
 catch (  Exception e) {
    pstmt=null;
  }
  if (category != null) {
    s_products.put(product,category);
    s_log.fine("M_Product_ID=" + M_Product_ID + "("+ category+ ") in M_Product_Category_ID="+ M_Product_Category_ID+ " - "+ (category.intValue() == M_Product_Category_ID));
    return category.intValue() == M_Product_Category_ID;
  }
  s_log.log(Level.SEVERE,"Not found M_Product_ID=" + M_Product_ID);
  return false;
}

public static boolean isCategory ( int M_Product_Category_ID , int M_Product_ID ) { if ( M_Product_ID == 0 || M_Product_Category_ID == 0 ) return false ; Integer product = new Integer ( M_Product_ID ) ; Integer category = ( Integer ) s_products . get ( product ) ; if ( category != null ) return category . intValue ( ) == M_Product_Category_ID ; String sql = "SELECT M_Product_Category_ID FROM M_Product WHERE M_Product_ID=?" ; PreparedStatement pstmt = null ; try { pstmt = DB . prepareStatement ( sql , null ) ; pstmt . setInt ( 1 , M_Product_ID ) ; ResultSet rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) category = new Integer ( rs . getInt ( 1 ) ) ; rs . close ( ) ; pstmt . close ( ) ; pstmt = null ; } catch ( Exception e ) { s_log . log ( Level . SEVERE , sql , e ) ; } try { if ( pstmt != null ) pstmt . close ( ) ; pstmt = null ; } catch ( Exception e ) { pstmt = null ; } if ( category != null ) { s_products . put ( product , category ) ; s_log . fine ( "M_Product_ID=" + M_Product_ID + "(" + category + ") in M_Product_Category_ID=" + M_Product_Category_ID + " - " + ( category . intValue ( ) == M_Product_Category_ID ) ) ; return category . intValue ( ) == M_Product_Category_ID ; } s_log . log ( Level . SEVERE , "Not found M_Product_ID=" + M_Product_ID ) ; return false ; }
is product in category
