Пример #1
0
        public static List <Att_Grade> getAllGrade2(List <Guid> listProfileId, DateTime monthYear)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork    = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_Grade = new CustomBaseRepository <Att_Grade>(unitOfWork);

                List <Att_Grade> lst        = new List <Att_Grade>();
                string[]         strInclude = new string[] { "Cat_GradeAttendance" };

                lst = repoAtt_Grade.FindBy(gd => listProfileId.Contains(gd.ProfileID.Value) &&
                                           gd.MonthStart <= monthYear).OrderByDescending(prop => prop.MonthStart).ToList();

                List <Att_Grade> lstGrade = new List <Att_Grade>();
                foreach (Att_Grade grade in lst)
                {
                    Att_Grade grade1 = lstGrade.FirstOrDefault(prop => prop.ProfileID == grade.ProfileID);
                    if (grade1 == null)
                    {
                        lstGrade.Add(grade);
                    }
                }
                return(lstGrade);
            }
        }
Пример #2
0
        public void CompleteComputingTask(Guid asynTaskID, Guid userID,
                                          int totalComputed, int totalProfile, DataErrorCode dataErrorCode)
        {
            #region Lưu Sys_AsynTask khi xử lý xong

            if (asynTaskID != Guid.Empty)
            {
                using (var taskContext = new VnrHrmDataContext())
                {
                    IUnitOfWork taskunitOfWork = new UnitOfWork(taskContext);
                    var         asynTask       = taskunitOfWork.CreateQueryable <Sys_AsynTask>(s => s.ID == asynTaskID).FirstOrDefault();

                    if (asynTask != null)
                    {
                        asynTask.PercentComplete = 1D;
                        asynTask.TimeEnd         = DateTime.Now;
                        asynTask.Status          = AsynTaskStatus.Done.ToString();

                        var time = asynTask.TimeEnd.Value.Subtract(asynTask.TimeStart).TotalMinutes;
                        asynTask.Description += " - Result: " + totalComputed + "/" + totalProfile;
                        asynTask.Description += " - Time: " + time.ToString("N2");

                        if (dataErrorCode == DataErrorCode.Locked)
                        {
                            asynTask.PercentComplete = 1D;//Không cần nhân với 100
                            asynTask.Description     = "Dữ Liệu Quẹt Thẻ Đã Bị Khóa";
                        }

                        dataErrorCode = taskunitOfWork.SaveChanges();
                    }
                }
            }

            #endregion
        }
Пример #3
0
        public static Att_Grade GetGrade(Hre_Profile profile, DateTime effectMonth)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork    = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_Grade = new CustomBaseRepository <Att_Grade>(unitOfWork);
                //NOTE: can modify lai cau truy van de gioi han data lay len
                List <Att_Grade> lst = repoAtt_Grade
                                       .FindBy(alw => alw.IsDelete == null &&
                                               alw.ProfileID == profile.ID &&
                                               alw.MonthStart <= effectMonth)
                                       .OrderByDescending(alw => alw.MonthStart).ToList();

                if (lst != null && lst.Count > 0)
                {
                    // Lấy grade có ngày đến hạn, nếu không có ngày đến hạn xem như Ok không hết hạn, nếu có ngày đến hạn
                    DateTime temp = new DateTime(effectMonth.Year, effectMonth.Month, 1);
                    if (!lst[0].MonthEnd.HasValue || (lst[0].MonthEnd.HasValue && lst[0].MonthEnd.Value >= temp))
                    {
                        return(lst[0]);
                    }
                }
                return(null);
            }
        }
Пример #4
0
        public string DeleteConditionInGroupCondition(Guid GroupConditionID, string ConditionIDs)
        {
            using (var context = new VnrHrmDataContext())
            {
                var         unitOfWork     = (IUnitOfWork)(new UnitOfWork(context));
                var         repo           = new Rec_GroupConditionRepository(unitOfWork);
                var         ilConditionIDs = ConditionIDs.Split(',');
                List <Guid> lsConditionIDs = new List <Guid>();
                lsConditionIDs = ConditionIDs.Split(',').Select(x => Guid.Parse(x)).ToList();

                Rec_GroupCondition GroupCondition = repo.GetById(GroupConditionID);
                if (GroupCondition == null)
                {
                    return(null);
                }
                List <Guid> lstCondition = new List <Guid>();
                lstCondition = GroupCondition.JobConditionIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
                if (lstCondition != null && lstCondition.Count != 0)
                {
                    lstCondition = lstCondition.Where(x => !lsConditionIDs.Contains(x)).ToList();
                    GroupCondition.JobConditionIDs = string.Join(",", lstCondition);
                    repo.SaveChanges();
                    return(GroupCondition.JobConditionIDs);
                }
            }
            return(null);
        }
Пример #5
0
        public Guid ComputeAnnualLeaveAllowance(Sal_UnusualAllowanceEntity model)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork       = (IUnitOfWork) new UnitOfWork(context);
                var repoSys_AsynTask = new CustomBaseRepository <Sys_AsynTask>(unitOfWork);
                var repoCat_Element  = new CustomBaseRepository <Cat_Element>(unitOfWork);


                //tạo asynTask
                Sys_AsynTask asynTask = new Sys_AsynTask()
                {
                    ID              = Guid.NewGuid(),
                    Summary         = "Tính phép năm : " + model.MonthStart.Value.ToString("dd/MM/yyyy"),
                    Type            = AsynTask.Payroll_Compute_AnnualLeaveAllowance.ToString(),
                    Status          = AsynTaskStatus.Doing.ToString(),
                    TimeStart       = DateTime.Now,
                    PercentComplete = 0.01,
                };
                repoSys_AsynTask.Add(asynTask);
                unitOfWork.SaveChanges();

                Thread threadCompute = new Thread(() => ComputeBonusUnusualAllowance_Progress(asynTask.ID, model, true));
                threadCompute.Start();

                return(asynTask.ID);
            }
        }
Пример #6
0
        public static List <EnumDataInfo> GetEnumDataInfo(Type enumType)
        {
            var listEnumDataInfo = Utilities.GetEnumDataInfo(enumType);

            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);

                var listEnumName = unitOfWork.CreateQueryable <Sys_EnumFilter>(Guid.Empty,
                                                                               d => d.EnumType == enumType.Name).Select(d => d.EnumName).ToList();

                if (listEnumName != null && listEnumName.Count() > 0)
                {
                    listEnumDataInfo = listEnumDataInfo.Where(d => !listEnumName.Contains(d.Name)).ToList();
                }

                foreach (var item in listEnumDataInfo)
                {
                    var enumValue = Enum.Parse(enumType, item.Name);
                    item.Translate = item.Name.TranslateString();
                }
            }

            return(listEnumDataInfo);
        }
