Example #1
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;
        }
Example #2
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();


            }
        }
        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
        }
Example #4
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;
            }
        }
Example #5
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;
        }
Example #6
0
        public List<Hre_ReportCodeNotInSystemEntity> GetReportCodeNotInSystem(DateTime? DateFrom, DateTime? DateTo)
        {
            List<Hre_ReportCodeNotInSystemEntity> lstReportCodeNotInSystem = new List<Hre_ReportCodeNotInSystemEntity>();
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Hre_ProfileRepository(unitOfWork);
                var codeAttendance = repo.FindBy(s => s.IsDelete == null).Select(m => m.CodeAttendance).Distinct().ToList();
                var repoTAMScanLog = new Att_TAMScanLogRepository(unitOfWork);
                var lstCardHistory = repoTAMScanLog.FindBy(m => m.TimeLog >= DateFrom && m.TimeLog <= DateTo && !codeAttendance.Contains(m.CardCode))
                .Select(m => new { m.CardCode, m.TimeLog, m.MachineNo, m.Type, m.SrcType, m.DateCreate, m.UserCreate }).ToList();

                foreach (var CardHistory in lstCardHistory)
                {
                    Hre_ReportCodeNotInSystemEntity codeNotInSystemEntity = new Hre_ReportCodeNotInSystemEntity();
                    codeNotInSystemEntity.Code = CardHistory.CardCode;
                    codeNotInSystemEntity.Type = CardHistory.Type;
                    codeNotInSystemEntity.Time = CardHistory.TimeLog;
                    codeNotInSystemEntity.Machine = CardHistory.MachineNo;
                    codeNotInSystemEntity.UserCreate = CardHistory.UserCreate;
                    codeNotInSystemEntity.DateCreate = CardHistory.DateCreate;
                    lstReportCodeNotInSystem.Add(codeNotInSystemEntity);
                }
                return lstReportCodeNotInSystem;
            }
        }
Example #7
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;
            }
        }
        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;
        }
Example #9
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;
     }
 }
Example #10
0
        public string ActionBlackListCandidate(string selectedIds, Guid? _ReasonBlackListID)
        {
            using (var context = new VnrHrmDataContext())
            {
                BaseService service = new BaseService();
                string message = string.Empty;
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCandidate = new Rec_CandidateRepository(unitOfWork);
                var repoHistory = new Rec_RecruitmentHistoryRepository(unitOfWork);
                List<Guid> lstcandidateIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
                var lstCandidates = repoCandidate.FindBy(m => m.ID != null && lstcandidateIds.Contains(m.ID)).ToList();

                var lstRecruimentHistory = repoHistory.FindBy(m => m.CandidateID != null && lstcandidateIds.Contains(m.CandidateID)).ToList();

                foreach (var Candidate in lstCandidates)
                {
                    Candidate.IsBlackList = true;
                    Candidate.ReasonBlackListID = _ReasonBlackListID;
                    var hisbycandidate = lstRecruimentHistory.Where(s => s.CandidateID == Candidate.ID).OrderByDescending(s => s.DateApply).FirstOrDefault();
                    hisbycandidate.IsBlackList = true;
                }
                repoCandidate.SaveChanges();
                repoHistory.SaveChanges();
                message = NotificationType.Success.ToString();
                return message;
            }
        }
