public static boolean isCashBookAssignedValid(Properties ctx,int terminalId,int cashBookId,String trxName) throws OperationException {
  boolean valid=false;
  StringBuffer sqlStmt=new StringBuffer();
  sqlStmt.append("SELECT COUNT(*) FROM U_POSTerminal ");
  sqlStmt.append("WHERE AD_Client_ID=? AND U_POSTerminal_ID<>? AND C_CashBook_ID=? ");
  sqlStmt.append("AND U_POSTerminal.IsActive='Y' ");
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  try {
    pstmt=DB.prepareStatement(sqlStmt.toString(),trxName);
    pstmt.setInt(1,Env.getAD_Client_ID(ctx));
    pstmt.setInt(2,terminalId);
    pstmt.setInt(3,cashBookId);
    rs=pstmt.executeQuery();
    if (rs.next()) {
      valid=(rs.getInt(1) == 0);
    }
  }
 catch (  Exception ex) {
    throw new OperationException("Could not check validity of Cash Book",ex);
  }
 finally {
    DB.close(rs,pstmt);
    rs=null;
    pstmt=null;
  }
  return valid;
}

public static boolean isCashBookAssignedValid ( Properties ctx , int terminalId , int cashBookId , String trxName ) throws OperationException { boolean valid = false ; StringBuffer sqlStmt = new StringBuffer ( ) ; sqlStmt . append ( "SELECT COUNT(*) FROM U_POSTerminal " ) ; sqlStmt . append ( "WHERE AD_Client_ID=? AND U_POSTerminal_ID<>? AND C_CashBook_ID=? " ) ; sqlStmt . append ( "AND U_POSTerminal.IsActive='Y' " ) ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { pstmt = DB . prepareStatement ( sqlStmt . toString ( ) , trxName ) ; pstmt . setInt ( 1 , Env . getAD_Client_ID ( ctx ) ) ; pstmt . setInt ( 2 , terminalId ) ; pstmt . setInt ( 3 , cashBookId ) ; rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { valid = ( rs . getInt ( 1 ) == 0 ) ; } } catch ( Exception ex ) { throw new OperationException ( "Could not check validity of Cash Book" , ex ) ; } finally { DB . close ( rs , pstmt ) ; rs = null ; pstmt = null ; } return valid ; }
checks whether a check book can be set on a terminal