Пример #7
0
        public void SyncTAMLog(Guid userID, Guid taskID, bool isExcept, DateTime dateFrom, DateTime dateTo,
                               List <Guid> listOrgStructureID, List <Guid> listPayrollGroupID, List <Guid> listWorkplaceID)
        {
            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                string      waitStatus = ProfileStatusSyn.E_WAITING.ToString();

                var profileQueryable = unitOfWork.CreateQueryable <Hre_Profile>(userID);

                if (listOrgStructureID != null && listOrgStructureID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.OrgStructureID.HasValue &&
                                                              listOrgStructureID.Contains(d.OrgStructureID.Value));
                }

                if (listPayrollGroupID != null && listPayrollGroupID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.PayrollGroupID.HasValue &&
                                                              listPayrollGroupID.Contains(d.PayrollGroupID.Value));
                }

                if (listWorkplaceID != null && listWorkplaceID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.WorkPlaceID.HasValue &&
                                                              listWorkplaceID.Contains(d.WorkPlaceID.Value));
                }

                var listProfileID = profileQueryable.Where(d => (d.StatusSyn == null || d.StatusSyn != waitStatus) &&
                                                           (d.DateQuit == null || d.DateQuit.Value > dateFrom)).Select(d => d.ID).ToList();

                SyncTAMLog(userID, taskID, isExcept, dateFrom, dateTo, listProfileID);
            }
        }
Пример #8
0
 public string AddConditionIntoGroupCondition(Guid GroupConditionID, string ConditionIDs)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo       = new Rec_GroupConditionRepository(unitOfWork);
         Rec_GroupCondition GroupCondition = repo.GetById(GroupConditionID);
         if (GroupCondition == null)
         {
             return(null);
         }
         List <Guid> lstCondition    = new List <Guid>();
         List <Guid> lstAddCondition = new List <Guid>();
         lstAddCondition = ConditionIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
         if (!string.IsNullOrEmpty(GroupCondition.JobConditionIDs))
         {
             lstCondition = GroupCondition.JobConditionIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
         }
         lstCondition.AddRange(lstAddCondition);
         lstCondition = lstCondition.Distinct().ToList();
         GroupCondition.JobConditionIDs = string.Join(",", lstCondition);
         repo.SaveChanges();
         return(GroupCondition.JobConditionIDs);
     }
 }
Пример #9
0
        private bool DeletePayrollTable(List <Guid> listProfileID, Guid cutOffDurationID)
        {
            #region Delete PayrollTable

            try
            {
                using (var context = new VnrHrmDataContext())
                {
                    var unitOfWork = new UnitOfWork(context);
                    int pageSize   = 2000;//tối đa là 2100 parameter
                    int result     = 0;

                    foreach (var listProfileIDBySize in listProfileID.Chunk(pageSize))
                    {
                        result += unitOfWork.SetIsDelete(context.Sal_PayCommission.Where(m => m.CutoffDurationID != null && m.ProfileID != null && !m.IsDelete.HasValue && (Guid)m.CutoffDurationID == cutOffDurationID && listProfileIDBySize.Contains((Guid)m.ProfileID)));
                    }

                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }

            #endregion
        }
Пример #10
0
        /// <summary>
        /// Lay DS luong hieu luc cua toan cong ty. Moi nhan vien chi co 1 muc luong trong danh sach.
        /// </summary>
        /// <param name="lstSalaryAll">get all Salary</param>
        /// <param name="monthEffect"></param>
        /// <returns></returns>


        public void Approved(List <Guid> selectedIds, string status, string userLoginName)
        {
            using (var context = new VnrHrmDataContext())
            {
                string statusMessage   = string.Empty;
                var    unitOfWork      = (IUnitOfWork)(new UnitOfWork(context));
                var    repoProfile     = new Hre_ProfileRepository(unitOfWork);
                var    repoHoldSalary  = new Sal_HoldSalaryRepository(unitOfWork);
                var    lstHoldSalary   = repoHoldSalary.FindBy(s => selectedIds.Contains(s.ID)).ToList();
                var    lstProfileIDs   = lstHoldSalary.Select(s => s.ProfileID).ToList();
                var    profileServices = new Hre_ProfileServices();
                var    objProfile      = new List <object>();
                objProfile.AddRange(new object[17]);
                objProfile[15] = 1;
                objProfile[16] = int.MaxValue - 1;
                var lstProfile = profileServices.GetData <Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileAll, userLoginName, ref statusMessage).ToList().Translate <Hre_Profile>();
                //var lstProfiles = repoProfile.FindBy(m => m.ID != null && lstProfileIDs.Contains(m.ID)).ToList();

                foreach (var holdSalary in lstHoldSalary)
                {
                    holdSalary.Status = status;
                    var profileByID = lstProfile.Where(s => s.ID == holdSalary.ProfileID.Value).FirstOrDefault();
                    profileByID.MonthHoldSal = holdSalary.MonthSalary;
                    profileByID.IsHoldSal    = true;
                }
                repoHoldSalary.SaveChanges();
                repoProfile.SaveChanges();
            }
        }
Пример #11
0
 public string ActionCancel(string selectedIds, string userLogin)
 {
     using (var context = new VnrHrmDataContext())
     {
         string      message         = string.Empty;
         var         unitOfWork      = (IUnitOfWork)(new UnitOfWork(context));
         var         repo            = new Hre_StopWorkingRepository(unitOfWork);
         var         profileServices = new Hre_ProfileServices();
         string      status          = string.Empty;
         List <Guid> lstIds          = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
         var         lstStopWorkings = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList();
         foreach (var StopWorking in lstStopWorkings)
         {
             var profile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(StopWorking.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();
             profile.StatusSyn    = StopWorking.LastStatusSyn;
             StopWorking.Status   = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_CANCEL.ToString();
             profile.StopWorkType = null;
             profile.TypeSuspense = null;
             profile.RequestDate  = null;
             profile.DateQuit     = null;
             profile.ResReasonID  = null;
             profile.IsHoldSal    = false;
             profile.ResignNo     = null;
             profile.TypeOfStop   = null;
             profileServices.Edit(profile);
         }
         repo.SaveChanges();
         message = NotificationType.Success.ToString();
         return(message);
     }
 }
Пример #12
0
        public string Delete(Type entityType, params object[] entities)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                try
                {
                    unitOfWork.RemoveObject(entityType, entities);
                    var status = unitOfWork.SaveChanges(Guid.Empty);

                    if (status == DataErrorCode.Locked)
                    {
                        return(NotificationType.Locked.ToString());
                    }
                    else
                    {
                        return(NotificationType.Success.ToString());
                    }
                }
                catch (Exception ex)
                {
                    return(NotificationType.Error + "," + ex.Message);
                }
            }
        }
