Exemplo n.º 1
0
        private static Boolean CheckPeriod(MFactAccumulation accum, DateTime?dateFrom)
        {
            Boolean retVal = true;
            String  sql    = "  SELECT 1 FROM fact_acct a "
                             + " WHERE NOT EXISTS( SELECT 1 " +
                             " FROM C_Period " +
                             " WHERE C_Year_ID IN (SELECT C_Year_ID " +
                             " FROM C_Year " +
                             " WHERE C_Calendar_ID= " + accum.GetC_Calendar_ID() + ") " +
                             " AND a.dateacct BETWEEN TRUNC(StartDate,'DD') AND TRUNC(EndDate,'DD')+ 0.999988 " +
                             " AND c_period.IsActive='Y' AND PeriodType='S') ";

            if (dateFrom != null)
            {
                sql += "  AND DateAcct >= '" + dateFrom.Value + "'";
            }

            IDataReader idr = null;

            try
            {
                idr = DB.ExecuteReader(sql, null, accum.Get_TrxName());
                if (idr.Read())
                {
                    retVal = false;
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                    idr = null;
                }
            }
            return(retVal);
        }