Example #11
0
        public string ActionApprovedCandidate(string selectedIds)
        {
            using (var context = new VnrHrmDataContext())
            {
                BaseService service = new BaseService();
                string message = string.Empty;
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCandidate = new Rec_CandidateRepository(unitOfWork);
                var repoHistory = new Rec_RecruitmentHistoryRepository(unitOfWork);
                List<Guid> lstcandidateIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
                var lstCandidates = repoCandidate.FindBy(m => m.ID != null && lstcandidateIds.Contains(m.ID)).ToList();

                var lstRecruimentHistory = repoHistory.FindBy(m => m.CandidateID != null && lstcandidateIds.Contains(m.CandidateID)).ToList();

                foreach (var Candidate in lstCandidates)
                {
                    Candidate.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_APPROVE.ToString();
                    Candidate.DateUpdate = DateTime.Now;
                    var hisbycandidate = lstRecruimentHistory.Where(s => s.CandidateID == Candidate.ID).OrderByDescending(s => s.DateApply).FirstOrDefault();
                    hisbycandidate.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_APPROVE.ToString();
                    hisbycandidate.CandidateID = Candidate.ID;
                    hisbycandidate.DateUpdate = DateTime.Now;
                }
                repoCandidate.SaveChanges();
                repoHistory.SaveChanges();
                message = NotificationType.Success.ToString();
                return message;
            }
        }
Example #12
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;
        }
Example #13
0
        public List<FIN_ClaimEntity> GetClaimApprovedList(Guid UserLogin)
        {
            List<FIN_ClaimEntity> lstReturn = new List<FIN_ClaimEntity>();

            string appType = ApproveType.E_FIN_ClaimRequest.ToString();
            string status = string.Empty;
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoFIN_Claim = new CustomBaseRepository<FIN_Claim>(unitOfWork);
                List<Sys_ConditionApproved> lstCondition = new List<Sys_ConditionApproved>();
                List<Hre_ProfileEntity> lstProfile = new List<Hre_ProfileEntity>();
                GetProfileWithPermissionLogin(UserLogin, appType, out lstCondition, out lstProfile);

                var lstExpensesCondition = lstCondition.Select(s => s.ExpensesType).Distinct().ToList();
                var dataClaim = repoFIN_Claim
                    .FindBy(s => s.IsDelete == null && lstExpensesCondition.Contains(s.ExpensesType))
                    .ToList().Translate<FIN_ClaimEntity>();

                foreach (var condition in lstCondition)
                {
                    List<Guid> lstGuidOrg = GetOrgInCondition(condition);
                    var profileInOrg = lstProfile.Where(s => lstGuidOrg.Contains(s.OrgStructureID.Value)).Select(a => a.ID).ToList();
                    
                    var resultCondition = dataClaim.Where(s => profileInOrg.Contains(s.ProfileID.Value)).ToList();
                    lstReturn.AddRange(resultCondition);
                }
            }
            return lstReturn;
        }
Example #14
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
        }
Example #15
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
     }
 }  
        public List<Att_WorkdayEntity> ComputeWorkdayAdjust(ListQueryModel lstModel, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                string status = string.Empty;

                #region xử lý lấy lstProfileIds theo OrgStructureID
                //List<Hre_ProfileEntity> lstProfile = new List<Hre_ProfileEntity>();
                //List<Guid> lstProfileIDs = new List<Guid>();
                //List<object> lstObj = new List<object>();
                //lstObj.Add(search.OrgStructureID);
                //lstObj.Add(null);
                //lstObj.Add(null);
                //if (search.ProfileName != null && search.OrgStructureID == null)
                //{
                //}
                //else
                //{
                //    lstProfile = GetData<Hre_ProfileEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status);
                //    lstProfileIDs = lstProfile.Select(s => s.ID).ToList();
                //}
                #endregion

                var lstWorkday = GetData<Att_WorkdayEntity>(lstModel, ConstantSql.hrm_att_sp_get_WorkDay, UserLogin, ref status);
                SetStatusLeaveOnWorkday(lstWorkday, unitOfWork);
                return lstWorkday;
            }
        }
Example #17
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;
            }
        }
Example #18
0
 public string SaveList(List<Att_RosterEntity> lstModel)
 {
     using (var context = new VnrHrmDataContext())
     {
         List<Att_Roster> lstSave = new List<Att_Roster>();
         lstSave = lstModel.Translate<Att_Roster>();
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new CustomBaseRepository<Att_Roster>(unitOfWork);
         //int count = 0;
         foreach (var item in lstSave)
         {
             //count += 1;
             item.ID = Guid.NewGuid();
             repo.Add(item);
         }
         try
         {
             repo.SaveChanges();
             return "Success";
         }
         catch (Exception)
         {
             return "Error";
         }
     }
 }