Пример #13
0
        public bool UpdateResource(List <Sys_ResourceEntity> lstResource)
        {
            using (var context = new VnrHrmDataContext())
            {
                var    isExistedUser  = false;
                var    unitOfWork     = (IUnitOfWork)(new UnitOfWork(context));
                var    repo           = new Sys_ResourceRepository(unitOfWork);
                string status         = string.Empty;
                var    resources      = GetAllUseEntity <Sys_Resource>(ref status);
                var    resourceAdding = new List <Sys_Resource>();
                foreach (var sysResource in lstResource)
                {
                    var resourceExist = resources.Where(p => p.ResourceName == sysResource.ResourceName).FirstOrDefault();
                    if (resourceExist == null)
                    {
                        if (sysResource != null && sysResource.ResourceType == HRM.Infrastructure.Utilities.ResourceType.Other.ToString() && !string.IsNullOrEmpty(sysResource.ResourceName))
                        {
                            sysResource.Category = sysResource.ModuleName;
                        }

                        var resourceAddNew = sysResource.CopyData <Sys_Resource>();
                        resourceAddNew.ID = Guid.NewGuid();
                        var resourceExisted = resourceAdding.Where(p => sysResource != null && p.ResourceName == sysResource.ResourceName).FirstOrDefault();
                        if (resourceExisted == null)
                        {
                            resourceAdding.Add(resourceAddNew);
                        }
                    }
                }
                repo.Add(resourceAdding);
                repo.SaveChanges();
            }
            return(false);
        }
Пример #14
0
        public string Delete <TEntity>(List <TEntity> listEntity) where TEntity : class
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                try
                {
                    unitOfWork.RemoveObject(typeof(TEntity), listEntity);
                    var status = unitOfWork.SaveChanges(Guid.Empty);

                    if (status == DataErrorCode.Locked)
                    {
                        return(NotificationType.Locked.ToString());
                    }
                    else
                    {
                        return(NotificationType.Success.ToString());
                    }
                }
                catch (Exception ex)
                {
                    return(NotificationType.Error + "," + ex.Message);
                }
            }
        }
Пример #15
0
        /// <summary>
        /// [Chuc.Nguyen] - Xóa một đối tượng
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        public string Delete <TEntity>(Guid ID) where TEntity : class
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                try
                {
                    //string tableName = typeof(TEntity).Name.Replace("Entity", "");
                    string tableName = typeof(TEntity).Name;
                    tableName = tableName.Substring(0, tableName.Length - 6);
                    Type   dbEntityType = LibraryService.GetEntityType(tableName);
                    object dbEntity     = unitOfWork.CreateQueryable(Guid.Empty, dbEntityType, Constant.ID + " = @0", ID).FirstOrDefault();
                    unitOfWork.RemoveObject(dbEntityType, dbEntity);
                    var status = unitOfWork.SaveChanges(Guid.Empty);

                    if (status == DataErrorCode.Locked)
                    {
                        return(NotificationType.Locked.ToString());
                    }
                    else
                    {
                        return(NotificationType.Success.ToString());
                    }
                }
                catch (Exception ex)
                {
                    return(NotificationType.Error + "," + ex.Message);
                }
            }
        }
Пример #16
0
        /// <summary>
        /// [HieuVan] - Chuyển đổi trạng thái của một đối tượng Status
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        public string UpdateStatus <TEntity>(Guid ID, string type) where TEntity : class
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new CustomBaseRepository <TEntity>(unitOfWork);
                try
                {
                    List <object> listParamater = new List <object>();
                    string        tableName     = typeof(TEntity).Name;
                    tableName = tableName.Substring(0, tableName.Length - 6);
                    Type   dbEntityType = LibraryService.GetEntityType(tableName);
                    object dbEntity     = unitOfWork.CreateQueryable(Guid.Empty, dbEntityType, Constant.ID + " = @0", ID).FirstOrDefault();
                    dbEntity.SetPropertyValue("Status", type);
                    var status = unitOfWork.SaveChanges(Guid.Empty);

                    if (status == DataErrorCode.Locked)
                    {
                        return(NotificationType.Locked.ToString());
                    }
                    else
                    {
                        return(NotificationType.Success.ToString());
                    }
                }
                catch (Exception ex)
                {
                    return(NotificationType.Error + "," + ex.Message);
                }
            }
        }
Пример #17
0
        public DataTable GetDataContractByProfileIDSchema()
        {
            using (var context = new VnrHrmDataContext())
            {
                DataTable tb = new DataTable("Hre_ReportProfileComeBackEntity");
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.CodeEmp);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.ProfileName);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.E_UNIT);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.E_DIVISION);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.E_DEPARTMENT);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.E_TEAM);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.E_SECTION);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.PositionName);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.DateOfBirth, typeof(DateTime));
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.Gender);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.PlaceOfBirth);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.IDPlaceOfIssue);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.PAddress);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.HomePhone);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.Cellphone);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.IDNo);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.DateComeBack, typeof(DateTime));
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.SalaryRankName);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.DateHire, typeof(DateTime));
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.DateQuit, typeof(DateTime));
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.TypeOfStop);
                tb.Columns.Add(Hre_ReportProfileComeBackEntity.FieldNames.ResignReasonName);

                return(tb);
            }
        }
Пример #18
0
 public string SaveEvalutionData(int year, Guid?TimesGetDataID, string orgStructureID, DateTime?_dateStart, DateTime?_dateEnd, string userLogin)
 {
     using (var context = new VnrHrmDataContext())
     {
         var evaServices = new Eva_ReportServices();
         List <Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List <Eva_EvalutionDataEntity>();
         lstEvalutionDataEntity = evaServices.SummaryEvalutionData(year, TimesGetDataID, orgStructureID, _dateStart, _dateEnd, userLogin);
         var unitOfWork            = (IUnitOfWork) new UnitOfWork(context);
         var repoEva_EvalutionData = new CustomBaseRepository <Eva_EvalutionData>(unitOfWork);
         List <Eva_EvalutionData> lstEvalutionData = new List <Eva_EvalutionData>();
         lstEvalutionData = lstEvalutionDataEntity.Translate <Eva_EvalutionData>();
         if (lstEvalutionData != null)
         {
             int _total     = lstEvalutionData.Count;
             int _totalPage = _total / 200 + 1;
             int _pageSize  = 200;
             for (int _page = 1; _page <= _totalPage; _page++)
             {
                 int _skip           = _pageSize * (_page - 1);
                 var _listCurrenPage = lstEvalutionData.Skip(_skip).Take(_pageSize).ToList();
                 foreach (var item in _listCurrenPage)
                 {
                     repoEva_EvalutionData.Add(item);
                 }
                 unitOfWork.SaveChanges();
             }
         }
         return("SaveSuccess");
         //    #endregion
     }
 }
