Exemple #1
0
        /// <summary>
        /// [Son.Vo] - 20140724 - Lấy dữ liệu BC Tổng Hợp Suất Ăn Của Nhân Viên
        /// </summary>
        /// <param name="CarteringIDs"></param>
        /// <param name="CanteenIDS"></param>
        /// <param name="LineIDS"></param>
        /// <param name="DateFrom"></param>
        /// <param name="DateTo"></param>
        /// <returns></returns>
        public List <Can_ReportMealTimeSummaryEntity> ReportMealTimeSummary(List <int?> CarteringIDs, List <int?> CanteenIDS, List <int?> LineIDS, DateTime DateFrom, DateTime DateTo)
        {
            #region GetData
            var lstMealRecord = new List <Can_MealRecord>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new Can_MealRecordRepository(unitOfWork);
                lstMealRecord = repo.FindBy(m => (m.TimeLog >= DateFrom || m.TimeLog <= DateTo) && m.CardCode != null).ToList();
            }

            var lstCanteens = new List <Can_Canteen>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new Can_CanteenRepository(unitOfWork);
                if (CanteenIDS != null)
                {
                    lstCanteens = repo.FindBy(s => CanteenIDS.Contains(s.Id)).ToList();
                }
                else
                {
                    lstCanteens = repo.GetAll().ToList();
                }
            }

            var lstCaterings = new List <Can_Catering>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new Can_CateringRepository(unitOfWork);
                if (CarteringIDs != null)
                {
                    lstCaterings = repo.FindBy(s => CarteringIDs.Contains(s.Id)).ToList();
                }
                else
                {
                    lstCaterings = repo.GetAll().ToList();
                }
            }

            var lstLines = new List <Can_Line>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new Can_LineRepository(unitOfWork);
                if (LineIDS != null)
                {
                    lstLines = repo.FindBy(s => LineIDS.Contains(s.Id)).ToList();
                }
                else
                {
                    lstLines = repo.GetAll().ToList();
                }
            }
            #endregion
            List <Can_ReportMealTimeSummaryEntity> lstReportMealTimeSummary = new List <Can_ReportMealTimeSummaryEntity>();
            foreach (var cate in lstCaterings)
            {
                Can_ReportMealTimeSummaryEntity ReportAdjustmentMealAllowancePayment = new Can_ReportMealTimeSummaryEntity();
                ReportAdjustmentMealAllowancePayment.Catering = cate.CateringName;
                foreach (var item in lstCanteens)
                {
                    ReportAdjustmentMealAllowancePayment.Canteen = item.CanteenName;
                    foreach (var line in lstLines)
                    {
                        ReportAdjustmentMealAllowancePayment.Line  = line.LineName;
                        ReportAdjustmentMealAllowancePayment.Price = line.Amount.Value;
                        var sum  = lstMealRecord.Where(s => s.CateringID == cate.Id && s.CanteenID == cate.Id && s.LineID == line.Id).Sum(s => s.Amount);
                        var rate = lstMealRecord.Where(s => s.CateringID == cate.Id && s.LineID == line.Id).Sum(s => s.Amount) / sum;
                        ReportAdjustmentMealAllowancePayment.TotalAmount = sum != null ? sum.Value : 0;
                        ReportAdjustmentMealAllowancePayment.Rate        = rate != null ? rate.Value : 0;
                    }
                }
                lstReportMealTimeSummary.Add(ReportAdjustmentMealAllowancePayment);
            }
            return(lstReportMealTimeSummary);
        }
