Beispiel #1
0
        /// <summary>
        /// hàm tính ra số phép bù còn lại của tháng và cuối năm
        /// </summary>
        /// <param name="DateCheck"></param>
        /// <param name="ProfileIDs"></param>
        /// <param name="lstTimeOffInLieulInput"></param>
        /// <returns></returns>
        public List<Att_RemainLeaveEntity> GetRemainLeave_TimeOffInLieu(DateTime DateCheck, List<Guid> ProfileIDs, List<Att_TimeOffInLieu> lstTimeOffInLieulInput)
        {
            DateTime DateEndYear = (new DateTime(DateCheck.Year, 1, 1)).AddYears(1).AddSeconds(-1);
            List<Att_RemainLeaveEntity> RemainLeaveResult = new List<Att_RemainLeaveEntity>();
            List<Att_TimeOffInLieu> lstTimeOffInLieu = lstTimeOffInLieulInput.Where(m => m.Date <= DateEndYear).ToList();

            foreach (var item in ProfileIDs)
            {
                Att_RemainLeaveEntity RemainLeave = new Att_RemainLeaveEntity();
                RemainLeave.ProfileID = item;
                var LstAnnualDetailByprofile = lstTimeOffInLieu.Where(m => m.ProfileID == item).ToList();
                if (LstAnnualDetailByprofile.Count > 0)
                {
                    var AnnualDetailByprofile_Present = LstAnnualDetailByprofile.Where(m => m.Date <= DateCheck).ToList();
                    if (AnnualDetailByprofile_Present != null)
                    {
                        RemainLeave.RemainEndMonth = AnnualDetailByprofile_Present.Sum(m => m.UnusualLeaves - m.TakenLeaves);
                    }
                    var AnnualDetailByprofile_EndYear = LstAnnualDetailByprofile.Where(m => m.Date <= DateEndYear).ToList();
                    if (AnnualDetailByprofile_EndYear != null)
                    {
                        RemainLeave.RemainEndYear = AnnualDetailByprofile_EndYear.Sum(m => m.UnusualLeaves - m.TakenLeaves);
                    }
                }
                RemainLeaveResult.Add(RemainLeave);
            }
            return RemainLeaveResult;
        }
Beispiel #2
0
        /// <summary>
        /// hàm tính ra số phép năm còn lại của tháng và cuối năm
        /// </summary>
        /// <param name="DateCheck"></param>
        /// <param name="ProfileIDs"></param>
        /// <param name="lstAnnualDetailInput"></param>
        /// <returns></returns>
        public List<Att_RemainLeaveEntity> GetRemainLeave_Annual(DateTime DateCheck, List<Guid> ProfileIDs, List<Att_AnnualDetail> lstAnnualDetailInput)
        {
            DateCheck = new DateTime(DateCheck.Year, DateCheck.Month, 1);
            int year = DateCheck.Year;
            List<Att_RemainLeaveEntity> RemainLeaveResult = new List<Att_RemainLeaveEntity>();
            List<Att_AnnualDetail> lstAnnualDetail = lstAnnualDetailInput.Where(m => m.Year == year).ToList();

            foreach (var item in ProfileIDs)
            {
                Att_RemainLeaveEntity RemainLeave = new Att_RemainLeaveEntity();
                RemainLeave.ProfileID = item;
                var LstAnnualDetailByprofile = lstAnnualDetail.Where(m => m.ProfileID == item).ToList();
                if (LstAnnualDetailByprofile.Count > 0)
                {
                    var AnnualDetailByprofile_CurrentMonth = LstAnnualDetailByprofile.Where(m => m.MonthYear == DateCheck).FirstOrDefault();
                    if (AnnualDetailByprofile_CurrentMonth != null)
                    {
                        RemainLeave.RemainEndMonth = AnnualDetailByprofile_CurrentMonth.Remain;
                    }
                    int MonthBeginYearANL = LstAnnualDetailByprofile.FirstOrDefault().MonthBeginInYear ?? 1;
                    int EndYearANL = (MonthBeginYearANL - 1) == 0 ? 12 : (MonthBeginYearANL - 1);
                    DateTime MonthEndYear = new DateTime(DateCheck.Year, EndYearANL, 1);
                    var AnnualDetailByprofile_EndYear = LstAnnualDetailByprofile.Where(m => m.MonthYear == MonthEndYear).FirstOrDefault();
                    if (AnnualDetailByprofile_EndYear != null)
                    {
                        RemainLeave.RemainEndYear = AnnualDetailByprofile_EndYear.Remain;
                    }
                }
                RemainLeaveResult.Add(RemainLeave);
            }
            return RemainLeaveResult;
        }