Example #1
0
        public DataTable GetReportMonthlyTimeSheet(DateTime? dateStart, DateTime DateTo, string strOrgStructure, List<Hre_ProfileEntity> profiles, Guid[] shiftIDs, Guid[] payrollIDs, bool isIncludeQuitEmp, bool isNotAllowZero, Guid exportid, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                DataTable table = CreateReportMonthlyTimeSheetSchema(UserLogin);

                dateStart = new DateTime(dateStart.Value.Year, dateStart.Value.Month, 1);
                DateTime monthEnd = new DateTime(dateStart.Value.Year, dateStart.Value.Month, DateTime.DaysInMonth(dateStart.Value.Year, dateStart.Value.Month));
                monthEnd = monthEnd.AddDays(1).AddMilliseconds(-1);
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoProfile = new Hre_ProfileRepository(unitOfWork);
                var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork);
                var orgs = repoCat_OrgStructure.FindBy(s => s.Code != null).ToList();
                var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork);
                var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList();
                var repoCat_Position = new Cat_PositionRepository(unitOfWork);
                var positions = repoCat_Position.FindBy(s => s.Code != null).Select(s => new { s.ID, s.Code, s.PositionName }).ToList();
                var repoCat_JobTitle = new Cat_JobTitleRepository(unitOfWork);
                var jobtitles = repoCat_JobTitle.FindBy(s => s.Code != null).Select(s => new { s.ID, s.Code, s.JobTitleName }).ToList();
                var repoCat_LeaveDayType = new Cat_LeaveDayTypeRepository(unitOfWork);
                var leavedayTypes = repoCat_LeaveDayType.FindBy(s => s.Code != null && s.IsDelete == null).Select(s => new { s.Code, s.ID, s.PaidRate, s.LeaveDayTypeName }).ToList();
                var repoCat_OvertimeType = new Cat_OvertimeTypeRepository(unitOfWork);
                var overtimTypes = repoCat_OvertimeType.FindBy(s => s.Code != null && s.IsDelete == null).Select(s => new { s.ID, s.Code, s.OvertimeTypeName }).ToList();
                var codeCenters = unitOfWork.CreateQueryable<Cat_CostCentre>(Guid.Empty, s => s.Code != null).Select(s => new { s.ID, s.Code }).ToList();
                List<Guid> profileIds = profiles.Select(s => s.ID).ToList();
                string status = string.Empty;
                List<object> para_reportWorDay = new List<object>();
                para_reportWorDay.AddRange(new object[2]);
                para_reportWorDay[0] = dateStart;
                para_reportWorDay[0] = monthEnd;
                var repoWorkDay = new Att_WorkDayServices();
                List<Att_WorkdayEntity> workDays = repoWorkDay.GetData<Att_WorkdayEntity>(para_reportWorDay, ConstantSql.hrm_att_sp_getdata_reportWorDay, UserLogin, ref status).ToList();
                workDays = workDays.Where(s => profileIds.Contains(s.ProfileID)).ToList();
                if (payrollIDs != null)
                {
                    profiles = profiles.Where(s => s.PayrollGroupID != null && payrollIDs.Contains(s.PayrollGroupID.Value)).ToList();
                }
                if (shiftIDs != null)
                {
                    workDays = workDays.Where(s => s.ShiftID.HasValue && shiftIDs.Contains(s.ShiftID.Value)).ToList();
                    profileIds = workDays.Select(s => s.ProfileID).ToList();
                    profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList();
                }
                if (!isIncludeQuitEmp)
                {
                    profiles = profiles.Where(s => s.DateQuit == null || s.DateQuit > dateStart).ToList();
                }
                profileIds = profiles.Select(s => s.ID).ToList();
                var repoAtt_AttendencaTable = new Att_AttendanceTableRepository(unitOfWork);
                List<object> para = new List<object>();
                para.AddRange(new object[7]);
                para[3] = dateStart;
                para[4] = monthEnd;
                para[5] = 1;
                para[6] = int.MaxValue;

                var attService = new Att_AttendanceServices();
                List<Att_AttendanceTableEntity> lstAttendanceTable = attService.GetData<Att_AttendanceTableEntity>(para, ConstantSql.hrm_att_sp_get_attdancetable, UserLogin, ref status).ToList();
                var attendanceTables = lstAttendanceTable.Where(s => profileIds.Contains(s.ProfileID)).ToList();

                profileIds = attendanceTables.Select(s => s.ProfileID).ToList();
                profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList();
                foreach (var profile in profiles)
                {
                    var attendanceTableProfile = attendanceTables.FirstOrDefault(s => s.ProfileID == profile.ID);
                    if (attendanceTableProfile == null)
                    {
                        continue;
                    }
                    DataRow row = table.NewRow();
                    Guid? orgId = profile.OrgStructureID;
                    var org = orgs.FirstOrDefault(s => s.ID == profile.OrgStructureID);

                    var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, orgs, orgTypes);
                    var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes);
                    var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, orgs, orgTypes);
                    var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes);

                    var cost = codeCenters.FirstOrDefault(s => s.ID == profile.CostCentreID);
                    var positon = positions.FirstOrDefault(s => s.ID == profile.PositionID);
                    var jobtitle = jobtitles.FirstOrDefault(s => s.ID == profile.JobTitleID);

                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.ProfileName] = profile.ProfileName;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeEmp] = profile.CodeEmp;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.BranchCode] = orgBranch != null ? orgBranch.Code : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeOrg] = orgOrg != null ? orgOrg.Code : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.BranchName] = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.PositionName] = positon != null ? positon.PositionName : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeCenter] = cost != null ? cost.Code : string.Empty;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.StdWorkDayCount] = attendanceTableProfile.StdWorkDayCount > 0 ? (object)attendanceTableProfile.StdWorkDayCount : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.RealWorkDayCount] = attendanceTableProfile.RealWorkDayCount > 0 ? (object)attendanceTableProfile.RealWorkDayCount : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.PaidWorkDayCount] = attendanceTableProfile.PaidWorkDayCount > 0 ? (object)attendanceTableProfile.PaidWorkDayCount : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.AnlDayAvailable] = attendanceTableProfile.AnlDayAvailable > 0 ? (object)attendanceTableProfile.AnlDayAvailable : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.NightShiftHours] = attendanceTableProfile.NightShiftHours > 0 ? (object)attendanceTableProfile.NightShiftHours : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.LateEarlyDeductionHours] = attendanceTableProfile.LateEarlyDeductionHours > 0 ? (object)attendanceTableProfile.LateEarlyDeductionHours : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.AnlDayTaken] = attendanceTableProfile.AnlDayTaken > 0 ? (object)attendanceTableProfile.AnlDayTaken : DBNull.Value;
                    row[Att_ReportMonthlyTimeSheetEntity.FieldNames.Note] = attendanceTableProfile.Note != null ? attendanceTableProfile.Note : string.Empty;
                    #region Export theo cot dong
                    if (exportid != Guid.Empty)
                    {
                        var leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay1Type);
                        if (leaday != null && !string.IsNullOrEmpty(leaday.Code) && table.Columns.Contains(leaday.Code))
                        {
                            row[leaday.Code] = attendanceTableProfile.LeaveDay1Hours > 0 ? (object)attendanceTableProfile.LeaveDay1Hours : DBNull.Value;
                        }
                        leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay2Type);
                        if (leaday != null)
                        {
                            row[leaday.Code] = attendanceTableProfile.LeaveDay2Hours > 0 ? (object)attendanceTableProfile.LeaveDay2Hours : DBNull.Value;
                        }
                        leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay3Type);
                        if (leaday != null)
                        {
                            row[leaday.Code] = attendanceTableProfile.LeaveDay3Hours > 0 ? (object)attendanceTableProfile.LeaveDay3Hours : DBNull.Value;
                        }
                        leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay4Type);
                        if (leaday != null)
                        {
                            row[leaday.Code] = attendanceTableProfile.LeaveDay4Hours > 0 ? (object)attendanceTableProfile.LeaveDay4Hours : DBNull.Value;
                        }
                        var overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime1Type);
                        if (overtimeType != null)
                        {
                            // row[overtimeType.Code] = attendanceTableProfile.Overtime1Hours > 0 ? (object)attendanceTableProfile.Overtime1Hours : DBNull.Value;
                            row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime1Hours > 0 ? (object)attendanceTableProfile.Overtime1Hours : DBNull.Value;
                        }
                        overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime2Type);
                        if (overtimeType != null)
                        {
                            // row[overtimeType.Code] = attendanceTableProfile.Overtime2Hours > 0 ? (object)attendanceTableProfile.Overtime2Hours : DBNull.Value;
                            row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime2Hours > 0 ? (object)attendanceTableProfile.Overtime2Hours : DBNull.Value;
                        }
                        overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime3Type);
                        if (overtimeType != null)
                        {
                            //row[overtimeType.Code] = attendanceTableProfile.Overtime3Hours > 0 ? (object)attendanceTableProfile.Overtime3Hours : DBNull.Value;
                            row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime3Hours > 0 ? (object)attendanceTableProfile.Overtime3Hours : DBNull.Value;
                        }
                        overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime4Type);
                        if (overtimeType != null)
                        {
                            //row[overtimeType.Code] = attendanceTableProfile.Overtime4Hours > 0 ? (object)attendanceTableProfile.Overtime4Hours : DBNull.Value;
                            row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime4Hours > 0 ? (object)attendanceTableProfile.Overtime4Hours : DBNull.Value;
                        }
                        overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime5Type);
                        if (overtimeType != null)
                        {
                            //row[overtimeType.Code] = attendanceTableProfile.Overtime5Hours > 0 ? (object)attendanceTableProfile.Overtime5Hours : DBNull.Value;
                            row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime5Hours > 0 ? (object)attendanceTableProfile.Overtime5Hours : DBNull.Value;
                        }
                        overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime6Type);
                        if (overtimeType != null)
                        {
                            //row[overtimeType.Code] = attendanceTableProfile.Overtime6Hours > 0 ? (object)attendanceTableProfile.Overtime6Hours : DBNull.Value;
                            row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime6Hours > 0 ? (object)attendanceTableProfile.Overtime6Hours : DBNull.Value;
                        }



                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateEarly] = (object)attendanceTableProfile.CardMissingCount ?? DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateLess2H] = (object)attendanceTableProfile.LateEarlyLeastCount ?? DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateMore2H] = (object)attendanceTableProfile.LateEarlyGreaterCount ?? DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.UsableLeave] = attendanceTableProfile.TotalAnlDayAvailable > 0 ? (object)attendanceTableProfile.TotalAnlDayAvailable : DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SickLeave] = attendanceTableProfile.TotalSickDayAvailable > 0 ? (object)attendanceTableProfile.TotalSickDayAvailable : DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CurrentMonth] = attendanceTableProfile.AnlDayTaken > 0 ? (object)attendanceTableProfile.AnlDayTaken : DBNull.Value;
                        //row["SickCurrentMonth"] = attendanceTableProfile.SickDayTaken > 0 ? (object)attendanceTableProfile.SickDayTaken : DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SickCurrentMonth] = attendanceTableProfile.SickDayTaken > 0 ? (object)attendanceTableProfile.SickDayTaken : DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.YearToDate] = attendanceTableProfile.AnlDayAdjacent > 0 ? (object)attendanceTableProfile.AnlDayAdjacent : DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SickYearToDate] = attendanceTableProfile.SickDayAdjacent > 0 ? (object)attendanceTableProfile.SickDayAdjacent : DBNull.Value;
                        row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SumMuteLateEarly] = (object)attendanceTableProfile.LateEarlyTotal ?? DBNull.Value;
                    }
                    #endregion
                    table.Rows.Add(row);
                }
                if (exportid != Guid.Empty)
                {
                    return table.ConfigDatatable();
                }
                return table;
            }
        }