Пример #19
0
        /// <summary>
        /// [Hieu.Van] - Tạo mới một đối tượng return model
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        public TEntity Add <TEntity>(TEntity entity, ref string status) where TEntity : class
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new CustomBaseRepository <TEntity>(unitOfWork);
                try
                {
                    entity.SetPropertyValue(Constant.DateCreate, DateTime.Now);
                    repo.Add(entity);
                    var saveStatus = repo.SaveChanges();

                    if (saveStatus == DataErrorCode.Locked)
                    {
                        status = NotificationType.Locked.ToString();
                    }
                    else
                    {
                        status = NotificationType.Success.ToString();
                    }

                    return(entity);
                }
                catch (Exception ex)
                {
                    status = NotificationType.Error + "," + ex.Message;
                    return(null);
                }
            }
        }
Пример #20
0
 /// <summary>Kiểm tra googleEmail co tồn tại trong hệ thống VNR chưa</summary>
 /// <param name="googleEmail">Google Email</param>
 /// <param name="googleProfileName">ProfileName của google</param>
 /// <returns></returns>
 public Sys_UserInfoEntity CheckEmailExisted(string googleEmail, string googleProfileName)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Sys_UserRepository(unitOfWork);
         var userInfo = unitOfWork.CreateQueryable<Sys_UserInfo>(Guid.Empty, m => m.UserLogin == googleEmail).FirstOrDefault();
         var userInfoEntity = userInfo.CopyData<Sys_UserInfoEntity>();
         if (userInfo == null && !string.IsNullOrEmpty(googleEmail))
         {
             //neu chua co googleEmail => tao moi user
             Sys_UserInfo usr = new Sys_UserInfo
             {
                 Email = googleEmail,
                 FullName = googleProfileName,
                 UserLogin = googleEmail,
                 UserInfoName = googleProfileName,
                 Password = "******",
                 IsActivate = true
             };
             repo.Add(usr);
             repo.SaveChanges();
             userInfoEntity = usr.CopyData<Sys_UserInfoEntity>();
         }
         else
         {
             return userInfoEntity;
         }
         return userInfoEntity;
     }
 }
Пример #21
0
        public Cat_MasterDataGroupItemEntity AddMasterDataGroupItems(Cat_MasterDataGroupItemEntity model)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoMasterDataGroupItem    = new Cat_MasterDataGroupItemRepository(unitOfWork);
                var lstCat_MasterDataGroupItem = new List <Cat_MasterDataGroupItem>();

                #region Lấy ds MasterDataGroupItem theo MasterDataGroupID
                var masterDataGroupItem_objectIdExists = unitOfWork.CreateQueryable <Cat_MasterDataGroupItem>(Guid.Empty, m => m.MasterDataGroupID == model.MasterDataGroupID).Select(p => p.ObjectID).ToList();
                #endregion

                if (model.ObjectIDs.Any())
                {
                    //không lưu những item co objectId đã tồn tại trong masterDataGroupItem theo masterDataGroupID
                    model.ObjectIDs = model.ObjectIDs.Except(masterDataGroupItem_objectIdExists).ToList();

                    foreach (var objectId in model.ObjectIDs)
                    {
                        var masterDataGroupItem = new  Cat_MasterDataGroupItem();
                        masterDataGroupItem.ID                = Guid.NewGuid();
                        masterDataGroupItem.ObjectID          = objectId;
                        masterDataGroupItem.ObjectName        = model.ObjectName;
                        masterDataGroupItem.MasterDataGroupID = model.MasterDataGroupID;
                        lstCat_MasterDataGroupItem.Add(masterDataGroupItem);//add vao repo
                    }
                    if (lstCat_MasterDataGroupItem.Any())
                    {
                        repoMasterDataGroupItem.Add(lstCat_MasterDataGroupItem);
                        repoMasterDataGroupItem.SaveChanges();
                    }
                }
            }
            return(model);
        }
Пример #22
0
        public void UpdateUserMasterDataGroup(Guid userID, List<Guid?> listMasterDataGroupID)
        {
            if (userID != Guid.Empty && listMasterDataGroupID != null)
            {
                using (var context = new VnrHrmDataContext())
                {
                    IUnitOfWork unitOfWork = new UnitOfWork(context);

                    var listMasterDataGroupNumber = unitOfWork.CreateQueryable<Cat_MasterDataGroup>(d => d.OrderNumber.HasValue
                        && listMasterDataGroupID.Contains(d.ID)).Select(d => d.OrderNumber.Value).ToList();

                    var userMasterDataGroup = unitOfWork.CreateQueryable<Sys_UserMasterData>(d =>
                        d.UserID == userID).FirstOrDefault();

                    if (userMasterDataGroup == null)
                    {
                        userMasterDataGroup = new Sys_UserMasterData
                        {
                            UserID = userID
                        };

                        unitOfWork.AddObject(typeof(Sys_UserMasterData), userMasterDataGroup);
                    }

                    userMasterDataGroup.MasterDataGroups = listMasterDataGroupNumber.ToBinary();
                    userMasterDataGroup.MasterDataGroup = string.Join(",", listMasterDataGroupNumber);
                    unitOfWork.SaveChanges(userID);
                }
            }

        }