Exemple #2
0
        public DataTable ReportMultiSlideCard(List <int?> CarteringIDs, List <int?> CanteenIDS, List <int?> LineIDS, DateTime dateStart, DateTime dateEnd, List <int> lstProfileIds)
        {
            List <Can_ReportMultiSlideCardEntity> lstReportMultiSlideCard = new List <Can_ReportMultiSlideCardEntity>();
            DataTable datatable = CreateReportMultiSlideCardSchema(dateStart, dateEnd);

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork  = (IUnitOfWork)(new UnitOfWork(context));
                var mealRecords = new List <Can_MealRecord>().Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID }).ToList();
                var repo        = new Can_MealRecordRepository(unitOfWork);
                mealRecords = repo.FindBy(s => s.CardCode != null && dateStart <= s.TimeLog && s.TimeLog <= dateEnd && s.NoWorkDay == true)
                              .Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID }).ToList();
                var lstcateringids = mealRecords.Select(m => m.CateringID).ToList();
                var lstcanteenids  = mealRecords.Select(m => m.CanteenID).ToList();
                var lstlineids     = mealRecords.Select(m => m.LineID).ToList();

                var workDays    = new List <Att_WorkDay>().Select(s => new { s.ProfileID, s.WorkDate }).ToList();
                var repoWorkDay = new Att_WorkDayRepository(unitOfWork);
                workDays = repoWorkDay.FindBy(s => s.ProfileID != null && dateStart <= s.WorkDate && s.WorkDate <= dateEnd)
                           .Select(s => new { s.ProfileID, s.WorkDate }).ToList();

                var Cardcode    = mealRecords.Select(s => s.CardCode).Distinct().ToList();
                var repoProfile = new Hre_ProfileRepository(unitOfWork);
                var profiles    = repoProfile.FindBy(m => Cardcode.Contains(m.CodeAttendance) && lstProfileIds.Contains(m.Id)).Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp, s.CodeAttendance }).ToList();

                var repoOrg = new Cat_OrgStructureRepository(unitOfWork);
                var orgs    = repoOrg.FindBy(m => m.Code != null).ToList();

                var catering     = new List <Can_Catering>().ToList();
                var repocatering = new Can_CateringRepository(unitOfWork);
                if (CarteringIDs != null && CarteringIDs.Count > 0)
                {
                    catering = repocatering.FindBy(m => CarteringIDs.Contains(m.Id)).ToList();
                }
                else
                {
                    catering = repocatering.GetAll().ToList();
                }


                var canteen     = new List <Can_Canteen>().ToList();
                var repocanteen = new Can_CanteenRepository(unitOfWork);
                if (CanteenIDS != null && CanteenIDS.Count > 0)
                {
                    canteen = repocanteen.FindBy(m => CanteenIDS.Contains(m.Id)).ToList();
                }
                else
                {
                    canteen = repocanteen.GetAll().ToList();
                }

                var line     = new List <Can_Line>().ToList();
                var repoline = new Can_LineRepository(unitOfWork);
                if (LineIDS != null && LineIDS.Count > 0)
                {
                    line = repoline.FindBy(m => LineIDS.Contains(m.Id)).ToList();
                }
                else
                {
                    line = repoline.GetAll().ToList();
                }

                Can_ReportMultiSlideCardEntity ReportMultiSlideCardEntity = new Can_ReportMultiSlideCardEntity();
                foreach (var profile in profiles)
                {
                    DataRow row               = datatable.NewRow();
                    var     orgbyprofile      = orgs.Where(m => m.Id == profile.OrgStructureID).FirstOrDefault();
                    var     cateringbyprofile = catering.Where(m => lstcateringids.Contains(m.Id)).FirstOrDefault();
                    var     lineprofile       = line.Where(m => lstlineids.Contains(m.Id)).FirstOrDefault();
                    var     canteenbyprofile  = canteen.Where(m => lstcanteenids.Contains(m.Id)).FirstOrDefault();
                    row[Can_ReportMultiSlideCardEntity.FieldNames.CodeEmp]          = profile.CodeEmp;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.ProfileName]      = profile.ProfileName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.OrgStructureName] = orgbyprofile.OrgStructureName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.Cartering]        = cateringbyprofile.CateringName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.Canteen]          = canteenbyprofile.CanteenName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.Line]             = lineprofile.LineName;
                    var mealRecordProfiles = mealRecords.Where(s => s.CardCode == profile.CodeAttendance).ToList();
                    var workDayProfiles    = workDays.Where(s => s.ProfileID == profile.Id).ToList();
                    for (DateTime date = dateStart; date <= dateEnd; date = date.AddDays(1))
                    {
                        var meal = mealRecords.FirstOrDefault(s => s.CardCode == profile.CodeAttendance && s.TimeLog == date);
                        if (meal != null)
                        {
                            row["Date" + date.Day] = (object)meal.TimeLog ?? DBNull.Value;
                            //row["SumCardMore" + date.Day] = mealRecordProfiles.Count(s => s.TimeLog == date) - workDayProfiles.Count(s => s.WorkDate == date);
                        }
                    }
                    datatable.Rows.Add(row);
                }
            }
            return(datatable);
        }