Example #2
0
        public DataTable GetReportDailyAttendance(DateTime dateStart, DateTime dateEnd, string userExport, List<Hre_ProfileEntity> lstProfileAll, Guid[] payrollIDs, bool excludeNotInOut, bool isCreateTemplate, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                DataTable table = CreateReportDailyAttendanceSchema();
                if (isCreateTemplate)
                {
                    return table.ConfigDatatable();
                }

                List<Guid> lstProfileIDs = lstProfileAll.Select(s => s.ID).ToList();
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_Workday = new Att_WorkDayRepository(unitOfWork);
                var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork);
                var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork);
                var repoCat_Position = new Cat_PositionRepository(unitOfWork);
                var repoCat_JobTitle = new Cat_JobTitleRepository(unitOfWork);
                // var repoCat_Shift = new Cat_ShiftRepository(unitOfWork);
                var repoWorkDay = new Att_WorkDayServices();
                var repoCat_Shift = new Cat_ShiftServices();
                var profiles = lstProfileAll.Select(s => new { s.ID, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp, s.PositionID, s.JobTitleID, s.PayrollGroupID }).ToList();
                if (payrollIDs != null)
                {
                    profiles = profiles.Where(m => m.PayrollGroupID != null && payrollIDs.Contains(m.PayrollGroupID.Value)).ToList();
                }
                var profileIds = profiles.Select(s => s.ID).Distinct().ToList();
                string status = string.Empty;
                string E_APPROVED = WorkdayStatus.E_APPROVED.ToString();
                List<object> para_reportWorDay = new List<object>();
                para_reportWorDay.AddRange(new object[3]);
                para_reportWorDay[1] = dateStart;
                para_reportWorDay[2] = dateEnd;

                List<Att_WorkdayEntity> workDays = repoWorkDay.GetData<Att_WorkdayEntity>(para_reportWorDay, ConstantSql.hrm_att_sp_getdata_reportWorDay, UserLogin, ref status).ToList();
                workDays = workDays.Where(m => profileIds.Contains(m.ProfileID) && m.Status == E_APPROVED).ToList();
                var orgs = repoCat_OrgStructure.FindBy(s => s.IsDelete == null && s.Code != null).ToList();
                #region
                var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList();
                var positions = repoCat_Position.FindBy(s => s.IsDelete == null && s.Code != null).Select(s => new { s.ID, s.Code, s.PositionName }).ToList();
                var jobtitles = repoCat_JobTitle.FindBy(s => s.IsDelete == null && s.Code != null).Select(s => new { s.ID, s.Code, s.JobTitleName }).ToList();
                #endregion
                if (workDays == null || workDays.Count == 0)
                {
                    return table;
                }
                profileIds = workDays.Select(m => m.ProfileID).Distinct().ToList();
                profiles = profiles.Where(m => profileIds.Contains(m.ID)).ToList();
                List<object> para_repoCatShift = new List<object>();
                //para_repoCatShift.AddRange(new object[4]);
                //para_repoCatShift[0] = null;
                //para_repoCatShift[1] = null;
                //para_repoCatShift[2] = null;
                //para_repoCatShift[3] = null;
                List<Cat_ShiftEntity> lstShift = repoCat_Shift.GetData<Cat_ShiftEntity>(para_repoCatShift, ConstantSql.hrm_cat_sp_get_Shift, UserLogin, ref status).ToList();
                foreach (var item in workDays)
                {
                    DataRow row = table.NewRow();
                    row[Att_ReportDailyAttendanceEntity.FieldNames.DateFrom] = dateStart;
                    row[Att_ReportDailyAttendanceEntity.FieldNames.DateTo] = dateEnd;
                    var Profile = profiles.Where(m => m.ID == item.ProfileID).FirstOrDefault();
                    if (Profile != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.CodeEmp] = Profile.CodeEmp != null ? Profile.CodeEmp : string.Empty;
                        row[Att_ReportDailyAttendanceEntity.FieldNames.ProfileName] = Profile.ProfileName != null ? Profile.ProfileName : string.Empty;
                        Guid? orgId = Profile.OrgStructureID;
                        if (orgId != null)
                        {

                            var org = orgs.FirstOrDefault(s => s.ID == Profile.OrgStructureID);
                            var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, orgs, orgTypes);
                            var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes);
                            var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, orgs, orgTypes);
                            var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes);
                            row[Att_ReportDailyAttendanceEntity.FieldNames.ProfileOrgCode] = orgOrg != null ? orgOrg.Code : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.BranchCode] = orgBranch != null ? orgBranch.Code : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.BranchName] = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
                            row[Att_ReportDailyAttendanceEntity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                        }
                        var positon = positions.FirstOrDefault(s => s.ID == Profile.PositionID);
                        var jobtitle = jobtitles.FirstOrDefault(s => s.ID == Profile.JobTitleID);
                        row[Att_ReportDailyAttendanceEntity.FieldNames.PositionName] = positon != null ? positon.PositionName : string.Empty;
                        row[Att_ReportDailyAttendanceEntity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty;
                    }
                    var shift = lstShift.Where(m => m.ID == item.ShiftID).FirstOrDefault();
                    if (shift != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.ShiftName] = shift.ShiftName;
                    }
                    var shiftActual = lstShift.Where(m => m.ID == item.ShiftActual).FirstOrDefault();
                    if (shiftActual != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.ActualShift] = shiftActual.ShiftName;
                    }
                    if (item.WorkDate != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.WorkDate] = item.WorkDate;
                    }
                    var shiftApprove = lstShift.Where(m => m.ID == item.ShiftApprove).FirstOrDefault();
                    if (shiftApprove != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.ApprovedShift] = shiftApprove.ShiftName;
                    }
                    if (item.InTime1 != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.TimeIn] = item.InTime1;
                    }
                    if (item.OutTime1 != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.TimeOut] = item.OutTime1;
                    }
                    row[Att_ReportDailyAttendanceEntity.FieldNames.Type] = item.Type;
                    row[Att_ReportDailyAttendanceEntity.FieldNames.SrcType] = item.SrcType;
                    row[Att_ReportDailyAttendanceEntity.FieldNames.Status] = item.Status;
                    row[Att_ReportDailyAttendanceEntity.FieldNames.Note] = item.Note;
                    if (item.LateDuration1 != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.LateDuration1] = item.LateDuration1;
                    }
                    if (item.EarlyDuration1 != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyDuration1] = item.EarlyDuration1;
                    }
                    if (item.LateEarlyDuration != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.LateEarlyDuration] = item.LateEarlyDuration;
                    }
                    if (item.LateEarlyRoot != null)
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.LateEarlyRoot] = item.LateEarlyRoot;
                    }

                    row[Att_ReportDailyAttendanceEntity.FieldNames.LateEarlyReason] = item.LateEarlyReason;
                    row[Att_ReportDailyAttendanceEntity.FieldNames.UserExport] = userExport;
                    row[Att_ReportDailyAttendanceEntity.FieldNames.DateExport] = DateTime.Today;
                    if (item.InTimeRoot != null)
                        row[Att_ReportDailyAttendanceEntity.FieldNames.InTimeRoot] = item.InTimeRoot.Value;
                    if (item.OutTimeRoot != null)
                        row[Att_ReportDailyAttendanceEntity.FieldNames.OutTimeRoot] = item.OutTimeRoot.Value;
                    if (item.LateEarlyDuration != null)
                    {
                        if (item.LateEarlyDuration.Value < 120)
                        {
                            row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyLateLess2h] = "X";
                        }
                        else
                        {
                            row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyLateOver2h] = "X";
                        }
                    }
                    else
                    {
                        row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyLateLess2h] = "X";
                    }
                    table.Rows.Add(row);
                }
                return table;
            }
        }