Пример #23
0
 public bool SetApproveKaiZenData(List <Guid> SelectIds)
 {
     using (var context = new VnrHrmDataContext())
     {
         try
         {
             var    unitOfWork                     = (IUnitOfWork)(new UnitOfWork(context));
             string status                         = string.Empty;
             var    repoKai_KaizenData             = new CustomBaseRepository <Kai_KaizenData>(unitOfWork);
             List <Kai_KaizenData> ListKaiZendData = repoKai_KaizenData.FindBy(m => m.IsDelete != true).ToList();
             foreach (var i in ListKaiZendData)
             {
                 if (SelectIds.Any(m => m == i.ID))
                 {
                     i.Status = EnumDropDown.Kai_KaizenDataStatus.E_APPROVED.ToString();
                 }
             }
             unitOfWork.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Пример #24
0
 public bool UpdateRecruitmentCampaignActive(string selectedIds, bool Value)
 {
     using (var context = new VnrHrmDataContext())
     {
         var         unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var         repo       = new Rec_RecruitmentCampaignRepository(unitOfWork);
         var         lstIds     = selectedIds.Split(',');
         List <Guid> listID     = new List <Guid>();
         for (int i = 0; i < lstIds.Length; i++)
         {
             try
             {
                 listID.Add(Guid.Parse(lstIds[i].ToString()));
             }
             catch
             { }
         }
         var listRecruitmentCampaign = repo.FindBy(x => listID.Contains(x.ID)).ToList();
         foreach (var item in listRecruitmentCampaign)
         {
             item.IsActivate = Value;
         }
         repo.SaveChanges();
     }
     return(true);
 }
Пример #25
0
 public List <EntityType> GetListEntityType()
 {
     using (var context = new VnrHrmDataContext())
     {
         UnitOfWork unitOfWork = new UnitOfWork(context);
         return(unitOfWork.ListEntityType);
     }
 }
Пример #26
0
        /// <summary>
        /// [Hieu.Van]
        /// Xử lý Gửi yêu cầu phê duyệt
        /// </summary>
        /// <param name="LoginID"></param>
        /// <param name="userApprovedID"></param>
        /// <param name="recordID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public string ProcessSendRequest(string host, Guid LoginID, Guid userApprovedID, Guid recordID, string type)
        {
            DataErrorCode status = DataErrorCode.Success;

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoFIN_PurchaseRequest = new CustomBaseRepository <FIN_PurchaseRequest>(unitOfWork);
                var repoSys_UserApprove     = new CustomBaseRepository <Sys_UserApprove>(unitOfWork);

                var record = repoFIN_PurchaseRequest.FindBy(s => s.ID == recordID).FirstOrDefault();
                if (record.UserCreateID != LoginID)
                {
                    return(DataErrorCode.NoPermission.ToString());
                }
                if (record.Status == EnumDropDown.Status.E_REJECTED.ToString())
                {
                    return(DataErrorCode.Error_Reject.ToString());
                }
                if (record.Status != null)
                {
                    return(DataErrorCode.Error_SendRequest.ToString());
                }
                var userApproved = repoSys_UserApprove.FindBy(s => s.ID == userApprovedID).FirstOrDefault();
                // Lấy status hiện tại của bản ghi
                string currentStatus = record.Status;

                // truyền từ Dropdownlist chọn người duyệt, lấy ra giá trị Status tiếp theo
                string nextStatus = userApproved.CurrentStatus;

                record.Status        = nextStatus;
                record.UserApproveID = userApprovedID;
                repoFIN_PurchaseRequest.Edit(record);
                status = repoFIN_PurchaseRequest.SaveChanges();


                if (status == DataErrorCode.Success)
                {
                    if (nextStatus != "Approved")
                    {
                        status = SendMail_ToNextApproved(host, recordID, userApprovedID, nextStatus, type);
                    }

                    var repoSys_ConfigProcessApprove = new CustomBaseRepository <Sys_ConfigProcessApprove>(unitOfWork);
                    var configProcess = repoSys_ConfigProcessApprove.FindBy(s => s.IsDelete == null && s.Function == type && s.CurrentStatus == record.Status).FirstOrDefault();
                    if (configProcess == null)
                    {
                        return(DataErrorCode.Success.ToString());
                    }
                    else
                    {
                        return(DataErrorCode.Success_Forward.ToString());
                    }
                }

                return(status.ToString());
            }
        }
Пример #27
0
 public Hre_ProfileEntity GetProfileName(Guid userID)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var profile = unitOfWork.CreateQueryable<Hre_Profile>(Guid.Empty, m => m.ID == userID).Select(p => new Hre_ProfileEntity { ProfileName = p.ProfileName, ID = p.ID }).FirstOrDefault();
         return profile;
     }
 }
Пример #28
0
 public List <Sal_UnusualAllowanceEntity> GetUnusualAllowanceByUnusualEDTypeIDAndDateOccur(Guid?ProfileID, Guid?UnusualEDTypeID, DateTime?_datestart, DateTime?_dateend)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork          = (IUnitOfWork) new UnitOfWork(context);
         var lstUnusualAllowance = unitOfWork.CreateQueryable <Sal_UnusualAllowance>(Guid.Empty, s => s.ProfileID == ProfileID && s.UnusualEDTypeID == UnusualEDTypeID && s.DateOccur != null && s.DateOccur >= _datestart && s.DateOccur <= _dateend).Select(s => new  { s.ProfileID, s.DateOccur }).ToList();
         return(lstUnusualAllowance.Translate <Sal_UnusualAllowanceEntity>());
     }
 }
Пример #29
0
        public bool AddList(List <Att_AnnualLeaveDetailEntity> models)
        {
            bool isSuccess = false;
            var  leaveType = string.Empty;
            var  status    = string.Empty;
            var  year      = 2013;

            if (models != null && models.FirstOrDefault() != null && models.FirstOrDefault().Year != null)
            {
                year      = Convert.ToInt32(models.FirstOrDefault().Year);
                leaveType = models.FirstOrDefault().Type;
            }

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new CustomBaseRepository <Att_AnnualLeaveDetail>(unitOfWork);
                try
                {
                    var annualLeaveDetails = GetAllUseEntity <Att_AnnualLeaveDetail>(ref status).Where(p => p.Type == leaveType && p.Year == year).ToList().AsQueryable();
                    foreach (var attAnnualLeaveDetail in models)
                    {
                        var addSuccess        = false;
                        var existAnnualDetail = annualLeaveDetails.Where(p => p.ProfileID == attAnnualLeaveDetail.ProfileID).FirstOrDefault();
                        if (existAnnualDetail != null)
                        {
                            existAnnualDetail.Month1  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month2  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month3  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month4  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month5  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month6  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month7  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month8  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month9  = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month10 = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month11 = attAnnualLeaveDetail.Month1;
                            existAnnualDetail.Month12 = attAnnualLeaveDetail.Month1;

                            repo.Edit(existAnnualDetail);
                        }
                        else
                        {
                            Att_AnnualLeaveDetail temp = new Att_AnnualLeaveDetail();
                            temp = attAnnualLeaveDetail.CopyData <Att_AnnualLeaveDetail>();
                            repo.Add(temp);
                        }
                    }
                    repo.SaveChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
Пример #30
0
 public List <Eva_PerformanceDetailEntity> GetPerformanceDetailsByTemplateID(Guid templateId)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var lstEvaPerformanceDetails = unitOfWork.CreateQueryable <Eva_PerformanceDetail>(Guid.Empty, m => m.PerformanceTemplateID == templateId).ToList().Translate <Eva_PerformanceDetailEntity>();
         return(lstEvaPerformanceDetails);
     }
 }