Exemple #3
0
        /// <summary>
        /// [Son.Vo] - 20140724 - Lấy dữ liệu BC Tổng Hợp Suất Ăn Của Nhân Viên
        /// </summary>
        /// <param name="CarteringIDs"></param>
        /// <param name="CanteenIDS"></param>
        /// <param name="LineIDS"></param>
        /// <param name="DateFrom"></param>
        /// <param name="DateTo"></param>
        /// <returns></returns>
        public List<Can_ReportMealTimeSummaryEntity> ReportMealTimeSummary(List<int?> CarteringIDs, List<int?> CanteenIDS, List<int?> LineIDS, DateTime DateFrom, DateTime DateTo)
        {
            #region GetData
            var lstMealRecord = new List<Can_MealRecord>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_MealRecordRepository(unitOfWork);
                lstMealRecord = repo.FindBy(m => (m.TimeLog >= DateFrom || m.TimeLog <= DateTo) && m.CardCode != null).ToList();
            }

            var lstCanteens = new List<Can_Canteen>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_CanteenRepository(unitOfWork);
                if (CanteenIDS != null)
                {
                    lstCanteens = repo.FindBy(s => CanteenIDS.Contains(s.Id)).ToList();
                }
                else lstCanteens = repo.GetAll().ToList();
            }

            var lstCaterings = new List<Can_Catering>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_CateringRepository(unitOfWork);
                if (CarteringIDs != null)
                {
                    lstCaterings = repo.FindBy(s => CarteringIDs.Contains(s.Id)).ToList();
                }
                else lstCaterings = repo.GetAll().ToList();
            }

            var lstLines = new List<Can_Line>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_LineRepository(unitOfWork);
                if (LineIDS != null)
                {
                    lstLines = repo.FindBy(s => LineIDS.Contains(s.Id)).ToList();
                }
                else lstLines = repo.GetAll().ToList();
            }
            #endregion
            List<Can_ReportMealTimeSummaryEntity> lstReportMealTimeSummary = new List<Can_ReportMealTimeSummaryEntity>();
            foreach (var cate in lstCaterings)
            {
                Can_ReportMealTimeSummaryEntity ReportAdjustmentMealAllowancePayment = new Can_ReportMealTimeSummaryEntity();
                ReportAdjustmentMealAllowancePayment.Catering = cate.CateringName;
                foreach (var item in lstCanteens)
                {
                    ReportAdjustmentMealAllowancePayment.Canteen = item.CanteenName;
                    foreach (var line in lstLines)
                    {
                        ReportAdjustmentMealAllowancePayment.Line = line.LineName;
                        ReportAdjustmentMealAllowancePayment.Price = line.Amount.Value;
                        var sum = lstMealRecord.Where(s => s.CateringID == cate.Id && s.CanteenID == cate.Id && s.LineID == line.Id).Sum(s => s.Amount);
                        var rate = lstMealRecord.Where(s => s.CateringID == cate.Id && s.LineID == line.Id).Sum(s => s.Amount) / sum;
                        ReportAdjustmentMealAllowancePayment.TotalAmount = sum != null ? sum.Value : 0;
                        ReportAdjustmentMealAllowancePayment.Rate = rate != null ? rate.Value : 0;
                        lstReportMealTimeSummary.Add(ReportAdjustmentMealAllowancePayment);
                    }
                }
            }
            return lstReportMealTimeSummary;
        }
