Esempio n. 1
0
        public void SavePlanValues()
        {
            if (planPeeker == null)
            {
                planPeeker = new PlansPeeker();
            }
            double k = (double)DateTime.DaysInMonth(dtToTime.Year, dtToTime.Month) / (dtToTime - dtFromTime).Days;

            //DateTime.DaysInMonth(dtToTime.Year, dtToTime.Month) / (dtToTime - dtFromTime).Days;
            savePlanMode.Invoke(statList, dtToTime, k);
        }
Esempio n. 2
0
        // Поиск и расчет плановых значений
        public bool SetPlanValues()
        {
            if (statList == null)
            {
                throw new Exception("Плановые показатели не могут быть рассчитаны до определения фактических значений");
            }
            // Период выходит за рамки одного отчетного месяца
            if (dtFromTime.AddDays(1).Month != dtToTime.Month && dtFromTime.Year != dtToTime.Year)
            {
                return(false);
            }
            planPeeker = new PlansPeeker();
            try
            {
                float[] planValues = planPeeker.getPlan(dtToTime);

                int duration = (dtToTime - dtFromTime).Days;

                for (int i = 0; i < statList.Count; i++)
                {
                    StatisticValue statisticValue = statList.ElementAt(i);
                    statisticValue.plan = (planValues[i] / (DateTime.DaysInMonth(dtToTime.Year, dtToTime.Month))) * duration;
                    if (statisticValue.value != 0)
                    {
                        statisticValue.percentage = (statisticValue.value / statisticValue.plan);
                    }
                }
                savePlanMode = planPeeker.updatePlan;
                return(true);
            }
            catch (ArgumentException ex)
            {
                savePlanMode = planPeeker.addPlan;
                throw ex;
            }
        }