示例#1
0
        /// <summary>
        /// Get achieved Achievements Of Measure
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="PA_Measure_ID">measure id</param>
        /// <returns>array of Achievements</returns>
        public static MAchievement[] GetOfMeasure(Ctx ctx, int PA_Measure_ID)
        {
            List <MAchievement> list = new List <MAchievement>();
            String sql = "SELECT * FROM PA_Achievement "
                         + "WHERE PA_Measure_ID=" + PA_Measure_ID + " AND IsAchieved='Y' ORDER BY SeqNo, DateDoc";

            try
            {
                DataSet ds = DataBase.DB.ExecuteDataset(sql, null, null);
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        list.Add(new MAchievement(ctx, dr, null));
                    }
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }

            //
            MAchievement[] retValue = new MAchievement[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
示例#2
0
        }       //	updateManualGoals

        /**
         *  Update/save Goals with Achievement
         *  @return true if updated
         */
        private Boolean UpdateAchievementGoals()
        {
            if (!MEASURETYPE_Achievements.Equals(GetMeasureType()))
            {
                return(false);
            }
            DateTime today = DateTime.Now;

            MGoal[] goals = MGoal.GetMeasureGoals(GetCtx(), GetPA_Measure_ID());
            for (int i = 0; i < goals.Length; i++)
            {
                MGoal  goal         = goals[i];
                String MeasureScope = goal.GetMeasureScope();
                String trunc        = TimeUtil.TRUNC_DAY;
                if (MGoal.MEASUREDISPLAY_Year.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_YEAR;
                }
                else if (MGoal.MEASUREDISPLAY_Quarter.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_QUARTER;
                }
                else if (MGoal.MEASUREDISPLAY_Month.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_MONTH;
                }
                else if (MGoal.MEASUREDISPLAY_Week.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_WEEK;
                }
                DateTime compare = TimeUtil.Trunc(today, trunc);
                //
                MAchievement[] achievements = MAchievement.GetOfMeasure(GetCtx(), GetPA_Measure_ID());
                Decimal        ManualActual = Env.ZERO;
                for (int j = 0; j < achievements.Length; j++)
                {
                    MAchievement achievement = achievements[j];
                    if (achievement.IsAchieved() && achievement.GetDateDoc() != null)
                    {
                        DateTime ach = TimeUtil.Trunc(achievement.GetDateDoc(), trunc);
                        if (compare.Equals(ach))
                        {
                            ManualActual = Decimal.Add(ManualActual, achievement.GetManualActual());
                        }
                    }
                }
                goal.SetMeasureActual(ManualActual);
                goal.Save();
            }
            return(true);
        }