Пример #31
0
        //[TestMethod]
        public void ExportData()
        {
            using (var context = new VnrHrmDataContext())
            {
                #region Cat_Export
                List<Cat_Export> listExport = new List<Cat_Export>();
                Cat_Export _export = new Cat_Export()
                {
                    Id = 1,
                    ExportName = "Test Export",
                    ExportCode = "Test",
                    ScreenName = "Test Screen",
                    ObjectName = "Hre_Profile",
                    IsReadOnly = true,
                    IsProtected = true,
                    SheetIndex = 1,
                    StartColumnIndex = 1,
                    StartRowIndex = 2,
                    TemplateFile = "Test Template File",
                    IsGroup = true
                };
                listExport.Add(_export);
                #endregion

                #region Cat_ExportItem
                List<Cat_ExportItem> listExportItem = new List<Cat_ExportItem>();
                Cat_ExportItem _exportItemEntity1 = new Cat_ExportItem()
                {
                    ExportID = 1,
                    DataField = "ProfileName",
                    ExcelField = "B"
                };
                Cat_ExportItem _exportItemEntity2 = new Cat_ExportItem()
                {
                    ExportID = 1,
                    DataField = "CodeEmp",
                    ExcelField = "C"
                };
                Cat_ExportItem _exportItemEntity3 = new Cat_ExportItem()
                {
                    ExportID = 1,
                    DataField = "DateHire",
                    ExcelField = "D"
                };
                listExportItem.Add(_exportItemEntity1);
                listExportItem.Add(_exportItemEntity2);
                listExportItem.Add(_exportItemEntity3);
                #endregion

                context.Cat_ExportItem.Add(_exportItemEntity1);
                context.Cat_ExportItem.Add(_exportItemEntity2);
                context.Cat_ExportItem.Add(_exportItemEntity3);
                context.Cat_Export.Add(_export);
                context.SaveChanges();
            }

            string passwordwrite = "123";
            string passwordread = "123";

            string filename = "D:\\New Microsoft Excel Worksheet.xls";
            string templatePath = "D:\\Template";

            #region Datasource
            List<Hre_ProfileEntity> listdataProfile = new List<Hre_ProfileEntity>();
            Hre_ProfileEntity _Profile1 = new Hre_ProfileEntity()
            {
                ProfileName = "Name1",
                CodeEmp = "001",
                DateHire = DateTime.Now
            };
            Hre_ProfileEntity _Profile2 = new Hre_ProfileEntity()
            {
                ProfileName = "Name2",
                CodeEmp = "002",
                DateHire = DateTime.Now
            };
            listdataProfile.Add(_Profile1);
            listdataProfile.Add(_Profile2);
            #endregion

            ExportService service = new ExportService();
            service.ExportByTemplate(1, filename, passwordwrite, passwordread, templatePath, null, listdataProfile);
            Process.Start(filename);
        }
Пример #32
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;
        }
Пример #33
0
        /// <summary>
        /// [Son.Vo] - 20140724 - BC Thanh Toán Trợ Cấp Ăn Ca Cho 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_ReportAdjustmentMealAllowancePaymentEntity> ReportAdjustmentMealAllowancePayment(DateTime DateFrom, DateTime DateTo, List<int> lstProfileIDs)
        {
            #region GetData
            var lstMealRecord = new List<Can_MealRecord>().Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID, s.Amount, s.MealAllowanceType,  s.NoWorkDay }).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).Select(
               s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID, s.Amount, s.MealAllowanceType,  s.NoWorkDay }).ToList();
            }
            var cardcode = lstMealRecord.Select(s => s.CardCode).Distinct().ToList();
            var profiles = new List<Hre_Profile>().Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeAttendance, s.CodeEmp, s.PositionID, s.JobTitleID }).ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Hre_ProfileRepository(unitOfWork);
                profiles = repo.FindBy(s => cardcode.Contains(s.CodeAttendance)).Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeAttendance, s.CodeEmp, s.PositionID, s.JobTitleID }).ToList();
            }

            var mealAllowanceTypeSantandIDs = new List<Can_MealAllowanceTypeSetting>().Select(m=> m.Id).ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_MealAllowanceTypeSettingRepository(unitOfWork);
                mealAllowanceTypeSantandIDs = repo.FindBy(s => s.Standard == true).Select(m=> m.Id).ToList();
            }

            var lineHDTJobIDs = new List<Can_Line>().Select(m => m.Id).ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_LineRepository(unitOfWork);
                lineHDTJobIDs = repo.FindBy(s => s.LineHDTJOB != null).Select(m => m.Id).ToList();
            }

            var lines = new List<Can_Line>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Can_LineRepository(unitOfWork);
                lines = repo.GetAll().ToList();
            }

            var lstOrgAll = new List<Cat_OrgStructure>().ToList();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Cat_OrgStructureRepository(unitOfWork);
                lstOrgAll = repo.GetAll().ToList();
            }
            #endregion
            List<Can_ReportAdjustmentMealAllowancePaymentEntity> lstReportAdjustmentMealAllowancePayment = new List<Can_ReportAdjustmentMealAllowancePaymentEntity>();
            foreach (var profile in profiles)
            {
                Can_ReportAdjustmentMealAllowancePaymentEntity ReportAdjustmentMealAllowancePayment = new Can_ReportAdjustmentMealAllowancePaymentEntity();
                var orgbyprofile = lstOrgAll.Where(m => m.Id == profile.OrgStructureID).Select(m => m.OrgStructureName).FirstOrDefault();
                ReportAdjustmentMealAllowancePayment.CodeEmp = profile.CodeEmp;
                ReportAdjustmentMealAllowancePayment.ProfileName = profile.ProfileName;
                ReportAdjustmentMealAllowancePayment.OrgStructureName = orgbyprofile;
                var mealProfiles = lstMealRecord.Where(s => s.CardCode == profile.CodeAttendance).ToList();
                if (mealProfiles.Count > 0)
                {
                    var line = lines.FirstOrDefault(s => s.Id == mealProfiles[0].LineID);
                    if (line != null)
                    {
                        ReportAdjustmentMealAllowancePayment.TotalAdditionalAmount = mealProfiles.Count * line.Amount;
                    }
                    ReportAdjustmentMealAllowancePayment.TotalMealTime = mealProfiles.Where(m => m.MealAllowanceType != null
                        && mealAllowanceTypeSantandIDs.Contains(m.MealAllowanceType)).Count();
                    ReportAdjustmentMealAllowancePayment.TotalDeductionAmount = mealProfiles.Where(m => m.MealAllowanceType != null
                      && mealAllowanceTypeSantandIDs.Contains(m.MealAllowanceType)).Sum(m => m.Amount.Value);
                    var countCardMore1 = 0;
                    double? AmountSubtractCardMore1 = 0;
                    for (DateTime date = DateFrom; date <= DateTo; date = date.AddDays(1))
                    {
                        if (mealProfiles.Count(s => s.TimeLog == date) > 1)
                        {
                            countCardMore1++;
                            var meal = mealProfiles.FirstOrDefault(s => s.TimeLog == date);
                            if (meal != null)
                            {
                                AmountSubtractCardMore1 += meal.Amount;
                            }

                        }
                    }
                    ReportAdjustmentMealAllowancePayment.TotalScanManyTime = countCardMore1;
                    ReportAdjustmentMealAllowancePayment.TotalDeductionScanManyTime = AmountSubtractCardMore1.Value;
                    ReportAdjustmentMealAllowancePayment.TotalNotWorkButEatTime = mealProfiles.Count(s => s.NoWorkDay == true);
                    ReportAdjustmentMealAllowancePayment.TotalNotWorkButEatAmount = mealProfiles.Sum(s => s.Amount.Value);
                    ReportAdjustmentMealAllowancePayment.TotalNotWorkButEatAmount = mealProfiles.Sum(s => s.Amount.Value);
                }
                lstReportAdjustmentMealAllowancePayment.Add(ReportAdjustmentMealAllowancePayment);
            }
            return lstReportAdjustmentMealAllowancePayment;
        }