Exemple #4
0
        public DataTable ReportMultiSlideCard(List<int?> CarteringIDs, List<int?> CanteenIDS, List<int?> LineIDS, DateTime dateStart, DateTime dateEnd, List<int> lstProfileIds)
        {
            List<Can_ReportMultiSlideCardEntity> lstReportMultiSlideCard = new List<Can_ReportMultiSlideCardEntity>();
            DataTable datatable = CreateReportMultiSlideCardSchema(dateStart, dateEnd);
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var mealRecords = new List<Can_MealRecord>().Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID }).ToList();
                var repo = new Can_MealRecordRepository(unitOfWork);
                mealRecords = repo.FindBy(s => s.CardCode != null && dateStart <= s.TimeLog && s.TimeLog <= dateEnd && s.NoWorkDay == true)
                        .Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID }).ToList();
                var lstcateringids = mealRecords.Select(m =>m.CateringID).ToList();
                var lstcanteenids = mealRecords.Select(m =>m.CanteenID).ToList();
                var lstlineids = mealRecords.Select(m => m.LineID).ToList();

                var workDays = new List<Att_WorkDay>().Select(s => new { s.ProfileID, s.WorkDate }).ToList();
                var repoWorkDay = new Att_WorkDayRepository(unitOfWork);
                workDays = repoWorkDay.FindBy(s => s.ProfileID != null && dateStart <= s.WorkDate && s.WorkDate <= dateEnd)
                    .Select(s => new { s.ProfileID, s.WorkDate }).ToList();
                
                var Cardcode = mealRecords.Select(s => s.CardCode).Distinct().ToList();
                var repoProfile = new Hre_ProfileRepository(unitOfWork);
                var profiles = repoProfile.FindBy(m => Cardcode.Contains(m.CodeAttendance) && lstProfileIds.Contains(m.Id)).Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp, s.CodeAttendance }).ToList();

                var repoOrg = new Cat_OrgStructureRepository(unitOfWork);
                var orgs = repoOrg.FindBy(m => m.Code != null).ToList();

                var catering = new List<Can_Catering>().ToList();
                var repocatering = new Can_CateringRepository(unitOfWork);
                if(CarteringIDs != null && CarteringIDs.Count >0)
                {
                    catering = repocatering.FindBy(m => CarteringIDs.Contains(m.Id)).ToList();
                }
                else
                    catering = repocatering.GetAll().ToList();


                var canteen = new List<Can_Canteen>().ToList();
                var repocanteen = new Can_CanteenRepository(unitOfWork);
                if (CanteenIDS != null && CanteenIDS.Count > 0)
                {
                    canteen = repocanteen.FindBy(m => CanteenIDS.Contains(m.Id)).ToList();
                }
                else
                    canteen = repocanteen.GetAll().ToList();

                var line = new List<Can_Line>().ToList();
                var repoline = new Can_LineRepository(unitOfWork);
                if (LineIDS != null && LineIDS.Count > 0)
                {
                    line = repoline.FindBy(m => LineIDS.Contains(m.Id)).ToList();
                }
                else
                    line = repoline.GetAll().ToList();

                Can_ReportMultiSlideCardEntity ReportMultiSlideCardEntity = new Can_ReportMultiSlideCardEntity();
                foreach (var profile in profiles)
                {
                    DataRow row = datatable.NewRow();
                    var orgbyprofile = orgs.Where(m => m.Id == profile.OrgStructureID).FirstOrDefault();
                    var cateringbyprofile = catering.Where(m => lstcateringids.Contains(m.Id)).FirstOrDefault();
                    var lineprofile = line.Where(m => lstlineids.Contains(m.Id)).FirstOrDefault();
                    var canteenbyprofile = canteen.Where(m =>  lstcanteenids.Contains(m.Id)).FirstOrDefault();
                    row[Can_ReportMultiSlideCardEntity.FieldNames.CodeEmp] = profile.CodeEmp;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.ProfileName] = profile.ProfileName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.OrgStructureName] = orgbyprofile.OrgStructureName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.Cartering] = cateringbyprofile.CateringName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.Canteen] = canteenbyprofile.CanteenName;
                    row[Can_ReportMultiSlideCardEntity.FieldNames.Line] = lineprofile.LineName;
                    var mealRecordProfiles = mealRecords.Where(s => s.CardCode == profile.CodeAttendance).ToList();
                    var workDayProfiles = workDays.Where(s => s.ProfileID == profile.Id).ToList();
                    for (DateTime date = dateStart; date <= dateEnd; date = date.AddDays(1))
                    {
                        var meal = mealRecords.FirstOrDefault(s => s.CardCode == profile.CodeAttendance && s.TimeLog == date);
                        if (meal != null)
                        {
                            row["Date" + date.Day] = (object)meal.TimeLog ?? DBNull.Value;
                            //row["SumCardMore" + date.Day] = mealRecordProfiles.Count(s => s.TimeLog == date) - workDayProfiles.Count(s => s.WorkDate == date);
                        }
                    }
                    datatable.Rows.Add(row);
                }
            }
            return datatable;
        }
