/// <summary> /// Get Dunning Level /// </summary> /// <returns>level</returns> public MDunningLevel GetLevel() { if (_level == null) { _level = new MDunningLevel(GetCtx(), GetC_DunningLevel_ID(), Get_TrxName()); } return(_level); }
/// <summary> /// get Previous Levels /// </summary> /// <returns>Array of previous DunningLevels</returns> public MDunningLevel[] GetPreviousLevels() { // Prevent generation if not Sequentially if (!GetParent().IsCreateLevelsSequentially()) { return(null); } List <MDunningLevel> list = new List <MDunningLevel>(); String sql = "SELECT * FROM C_DunningLevel WHERE C_Dunning_ID=@Param1 AND DaysAfterDue+DaysBetweenDunning<@Param2"; DataTable dt = null; IDataReader idr = null; SqlParameter[] Param = new SqlParameter[2]; try { int totalDays = Utility.Util.GetValueOfInt(GetDaysAfterDue()) + GetDaysBetweenDunning(); Param[0] = new SqlParameter("@Param1", GetParent().Get_ID()); Param[1] = new SqlParameter("@param2", totalDays); idr = DataBase.DB.ExecuteReader(sql, Param, Get_TrxName()); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { list.Add(new MDunningLevel(GetCtx(), dr, Get_TrxName())); } } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } finally { dt = null; } // MDunningLevel[] retValue = new MDunningLevel[list.Count]; retValue = list.ToArray(); return(retValue); }