Пример #34
0
 /// <summary>
 /// [Tam.Le] - 20140725 - Lấy dữ liệu BC Chi Tiết Nhân Viên Không Chấm Công Nhưng Có Ă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_ReportMealTimeDetailEntity> ReportMealTimeDetail(List<int?> CarteringIDs, List<int?> CanteenIDS, List<int?> LineIDS, DateTime dateStart, DateTime dateEnd, List<int?> orgIDs)
 {
     var mealRecords = new List<Can_MealRecord>().Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID }).ToList();
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Can_MealRecordRepository(unitOfWork);
         if (LineIDS != null)
         {
             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();
         }
         else mealRecords = repo.GetAll().Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID }).ToList();
     }
     var lstCodeAttendance = mealRecords.Select(s => s.CardCode).Distinct().ToList();
     var lstProfile = new List<Hre_Profile>().Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp }).ToList();
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Hre_ProfileRepository(unitOfWork);
         lstProfile = repo.FindBy(s => lstCodeAttendance.Contains(s.CodeAttendance))
         .Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp }).ToList();
     }
     List<Cat_OrgStructure> orgs = new List<Cat_OrgStructure>();
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Cat_OrgStructureRepository(unitOfWork);
         orgs = repo.FindBy(s => s.Code != null).ToList();
     }
     lstProfile = lstProfile.Where(s => s.OrgStructureID != null && orgIDs.Contains(s.OrgStructureID.Value)).ToList();
     //if (!isIncludeQuitEmp)
     //{
     //    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();
     //}
     if (CanteenIDS != null)
     {
         mealRecords = mealRecords.Where(s => s.CanteenID != null && CanteenIDS.Contains(s.CanteenID.Value)).ToList();
     }
     if (CarteringIDs != null)
     {
         mealRecords = mealRecords.Where(s => s.CateringID != null && CarteringIDs.Contains(s.CateringID.Value)).ToList();
     }
     if (LineIDS != null)
     {
         mealRecords = mealRecords.Where(s => s.LineID != null && LineIDS.Contains(s.LineID.Value)).ToList();
     }
     lstCodeAttendance = mealRecords.Select(s => s.CardCode).Distinct().ToList();
     List<Hre_Profile> profiles = new List<Hre_Profile>();
     var lstProfileId = new List<int>();
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Hre_ProfileRepository(unitOfWork);
         profiles = repo.FindBy(s => lstCodeAttendance.Contains(s.CodeAttendance)).ToList();
         lstProfileId = profiles.Select(s => s.Id).ToList();
     }
     var orgTypes = new List<Cat_OrgStructureType>();
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Cat_OrgStructureTypeRepository(unitOfWork);
         orgTypes = repo.FindBy(s => s.IsDelete == null).ToList<Cat_OrgStructureType>();
     }
     Can_ReportMealTimeDetailEntity reportMealTimeDetailEntity = null;
     List<Can_ReportMealTimeDetailEntity> lstreportMealTimeDetailEntity = new List<Can_ReportMealTimeDetailEntity>();
     foreach (var mealRecord in mealRecords)
     {
         reportMealTimeDetailEntity = new Can_ReportMealTimeDetailEntity();
         var profile = profiles.FirstOrDefault(s => s.CodeAttendance == mealRecord.CardCode);
         if (profile != null)
         {
             int? 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);
             reportMealTimeDetailEntity.BranchCode = orgBranch != null ? orgBranch.Code : string.Empty;
             reportMealTimeDetailEntity.DepartmentCode = orgOrg != null ? orgOrg.Code : string.Empty;
             reportMealTimeDetailEntity.TeamCode = orgTeam != null ? orgTeam.Code : string.Empty;
             reportMealTimeDetailEntity.SectionCode = orgSection != null ? orgSection.Code : string.Empty;
             reportMealTimeDetailEntity.BranchName = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
             reportMealTimeDetailEntity.DepartmentName = orgOrg != null ? orgOrg.OrgStructureName : string.Empty;
             reportMealTimeDetailEntity.TeamName = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
             reportMealTimeDetailEntity.SectionName = orgSection != null ? orgSection.OrgStructureName : string.Empty;
             reportMealTimeDetailEntity.CodeEmp = profile.CodeEmp;
             reportMealTimeDetailEntity.ProfileName = profile.ProfileName;
             reportMealTimeDetailEntity.Date = mealRecord.TimeLog;
         }
         lstreportMealTimeDetailEntity.Add(reportMealTimeDetailEntity);
     }
     return lstreportMealTimeDetailEntity;
 }