Exemple #5
0
        public DataTable ReportCardByLocation(List<Guid?> CarteringIDs, List<Guid?> CanteenIDS, List<Guid?> LineIDS, DateTime dateStart, DateTime dateEndSearch, 
            List<Guid> lstProfileIds, List<Guid?> workPlaceIds, List<Guid?> eatLocationIds, Boolean isCludeEmpQuit)
        {
            DataTable datatable = CreateReportCardByLocationSchema(dateStart, dateEndSearch);
            using (var context = new VnrHrmDataContext())
            {
                DateTime dateEnd = dateEndSearch.AddDays(1).AddMilliseconds(-1);
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCan_Line = new Can_LineRepository(unitOfWork);

                var repo = new Can_MealRecordRepository(unitOfWork);
                var mealRecords = repo.FindBy(s => s.ProfileID != null && s.WorkDay != null && s.TimeLog != null
                    && dateStart <= s.WorkDay && s.WorkDay <= dateEnd).ToList();
                if (mealRecords == null && mealRecords.Count < 1)
                {
                    return datatable;
                }
                var profileIds = mealRecords.Select(s => s.ProfileID.Value).Distinct().ToList();
                var repoProfile = new Hre_ProfileRepository(unitOfWork);
                var profiles = repoProfile.FindBy(m => profileIds.Contains(m.ID)).ToList();
                var repoCan_Location = new Can_LocationRepository(unitOfWork);
                var lstLocation = repoCan_Location.FindBy(s => s.IsDelete == null).ToList();

                if (lstProfileIds != null && lstProfileIds.Count >= 1)
                {
                    profiles = profiles.Where(s => lstProfileIds.Contains(s.ID)).ToList();
                }

                if (workPlaceIds != null && workPlaceIds[0] != null)
                {
                    profiles = profiles.Where(s => workPlaceIds.Contains(s.WorkPlaceID)).ToList();
                }

                if(isCludeEmpQuit != true)
                {
                    profiles = profiles.Where(s => s.DateQuit == null || s.DateQuit > dateEnd).ToList();
                }
                profileIds = profiles.Select(s => s.ID).ToList();
                mealRecords = mealRecords.Where(s => profileIds.Contains(s.ProfileID.Value)).ToList();

                var lstcateringids = mealRecords.Select(m => m.CateringID).ToList();
                var lstcanteenids = mealRecords.Select(m => m.CanteenID).ToList();
                var Cardcode = mealRecords.Select(s => s.ProfileID).Distinct().ToList();
                var repoOrg = new Cat_OrgStructureRepository(unitOfWork);
                var orgs = repoOrg.FindBy(m => m.Code != null).ToList();

                if (CarteringIDs != null && CarteringIDs[0] != null)
                {
                    mealRecords = mealRecords.Where(m => m.CateringID != null && CarteringIDs.Contains(m.CateringID)).ToList();
                }

                if (CanteenIDS != null && CanteenIDS[0] != null)
                {
                    mealRecords = mealRecords.Where(m => m.CanteenID != null && CanteenIDS.Contains(m.CanteenID)).ToList();
                }

                if (LineIDS != null && LineIDS[0] != null)
                {
                    mealRecords = mealRecords.Where(m => m.LineID != null && LineIDS.Contains(m.LineID)).ToList();
                }

                var repocanteen = new Can_CanteenRepository(unitOfWork);
                if (eatLocationIds != null && eatLocationIds[0] != null)
                {
                    var lstcanteenbylocation = repocanteen.FindBy(c => c.IsDelete == null && c.LocationID != null && eatLocationIds.Contains(c.LocationID.Value));
                    var lstcanteenbylocationID = lstcanteenbylocation.Select(s => s.ID).ToList();
                    mealRecords = mealRecords.Where(s => s.CanteenID != null && lstcanteenbylocationID.Contains(s.CanteenID.Value)).ToList();
                }

                if (mealRecords == null && mealRecords.Count < 1)
                {
                    return datatable;
                }

                var repoWorkLocation = new Cat_WorkPlaceRepository(unitOfWork);
                var lstWorkPlace = repoWorkLocation.GetAll().ToList();
                var repocatering = new Can_CateringRepository(unitOfWork);
                var caterings = repocatering.GetAll().ToList();
                var canteens = repocanteen.GetAll().ToList();
                var repoline = new Can_LineRepository(unitOfWork);
                var lines = repoline.GetAll().ToList();
                var orgTypes = new List<Cat_OrgStructureType>();
                var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork);
                orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList<Cat_OrgStructureType>();
                foreach (var profile in profiles)
                {
                    for (DateTime date = dateStart; date <= dateEnd; date = date.AddDays(1))
                    {
                        var meal = mealRecords.FirstOrDefault(s => s.TimeLog != null && s.ProfileID == profile.ID && s.TimeLog.Value.Date == date.Date);
                        if (meal != null)
                        {
                            DataRow row = datatable.NewRow();
                            var cateen = canteens.FirstOrDefault(s => s.ID == meal.CanteenID);
                            var cate = caterings.FirstOrDefault(s => s.ID == meal.CateringID);
                            var line = lines.FirstOrDefault(s => s.ID == meal.LineID);
                            Guid? orgId = profile.OrgStructureID;
                            var org = orgs.FirstOrDefault(s => s.ID == profile.OrgStructureID);
                            var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_DIVISION, orgs, orgTypes);
                            var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes);
                            var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes);
                            var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_GROUP, orgs, orgTypes);

                            row[Can_ReportCardByLocationEntity.FieldNames.BranchName] = orgBranch != null ? orgBranch.Code : string.Empty;
                            row[Can_ReportCardByLocationEntity.FieldNames.DepartmentName] = orgOrg != null ? orgOrg.Code : string.Empty;
                            row[Can_ReportCardByLocationEntity.FieldNames.TeamName] = orgTeam != null ? orgTeam.Code : string.Empty;
                            row[Can_ReportCardByLocationEntity.FieldNames.SectionName] = orgSection != null ? orgSection.Code : string.Empty;
                            row[Can_ReportCardByLocationEntity.FieldNames.CodeEmp] = profile.CodeEmp;
                            row[Can_ReportCardByLocationEntity.FieldNames.ProfileName] = profile.ProfileName;
                            row[Can_ReportCardByLocationEntity.FieldNames.DateFrom] = dateStart;
                            row[Can_ReportCardByLocationEntity.FieldNames.DateTo] = dateEnd;
                            row[Can_ReportCardByLocationEntity.FieldNames.DatePrint] = DateTime.Now;
                            var location = cateen != null ? cateen.LocationID : null;
                            row[Can_ReportCardByLocationEntity.FieldNames.CateringName] = cate != null ? cate.CateringName : string.Empty;
                            row[Can_ReportCardByLocationEntity.FieldNames.CanteenName] = cateen != null ? cateen.CanteenName : string.Empty;
                            row[Can_ReportCardByLocationEntity.FieldNames.LineName] = line != null ? line.LineName : string.Empty;
                            if (lstWorkPlace != null && lstWorkPlace.Count > 0)
                            {
                                var workPlaceByPro = lstWorkPlace.Where(m => m.ID == profile.WorkPlaceID).FirstOrDefault();
                                row[Can_ReportCardByLocationEntity.FieldNames.WorkLocationCode] = workPlaceByPro != null ? workPlaceByPro.Code : string.Empty;
                                row[Can_ReportCardByLocationEntity.FieldNames.WorkLocationHD] = workPlaceByPro != null ? workPlaceByPro.WorkPlaceName : string.Empty;
                            }

                            if (location != null && location != Guid.Empty)
                            {
                                var locationname = lstLocation.Where(s => s.ID == location).FirstOrDefault();
                                row[Can_ReportCardByLocationEntity.FieldNames.EatLoCationCode] = location != null ? locationname.LocationCode : string.Empty;
                                row[Can_ReportCardByLocationEntity.FieldNames.EatLoCationHD] = location != null ? locationname.LocationName : string.Empty;
                            }
                            if (meal.WorkDay != null)
                            {
                                row["Data" + date.Day] = meal.WorkDay.Value.ToString(ConstantFormat.HRM_Format_Grid_ShortTime);
                                row[Can_ReportCardByLocationEntity.FieldNames.Quantity] = 1;
                            }
                            row[Can_ReportCardByLocationEntity.FieldNames.Amount] = (object)meal.Amount ?? DBNull.Value;
                            row[Can_ReportCardByLocationEntity.FieldNames.Date] = meal.WorkDay;
                            if (meal.TimeLog != null)
                            {
                                row[Can_ReportCardByLocationEntity.FieldNames.Hour] = meal.TimeLog.Value;
                            }
                            datatable.Rows.Add(row);
                        }
                    }
                }
            }
            return datatable;
        }