Example #19
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;
        }
Example #20
0
        public FIN_ApproverECLAIMEntity AddApprovers(FIN_ApproverECLAIMEntity model)
        {
            var result = new FIN_ApproverECLAIMEntity();
            using (var context = new VnrHrmDataContext())
            {
                var status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                //lay ds Approved theo profileId
                var profileId = Common.DotNetToOracle(string.Empty.ToString());
                if (model != null && model.ProfileID != null)
                {
                    profileId = Common.DotNetToOracle(model.ProfileID.ToString());
                }

                if (model != null)
                {
                    model.ApprovedIDs = model.ApprovedIDs.Where(m => m != Guid.Empty).ToList();
                    var lstEvaluators = model.ApprovedIDs == null ? new List<Guid>() : model.ApprovedIDs;
                    foreach (var evaluator in lstEvaluators)
                    {
                        result = model.CopyData<FIN_ApproverECLAIMEntity>();
                        result.ApprovedID = evaluator;
                        Add(result);
                    }
                    if (!lstEvaluators.Any())
                    {
                        //khi khong chon nguoi danh gia
                        result = model.CopyData<FIN_ApproverECLAIMEntity>();
                        result.ApprovedID = null;
                        Add(result);
                    }
                }
            }//end context
            return result;
        }
Example #21
0
 public DateTime CurrentDateTime()
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Sys_UserRepository(unitOfWork);
         return repo.CurrentDateTime();
     }
 }
Example #22
0
 public Sys_DataPermissionEntity  CheckDuplicateDataPermission(Guid userId, Guid groupId)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Sys_DataPermissionRepository(unitOfWork);
         return repo.CheckDuplicateDataPermission(userId, groupId);
     }
 }
Example #23
0
 public List<Guid> GetUsers()
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork) (new UnitOfWork(context));
         var repo = new Sys_DataPermissionRepository(unitOfWork);
         return repo.FindBy(p => p.IsDelete == null).Select(p => p.UserID).ToList();
     }
 }
        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;
                }

            }
        }
Example #25
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();
            }
        }
Example #26
0
 /// <summary>
 /// Lấy tất cả các bản ghi 
 /// Get by key
 /// </summary>
 /// <returns></returns>
 public List<Sys_AllSettingEntity> Get(string key)
 {
     using (var context = new VnrHrmDataContext())
     {
         IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         Sys_AllSettingRepository repo = new Sys_AllSettingRepository(unitOfWork);
         return repo.GetAllSettings(key);
     }
 }
Example #27
0
 public void UpdateSettingByName(string strName, string value)
 {
     using (var context = new VnrHrmDataContext())
     {
         IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         Sys_AllSettingRepository repo = new Sys_AllSettingRepository(unitOfWork);
         repo.UpdateSettingByName(strName, value);
     }
 }
Example #28
0
 /// <summary>
 /// [Hieu.Van] 14/07/2014
 /// Thay Đổi trạng thái ngày nghỉ
 /// </summary>
 /// <param name="selectedIds"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool UpdateStatusLeaveday(string selectedIds, string type)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Att_LeavedayRepository(unitOfWork);
         return repo.UpdateStatusLeaveday(selectedIds, type);
     }
 }
Example #29
0
 /// <summary>
 /// Lấy toàn bộ data
 /// </summary>
 /// <returns></returns>
 public List<WorkdayCustom> GetWorkDaysByInOut(DateTime inTime, DateTime outTime)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Att_WorkDayRepository(unitOfWork);
         return repo.GetWorkDaysByInOut(inTime, outTime).Translate<WorkdayCustom>();
     }
 }
 public bool CalculateAnnualLeaveDetails(int year)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo = new Att_AnnualLeaveDetailRepository(unitOfWork);
         var rs = repo.CalculateAnnualLeaveDetails(year);
         return false;
     }
 }