예제 #1
0
        /**
         *  Get Check for Payment
         *	@param ctx context
         *	@param C_Payment_ID id
         *	@param trxName transaction
         *	@return pay selection check for payment or null
         */
        public static MPaySelectionCheck GetOfPayment(Ctx ctx, int C_Payment_ID, Trx trxName)
        {
            MPaySelectionCheck retValue = null;
            String             sql      = "SELECT * FROM C_PaySelectionCheck WHERE C_Payment_ID=" + C_Payment_ID;
            int         count           = 0;
            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, trxName);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();

                foreach (DataRow dr in dt.Rows)
                {
                    MPaySelectionCheck psc = new MPaySelectionCheck(ctx, dr, trxName);
                    if (retValue == null)
                    {
                        retValue = psc;
                    }
                    else if (!retValue.IsProcessed() && psc.IsProcessed())
                    {
                        retValue = psc;
                    }
                    count++;
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
                dt = null;
            }
            if (count > 1)
            {
                _log.Warning("More then one for C_Payment_ID=" + C_Payment_ID);
            }
            return(retValue);
        }