Example #1
0
        private void CalculateWeeklyWorkingModels(EmployeeWeek planningweek)
        {
            Debug.Assert(planningweek != null);

            if (planningweek.IsValidWeek)
            {
                EmployeeDay epday = planningweek.GetDay(planningweek.EndDate);
                EmployeeWorkingModel entity = null;

                foreach (WorkingModelWrapperNew wrap in _weeklyModels)
                {
                    if (!planningweek.PlannedWeek)
                    {
                        if (!wrap.Model.UseInRecording) continue;

                    }

                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                        planningweek.BeginDate, planningweek.EndDate)) continue;

                    if (wrap.Validate(planningweek, planningweek.BeginDate))
                    {
                        entity = new EmployeeWorkingModel();
                        entity.EmployeeID = epday.EmployeeId;
                        entity.Date = epday.Date;
                        entity.WorkingModelID = wrap.Model.ID;
                        if (!wrap.IsMessageModel)
                        {
                            entity.Hours = wrap.GetModelValue;
                            entity.AdditionalCharge = wrap.Model.AddCharges;

                            if (wrap.Model.AddCharges)
                            {
                                epday.CountDailyAdditionalCharges += entity.Hours;
                            }
                            else
                            {
                                epday.CountDailyPlannedWorkingHours += entity.Hours;
                            }
                        }
                        //if (!wrap.IsMessageModel)
                        //{
                        //    int result = 0;
                        //    if (wrap.Model.AddValue != 0)
                        //    {
                        //        result += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                        //    }
                        //    if (wrap.Model.MultiplyValue != 0)
                        //    {
                        //        result += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                        //    }

                        //    if (wrap.Model.AddCharges)
                        //    {
                        //        entity.AdditionalCharge = true;
                        //        entity.Hours = result;
                        //        epday.CountDailyAdditionalCharges += result;

                        //    }
                        //    else
                        //    {
                        //        entity.AdditionalCharge = false;
                        //        entity.Hours = result;
                        //        epday.CountDailyPlannedWorkingHours += result;
                        //    }
                        //}
                        if (epday.WorkingModels == null)
                            epday.WorkingModels = new List<EmployeeWorkingModel>();
                        epday.WorkingModels.Add(entity);
                    }
                }
            }
        }
Example #2
0
        private void CalculateWeeklyMessageOrSaldoWorkingModels(EmployeeWeek planningweek)
        {
            if (planningweek.IsValidWeek)
            {
                EmployeeDay epday = planningweek.GetDay(planningweek.EndDate);
                EmployeeWorkingModel entity = null;
                foreach (WorkingModelWrapperNew wrap in _weeklyMessagesModels)
                {
                    if (!planningweek.PlannedWeek)
                    {
                        if (!wrap.Model.UseInRecording) continue;

                    }
                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                        planningweek.BeginDate, planningweek.EndDate)) continue;

                    if (wrap.Validate(planningweek, planningweek.BeginDate))
                    {
                        if (wrap.IsMessageModel)
                        {
                            entity = new EmployeeWorkingModel();
                            entity.EmployeeID = epday.EmployeeId;
                            entity.Date = epday.Date;
                            entity.WorkingModelID = wrap.Model.ID;

                            if (epday.WorkingModels == null)
                                epday.WorkingModels = new List<EmployeeWorkingModel>();
                            epday.WorkingModels.Add(entity);
                        }
                    }
                }
            }
        }