Пример #35
0
        /// <summary>
        /// [Tam.Le] - 20140726 - Lấy dữ liệu BC Trường Hợp Quẹt Thẻ Ở Hàng Ăn Không Tiêu Chuẩ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_ReportCardNotStandEntity> ReportCardNotStand(List<int?> cateringIDs, List<int?> canteenIDs, List<int?> lineIDs, DateTime dateStart, DateTime dateEnd, List<int?> orgIDs)
        {
            DataTable datatable = CreateReportCardNotStandSchema(dateStart, dateEnd);
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));               
                var repoCan_MealRecord = new Can_MealRecordRepository(unitOfWork);
                var mealRecords = repoCan_MealRecord.FindBy(s => s.CardCode != null && dateStart <= s.TimeLog && s.TimeLog <= dateEnd)
                 .Select(s => new { s.CardCode, s.TimeLog, s.CanteenID, s.CateringID, s.LineID, s.Amount,s.MealAllowanceType }).ToList();
                //var profileIds = mealRecords.Select(s => s.ProfileID.Value).Distinct().ToList();
                var codeAttendances = mealRecords.Select(s => s.CardCode).Distinct().ToList();
                var repoHre_Profile = new Hre_ProfileRepository(unitOfWork);
                var profiles = repoHre_Profile.FindBy(s => codeAttendances.Contains(s.CodeAttendance))
                 .Select(s => new { s.Id, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp,s.CodeAttendance }).ToList();
                var repoCan_MealAllowanceTypeSetting = new Can_MealAllowanceTypeSettingRepository(unitOfWork);
                var mealAllowanceTypeSantandIDs = repoCan_MealAllowanceTypeSetting.FindBy(s => s.Standard == true)
                  .Select(s => s.Id).ToList();
                var repoCan_Line = new Can_LineRepository(unitOfWork);
                var lineHDTJobIDs = repoCan_Line.FindBy(s => s.LineHDTJOB != null)
                  .Select(s => s.Id).ToList();
                var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork);
                var orgs = repoCat_OrgStructure.FindBy(s => s.Code != null).ToList();                
                if (orgIDs != null)
                {
                    profiles = profiles.Where(s => s.OrgStructureID != null && orgIDs.Contains(s.OrgStructureID.Value)).ToList();
                }
                //if (!isIncludeQuitEmp)
                //{
                //    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();
                //}
                if (canteenIDs != null)
                {
                    mealRecords = mealRecords.Where(s => s.CanteenID != null && canteenIDs.Contains(s.CanteenID.Value)).ToList();
                }
                if (cateringIDs != null)
                {
                    mealRecords = mealRecords.Where(s => s.CateringID != null && cateringIDs.Contains(s.CateringID.Value)).ToList();
                }
                if (lineIDs != null)
                {
                    mealRecords = mealRecords.Where(s => s.LineID != null && lineIDs.Contains(s.LineID.Value)).ToList();
                }                
                //for (DateTime date = dateStart; date <= dateEnd; date = date.AddDays(1))
                //{
                //    if (!table.Columns.Contains("Date" + date.Day))
                //        table.Columns.Add("Date" + date.Day, typeof(DateTime));
                //}
                mealRecords = mealRecords.Where(s => s.MealAllowanceType != null && mealAllowanceTypeSantandIDs.Contains(s.MealAllowanceType)
                            && s.LineID != null && !lineHDTJobIDs.Contains(s.LineID.Value)).ToList();
                profiles = profiles.Where(s => codeAttendances.Contains(s.CodeAttendance)).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>();
                Can_ReportCardNotStandEntity reportCardNotStandEntity = null;
                List<Can_ReportCardNotStandEntity> lstreportCardNotStandEntity = new List<Can_ReportCardNotStandEntity>();
                foreach (var profile in profiles)
                {
                    reportCardNotStandEntity = new Can_ReportCardNotStandEntity();
                    int? 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);
                    reportCardNotStandEntity.BranchCode = orgBranch != null ? orgBranch.Code : string.Empty;
                    reportCardNotStandEntity.DepartmentCode = orgOrg != null ? orgOrg.Code : string.Empty;
                    reportCardNotStandEntity.TeamCode = orgTeam != null ? orgTeam.Code : string.Empty;
                    reportCardNotStandEntity.SectionCode = orgSection != null ? orgSection.Code : string.Empty;
                    reportCardNotStandEntity.BranchName = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
                    reportCardNotStandEntity.DepartmentName = orgOrg != null ? orgOrg.OrgStructureName : string.Empty;
                    reportCardNotStandEntity.TeamName = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
                    reportCardNotStandEntity.SectionName = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                    reportCardNotStandEntity.CodeEmp = profile.CodeEmp;
                    reportCardNotStandEntity.ProfileName = profile.ProfileName;
                    //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;
                    //    }
                    //}
                    reportCardNotStandEntity.CountCard = mealRecords.Count(s => s.CardCode == profile.CodeAttendance);
                    reportCardNotStandEntity.SumAmount = mealRecords.Where(s => s.CardCode == profile.CodeAttendance).Sum(s => s.Amount);
                    lstreportCardNotStandEntity.Add(reportCardNotStandEntity);
                }
                return lstreportCardNotStandEntity;
            }
        }
Пример #36
0
        public void NUnit_WorkDay_Domain_SummaryInOut()
        {
            #region listShift
            using (var contextCategory = new VnrHrmDataContext())
            {
                List<Cat_Shift> listShift = new List<Cat_Shift>();
                Cat_Shift _shift = new Cat_Shift()
                {
                    Id = 1,
                    ShiftName = "Ca Test",
                    InTime = DateTime.Parse("01-09-14 08:00:00"),
                    CoOut = 9,
                    CoBreakIn = 4,
                    CoBreakOut = 5,
                };
                listShift.Add(_shift);
                contextCategory.Cat_Shift.Add(_shift);
                contextCategory.SaveChanges();
            }
            #endregion
            #region listRoster
            using (var contextAtt = new VnrHrmDataContext())
            {
                List<Att_Roster> listRoster = new List<Att_Roster>();
                Att_Roster _roster = new Att_Roster()
                {
                    ProfileID = 1,
                    RosterGroupName = "Nhom 1",
                    Type = "E_DEFAULT",
                    Status = "",
                    DateEnd = DateTime.Parse("01-03-2014"),
                    DateStart = DateTime.Parse("01-02-2014"),
                    MonShiftID = 1,
                    TueShiftID = 1,
                    WedShiftID = 1,
                    ThuShiftID = 1,
                    FriShiftID = 1,
                    SatShiftID = 1,
                    SunShiftID = 1
                };
                listRoster.Add(_roster);
                contextAtt.Att_Roster.Add(_roster);
                contextAtt.SaveChanges();
                #endregion
                #region listTamScanLog
                List<Att_TAMScanLog> listTamScanLog = new List<Att_TAMScanLog>();
                Att_TAMScanLog _tamScanLog1 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("01-02-2014 08:00:00"),
                    SrcType = "E_IN",
                    Type = ""
                };
                Att_TAMScanLog _tamScanLog2 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("01-02-2014 17:00:00"),
                    SrcType = "E_OUT",
                    Type = ""
                };
                Att_TAMScanLog _tamScanLog3 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("02-02-2014 08:00:00"),
                    SrcType = "E_IN",
                    Type = ""
                };
                Att_TAMScanLog _tamScanLog4 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("02-02-2014 17:00:00"),
                    SrcType = "E_OUT",
                    Type = ""
                };
                listTamScanLog.Add(_tamScanLog1);
                listTamScanLog.Add(_tamScanLog2);
                listTamScanLog.Add(_tamScanLog3);
                listTamScanLog.Add(_tamScanLog4);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog1);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog2);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog3);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog4);
                contextAtt.SaveChanges();
            }
            #endregion
            # region CardHistory
            using (var contextHr = new VnrHrmDataContext())
            {
                List<Hre_CardHistory> listcardhistory = new List<Hre_CardHistory>();
                Hre_CardHistory cardhistory = new Hre_CardHistory()
                {
                    ProfileID = 1,
                    CardCode = "123",
                    DateEffect = DateTime.Parse("01-01-2014")
                };
                listcardhistory.Add(cardhistory);
                contextHr.Hre_CardHistory.Add(cardhistory);
                contextHr.SaveChanges();
            }
            #endregion
            DateTime dateFrom = DateTime.Parse("01-02-2014");
            DateTime dateTo = DateTime.Parse("01-03-2014");

            List<int> listSelectedProfileID = new List<int>(){1,2};

            Att_WorkDayServices service = new Att_WorkDayServices();
            //List<Att_WorkDayEntity> ListInOut = service.SummaryInOut(dateFrom, dateTo, listSelectedProfileID);
        }
Пример #37
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;
        }