Ejemplo n.º 1
0
        public static Att_TimeOffInLieu AddTimeOffInLieu(Att_LeaveDay leaveDay)
        {
            Att_TimeOffInLieu timeOffInLieu = null;
            if (leaveDay.ID != Guid.Empty)
            {
                Hre_Profile profile = leaveDay.Hre_Profile;
                timeOffInLieu = new Att_TimeOffInLieu();

                //double HourOnWorkDate = 8;
                //Sal_Grade grade = GradeDAO.GetGrade(profile, leaveDay.DateStart, context, userid);
                //if (grade != null)
                //{
                //    Cat_GradeCfg gradecfg = grade.Cat_GradeCfg;
                //    HourOnWorkDate = gradecfg.HourOnWorkDate == null ? 8 : gradecfg.HourOnWorkDate.Value;
                //}

                double ApproveHour;

                if (leaveDay.DurationType == LeaveDayDurationType.E_FULLSHIFT.ToString())
                {
                    ApproveHour = leaveDay.LeaveDays.Value * leaveDay.LeaveHours.Value;
                }
                else
                {
                    ApproveHour = leaveDay.LeaveHours.Value;
                }
                double HourTimeOffInLieu = ApproveHour;
                double accumulateLeaves = Att_LeavedayServices.getAccumulateLeaves(profile.ID);
                double RemainLeaves = accumulateLeaves - HourTimeOffInLieu;

                timeOffInLieu.AccumulateLeaves = accumulateLeaves;
                timeOffInLieu.UnusualLeaves = 0;
                timeOffInLieu.TakenLeaves = HourTimeOffInLieu;
                timeOffInLieu.RemainLeaves = RemainLeaves;
                timeOffInLieu.Date = leaveDay.DateStart;
                if (leaveDay.DateApprove != null)
                    timeOffInLieu.DateApprove = leaveDay.DateApprove.Value;
                // so gio quy ra tien = 0
                timeOffInLieu.ConvertedCashHours = 0;
                timeOffInLieu.Att_LeaveDay = leaveDay;
                timeOffInLieu.Hre_Profile = profile;
                //timeOffInLieu.DateCreate = DateTime.Now;
            }
            return timeOffInLieu;
        }
Ejemplo n.º 2
0
        public Att_TimeOffInLieu AddTimeOffInLieu(Att_Overtime overtime)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoHre_Profile = new CustomBaseRepository<Hre_Profile>(unitOfWork);
                //Insert vào Att_TimeOffInLieu
                Att_TimeOffInLieu timeOffInLieu = null;
                if (overtime.ID != Guid.Empty)
                {
                    Hre_Profile profile = repoHre_Profile.FindBy(m => m.ID == overtime.ProfileID).FirstOrDefault();
                    timeOffInLieu = new Att_TimeOffInLieu();
                    Cat_OvertimeType overtimeType = overtime.Cat_OvertimeType;
                    double Hour = 0;
                    if (overtime.Status == OverTimeStatus.E_CONFIRM.ToString())
                    {
                        Hour = overtime.ConfirmHours == null ? 0 : overtime.ConfirmHours;
                    }
                    else if (overtime.Status == OverTimeStatus.E_APPROVED.ToString())
                    {
                        Hour = overtime.ApproveHours == null ? 0 : overtime.ApproveHours.Value;
                    }
                    double HourTimeOffInLieu = Hour;
                    double UnusualLeaves = 0;
                    if (overtimeType != null)
                    {
                        UnusualLeaves = HourTimeOffInLieu * (overtimeType.TimeOffInLieuRate == null ? 0 : overtimeType.TimeOffInLieuRate.Value);
                    }
                    double accumulateLeaves = Att_LeavedayServices.getAccumulateLeaves(profile.ID);

                    timeOffInLieu.AccumulateLeaves = accumulateLeaves;
                    timeOffInLieu.UnusualLeaves = UnusualLeaves;
                    timeOffInLieu.TakenLeaves = 0;
                    timeOffInLieu.RemainLeaves = UnusualLeaves + accumulateLeaves;
                    timeOffInLieu.Date = overtime.WorkDate.Date;
                    if (overtime.DateApprove != null)
                        timeOffInLieu.DateApprove = overtime.DateApprove.Value;
                    timeOffInLieu.ConvertedCashHours = UnusualLeaves;
                    timeOffInLieu.Att_Overtime = overtime;
                    timeOffInLieu.Hre_Profile = profile;
                }
                return timeOffInLieu;
            }

        }