Exemplo n.º 1
0
        public Sys_AllSettingModel Put(Sys_AllSettingModel model)
        {
            var sysAllSetting = new Sys_AllSettingEntity
            {
                ID = model.ID,
                Name = model.Name + "_" + model.UserID.ToString(),
                Value1 = model.Value1,
                Value2 = model.Value2,
                ModuleName = model.ModuleName,
                UserID = model.UserID
            };
            //var service = new Sys_AllSettingServices();
            //if (model.ID != Guid.Empty)
            //{
            //    sysAllSetting.ID = model.ID;
            //    service.Edit<Sys_AllSettingEntity>(sysAllSetting);
            //}
            //else
            //{
            //    service.Add<Sys_AllSettingEntity>(sysAllSetting);
            //}

            var sysAllSettingServices = new Sys_AttOvertimePermitConfigServices();
            sysAllSettingServices.CreateOrUpdateSysAllSetting(sysAllSetting.Name, model.Value1);
            return model;
        }
Exemplo n.º 2
0
 public String Post([Bind]Sys_HreConfigModel model)
 {
     string message = string.Empty;
     var service = new Sys_AttOvertimePermitConfigServices();
     var entity = model.CopyData<Sys_HreConfigEntity>();
     service.SaveHrConfig(entity);
     return message;
 }
Exemplo n.º 3
0
        public String Post([Bind] Sys_SalConfigModel model)
        {
            string message = string.Empty;
            var    service = new Sys_AttOvertimePermitConfigServices();
            var    entity  = model.CopyData <Sys_SalConfigEntity>();

            service.SavePayrollConfig(entity);
            return(message);
        }
        public String Post([Bind] Sys_CatTastAfterImportConfigModel model)
        {
            string message = string.Empty;
            var    service = new Sys_AttOvertimePermitConfigServices();
            var    entity  = model.CopyData <Sys_CatTaskAfterImportConfigEntity>();

            service.SaveCatAfterConfig(entity);
            return(message);
        }
Exemplo n.º 5
0
 public Sys_EvaConfigModel GetById(Guid id)
 {
     var model = new Sys_EvaConfigModel();
     var service = new Sys_AttOvertimePermitConfigServices();
     var entity = service.GetEvaConfig();
     if (entity != null)
     {
         model = entity.CopyData<Sys_EvaConfigModel>();
     }
     return model;
 }
Exemplo n.º 6
0
        /// <summary>
        /// [Kiet.Chung] - Lấy dữ liệu theo Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Sys_SalConfigModel GetById(Guid id)
        {
            var model   = new Sys_SalConfigModel();
            var service = new Sys_AttOvertimePermitConfigServices();
            var entity  = service.GetPayrollConfig();

            if (entity != null)
            {
                model = entity.CopyData <Sys_SalConfigModel>();
            }
            return(model);
        }
        public Sys_CatTastAfterImportConfigModel GetById(Guid id)
        {
            var model   = new Sys_CatTastAfterImportConfigModel();
            var service = new Sys_AttOvertimePermitConfigServices();
            var entity  = service.GetCatAfterConfig();

            if (entity != null)
            {
                model = entity.CopyData <Sys_CatTastAfterImportConfigModel>();
            }
            return(model);
        }
Exemplo n.º 8
0
 public Sys_UserSettingModel Getbyid(Guid id)
 {
     var service = new Sys_AttOvertimePermitConfigServices();
     var language = service.GetConfigValue<string>(AppConfig.HRM_SYS_USERSETTING_LANGUAGE.ToString()+"_"+id.ToString());
     var theme = service.GetConfigValue<string>(AppConfig.HRM_SYS_USERSETTING_THEME + "_" + id.ToString());
     var userSetting = new Sys_UserSettingModel()
     {
         LanguageName = language,
         ThemeName = theme,
         UserCreateID = id
     };
     return userSetting;
 }
Exemplo n.º 9
0
        public String Post([Bind]Sys_EvaConfigModel model)
        {
            string message = string.Empty;
            #region Validate
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Sys_EvaConfigModel>(model, "Sys_EvaConfig", ref message);
            if (!checkValidate)
            {
               // model.ActionStatus = message;
                return message;
            }
            #endregion

            var service = new Sys_AttOvertimePermitConfigServices();
            var entity = model.CopyData<Sys_EvaConfigEntity>();
            service.SaveEvaConfig(entity);
            return message;
        }
Exemplo n.º 10
0
        public String Post([Bind] Sys_EvaConfigModel model)
        {
            string message = string.Empty;

            #region Validate
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sys_EvaConfigModel>(model, "Sys_EvaConfig", ref message);
            if (!checkValidate)
            {
                // model.ActionStatus = message;
                return(message);
            }
            #endregion

            var service = new Sys_AttOvertimePermitConfigServices();
            var entity  = model.CopyData <Sys_EvaConfigEntity>();
            service.SaveEvaConfig(entity);
            return(message);
        }
Exemplo n.º 11
0
        public Eva_PerformanceEvaModel GetById(Guid id)
        {
            string status = string.Empty;
            var model = new Eva_PerformanceEvaModel();
            var service = new ActionService(UserLogin);

            #region Thêm vào bảng Eva_performanceEvaDetail trước khi vào màn hình chờ đánh giá
            //truoc khi vào màn hình chờ đánh giá , sẽ thêm vào bảng eva_performanceEvaDetail nếu bảng này chưa có data ứng với performanceID
            var performanceService = new Eva_PerformanceServices();
            performanceService.AddPerformanceEvaDetail360(id);
            #endregion
            

           // var isEvaluation = false;
            var entity = service.GetByIdUseStore<Eva_PerformanceEvaEntity>(id, ConstantSql.hrm_eva_sp_get_PerformanceEvaById, ref status);
            if (entity != null)
            {
                model = entity.CopyData<Eva_PerformanceEvaModel>();
                
                Eva_PerformanceEvaServices service1 = new Eva_PerformanceEvaServices();
                var performanceservice = new Eva_PerformanceServices();
                if (model != null)
                {
                    model.IsSuperiorHasPerformance = service1.CheckSuperiorHasPerformance(model.PerformanceID ?? Guid.Empty, model.ID);
                    model.IsEvaluation = service1.CheckOrder(model.PerformanceID ?? Guid.Empty, model.ID);
                    model.AttachFileLast = performanceservice.GetAttachFileByOrderNo(model.PerformanceID ?? Guid.Empty, model.OrderEva ?? 0);
                    model.AttachFile = performanceservice.GetAttachFileByOrderNo(model.PerformanceID ?? Guid.Empty, model.OrderEva ?? 0);
                }
            }
            model.ActionStatus = status;

            #region lấy khoảng thời gian cho phép nhập điểm
            var serv = new Sys_AttOvertimePermitConfigServices();
            var dateEndMark = serv.GetConfigValue<DateTime>(AppConfig.HRM_EVA_CONFIG_DATEENDMARK);
            var dateStartMark = serv.GetConfigValue<DateTime?>(AppConfig.HRM_EVA_CONFIG_DATESTARTMARK);
            model.DateStartMark = dateStartMark;
            model.DateEndMark = dateEndMark;
            #endregion


            return model;
        }
Exemplo n.º 12
0
        public Eva_PerformanceEvaModel GetById(Guid id)
        {
            string status  = string.Empty;
            var    model   = new Eva_PerformanceEvaModel();
            var    service = new ActionService(UserLogin);

            #region Thêm vào bảng Eva_performanceEvaDetail trước khi vào màn hình chờ đánh giá
            //truoc khi vào màn hình chờ đánh giá , sẽ thêm vào bảng eva_performanceEvaDetail nếu bảng này chưa có data ứng với performanceID
            var performanceService = new Eva_PerformanceServices();
            performanceService.AddPerformanceEvaDetail360(id);
            #endregion


            // var isEvaluation = false;
            var entity = service.GetByIdUseStore <Eva_PerformanceEvaEntity>(id, ConstantSql.hrm_eva_sp_get_PerformanceEvaById, ref status);
            if (entity != null)
            {
                model = entity.CopyData <Eva_PerformanceEvaModel>();

                Eva_PerformanceEvaServices service1 = new Eva_PerformanceEvaServices();
                var performanceservice = new Eva_PerformanceServices();
                if (model != null)
                {
                    model.IsSuperiorHasPerformance = service1.CheckSuperiorHasPerformance(model.PerformanceID ?? Guid.Empty, model.ID);
                    model.IsEvaluation             = service1.CheckOrder(model.PerformanceID ?? Guid.Empty, model.ID);
                    model.AttachFileLast           = performanceservice.GetAttachFileByOrderNo(model.PerformanceID ?? Guid.Empty, model.OrderEva ?? 0);
                    model.AttachFile = performanceservice.GetAttachFileByOrderNo(model.PerformanceID ?? Guid.Empty, model.OrderEva ?? 0);
                }
            }
            model.ActionStatus = status;

            #region lấy khoảng thời gian cho phép nhập điểm
            var serv          = new Sys_AttOvertimePermitConfigServices();
            var dateEndMark   = serv.GetConfigValue <DateTime>(AppConfig.HRM_EVA_CONFIG_DATEENDMARK);
            var dateStartMark = serv.GetConfigValue <DateTime?>(AppConfig.HRM_EVA_CONFIG_DATESTARTMARK);
            model.DateStartMark = dateStartMark;
            model.DateEndMark   = dateEndMark;
            #endregion


            return(model);
        }
Exemplo n.º 13
0
        public List<Eva_EvalutionDataEntity> SummaryEvalutionData(int year, Guid? _TimesGetDataID, string orgStructureID, DateTime? _daystart, DateTime? _dayend,string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                //    #region Get Data
                string status = string.Empty;
                List<Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List<Eva_EvalutionDataEntity>();

                //    //ds nv
                var hrService = new Hre_ProfileServices();
                var service = new BaseService();
                List<object> strOrgIDs = new List<object>();
                strOrgIDs.AddRange(new object[1]);
                strOrgIDs[0] = (object)orgStructureID;

                var lstProfile = hrService.GetData<Hre_ProfileEntity>(strOrgIDs, ConstantSql.hrm_eva_sp_getdata_ProfileByOrg, userLogin, ref status).ToList();
                if (lstProfile == null || lstProfile.Count == 0)
                    return lstEvalutionDataEntity;
                List<Guid> lstProfileIDs = lstProfile.Select(s => s.ID).ToList();
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                var lstattattendancetable = new List<Att_AttendanceTable>().Select(d => new
                {
                    d.LateEarlyDeductionHours,
                    d.ProfileID
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstattattendancetable.AddRange(unitOfWork.CreateQueryable<Att_AttendanceTable>(Guid.Empty,
                        d => lstProfileID.Contains(d.ProfileID) && d.MonthYear >= _daystart
                            && d.MonthYear <= _dayend).Select(d => new
                            {
                                d.LateEarlyDeductionHours,
                                d.ProfileID
                            }).ToList());
                }

                #region Lay cau hinh luu vao cot C1->C16
                Sys_AttOvertimePermitConfigServices sysServices = new Sys_AttOvertimePermitConfigServices();
                string DataC1 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C1);
                string DataC2 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C2);
                string DataC3 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C3);
                string DataC4 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C4);
                string DataC5 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C5);
                string DataC6 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C6);
                string DataC7 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C7);
                string DataC8 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C8);
                string DataC9 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C9);
                string DataC10 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C10);
                string DataC11 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C11);
                string DataC12 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C12);
                string DataC13 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C13);
                string DataC14 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C14);
                string DataC15 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C15);
                string DataC16 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C16);
                #endregion

                string[] lstDataC1 = null;
                string[] lstDataC2 = null;
                string[] lstDataC3 = null;
                string[] lstDataC4 = null;
                string[] lstDataC5 = null;
                string[] lstDataC6 = null;
                string[] lstDataC7 = null;
                string[] lstDataC8 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC1 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC2 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC3 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC4 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC5 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC6 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC7 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC8 = null;
                List<object> tempobjparam = new List<object>();
                tempobjparam.Add(orgStructureID);
                var tempcatService = new Cat_LeaveDayTypeServices();
                var templstcatLeaveDayType = tempcatService.GetData<Cat_LeaveDayTypeEntity>(tempobjparam, ConstantSql.hrm_cat_getdata_LeaveDayType, userLogin, ref status).ToList();
                if (templstcatLeaveDayType.Count > 0)
                {

                    #region Loai Nghi
                    #region C1
                    if (DataC1 != null)
                    {
                        DataC1 = DataC1.Replace(" ", "").Trim();
                        lstDataC1 = DataC1.Split(',').ToArray();
                        if (lstDataC1 != null && lstDataC1.Count() > 0)
                        {
                            templstleavedaytypeC1 = templstcatLeaveDayType.Where(s => lstDataC1.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C2
                    if (DataC2 != null)
                    {
                        DataC2 = DataC2.Replace(" ", "").Trim();
                        lstDataC2 = DataC2.Split(',').ToArray();
                        if (lstDataC2 != null && lstDataC2.Count() > 0)
                        {
                            templstleavedaytypeC2 = templstcatLeaveDayType.Where(s => lstDataC2.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C3
                    if (DataC3 != null)
                    {
                        DataC3 = DataC3.Replace(" ", "").Trim();
                        lstDataC3 = DataC3.Split(',').ToArray();
                        if (lstDataC3 != null && lstDataC3.Count() > 0)
                        {
                            templstleavedaytypeC3 = templstcatLeaveDayType.Where(s => lstDataC3.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C4
                    if (DataC4 != null)
                    {
                        DataC4 = DataC4.Replace(" ", "").Trim();
                        lstDataC4 = DataC4.Split(',').ToArray();
                        if (lstDataC4 != null && lstDataC4.Count() > 0)
                        {
                            templstleavedaytypeC4 = templstcatLeaveDayType.Where(s => lstDataC4.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C5
                    if (DataC5 != null)
                    {
                        DataC5 = DataC5.Replace(" ", "").Trim();
                        lstDataC5 = DataC5.Split(',').ToArray();
                        if (lstDataC5 != null && lstDataC5.Count() > 0)
                        {
                            templstleavedaytypeC5 = templstcatLeaveDayType.Where(s => lstDataC5.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C6
                    if (DataC6 != null)
                    {
                        DataC6 = DataC6.Replace(" ", "").Trim();
                        lstDataC6 = DataC6.Split(',').ToArray();
                        if (lstDataC6 != null && lstDataC6.Count() > 0)
                        {
                            templstleavedaytypeC6 = templstcatLeaveDayType.Where(s => lstDataC6.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C7
                    if (DataC7 != null)
                    {
                        DataC7 = DataC7.Replace(" ", "").Trim();
                        lstDataC7 = DataC7.Split(',').ToArray();
                        if (lstDataC7 != null && lstDataC7.Count() > 0)
                        {
                            templstleavedaytypeC7 = templstcatLeaveDayType.Where(s => lstDataC7.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C8
                    if (DataC8 != null)
                    {
                        DataC8 = DataC8.Replace(" ", "").Trim();
                        lstDataC8 = DataC8.Split(',').ToArray();
                        if (lstDataC8 != null && lstDataC8.Count() > 0)
                        {
                            templstleavedaytypeC8 = templstcatLeaveDayType.Where(s => lstDataC8.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #endregion
                }
                #region doi tuong loc theo loai nghi
                //var catService = new Cat_LeaveDayTypeServices();
                //List<object> objparam = new List<object>();
                //objparam.Add(orgStructureID);
                //var lstcatLeaveDayType = catService.GetData<Cat_LeaveDayTypeEntity>(objparam, ConstantSql.hrm_cat_getdata_LeaveDayType, ref status).ToList();
                //var lstleavedaytypeC1 = lstcatLeaveDayType.Where(s => s.Code == "P").ToList();
                //var lstleavedaytypeC2 = lstcatLeaveDayType.Where(s => s.Code == "M" || s.Code == "SM" || s.Code == "SP" || s.Code == "DL" || s.Code == "DSP").ToList();
                //var lstleavedaytypeC3 = lstcatLeaveDayType.Where(s => s.Code == "SU" || s.Code == "SC").ToList();
                //var lstleavedaytypeC4 = lstcatLeaveDayType.Where(s => s.Code == "DP" || s.Code == "SD").ToList();
                //var lstleavedaytypeC5 = lstcatLeaveDayType.Where(s => s.Code == "AL").ToList();
                //var lstleavedaytypeC7 = lstcatLeaveDayType.Where(s => s.Code == "D").ToList();
                Dictionary<string, List<Cat_LeaveDayTypeEntity>> dicLeaveByType = new Dictionary<string, List<Cat_LeaveDayTypeEntity>>();
                //dicLeaveByType.Add("C1", lstleavedaytypeC1);
                //dicLeaveByType.Add("C2", lstleavedaytypeC2);
                //dicLeaveByType.Add("C3", lstleavedaytypeC3);
                //dicLeaveByType.Add("C4", lstleavedaytypeC4);
                //dicLeaveByType.Add("C5", lstleavedaytypeC5);
                //dicLeaveByType.Add("C7", lstleavedaytypeC7);
                if (templstleavedaytypeC1 != null && templstleavedaytypeC1.Count > 0)
                    dicLeaveByType.Add("C1", templstleavedaytypeC1);
                if (templstleavedaytypeC2 != null && templstleavedaytypeC2.Count > 0)
                    dicLeaveByType.Add("C2", templstleavedaytypeC2);
                if (templstleavedaytypeC3 != null && templstleavedaytypeC3.Count > 0)
                    dicLeaveByType.Add("C3", templstleavedaytypeC3);
                if (templstleavedaytypeC4 != null && templstleavedaytypeC4.Count > 0)
                    dicLeaveByType.Add("C4", templstleavedaytypeC4);
                if (templstleavedaytypeC5 != null && templstleavedaytypeC5.Count > 0)
                    dicLeaveByType.Add("C5", templstleavedaytypeC5);
                if (templstleavedaytypeC6 != null && templstleavedaytypeC6.Count > 0)
                    dicLeaveByType.Add("C6", templstleavedaytypeC6);
                if (templstleavedaytypeC7 != null && templstleavedaytypeC7.Count > 0)
                    dicLeaveByType.Add("C7", templstleavedaytypeC7);
                if (templstleavedaytypeC8 != null && templstleavedaytypeC8.Count > 0)
                    dicLeaveByType.Add("C8", templstleavedaytypeC8);
                #endregion
                #region ngay nghi
                string strE_APPROVED = LeaveDayStatus.E_APPROVED.ToString();
                var lstLeaveDay = new List<Att_LeaveDay>().Select(d => new
                {
                    d.LeaveDayTypeID,
                    d.ProfileID,
                    d.LeaveDays,
                    d.DateStart,
                    d.DateEnd
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstLeaveDay.AddRange(unitOfWork.CreateQueryable<Att_LeaveDay>(Guid.Empty,
                        d => lstProfileID.Contains(d.ProfileID) && d.DateStart <= _dayend
                            && d.DateEnd >= _daystart && d.Status == strE_APPROVED).Select(d => new
                            {
                                d.LeaveDayTypeID,
                                d.ProfileID,
                                d.LeaveDays,
                                d.DateStart,
                                d.DateEnd
                            }).ToList());
                }
                #endregion
                #region ky luat
                var lsthreDiscipline = new List<Hre_Discipline>().Select(d => new
                {
                    d.DisciplinedTypesSuggestID,
                    d.ProfileID
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lsthreDiscipline.AddRange(unitOfWork.CreateQueryable<Hre_Discipline>(Guid.Empty,
                        d => lstProfileID.Contains(d.ProfileID) && d.DateOfEffective >= _daystart
                            && d.DateOfEffective <= _dayend).Select(d => new
                            {
                                d.DisciplinedTypesSuggestID,
                                d.ProfileID
                            }).ToList());
                }
                #endregion
                #region loai ky luat
                List<object> paraDisciplinedTypes = new List<object>();
                paraDisciplinedTypes.AddRange(new object[3]);
                paraDisciplinedTypes[1] = 1;
                paraDisciplinedTypes[2] = int.MaxValue;
                var catSerciceDisciplinedTypes = new Cat_DisciplinedTypesServices();
                var lstDisciplinedTypes = catSerciceDisciplinedTypes.GetData<Cat_DisciplinedTypesEntity>(paraDisciplinedTypes, ConstantSql.hrm_cat_sp_get_DisciplinedTypes, userLogin, ref status);
                //var objDisciplinedTypeVW = lstDisciplinedTypes.Where(s => s.Code == "VW").FirstOrDefault();
                //var objDisciplinedTypeWW = lstDisciplinedTypes.Where(s => s.Code == "WW").FirstOrDefault();
                //var objDisciplinedTypeDS = lstDisciplinedTypes.Where(s => s.Code == "DS").FirstOrDefault();

                Cat_DisciplinedTypesEntity tempobjDisciplinedType11 = null;
                Cat_DisciplinedTypesEntity tempobjDisciplinedType12 = null;
                Cat_DisciplinedTypesEntity tempobjDisciplinedType13 = null;
                #endregion
                #region Loai ky luat
                if (lstDisciplinedTypes != null)
                {
                    #region C11
                    if (DataC11 != null)
                    {
                        DataC11 = DataC11.Replace(" ", "").Trim();
                        tempobjDisciplinedType11 = lstDisciplinedTypes.Where(s => s.Code == DataC11).FirstOrDefault();
                    }
                    #endregion
                    #region C12
                    if (DataC12 != null)
                    {
                        DataC12 = DataC12.Replace(" ", "").Trim();
                        tempobjDisciplinedType12 = lstDisciplinedTypes.Where(s => s.Code == DataC12).FirstOrDefault();
                    }
                    #endregion
                    #region C13
                    if (DataC13 != null)
                    {
                        DataC13 = DataC13.Replace(" ", "").Trim();
                        tempobjDisciplinedType13 = lstDisciplinedTypes.Where(s => s.Code == DataC13).FirstOrDefault();
                    }
                    #endregion
                }

                #endregion
                #region Danh gia
                var kaiServiceKaizenData = new Kai_KaiZenDataServices();
                var listKaiKaizenData = new List<Kai_KaizenData>().Select(d => new
                {
                    d.Accumulate,
                    d.MarkPerform,
                    d.ProfileID
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    listKaiKaizenData.AddRange(unitOfWork.CreateQueryable<Kai_KaizenData>(Guid.Empty, d => d.ProfileID.HasValue
                        && lstProfileID.Contains(d.ProfileID.Value) && d.Month >= _daystart && d.Month <= _dayend).Select(d => new
                        {
                            d.Accumulate,
                            d.MarkPerform,
                            d.ProfileID
                        }).ToList());
                }
                #endregion
                #region Loai thieu quet the la quen quet the voi ma la FC
                var objTamScanResonMissID = unitOfWork.CreateQueryable<Cat_TAMScanReasonMiss>(Guid.Empty, s => s.Code.Trim() == "FC").Select(s => s.ID).FirstOrDefault();
                #endregion
                #region lay du lieu quen quet the
          
                var lstworkDayProfiles = new List<Att_Workday>().Select(d => new
                {
                    d.ProfileID,
                    d.WorkDate
                    
                }).ToList();
                if (objTamScanResonMissID != null)
                {
                    List<string> lstType = new List<string> 
                    { 
                        WorkdayType.E_MISS_IN.ToString(),
                        WorkdayType.E_MISS_IN_OUT.ToString(),
                        WorkdayType.E_MISS_OUT.ToString()
                    };
                    foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                    {
                        lstworkDayProfiles.AddRange(unitOfWork.CreateQueryable<Att_Workday>(Guid.Empty, d => lstProfileID.Contains(d.ProfileID) && _daystart <= d.WorkDate && d.WorkDate <= _dayend && lstType.Contains(d.Type) && d.MissInOutReason == objTamScanResonMissID).Select(d => new
                        {
                            d.ProfileID,
                            d.WorkDate
                        }).ToList());
                    }
                }
              
                #endregion
                bool? _tempC9LATEEARLYDEDUCTIONHOURS = false;
                bool? _tempC9FAILINGTORECORDCARD = false;
                bool? _tempC10LATEEARLYDEDUCTIONHOURS = false;
                bool? _tempC10FAILINGTORECORDCARD = false;

                #region xac dinh dlieu luu cot C9 va C10
                if (DataC9 != null)
                {
                    if (DataC9.Replace(" ", "").Trim() == "LATEEARLYDEDUCTIONHOURS")
                    {
                        _tempC9LATEEARLYDEDUCTIONHOURS = true;
                    }
                    else if (DataC9.Replace(" ", "").Trim() == "FAILINGTORECORDCARD")
                    {
                        _tempC9FAILINGTORECORDCARD = true;
                    }
                }
                if (DataC10 != null)
                {
                    if (DataC10.Replace(" ", "").Trim() == "LATEEARLYDEDUCTIONHOURS")
                    {
                        _tempC10LATEEARLYDEDUCTIONHOURS = true;
                    }
                    else if (DataC10.Replace(" ", "").Trim() == "FAILINGTORECORDCARD")
                    {
                        _tempC10FAILINGTORECORDCARD = true;
                    }
                }
                #endregion
                #region xac dinh dlieu luu cot C14->C16
                bool? _tempC14MARKPERFORM = false;
                bool? _tempC14ACCUMULATE = false;
                bool? _tempC15MARKPERFORM = false;
                bool? _tempC15ACCUMULATE = false;
                bool? _tempC16MARKPERFORM = false;
                bool? _tempC16ACCUMULATE = false;

                if (DataC14 != null)
                {
                    if (DataC14.Replace(" ", "").Trim() == "MARKPERFORM")
                    {
                        _tempC14MARKPERFORM = true;
                    }
                    else if (DataC14.Replace(" ", "").Trim() == "ACCUMULATE")
                    {
                        _tempC14ACCUMULATE = true;
                    }
                }
                if (DataC15 != null)
                {
                    if (DataC15.Replace(" ", "").Trim() == "MARKPERFORM")
                    {
                        _tempC15MARKPERFORM = true;
                    }
                    else if (DataC15.Replace(" ", "").Trim() == "ACCUMULATE")
                    {
                        _tempC15ACCUMULATE = true;
                    }
                }
                if (DataC16 != null)
                {
                    if (DataC16.Replace(" ", "").Trim() == "MARKPERFORM")
                    {
                        _tempC16MARKPERFORM = true;
                    }
                    else if (DataC16.Replace(" ", "").Trim() == "ACCUMULATE")
                    {
                        _tempC16ACCUMULATE = true;
                    }
                }

                #endregion

                foreach (var profile in lstProfile)
                {
                    Eva_EvalutionDataEntity entity = new Eva_EvalutionDataEntity();
                    entity.CodeEmp = profile.CodeEmp;
                    entity.ProfileName = profile.ProfileName;
                    entity.ProfileID = profile.ID;
                    entity.TimesGetDataID = _TimesGetDataID;
                    entity.Year = new DateTime(year, 01, 01);
                    int C1 = 0;
                    int C2 = 0;
                    int C3 = 0;
                    int C4 = 0;
                    int C5 = 0;
                    int C6 = 0;
                    int C7 = 0;
                    int C8 = 0;
                    int C9 = 0;
                    int C10 = 0;
                    var lstLeaveDayprofile = lstLeaveDay.Where(s => s.ProfileID == profile.ID).ToList();
                    if (lstLeaveDayprofile.Count > 0)
                    {
                        foreach (var attLeaveDayprofile in lstLeaveDayprofile)
                        {
                            #region C1->C8
                            foreach (var item in dicLeaveByType)
                            {
                                List<Cat_LeaveDayTypeEntity> lstLeavetype = (List<Cat_LeaveDayTypeEntity>)item.Value;
                                int temp = 0;
                                if (attLeaveDayprofile.LeaveDayTypeID != null && lstLeavetype.Any(m => m.ID == attLeaveDayprofile.LeaveDayTypeID) && attLeaveDayprofile.LeaveDays > 0)
                                {
                                    string _strLeaveDays = attLeaveDayprofile.LeaveDays.ToString();
                                    string[] _partLeaveDays = _strLeaveDays.Split('.');
                                    int _intLeaveDays = int.Parse(_partLeaveDays[0]);
                                    if (_partLeaveDays.Count() > 1)
                                    {
                                        int _modLeaveDays = int.Parse(_partLeaveDays[1]);
                                        if (_modLeaveDays > 0)
                                        {
                                            temp += _intLeaveDays + 1;
                                        }
                                    }
                                    else
                                    {
                                        temp += _intLeaveDays;
                                    }
                                }
                                if (item.Key == "C1")
                                {
                                    C1 += temp;
                                }
                                if (item.Key == "C2")
                                {
                                    C2 += temp;
                                }
                                if (item.Key == "C3")
                                {
                                    C3 += temp;
                                }
                                if (item.Key == "C4")
                                {
                                    C4 += temp;
                                }
                                if (item.Key == "C5")
                                {
                                    C5 += temp;
                                }
                                if (item.Key == "C6")
                                {
                                    C6 += temp;
                                }
                                if (item.Key == "C7")
                                {
                                    C7 += temp;
                                }
                                if (item.Key == "C8")
                                {
                                    C8 += temp;
                                }
                            }
                        }
                            #endregion
                    }

                    #region tong tre som va quen quet the C9->C10
                    #region C9
                    if (_tempC9LATEEARLYDEDUCTIONHOURS == true)
                    {
                        var lstattattendancetableprofile = lstattattendancetable.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstattattendancetableprofile.Count > 0)
                        {
                            C9 = lstattattendancetableprofile.Where(s => s.LateEarlyDeductionHours > 0).Count();
                        }
                    }
                    else if (_tempC9FAILINGTORECORDCARD == true)
                    {
                        var lstworkDayprofile = lstworkDayProfiles.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstworkDayprofile.Count > 0)
                        {
                            C9 = lstworkDayprofile.Count();
                        }
                        if (lstLeaveDayprofile.Count > 0)
                        {
                            foreach (var objWorkDay in lstworkDayprofile)
                            {
                                var objLeaveDayByWorkDay = lstLeaveDayprofile.Where(s => s.DateStart <= objWorkDay.WorkDate && s.DateEnd >= objWorkDay.WorkDate).ToList();
                                if (objLeaveDayByWorkDay.Count > 0)
                                {
                                    C9 -= 1;
                                }
                            }
                        }
                    }
                    #endregion
                    #region C10
                    if (_tempC10LATEEARLYDEDUCTIONHOURS == true)
                    {
                        var lstattattendancetableprofile = lstattattendancetable.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstattattendancetableprofile.Count > 0)
                        {
                            C10 = lstattattendancetableprofile.Where(s => s.LateEarlyDeductionHours > 0).Count();
                        }
                    }
                    else if (_tempC10FAILINGTORECORDCARD == true)
                    {
                        var lstworkDayprofile = lstworkDayProfiles.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstworkDayprofile.Count > 0)
                        {
                            C10 = lstworkDayprofile.Count();
                        }
                        if (lstLeaveDayprofile.Count>0)
                        {
                            foreach (var objWorkDay in lstworkDayprofile)
                            {
                                var objLeaveDayByWorkDay = lstLeaveDayprofile.Where(s => s.DateStart <= objWorkDay.WorkDate && s.DateEnd >= objWorkDay.WorkDate).ToList();
                                if (objLeaveDayByWorkDay.Count > 0)
                                {
                                    C10 -= 1;
                                }
                            }
                        }
                    }
                    #endregion
                    #endregion
                    if (C1 > 0)
                        entity.C1 = C1;
                    if (C2 > 0)
                        entity.C2 = C2;
                    if (C3 > 0)
                        entity.C3 = C3;
                    if (C4 > 0)
                        entity.C4 = C4;
                    if (C5 > 0)
                        entity.C5 = C5;
                    if (C6 > 0)
                        entity.C6 = C6;
                    if (C7 > 0)
                        entity.C7 = C7;
                    if (C8 > 0)
                        entity.C8 = C8;
                    if (C9 > 0)
                        entity.C9 = C9;
                    if (C10 > 0)
                        entity.C10 = C10;
                    #region C11->C13
                    if (lsthreDiscipline.Count > 0)
                    {
                        var lsthreDisciplineprofile = lsthreDiscipline.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lsthreDisciplineprofile.Count > 0)
                        {
                            if (tempobjDisciplinedType11 != null)
                            {
                                var lsthreDiscipline11 = lsthreDisciplineprofile.Where(s => s.DisciplinedTypesSuggestID == tempobjDisciplinedType11.ID).ToList();
                                if (lsthreDiscipline11.Count > 0)
                                    entity.C11 = lsthreDiscipline11.Count;
                            }
                            if (tempobjDisciplinedType12 != null)
                            {
                                var lsthreDiscipline12 = lsthreDisciplineprofile.Where(s => s.DisciplinedTypesSuggestID == tempobjDisciplinedType12.ID).ToList();
                                if (lsthreDiscipline12.Count > 0)
                                    entity.C12 = lsthreDiscipline12.Count;
                            }
                            if (tempobjDisciplinedType13 != null)
                            {
                                var lsthreDiscipline13 = lsthreDisciplineprofile.Where(s => s.DisciplinedTypesSuggestID == tempobjDisciplinedType13.ID).ToList();
                                if (lsthreDiscipline13.Count > 0)
                                    entity.C13 = lsthreDiscipline13.Count;
                            }
                        }
                    }
                    #endregion
                    #region C14->C16
                    if (listKaiKaizenData.Count > 0)
                    {
                        var listKaiKaizenDataprofile = listKaiKaizenData.Where(s => s.ProfileID == profile.ID).ToList();
                        int _tempAccumulate = 0;
                        int _MarkPerform = 0;
                        if (listKaiKaizenDataprofile.Count > 0)
                        {
                            #region Danh Gia
                            _MarkPerform = listKaiKaizenDataprofile.Where(s => s.MarkPerform > 0).Count();
                            _tempAccumulate = int.Parse(listKaiKaizenDataprofile.Select(s => s.Accumulate).Sum().ToString());
                            #region C14
                            if (_tempC14MARKPERFORM == true && _MarkPerform > 0)
                            {
                                entity.C14 = _MarkPerform;
                            }
                            else if (_tempC14ACCUMULATE == true && _tempAccumulate > 0)
                            {
                                entity.C14 = _tempAccumulate;
                            }
                            #endregion
                            #region C15
                            if (_tempC15MARKPERFORM == true && _MarkPerform > 0)
                            {
                                entity.C15 = _MarkPerform;
                            }
                            else if (_tempC15ACCUMULATE == true && _tempAccumulate > 0)
                            {
                                entity.C15 = _tempAccumulate;
                            }
                            #endregion
                            #region C16
                            if (_tempC16MARKPERFORM == true && _MarkPerform > 0)
                            {
                                entity.C16 = _MarkPerform;
                            }
                            else if (_tempC16ACCUMULATE == true && _tempAccumulate > 0)
                            {
                                entity.C16 = _tempAccumulate;
                            }
                            #endregion
                            #endregion
                        }

                    }
                    #endregion
                    if (entity != null)
                    {
                        lstEvalutionDataEntity.Add(entity);
                    }
                }
                return lstEvalutionDataEntity;
                //    #endregion
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Báo cáo tổng thu nhập chịu thuế năm
        /// </summary>
        /// <param name="ProfileIds"></param>
        /// <param name="CutOffduration"></param>
        /// <returns></returns>
        public DataTable ReportTotalAnnualTaxableIncome(DateTime Year, List<string> WorkingPlace, List<string> ProfileIDs, string OrgStructure, List<string> UnusualAllowanceCfg, string UserLogin, bool IsCreateTemplate)
        {
            Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
            DateTime DateClose = Sys_Services.GetConfigValue<DateTime>(AppConfig.HRM_SAL_DATECLOSE_ALLOWANCE);
            DateClose = new DateTime(Year.Year, DateTime.Now.Month, DateClose.Day);

            DataTable Table = new DataTable("ReportTotalAnnualTaxableIncome");
            Table.Columns.Add("CodeEmp");
            Table.Columns.Add("ProfileName");
            Table.Columns.Add("CostCentre");
            foreach (var i in UnusualAllowanceCfg)
            {
                if (!Table.Columns.Contains(i))
                {
                    Table.Columns.Add(i);
                }
            }
            Table.Columns.Add("Remark");

            string status = string.Empty;
            List<object> listModel = new List<object>();
            DateTime YearStart = new DateTime(Year.Year, 1, 1);
            DateTime YearEnd = new DateTime(Year.Year, 12, 31);

            listModel = new List<object>();
            listModel.AddRange(new object[18]);
            listModel[2] = OrgStructure != string.Empty ? OrgStructure : null;
            listModel[16] = 1;
            listModel[17] = Int32.MaxValue - 1;
            List<Hre_ProfileEntity> listProfile = GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_Profile, UserLogin, ref status).Where(m => m.DateQuit == null || m.DateQuit >= DateClose).ToList();

            if (ProfileIDs.Count > 0)
            {
                //lọc theo workingPlace
                listProfile = listProfile.Where(m => ProfileIDs.Contains(m.ID.ToString())).ToList();
            }

            if (WorkingPlace.Count > 0)
            {
                //lọc theo workingPlace
                listProfile = listProfile.Where(m => m.WorkPlaceID != null && WorkingPlace.Contains(m.WorkPlaceID.ToString())).ToList();
            }

            listModel = new List<object>();
            listModel.AddRange(new object[9]);
            listModel[3] = YearStart;
            listModel[4] = YearEnd;
            listModel[7] = 1;
            listModel[8] = Int32.MaxValue - 1;
            List<Sal_UnusualAllowanceEntity> listUnusualAllowance = GetData<Sal_UnusualAllowanceEntity>(listModel, ConstantSql.hrm_sal_sp_get_UnusualED, UserLogin, ref status).Where(m => UnusualAllowanceCfg.Contains(m.UnusualEDTypeCode)).ToList();

            foreach (var profile in listProfile)
            {
                DataRow Row = Table.NewRow();
                Row["CodeEmp"] = profile.CodeEmp;
                Row["ProfileName"] = profile.ProfileName;
                Row["CostCentre"] = profile.CostCentreCode;
                string Remark = string.Empty;
                foreach (var i in UnusualAllowanceCfg)
                {
                    var listUnusualAllowanceByProfile = listUnusualAllowance.Where(m => m.ProfileID == profile.ID && m.UnusualEDTypeCode == i).ToList();
                    Row[i] = listUnusualAllowanceByProfile.Sum(m => m.Amount);
                    listUnusualAllowanceByProfile.ForEach(m => Remark += m.Notes);
                }
                Row["Remark"] = Remark;
                Table.Rows.Add(Row);
            }
            return Table;
        }
Exemplo n.º 15
0
        public DashboardAlertsModel Get() 
        {
            var profileServices = new Hre_ProfileServices();
            Sys_AttOvertimePermitConfigServices sysServices = new Sys_AttOvertimePermitConfigServices();
            DashboardAlertsModel dashboardAlertModel = new DashboardAlertsModel();
            ActionService service = new ActionService(UserLogin);
            BaseService baseServices = new BaseService();
            string status = string.Empty;


            Boolean ischeck = profileServices.IsShowExConByConResult();
               
           #region lay cau hinh hien thi hop dong sap den han
                //lay cau hinh hien thi hop dong sap den han
                dashboardAlertModel.ShowValue1 = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_CONTRACT_ALERT_EXPRIDAY);
                if (dashboardAlertModel.ShowValue1 != null && dashboardAlertModel.ShowValue1 == true)
                {
                    var ShowAfterDate1 = service.GetData<Sys_AllSettingEntity>("HRM_HRE_CONTRACT_ALERT_EXPRIDAY_VALUEAFTE", ConstantSql.hrm_sys_sp_get_AllSettingByKey, ref status).FirstOrDefault();
                    var ShowBeforDate1 = service.GetData<Sys_AllSettingEntity>("HRM_HRE_CONTRACT_ALERT_EXPRIDAY_VALUEBEFOR", ConstantSql.hrm_sys_sp_get_AllSettingByKey, ref status).FirstOrDefault();
                    DateTime? dateFrom = null;
                    DateTime? dateTo = null;
                    var count = 0;
                    string _status = EnumDropDown.Status.E_APPROVED.ToString();

                    if (ischeck == false)
                    {
                        dateTo = ShowAfterDate1.Value1 != null ? DateTime.Now.AddDays(Convert.ToDouble(ShowAfterDate1.Value1)) : DateTime.Now.AddDays(0);
                        dateFrom = ShowBeforDate1.Value1 != null ? DateTime.Now.AddDays(-Convert.ToDouble(ShowBeforDate1.Value1)) : DateTime.Now.AddDays(0);
                    }

                    #region lstObjExpiryContract
                    List<object> lstObjExpiryContract = new List<object>();
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(_status);
                    lstObjExpiryContract.Add(dateFrom);
                    lstObjExpiryContract.Add(dateTo);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(null);
                    lstObjExpiryContract.Add(1);
                    lstObjExpiryContract.Add(int.MaxValue - 1);
                    #endregion

                    #region lstObjContractType
                    var lstObjContractType = new List<object>();
                    lstObjContractType.Add(null);
                    lstObjContractType.Add(null);
                    lstObjContractType.Add(null);
                    lstObjContractType.Add(null);
                    lstObjContractType.Add(1);
                    lstObjContractType.Add(int.MaxValue - 1);
                    #endregion

                    var lstContractType = baseServices.GetData<CatContractTypeModel>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, UserLogin, ref status);

                    var lstExpiryContract = baseServices.GetData<Hre_ContractModel>(lstObjExpiryContract, ConstantSql.hrm_hr_sp_get_RptExpireContract, UserLogin, ref status).Where(s => s.StatusEvaluation != WorkdayStatus.E_APPROVED.ToString()).ToList();


                    foreach (var item in lstExpiryContract)
                    {
                        var dateCheck = DateTime.Now;
                        var contractTypeEntity = lstContractType.Where(s => item.ContractTypeID == s.ID).FirstOrDefault();
                        if (ischeck == true)
                        {
                        
                                if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                                {
                                    var dateExpiry = dateCheck.AddDays(contractTypeEntity.ExpiryContractLoop.Value);

                                    if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                                    {
                                        if (item.DateExtend != null && item.DateExtend <= dateExpiry)
                                        {
                                            count++;
                                        }
                                        if (item.DateExtend == null && item.DateEnd != null && item.DateEnd.Value <= dateExpiry)
                                        {
                                            count++;
                                        }
                                    }
                                }
                            
                        }
                        else
                        {
                                count++;
                        }
                    }
                    dashboardAlertModel.sumContract = count;
                }
                
                #endregion

           #region lay cau hinh hien thi sinh nhat trong thang

                dashboardAlertModel.ShowValue5 = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY);
                if (dashboardAlertModel.ShowValue5 != null && dashboardAlertModel.ShowValue5 == true)
                {
                    var Birthfrom = sysServices.GetConfigValue<double>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY_VALUEBEFOR);
                    var Birthto = sysServices.GetConfigValue<double>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY_VALUEAFTER);
                    var _DateFrom = DateTime.Now.AddDays(-Birthfrom); 
                    var _DateTo = DateTime.Now.AddDays(+Birthto);
                    List<object> lstObjBirthDay = new List<object>();
                    lstObjBirthDay.Add(new DateTime(DateTime.Now.Year,1,1));
                    lstObjBirthDay.Add(new DateTime(DateTime.Now.Year,12,31));
                    lstObjBirthDay.Add(null);
                    lstObjBirthDay.Add(null);
                    lstObjBirthDay.Add(null);
                    lstObjBirthDay.Add(null);
                    var _lstBirthday = baseServices.GetData<DashboardAlertsModel>(lstObjBirthDay, ConstantSql.hrm_hr_sp_get_RptBirthday, UserLogin, ref status);
                    if(_DateFrom !=_DateTo)
                    { 
                        var _kc = Convert.ToInt16((_DateTo - _DateFrom).ToString().Substring(0,(_DateTo - _DateFrom).ToString().IndexOf('.')));
                        if (_kc >= 365)
                        {
                            dashboardAlertModel.sumBirthDay = _lstBirthday.Count();
                        }
                        else
                        {
                            if (_DateFrom.Year < _DateTo.Year)
                            {
                                DateTime _dtf = (new DateTime(_DateTo.Year, 1, 1).AddMilliseconds(-1));
                                DateTime _dtt = (new DateTime(_DateTo.Year, 1, 1));
                                dashboardAlertModel.sumBirthDay = _lstBirthday.Where(s => (s.DateOfBirth >= _DateFrom && s.DateOfBirth <= _dtf) || (s.DateOfBirth >= _dtt && s.DateOfBirth <= _DateTo)).ToList().Count();
                          
                            }
                            else
                            {
                                dashboardAlertModel.sumBirthDay = _lstBirthday.Where(s => (s.DateOfBirth >= _DateFrom && s.DateOfBirth <= _DateTo)).ToList().Count();
                            }
                        }
                    }
                }
                #endregion

           #region lay cau hinh hien thi phu luc hop dong den han
                bool? _IsShowContractAppendixExpriday = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_CONTRACT_ALERT_APPENDDIXEXPRIDAY);

            if (_IsShowContractAppendixExpriday != null && _IsShowContractAppendixExpriday == true)
            {
                //lay cau hinh ngay hien thi
                int? _DayShowContractAppendixExpridayFrom = sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_CONTRACT_ALERT_DAYAPPENDDIXEXPRIDAYFROM);
                int? _DayShowContractAppendixExpridayTo = sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_CONTRACT_ALERT_DAYAPPENDDIXEXPRIDAYTO);
                if (_DayShowContractAppendixExpridayFrom != null && _DayShowContractAppendixExpridayTo != null)
                {
                    dashboardAlertModel.IsShowContractAppendixExpriday = true;
                    DateTime _dateFrom = DateTime.Now.AddDays(-_DayShowContractAppendixExpridayTo.Value);
                    DateTime _dateTo = DateTime.Now.AddDays(_DayShowContractAppendixExpridayFrom.Value);
                    var ObjAppendixContract = new List<object>();
                    ObjAppendixContract.AddRange(new object[7]);
                    ObjAppendixContract[3] = _dateFrom;
                    ObjAppendixContract[4] = _dateTo;
                    ObjAppendixContract[5] = 1;
                    ObjAppendixContract[6] = int.MaxValue - 1;
                    var sumAppendixContract = baseServices.GetData<Hre_AppendixContractModel>(ObjAppendixContract, ConstantSql.hrm_hr_sp_get_AppendixExpiredContract, UserLogin, ref status);
                    dashboardAlertModel.sumAppendixExpiryContract = sumAppendixContract != null ? sumAppendixContract.Count : 0;
                }
            }
            #endregion



           
            //lay cau hinh hien thi sinh nhat trong thang
            //dashboardAlertModel.ShowValue5 = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY);
            //if (dashboardAlertModel.ShowValue5 != null && dashboardAlertModel.ShowValue5 == true)
            //{
            //    dashboardAlertModel.sumBirthDay = baseServices.GetData<DashboardAlertsModel>(lstObjBirthDay, ConstantSql.hrm_hr_sp_get_RptBirthday, UserLogin, ref status).Select(s => s.ID).ToList().Count;
            //}
           
            List<object> lstObjProfileProbation = new List<object>();
            lstObjProfileProbation.AddRange(new object[22]);
            lstObjProfileProbation[20] = 1;
            lstObjProfileProbation[21] = int.MaxValue - 1;
            //Hre_ProfileProbationSearchModel modelsearch = new Hre_ProfileProbationSearchModel();
            //modelsearch.DateFrom = DateTime.Now;
            //modelsearch.DateTo = dateTo;
           

            //lay cau hinh hien canh bao trang chu Hết Hạn Thử Việc Trong Tháng hay khong
            dashboardAlertModel.ShowValue2 = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_PROBATION_EXPRIDAY);
            if(dashboardAlertModel.ShowValue2!=null && dashboardAlertModel.ShowValue2==true)
            {
                int ProbationValueBefore = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_PROFILE_ALERT_PROBATION_EXPRIDAY_VALUEBEFOR);
                int ProbationValueAfter = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_PROFILE_ALERT_PROBATION_EXPRIDAY_VALUEAFTER);
                //modelsearch.DateHireFrom = DateTime.Now.Date.AddMonths(-1);
                //modelsearch.DateHireTo = DateTime.Now.Date.AddMonths(1);
                lstObjProfileProbation[10] = DateTime.Now.Date.AddDays(-ProbationValueBefore);
                lstObjProfileProbation[11] = DateTime.Now.Date.AddDays(ProbationValueAfter);
                var sum = baseServices.GetData<DashboardAlertsModel>(lstObjProfileProbation, ConstantSql.hrm_hr_sp_get_ProbationProfile,UserLogin, ref status);
                dashboardAlertModel.sumProbation = sum != null ? sum.Count : 0;
            }
         

            //lay cau hinh hien thi luong co ban cho duyet
            dashboardAlertModel.IsShowBasicSalaryWaitingAprove = sysServices.GetConfigValue<bool>(AppConfig.HRM_SAL_BASICSALARY_ALERT_WAITINGAPROVE);

           
            //lay cau hinh hien thi hop dong cho duyet
            dashboardAlertModel.IsShowContractWaitingAprove = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_CONTRACT_ALERT_WAITINGAPROVE);
            if(dashboardAlertModel.IsShowContractWaitingAprove !=null && dashboardAlertModel.IsShowContractWaitingAprove==true)
            {
                //sum dh cho duyet
                List<object> paraContractWaiting = new List<object>();
                paraContractWaiting.AddRange(new object[20]);
                paraContractWaiting[18] = 1;
                paraContractWaiting[19] = int.MaxValue - 1;
                var lstContractWaiting = baseServices.GetData<Hre_ContractModel>(paraContractWaiting, ConstantSql.hrm_hr_sp_get_ContractWaiting,UserLogin, ref status);
                if (lstContractWaiting != null)
                    dashboardAlertModel.sumContractWaiting = lstContractWaiting.Count;
            }
            //canh bao so ngay tam hoan den han
            //get so ngay cau hinh
            //string keyDaySuspenseExpiry= AppConfig.HRM_HRE_CONFIG_DAYSUSPENSEEXPIRY.ToString();
            //var objDaySuspenseExpiry=baseServices.GetData<Sys_AllSettingEntity>(keyDaySuspenseExpiry,ConstantSql.hrm_sys_sp_get_AllSettingByKey,ref status).FirstOrDefault();
          
            #region lay cau hinh hien thi nv sap den ngay tam hoan

            bool? _IsShowDaySuspenseExpiry=sysServices.GetConfigValue<bool?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSUSPENSEEXPIRY);

            if (_IsShowDaySuspenseExpiry != null && _IsShowDaySuspenseExpiry == true)
            {
            

                //lay cau hinh ngay hien thi
                int? _DayShowDaySuspenseExpiryFrom = sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSUSPENSEEXPIRYFROM);
                int? _DayShowDaySuspenseExpiryTo = sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSUSPENSEEXPIRYTO);
                if (_DayShowDaySuspenseExpiryFrom != null && _DayShowDaySuspenseExpiryTo!=null)
                {
                    //var valueDaySuspenseExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYSUSPENSEEXPIRY);
                    //if (valueDaySuspenseExpiry >= 0)
                    //{
                    //DateTime _dateFromTemp = DateTime.Now.AddDays(-valueDaySuspenseExpiry);
                    //DateTime _dateFrom = new DateTime(_dateFromTemp.Year, _dateFromTemp.Month, _dateFromTemp.Day, 0, 0, 0);
                    //DateTime _dateTo = DateTime.Now;
                    dashboardAlertModel.IsShowDaySuspenseExpiry = true;
                    string _status = EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    DateTime _dateFrom = DateTime.Now.AddDays(-_DayShowDaySuspenseExpiryTo.Value);
                    DateTime _dateTo = DateTime.Now.AddDays(_DayShowDaySuspenseExpiryFrom.Value);
                    List<object> paraSuspense = new List<object>();
                    paraSuspense.AddRange(new object[13]);
                    paraSuspense[5] = _dateFrom;
                    paraSuspense[6] = _dateTo;
                    paraSuspense[8] = _status;
                    paraSuspense[11] = 1;
                    paraSuspense[12] = int.MaxValue - 1;
                    var lstSuspense = baseServices.GetData<Hre_StopWorkingModel>(paraSuspense, ConstantSql.hrm_hr_sp_get_Suspense, UserLogin, ref status);
                    if (lstSuspense != null)
                        dashboardAlertModel.sumDaySuspenseExpiry = lstSuspense.Count;

                    // }
                }
            }
            #endregion
      
            //canh bao nv sap den ngay nghi viec

            #region lay cau hinh hien thi nv sap den ngay nghi viec
            bool? _IsShowDayStopWorking=sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSTOPWORKING);
            if (_IsShowDayStopWorking != null && _IsShowDayStopWorking == true)
            {
                int? _DayShowDayStopWorkingFrom=sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSTOPWORKINGFROM);
                int? _DayShowDayStopWorkingTo=sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSTOPWORKINGTO);
                if( _DayShowDayStopWorkingFrom!= null && _DayShowDayStopWorkingTo != null)
                {
                    dashboardAlertModel.IsShowDayStopWorking = true;
                    //get cau hinh
                    //var valueDaytopworkingExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYSTOPWORKINGEXPIRY);
                    //if (valueDaytopworkingExpiry > 0)
                    //{
                  
                        //DateTime _dateFromTemp = DateTime.Now.AddDays(-valueDaytopworkingExpiry);
                        //DateTime _dateFrom = new DateTime(_dateFromTemp.Year, _dateFromTemp.Month, _dateFromTemp.Day, 0, 0, 0);
                        //DateTime _dateTo = DateTime.Now;
                    DateTime _dateFrom = DateTime.Now.AddDays(-_DayShowDayStopWorkingTo.Value);
                    DateTime _dateTo = DateTime.Now.AddDays(_DayShowDayStopWorkingFrom.Value);
                    string _status = EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    List<object> paraStopWorking = new List<object>();
                    paraStopWorking.AddRange(new object[17]);
                    paraStopWorking[0] = _status;
                    paraStopWorking[6] = _dateFrom;
                    paraStopWorking[7] = _dateTo;
                    paraStopWorking[15] = 1;
                    paraStopWorking[16] = int.MaxValue - 1;
                    var lstStopWorking = baseServices.GetData<Hre_StopWorkingModel>(paraStopWorking, ConstantSql.hrm_hr_sp_get_StopWorking, UserLogin, ref status);
                    if (lstStopWorking != null)
                        dashboardAlertModel.sumDayStopWorking = lstStopWorking.Count;
                //}
                }
            }
            #endregion

            #region lay cau hinh hien thi nv sap vao lam lai
            bool? _IsShowDayComeBackExpiry=sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYCOMEBACKEXPIRY);
            if (_IsShowDayComeBackExpiry != null && _IsShowDayComeBackExpiry == true)
            {
                //lay cau hinh ngay hien thi
                int? _DayShowDayComeBackExpiryFrom = sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYCOMEBACKEXPIRYFROM);
                int? _DayShowDayComeBackExpiryTo = sysServices.GetConfigValue<int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYCOMEBACKEXPIRYTO);
                if (_DayShowDayComeBackExpiryFrom != null && _DayShowDayComeBackExpiryTo!=null)
                {
                    dashboardAlertModel.IsShowDayComeBackExpiry = true;

                    //var valueDayComebackExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYCOMEBACKEXPIRY);
                    //if (valueDayComebackExpiry > 0)
                    //{
                        //DateTime _dateFromTemp = DateTime.Now.AddDays(-valueDayComebackExpiry);
                        //DateTime _dateFrom = new DateTime(_dateFromTemp.Year, _dateFromTemp.Month, _dateFromTemp.Day, 0, 0, 0);
                        //DateTime _dateTo = DateTime.Now;

                    string _status = EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    DateTime _dateFrom=DateTime.Now.AddDays(-_DayShowDayComeBackExpiryTo.Value);
                    DateTime _dateTo=DateTime.Now.AddDays(_DayShowDayComeBackExpiryFrom.Value);
                    List<object> paraComback = new List<object>();
                    paraComback.AddRange(new object[14]);
                    paraComback[0] = _status;
                    paraComback[6] = _dateFrom;
                    paraComback[7] = _dateTo;
                    paraComback[12] = 1;
                    paraComback[13] = int.MaxValue - 1;
                    var lstStopWorking = baseServices.GetData<Hre_StopWorkingModel>(paraComback, ConstantSql.hrm_hr_sp_get_RegisterComback,UserLogin, ref status).ToList();
                    if (lstStopWorking != null)
                        dashboardAlertModel.sumDayComeBackExpiry = lstStopWorking.Count;
               // }
                }
            }
            #endregion

            //lay cau hinh hien thi nv la, HDT cho duyet
            dashboardAlertModel.IsShowHDTJobWaitingApproved = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_HDTJOBWAINTINGAPPROVED);
            if(dashboardAlertModel.IsShowHDTJobWaitingApproved!=null&&dashboardAlertModel.IsShowHDTJobWaitingApproved==true)
            {
                //sum nv vao hdt cho duyet
                List<object> paraHDTJobWaitingApproved = new List<object>();
                paraHDTJobWaitingApproved.AddRange(new object[14]);
                paraHDTJobWaitingApproved[12] = 1;
                paraHDTJobWaitingApproved[13] = int.MaxValue - 1;
                var lstHDTJobWaitingApproved = baseServices.GetData<Hre_ContractModel>(paraHDTJobWaitingApproved, ConstantSql.hrm_hr_sp_get_HDTJobWaiting,UserLogin, ref status).ToList();
                if (lstHDTJobWaitingApproved != null)
                    dashboardAlertModel.sumHDTJobWaitingApproved = lstHDTJobWaitingApproved.Count;
            }
            //lay cau hinh hien thi nguoi cho danh gia
            dashboardAlertModel.IsShowEvalutionWaiting = sysServices.GetConfigValue<bool>(AppConfig.HRM_EVA_PROFILE_ALERT_EVALUTIONWAITING);
            // Giấy Phép LĐ Đến Hạn
            dashboardAlertModel.IsShowExpiryWorkPermit = sysServices.GetConfigValue<bool>(AppConfig.PAPRlABORPHEPSLED);
            if (dashboardAlertModel.IsShowExpiryWorkPermit == true)
            {
                int ValueBefore = sysServices.GetConfigValue<int>(AppConfig.PAPRlABORPHEPSLED_VALUEBEFOR);
                int ValueAfter = sysServices.GetConfigValue<int>(AppConfig.PAPRlABORPHEPSLED_VALUEAFTER);

                List<object> listObj = new List<object>();
                listObj.Add(DateTime.Now.AddDays(-ValueBefore));
                listObj.Add(DateTime.Now.AddDays(ValueAfter));
                listObj.Add(1);
                listObj.Add(int.MaxValue - 1);

                status = string.Empty;
                var result = baseServices.GetData<Hre_ProfileWorkPermitExpireModel>(listObj, ConstantSql.hrm_hr_sp_get_ProfileByWorkPermitExpiredDate,UserLogin, ref status);
                dashboardAlertModel.sumExpiryWorkPermit = result != null ? result.Count : 0;
            }

            //lấy số nhân viên nghỉ việc mà chưa được quyết toán theo cấu hình
            Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
            bool IsShowSETTLEMENT = Sys_Services.GetConfigValue<bool>(AppConfig.SAL_SETTLEMENT);
            if (IsShowSETTLEMENT)
            {
                dashboardAlertModel.IsShowSumProfileQuitNotSettlement = true;
                double ValueBeforeSettlement = sysServices.GetConfigValue<double>(AppConfig.SAL_SETTLEMENT_VALUEBEFOR);
                double ValueAfterSettlement = sysServices.GetConfigValue<double>(AppConfig.SAL_SETTLEMENT_VALUEAFTER);
                var DateSettlementFrom = DateTime.Now.AddDays(-ValueBeforeSettlement);
                var DateSettlementTo = DateTime.Now.AddDays(+ValueAfterSettlement);
                List<object> ListMode = new List<object>();
                ListMode.AddRange(new object[19]);
                ListMode[8] = DateSettlementFrom;
                ListMode[9] = DateSettlementTo;
                ListMode[17] = 1;
                ListMode[18] = Int32.MaxValue - 1;
                List<Hre_ProfileEntity> ListProfileQuit = baseServices.GetData<Hre_ProfileEntity>(ListMode, ConstantSql.hrm_hr_sp_get_ProfileQuit,UserLogin, ref status)
                    .Where(m => m.IsSettlement==null ||  m.IsSettlement == false).ToList();
                //int SumProfileQuitResult = 0;
                //foreach (var i in ListProfileQuit)
                //{
                //    if (i.DateQuit != null && DateTime.Now.Date.Subtract((DateTime)i.DateQuit.Value.Date).TotalDays >= ValueBeforeSettlement)
                //    {
                //        SumProfileQuitResult++;
                //    }
                //}
                //dashboardAlertModel.SumProfileQuitNotSettlement = SumProfileQuitResult;
                dashboardAlertModel.SumProfileQuitNotSettlement = ListProfileQuit.Count();
            }
            
            return dashboardAlertModel;
        }
Exemplo n.º 16
0
        public List<Sal_SalaryDepartmentItem> ComputeAmountPro(List<Sal_SalaryDepartmentItem> lstDepItem, Sal_SalaryDepartment salDep)
        {
            //Hệ số trung bình và tổng giờ công tất cả NV (Sum of Tổng công của từng NV * hệ số cá nhân )
            Double avgSalOrg = 0;
            Double totalHoursRateOrg = 0;

            //AppConfig
            var service = new Sys_AttOvertimePermitConfigServices();
            var value52 = service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE54);
            var value54 = service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE54);

            //Tính tổng công sản phẩm [Tổng Công Sản Phẩm = Công Đi làm + OT1 + OT2 + OT3 + OT4 + OT5 + OT6 (với: OT chưa quy đổi)]
            #region " Lấy tổng công"
            if (value52 == AppConfig.E_RATE_BY_ATUALARISING.ToString())
            {
                for (int i = 0; i < lstDepItem.Count(); i++)
                {
                    Sal_SalaryDepartmentItem item = lstDepItem[i];
                    Double totalOT = 0;
                    if (item.Overtime1TypeID != null)
                    {
                        Double hours = item.Overtime1Hours != null ? item.Overtime1Hours.Value : 0;
                        totalOT += hours;

                        Double rate = item.Cat_OvertimeType != null ? item.Cat_OvertimeType.Rate : 0;
                        item.udOT1 = hours * rate; //Lấy OT1 quy đổi để sử dụng tính số tiền OT (OT1AmountSalary)
                    }
                    if (item.Overtime2TypeID != null)
                    {
                        Double hours = item.Overtime2Hours != null ? item.Overtime2Hours.Value : 0;
                        totalOT += hours;

                        Double rate = item.Cat_OvertimeType1 != null ? item.Cat_OvertimeType1.Rate : 0;
                        item.udOT2 = hours * rate; //Lấy OT2 quy đổi để sử dụng tính số tiền OT (OT2AmountSalary)
                    }
                    if (item.Overtime3TypeID != null)
                    {
                        Double hours = item.Overtime3Hours != null ? item.Overtime3Hours.Value : 0;
                        totalOT += hours;

                        Double rate = item.Cat_OvertimeType2 != null ? item.Cat_OvertimeType2.Rate : 0;
                        item.udOT3 = hours * rate; //Lấy OT3 quy đổi để sử dụng tính số tiền OT (OT3AmountSalary)
                    }
                    if (item.Overtime4TypeID != null)
                    {
                        Double hours = item.Overtime4Hours != null ? item.Overtime4Hours.Value : 0;
                        totalOT += hours;

                        Double rate = item.Cat_OvertimeType3 != null ? item.Cat_OvertimeType3.Rate : 0;
                        item.udOT4 = hours * rate; //Lấy OT4 quy đổi để sử dụng tính số tiền OT (OT4AmountSalary)
                    }
                    if (item.Overtime5TypeID != null)
                    {
                        Double hours = item.Overtime5Hours != null ? item.Overtime5Hours.Value : 0;
                        totalOT += hours;

                        Double rate = item.Cat_OvertimeType4 != null ? item.Cat_OvertimeType4.Rate : 0;
                        item.udOT5 = hours * rate; //Lấy OT5 quy đổi để sử dụng tính số tiền OT (OT5AmountSalary)
                    }
                    if (item.Overtime6TypeID != null)
                    {
                        Double hours = item.Overtime6Hours != null ? item.Overtime6Hours.Value : 0;
                        totalOT += hours;

                        Double rate = item.Cat_OvertimeType5 != null ? item.Cat_OvertimeType5.Rate : 0;
                        item.udOT6 = hours * rate; //Lấy OT6 quy đổi để sử dụng tính số tiền OT (OT6AmountSalary)
                    }
                    item.udTotalHoursProduct = (lstDepItem[i].PaidWorkHours + totalOT);
                }
            }
            #endregion

            //Các trường hợp tính OT
            if (value54 == AppConfig.E_OT_CHANGE_COMPUTE.ToString())
            {
                #region "OT quy đổi"
                for (int i = 0; i < lstDepItem.Count(); i++)
                {
                    Sal_SalaryDepartmentItem item = lstDepItem[i];
                    Double totalOT = 0;

                    if (item.Overtime1TypeID != null)
                    {
                        Double hours = item.Overtime1Hours != null ? item.Overtime1Hours.Value : 0;
                        Double rate = item.Cat_OvertimeType != null ? item.Cat_OvertimeType.Rate : 0;
                        totalOT += hours * rate;
                    }
                    if (item.Overtime2TypeID != null)
                    {
                        Double hours = item.Overtime2Hours != null ? item.Overtime2Hours.Value : 0;
                        Double rate = item.Cat_OvertimeType1 != null ? item.Cat_OvertimeType1.Rate : 0;
                        totalOT += hours * rate;
                    }
                    if (item.Overtime3TypeID != null)
                    {
                        Double hours = item.Overtime3Hours != null ? item.Overtime3Hours.Value : 0;
                        Double rate = item.Cat_OvertimeType2 != null ? item.Cat_OvertimeType2.Rate : 0;
                        totalOT += hours * rate;
                    }
                    if (item.Overtime4TypeID != null)
                    {
                        Double hours = item.Overtime4Hours != null ? item.Overtime4Hours.Value : 0;
                        Double rate = item.Cat_OvertimeType3 != null ? item.Cat_OvertimeType3.Rate : 0;
                        totalOT += hours * rate;
                    }
                    if (item.Overtime5TypeID != null)
                    {
                        Double hours = item.Overtime5Hours != null ? item.Overtime5Hours.Value : 0;
                        Double rate = item.Cat_OvertimeType4 != null ? item.Cat_OvertimeType4.Rate : 0;
                        totalOT += hours * rate;
                    }
                    if (item.Overtime6TypeID != null)
                    {
                        Double hours = item.Overtime6Hours != null ? item.Overtime6Hours.Value : 0;
                        Double rate = item.Cat_OvertimeType5 != null ? item.Cat_OvertimeType5.Rate : 0;
                        totalOT += hours * rate;
                    }

                    //Tổng giờ công và Total OT của từng NV. 
                    item.udTotalHoursOTPaid = (lstDepItem[i].PaidWorkHours + totalOT);

                    //Tổng giờ công của tất cả NV trong ds tính = Sum(Tổng công của từng NV * hệ số cá nhân )
                    totalHoursRateOrg += lstDepItem[i].Rate * item.udTotalHoursOTPaid;
                    if (i == lstDepItem.Count() - 1 && totalHoursRateOrg != 0)
                    {
                        if (value52 == AppConfig.E_RATE_BY_ATUALARISING.ToString())
                            avgSalOrg = salDep.AmountAfterAdjust.Value / totalHoursRateOrg;
                        else
                            avgSalOrg = salDep.Amount / totalHoursRateOrg;
                    }
                }
                #endregion
            }
            else if (value54 == AppConfig.E_NOT_OT_COMPUTE.ToString())
            {
                #region "Không tính OT"
                for (int i = 0; i < lstDepItem.Count(); i++)
                {
                    Sal_SalaryDepartmentItem item = lstDepItem[i];

                    item.udTotalHoursOTPaid = lstDepItem[i].PaidWorkHours;
                    totalHoursRateOrg += lstDepItem[i].Rate * item.udTotalHoursOTPaid;
                    if (i == lstDepItem.Count() - 1 && totalHoursRateOrg != 0)
                    {
                        if (value52 == AppConfig.E_RATE_BY_ATUALARISING.ToString())
                            avgSalOrg = salDep.AmountAfterAdjust.Value / totalHoursRateOrg;
                        else
                            avgSalOrg = salDep.Amount / totalHoursRateOrg;
                    }
                }
                #endregion
            }
            else
            {
                #region "OT chưa quy đổi"
                for (int i = 0; i < lstDepItem.Count(); i++)
                {
                    Sal_SalaryDepartmentItem item = lstDepItem[i];
                    Double totalOT = 0;

                    if (item.Overtime1TypeID != null)
                    {
                        Double hours = item.Overtime1Hours != null ? item.Overtime1Hours.Value : 0;
                        totalOT += hours;
                    }
                    if (item.Overtime2TypeID != null)
                    {
                        Double hours = item.Overtime2Hours != null ? item.Overtime2Hours.Value : 0;
                        totalOT += hours;
                    }
                    if (item.Overtime3TypeID != null)
                    {
                        Double hours = item.Overtime3Hours != null ? item.Overtime3Hours.Value : 0;
                        totalOT += hours;
                    }
                    if (item.Overtime4TypeID != null)
                    {
                        Double hours = item.Overtime4Hours != null ? item.Overtime4Hours.Value : 0;
                        totalOT += hours;
                    }
                    if (item.Overtime5TypeID != null)
                    {
                        Double hours = item.Overtime5Hours != null ? item.Overtime5Hours.Value : 0;
                        totalOT += hours;
                    }
                    if (item.Overtime6TypeID != null)
                    {
                        Double hours = item.Overtime6Hours != null ? item.Overtime6Hours.Value : 0;
                        totalOT += hours;
                    }

                    item.udTotalHoursOTPaid = (lstDepItem[i].PaidWorkHours + totalOT);
                    totalHoursRateOrg += lstDepItem[i].Rate * item.udTotalHoursOTPaid;
                    if (i == lstDepItem.Count() - 1 && totalHoursRateOrg != 0)
                    {
                        if (value52 == AppConfig.E_RATE_BY_ATUALARISING.ToString())
                            avgSalOrg = salDep.AmountAfterAdjust.Value / totalHoursRateOrg;
                        else
                            avgSalOrg = salDep.Amount / totalHoursRateOrg;
                    }
                }
                #endregion
            }

            foreach (Sal_SalaryDepartmentItem item in lstDepItem)
            {
                //Tổng tiền sản phẩm. [udTotalHoursOTPaid = ngày công + tổng OT theo 3 TH (quy đổi, ko qđ, ko OT)]
                item.AmoutSalary = item.Rate * item.udTotalHoursOTPaid * avgSalOrg;

                //Nếu cách tính lương là dùng hệ số tự nhập từ màn hình nhập hệ số (Theo logic PHONGPHU)
                if (value52 == AppConfig.E_RATE_BY_ATUALARISING.ToString())
                {
                    //Tính StdAmountSalary (lương sản phẩm theo công). [udTotalHoursProduct = ngày công + tổng OT theo TH ko qđ]
                    if (item.udTotalHoursProduct != 0 && item.PaidWorkHours != 0)
                        item.StdAmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.PaidWorkHours;
                    else
                        item.StdAmountSalary = 0;

                    //Tính các tổng tiền OT và tiền phụ trội ca đêm (bổ sung thêm cho Phongphu)
                    if (item.udTotalHoursProduct == 0)
                    {
                        item.OT1AmountSalary = 0;
                        item.OT2AmountSalary = 0;
                        item.OT3AmountSalary = 0;
                        item.OT4AmountSalary = 0;
                        item.OT5AmountSalary = 0;
                        item.OT6AmountSalary = 0;
                        item.NightAmountSalary = 0;
                    }
                    else
                    {
                        item.OT1AmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.udOT1;
                        item.OT2AmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.udOT2;
                        item.OT3AmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.udOT3;
                        item.OT4AmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.udOT4;
                        item.OT5AmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.udOT5;
                        item.OT6AmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.udOT6;
                        item.NightAmountSalary = item.AmoutSalary / item.udTotalHoursProduct * item.NightShiftHours * 0.3; //0.3 là hệ số phụ trội ca đêm
                    }

                    //Tiền lương ngày
                    item.DayAmountSalary = item.StdAmountSalary + item.NightAmountSalary +
                                          item.OT1AmountSalary + item.OT2AmountSalary + item.OT3AmountSalary + item.OT4AmountSalary + item.OT5AmountSalary + item.OT6AmountSalary;
                }
            }
            salDep.TotalGroupHours = totalHoursRateOrg;
            return lstDepItem;
        }
Exemplo n.º 17
0
        public void ComputePayroll(List<Hre_ProfileEntity> listProfile, Att_CutOffDurationEntity CutOffDuration, Guid asynTaskID, string HeaderTemplateLog, string UserLogin, bool Settlement = false)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
                var repoSys_AsynTask = new CustomBaseRepository<Sys_AsynTask>(unitOfWork);
                var repoPayrollTable = new CustomBaseRepository<Sal_PayrollTable>(unitOfWork);
                var Sys_Model = repoSys_AsynTask.FindBy(m => m.ID == asynTaskID).FirstOrDefault();

                #region Ghi Log
                TraceLogManager FileLog = new TraceLogManager();
                //Lấy đường dẫn thư mục ghi log
                //set lại thư mục ghi log
                FileLog.SettingPath = Common.GetPath("Log");
                FileLog.DynamicDirectory = "ComputePayroll" + DateTime.Now.ToString("ddMMyyyy-HHmmss");
                FileLog.FileName = "LogFile";
                FileLog.WriteLog(HeaderTemplateLog, "", "");
                #endregion

                if (!DeletePayrollTable(listProfile.Select(d => d.ID).ToList(), CutOffDuration.ID, Settlement, FileLog))
                {
                    Sys_Model.Status = AsynTaskStatus.Error.ToString();
                    Sys_Model.Description = "Không thể xóa bảng lương cũ";
                    Sys_Model.PercentComplete = 1;
                    unitOfWork.SaveChanges();
                }
                else
                {
                    #region Get All Data

                    DateTime DatetimeStart = DateTime.Now;
                    ComputePayrollDataModel TotalData = GetDataForComputeSalary(CutOffDuration, UserLogin);
                    FileLog.WriteLog("", "Get All Data", Common.ComputeTime(DatetimeStart, DateTime.Now));

                    #endregion

                    //Kiểm tra xem có lỗi store hay không
                    if (TotalData.Status != null && TotalData.Status != string.Empty)
                    {
                        Sys_Model.Status = AsynTaskStatus.Error.ToString();
                        Sys_Model.Description = TotalData.Status;
                        Sys_Model.PercentComplete = 1;
                        FileLog.WriteLog("", "Store Error " + TotalData.Status);
                        unitOfWork.SaveChanges();
                    }
                    else
                    {
                        int pageSize = 100;//mỗi lần tính cho 100 nhân viên
                        int totalProfile = listProfile.Count;//Tổng số nhâ viên

                        Sys_AttOvertimePermitConfigServices ConfigServices = new Sys_AttOvertimePermitConfigServices();
                        bool ComputeOrderNumber = ConfigServices.GetConfigValue<bool>(AppConfig.HRM_SAL_COMPUTEPAYROLL_ORDERNUMBER);

                        foreach (var listProfileBySize in listProfile.Chunk(pageSize))
                        {
                            ComputePayroll_Progress(TotalData, listProfileBySize.ToList(), CutOffDuration, Sys_Model.ID, totalProfile, FileLog, ComputeOrderNumber, Settlement);
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
 public ActionResult GetDateStopWorkingSearch()
 {
     string status = string.Empty;
     DateTime DateFrom = DateTime.Now;
     DateTime DateTo = DateTime.Now;
     Sys_AttOvertimePermitConfigServices sysServices = new Sys_AttOvertimePermitConfigServices();
     var valueDaySuspenseExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYSTOPWORKINGEXPIRY);
     if (valueDaySuspenseExpiry >= 0)
     {
         DateFrom = DateTo.AddDays(-valueDaySuspenseExpiry);
     }
     return Json(DateFrom, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 19
0
        public List<Sal_HoldSalaryEntity> ComputeHoldSalary(Guid? cutOffDurationID, Guid[] ProfileIDs, string orgStructureID, Guid TimeAnalyze, string userLoginName)
        {
            using (var context = new VnrHrmDataContext())
            {
                #region Get Data
                string status = string.Empty;
                List<Sal_HoldSalaryEntity> lstHoldSalaryEntity = new List<Sal_HoldSalaryEntity>();

                //ds kỳ công
                var cutOffServies = new Att_CutOffDurationServices();
                var lstObjCutOff = new List<object>();
                lstObjCutOff.Add(null);
                lstObjCutOff.Add(1);
                lstObjCutOff.Add(int.MaxValue - 1);
                var lstCutOff = cutOffServies.GetData<Att_CutOffDurationEntity>(Common.DotNetToOracle(cutOffDurationID.Value.ToString()), ConstantSql.hrm_att_sp_get_CutOffDurationById, userLoginName, ref status).FirstOrDefault();

                //ds nv
                var hrService = new Hre_ProfileServices();
                List<object> strOrgIDs = new List<object>();
                strOrgIDs.AddRange(new object[3]);
                strOrgIDs[0] = (object)orgStructureID;
                var lstProfile = hrService.GetData<Hre_ProfileEntity>(strOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLoginName, ref status);

                if (ProfileIDs != null)
                {
                    lstProfile = lstProfile.Where(s => ProfileIDs.Contains(s.ID)).ToList();
                }

                //ds ngày nghỉ
                var leaveDayServices = new Att_LeavedayServices();
                var lstObjLeaveDay = new List<object>();
                lstObjLeaveDay.AddRange(new object[11]);
                lstObjLeaveDay[4] = lstCutOff.DateStart;
                lstObjLeaveDay[5] = lstCutOff.DateEnd;
                lstObjLeaveDay[9] = 1;
                lstObjLeaveDay[10] = int.MaxValue - 1;
                var lstLeaveDay = leaveDayServices.GetData<Att_LeaveDayEntity>(lstObjLeaveDay, ConstantSql.hrm_att_sp_get_Leaveday,userLoginName, ref status);

                //ds loại ngày nghỉ
                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                var lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(int.MaxValue - 1);
                var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType,userLoginName, ref status);

                lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(EnumDropDown.EntityType.E_CountAnalyzeHoldSalary.ToString());
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(int.MaxValue - 1);
                var ListNameEntity = leavedayTypeServices.GetData<Cat_NameEntityEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_NameEntityByKPI,userLoginName, ref status);

                ////ds chế độ lương
                //var Sal_GradeServices = new Sal_GradeServices();
                //var lstObjSal_Grade = new List<object>();
                //lstObjSal_Grade.AddRange(new object[7]);
                //lstObjSal_Grade[3] = lstCutOff.DateStart;
                //lstObjSal_Grade[4] = lstCutOff.DateEnd;//sửa lại store lấy lên tất cả các grade mà ko có ngày kết thúc
                //lstObjSal_Grade[5] = 1;
                //lstObjSal_Grade[6] = int.MaxValue - 1;
                //var lstSal_Grade = Sal_GradeServices.GetData<Sal_GradeEntity>(lstObjSal_Grade, ConstantSql.hrm_sal_sp_get_Sal_Grade, ref status).ToList();

                Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
                double DATECLOSE_SALARY = Sys_Services.GetConfigValue<double>(AppConfig.HRM_SAL_DATECLOSE_SALARY);

                foreach (var profile in lstProfile)
                {

                    Sal_HoldSalaryEntity entity = new Sal_HoldSalaryEntity();

                    entity.ProfileID = profile.ID;
                    entity.CodeEmp = profile.CodeEmp;
                    entity.ProfileName = profile.ProfileName;
                    entity.CodeAttendance = profile.CodeAttendance;
                    entity.EmployeeTypeName = profile.EmployeeTypeName;
                    entity.WorkPlaceName = profile.WorkPlaceName;
                    entity.IDNo = profile.IDNo;
                    entity.MonthSalary = lstCutOff.MonthYear;
                    entity.TimeAnalyzeID = TimeAnalyze;
                    entity.CatNameEntity = ListNameEntity.FirstOrDefault(m => m.ID == TimeAnalyze) != null ? ListNameEntity.FirstOrDefault(m => m.ID == TimeAnalyze).NameEntityName : "";
                    var lstLeavedayByProfileID = lstLeaveDay.Where(s => profile.ID == s.ProfileID).ToList();

                    #region NV Nghỉ việc trước ngày 18
                    if (profile.DateQuit != null)
                    {
                        if (profile.DateQuit.Value <= lstCutOff.DateEnd && profile.IsSettlement != true)
                        {
                            //if (profile.DateQuit.Value.Day <= 18)
                            //{
                            entity.Terminate = true;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                            //}
                        }
                    }
                    #endregion

                    #region kiểm tra nghỉ quá 12 ngày
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy12 = lstLeavedayType.Where(m => m.Code == "SP" || m.Code == "SC" || m.Code == "DSP" || m.Code == "DL" || m.Code == "M").ToList();
                        var _tmp = lstLeavedayByProfileID.Where(m => !lstLeavedayTypeBy12.Any(t => t.ID == m.LeaveDayTypeID)).ToList();
                        double count = 0;
                        foreach (var i in _tmp)
                        {
                            count += i.LeaveDays != null ? (double)i.LeaveDays : 0;
                        }
                        if (count >= 12)
                        {
                            entity.DayLeave = (int)count;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }
                    #endregion

                    #region trường hợp đăng ký thai sản trước ngày 18
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy12 = lstLeavedayType.Where(m => m.Code == "M").ToList();
                        var _tmp = lstLeavedayByProfileID.FirstOrDefault(m => lstLeavedayTypeBy12.Any(t => t.ID == m.LeaveDayTypeID) && m.DateStart.Day < 18);
                        if (_tmp != null)
                        {
                            entity.IsLeaveM = true;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }
                    #endregion

                    #region Nghỉ liên tục 3 ngày
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy3 = lstLeavedayType.Where(m => m.Code == "D").ToList();
                        //lấy ngày nghỉ theo loại ngày nghỉ D
                        var lstLeavedayByProfileID3 = lstLeavedayByProfileID.Where(m => lstLeavedayTypeBy3.Any(t => t.ID == m.LeaveDayTypeID)).ToList();

                        lstLeavedayByProfileID3 = lstLeavedayByProfileID3.Where(m => m.DateEnd.Day <= DATECLOSE_SALARY).ToList();
                        double count = 0;
                        //còn 1 bug đó là khi đăng ký 3 dòng  liền kế ngày nhau
                        foreach (var i in lstLeavedayByProfileID3)
                        {
                            count = i.LeaveDays != null ? (double)i.LeaveDays : 0;
                            if (count >= 3)
                            {
                                entity.IsLeaveContinuous = true;
                                break;
                            }
                        }
                        if (entity.IsLeaveContinuous != null && entity.IsLeaveContinuous == true)
                        {
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }

                    #endregion
                }
                return lstHoldSalaryEntity;
                #endregion



            }

        }
Exemplo n.º 20
0
        public DataTable ReportProfileSalaryNegative(string OrgStructure, List<Guid> ProfileIds, Att_CutOffDurationEntity CutoffDuration, List<Guid> SalaryRank, string UserLogin, bool IsCreateTemplate = false)
        {
            DataTable Table = new DataTable("ReportProfileSalaryNegative");
            Table.Columns.Add("CodeEmp");
            Table.Columns.Add("ProfileName");
            Table.Columns.Add("OrgStructure");

            #region GetData
            string status = string.Empty;
            var profileServices = new Hre_ProfileServices();
            var listModel = new List<object>();

            listModel = new List<object>();
            listModel.AddRange(new object[7]);
            listModel[5] = 1;
            listModel[6] = Int32.MaxValue - 1;
            var listElement = profileServices.GetData<Cat_ElementEntity>(listModel, ConstantSql.hrm_cat_sp_get_Element, UserLogin, ref status).Where(m => m.IsApplyGradeAll == true || m.GradePayrollID != null).ToList();

            if (IsCreateTemplate)
            {
                foreach (var i in listElement)
                {
                    if (!Table.Columns.Contains(i.ElementCode))
                    {
                        Table.Columns.Add(i.ElementCode);
                    }
                }
                return Table;
            }

            listModel = new List<object>();
            listModel.AddRange(new object[17]);
            listModel[2] = OrgStructure;
            listModel[15] = 1;
            listModel[16] = int.MaxValue - 1;
            var listProfile = profileServices.GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_ProfileAll, UserLogin, ref status);

            if (ProfileIds.Count > 0)
            {
                listProfile = listProfile.Where(m => ProfileIds.Contains(m.ID)).ToList();
            }

            if (SalaryRank.Count > 0)
            {
                listModel = new List<object>();
                listModel.AddRange(new object[10]);
                listModel[6] = CutoffDuration.DateEnd;
                listModel[8] = 1;
                listModel[9] = Int32.MaxValue - 1;
                List<Sal_BasicSalaryEntity> ListBasicSalary = GetData<Sal_BasicSalaryEntity>(listModel, ConstantSql.hrm_sal_sp_get_BasicPayroll, UserLogin, ref status);
                var ListProfileByRank = ListBasicSalary.Where(m => m.RankRateID != null && SalaryRank.Contains((Guid)m.RankRateID)).Select(m => m.ProfileID).ToList();
                listProfile = listProfile.Where(m => ListProfileByRank.Contains(m.ID)).ToList();
            }

            listModel = new List<object>();
            listModel.Add(null);
            listModel.Add(CutoffDuration.ID);
            listModel.Add(null);
            listModel.Add(null);
            listModel.Add(null);
            listModel.Add(null);
            listModel.Add(null);
            listModel.Add(1);
            listModel.Add(int.MaxValue - 1);
            var lstPayrollTableItem = GetData<Sal_PayrollTableItemEntity>(listModel, ConstantSql.hrm_sal_sp_get_PayrollTableItem, UserLogin, ref status).ToList();
            Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
            string REALWAGES = Sys_Services.GetConfigValue<string>(AppConfig.HRM_SAL_ELEMENT_REALWAGES);

            List<Sal_PayrollTableItemEntity> ListPayrollTableItemResult = new List<Sal_PayrollTableItemEntity>();

            //lọc nhân viên có phần tử lớn hơn 0
            if (!string.IsNullOrEmpty(REALWAGES))
            {
                string[] listPayrollTable = lstPayrollTableItem.Select(m => m.PayrollTableID.ToString()).ToArray();
                foreach (var i in listPayrollTable)
                {
                    //lấy các item thuộc PayrollTable tương ứng
                    var lstPayrollTableItemByTable = lstPayrollTableItem.Where(m => m.PayrollTableID.ToString() == i).ToList();
                    var Item = lstPayrollTableItemByTable.FirstOrDefault(m => m.Code == REALWAGES);
                    if (Item != null)
                    {
                        double _tmp = int.MaxValue;
                        double.TryParse(Item.Value, out _tmp);
                        if (_tmp != int.MaxValue && _tmp < 0)
                        {
                            ListPayrollTableItemResult.AddRange(lstPayrollTableItemByTable);
                        }
                    }
                }
            }

            //lọc nhân viên nghỉ việc
            listProfile = listProfile.Where(m => m.DateQuit != null && m.DateQuit <= CutoffDuration.DateEnd && ListPayrollTableItemResult.Any(t => t.ProfileID == m.ID)).ToList();

            #endregion

            foreach (var profile in listProfile)
            {
                DataRow Row = Table.NewRow();
                Row["CodeEmp"] = profile.CodeEmp;
                Row["ProfileName"] = profile.ProfileName;
                Row["OrgStructure"] = profile.OrgStructureName;

                var lstPayrollTableItemByProfile = ListPayrollTableItemResult.Where(m => m.ProfileID == profile.ID).ToList();
                foreach (var tableItem in lstPayrollTableItemByProfile)
                {
                    if (Table.Columns.Contains(tableItem.Code))//đã tồn tại cột
                    {
                        if (tableItem.ValueType == EnumDropDown.ElementDataType.Double.ToString())
                        {
                            double _tmp = 0;
                            Double.TryParse(tableItem.Value, out _tmp);
                            Row[tableItem.Code] = _tmp;
                        }
                        else if (tableItem.ValueType == EnumDropDown.ElementDataType.Datetime.ToString())
                        {
                            DateTime _tmp = DateTime.MinValue;
                            DateTime.TryParse(tableItem.Value, out _tmp);
                            Row[tableItem.Code] = _tmp;
                        }
                        else
                        {
                            Row[tableItem.Code] = tableItem.Value;
                        }
                    }
                    else//chưa tồn tại
                    {
                        if (tableItem.ValueType == EnumDropDown.ElementDataType.Double.ToString())
                        {
                            double _tmp = 0;
                            Table.Columns.Add(tableItem.Code, typeof(double));
                            Double.TryParse(tableItem.Value, out _tmp);
                            Row[tableItem.Code] = _tmp;
                        }
                        else if (tableItem.ValueType == EnumDropDown.ElementDataType.Datetime.ToString())
                        {
                            DateTime _tmp = DateTime.MinValue;
                            Table.Columns.Add(tableItem.Code, typeof(DateTime));
                            DateTime.TryParse(tableItem.Value, out _tmp);
                            Row[tableItem.Code] = _tmp;
                        }
                        else
                        {
                            Table.Columns.Add(tableItem.Code, typeof(string));
                            Row[tableItem.Code] = tableItem.Value;
                        }
                    }
                }
                Table.Rows.Add(Row);
            }


            return Table;
        }
Exemplo n.º 21
0
        //private static Thread threadCompute;

        /// <summary>
        /// Tính giữ lương
        /// </summary>
        /// <param name="listProfileIds">Id bảng HoldSalary</param>
        /// <param name="CutoffdurationID">Kỳ tính lương</param>
        /// <returns></returns>
        public ResultsObject ComputeHoldSalary(List<Guid> listHoldSalaryIDs, Guid CutoffdurationID, string UserLogin)
        {
            try
            {
                Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
                string elementBeforeTax = Sys_Services.GetConfigValue<string>(AppConfig.HRM_SAL_HOLDSALARY_ELEMENT);
                string elementAfterTax = Sys_Services.GetConfigValue<string>(AppConfig.HRM_SAL_HOLDSALARY_ELEMENT_AFTERTAX);
                //Nếu chưa có config thì out
                if (string.IsNullOrEmpty(elementBeforeTax) || string.IsNullOrEmpty(elementAfterTax))
                {
                    return new ResultsObject() { Success = false, Messenger = ConstantDisplay.HRM_Sal_HoldSalary_ConfigElementHoldSalary.TranslateString() };
                }

                using (var context = new VnrHrmDataContext())
                {
                    string status = string.Empty;
                    var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
                    var repoSys_AsynTask = new CustomBaseRepository<Sys_AsynTask>(unitOfWork);
                    var repoAtt_CutOffDuration = new CustomBaseRepository<Att_CutOffDuration>(unitOfWork);
                    var repoSal_HoldSalary = new CustomBaseRepository<Sal_HoldSalary>(unitOfWork);
                    var repoHre_Profile = new CustomBaseRepository<Hre_ProfileEntity>(unitOfWork);
                    var repoPayrollTable = new CustomBaseRepository<Sal_PayrollTable>(unitOfWork);
                    var payrollTableItem = new CustomBaseRepository<Sal_PayrollTableItem>(unitOfWork);
                    #region Get data
                    List<object> listModel = new List<object>();
                    listModel.AddRange(new object[3]);
                    listModel[1] = 1;
                    listModel[2] = Int32.MaxValue - 1;
                    List<Att_CutOffDurationEntity> listCutoffduration_All = GetData<Att_CutOffDurationEntity>(listModel, ConstantSql.hrm_att_sp_get_CutOffDurations, UserLogin, ref status).ToList();

                    listModel = new List<object>();
                    listModel.AddRange(new object[5]);
                    listModel[3] = 1;
                    listModel[4] = Int32.MaxValue - 1;
                    List<Sal_HoldSalary> listHoldSalary = repoSal_HoldSalary.FindBy(m => m.IsDelete != true && m.Terminate != true).ToList();
                    listHoldSalary = listHoldSalary.Where(m => listHoldSalaryIDs.Any(t => t == m.ID)).ToList();

                    listModel = new List<object>();
                    listModel.AddRange(new object[7]);
                    listModel[5] = 1;
                    listModel[6] = Int32.MaxValue - 1;
                    List<Cat_ElementEntity> listElement = GetData<Cat_ElementEntity>(listModel, ConstantSql.hrm_cat_sp_get_Element_All, UserLogin, ref status);

                    listModel = new List<object>();
                    listModel.AddRange(new object[18]);
                    listModel[16] = 1;
                    listModel[17] = Int32.MaxValue - 1;
                    List<Hre_ProfileEntity> listHre_profile = GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_Profile, UserLogin, ref status).ToList();
                    #endregion

                    //Get byid cutoff
                    Att_CutOffDurationEntity CutoffdurationItem = listCutoffduration_All.Single(m => m.ID == CutoffdurationID);

                    //Lọc cutoff, chỉ lấy cutoff có tháng/năm lớn hơn tháng/năm của nhân viên bị giữ lương có ngày bắt đầu giữ lương nhỏ nhất
                    DateTime dateCutoff = new DateTime(CutoffdurationItem.MonthYear.Year, CutoffdurationItem.MonthYear.Month, 1);
                    var _tmp = listHoldSalary.FirstOrDefault().MonthSalary.Value;
                    DateTime dateFirstHold = new DateTime(_tmp.Year, _tmp.Month, 1);
                    List<Att_CutOffDurationEntity> listCutoffduration = listCutoffduration_All.Where(m => new DateTime(m.MonthYear.Year, m.MonthYear.Month, 1) >= dateFirstHold && new DateTime(m.MonthYear.Year, m.MonthYear.Month, 1) < dateCutoff).ToList();

                    //Get dữ liệu lập công thức
                    ComputePayrollDataModel TotalData = GetDataForComputeSalary(CutoffdurationItem, UserLogin);

                    //Biến lưu giá trị tính được qua từng tháng theo từng nhân viên
                    Dictionary<Guid, double[]> listAmountHoldSalary = new Dictionary<Guid, double[]>();

                    for (int i = 0; i < listCutoffduration.Count; i++)
                    {
                        //lấy lại các dữ liệu liên quan tới cutoff
                        TotalData = GetDataForComputeSalary_ForCutOff(TotalData, listCutoffduration[i], UserLogin);

                        //biến tạm lưu các nhân viên được tính kỳ đang duyệt qua
                        List<Sal_HoldSalary> listProfile_Any_Cutoff = new List<Sal_HoldSalary>();
                        listProfile_Any_Cutoff = listHoldSalary.Where(m => new DateTime(m.MonthSalary.Value.Year, m.MonthSalary.Value.Month, 1) <= new DateTime(listCutoffduration[i].MonthYear.Year, listCutoffduration[i].MonthYear.Month, 1)).ToList();

                        //bắt đầu tính qua từng nhân viên bị giữ lương trong tháng đang duyệt qua
                        for (int j = 0; j < listProfile_Any_Cutoff.Count; j++)
                        {
                            #region Tính công thức
                            //tính công thức
                            var listElementByConfigBeforeTax = listElement.FirstOrDefault(m => m.ElementCode == elementBeforeTax);
                            var listElementByConfigAfterTax = listElement.FirstOrDefault(m => m.ElementCode == elementAfterTax);
                            List<Cat_ElementEntity> ListElement = new List<Cat_ElementEntity>();
                            ListElement.Add(listElementByConfigBeforeTax);
                            ListElement.Add(listElementByConfigAfterTax);
                            List<ElementFormula> listElementFormula = new List<ElementFormula>();
                            listElementFormula = ParseElementFormula(listElementFormula, ListElement, TotalData, listHre_profile.Single(m => m.ID == listProfile_Any_Cutoff[j].ProfileID), listCutoffduration[i], new Dictionary<Guid, ValueCount>(), false, new TraceLogManager());

                            //lưu vài biến tổng
                            if (listElementFormula != null)
                            {
                                if (listAmountHoldSalary.Any(m => m.Key == listProfile_Any_Cutoff[j].ID))
                                {
                                    listAmountHoldSalary[listProfile_Any_Cutoff[j].ID][0] += double.Parse(listElementFormula.FirstOrDefault(m => m.VariableName == listElementByConfigBeforeTax.ElementCode).Value.ToString());
                                    listAmountHoldSalary[listProfile_Any_Cutoff[j].ID][1] += double.Parse(listElementFormula.FirstOrDefault(m => m.VariableName == listElementByConfigAfterTax.ElementCode).Value.ToString());
                                }
                                else
                                {
                                    var ElementByConfigBeforeTax = listElementFormula.FirstOrDefault(m => m.VariableName == listElementByConfigBeforeTax.ElementCode);
                                    var ElementByConfigAfterTax = listElementFormula.FirstOrDefault(m => m.VariableName == listElementByConfigAfterTax.ElementCode);

                                    listAmountHoldSalary.Add(listProfile_Any_Cutoff[j].ID, new double[] { double.Parse(ElementByConfigBeforeTax.Value.ToString()), 0 });

                                    listAmountHoldSalary[listProfile_Any_Cutoff[j].ID][1] = double.Parse(ElementByConfigAfterTax.Value.ToString());
                                }
                            }
                            #endregion
                        }
                    }

                    for (int i = 0; i < listHoldSalary.Count; i++)
                    {
                        listHoldSalary[i].MonthEndSalary = CutoffdurationItem.MonthYear;
                        if (listAmountHoldSalary.Any(m => m.Key == listHoldSalary[i].ID))
                        {
                            listHoldSalary[i].AmountSalary = listAmountHoldSalary[listHoldSalary[i].ID][0];
                            listHoldSalary[i].AmountSalaryAfterTax = listAmountHoldSalary[listHoldSalary[i].ID][1];
                        }
                        else
                        {
                            listHoldSalary[i].AmountSalary = null;
                            listHoldSalary[i].AmountSalaryAfterTax = null;
                        }
                    }
                    unitOfWork.SaveChanges();
                    return new ResultsObject();
                }
            }
            catch (Exception ex)
            {
                return new ResultsObject() { Success = false, Messenger = ex.Message };
            }
        }
Exemplo n.º 22
0
        public Hashtable ComputeSalaryDepartment(DateTime monthYear, DateTime DateStart, DateTime DateEnd, List<Sal_SalaryDepartment> lstSalDep, ref Hashtable htSalGroup)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (UnitOfWork)(new UnitOfWork(context));
                Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();

                #region Ver8 chưa dùng
                //String enumFomula = PayrollComputeMethod.E_FORMULA.ToString();
                //var responCatGradeCfg = new CustomBaseRepository<Cat_GradeCfg>(unitOfWork);
                //var lstGradeCfg = responCatGradeCfg.GetAll().Where(gr => gr.IsDelete == null && gr.Formula == enumFomula).ToList();
                //if (lstGradeCfg.Count <= 0)
                //    return htSalGroup;
                #endregion

                if (lstSalDep == null)
                {
                    var responSalDept = new CustomBaseRepository<Sal_SalaryDepartment>(unitOfWork);
                    lstSalDep = responSalDept.FindBy(ls => ls.MonthYear == monthYear && ls.IsDelete == null).ToList();
                }
                List<Guid> lstGuidSalDep = lstSalDep.Select(sal => sal.ID).ToList();
                var responSalDeptItem = new CustomBaseRepository<Sal_SalaryDepartmentItem>(unitOfWork);
                List<Sal_SalaryDepartmentItem> lstSalDepItem = responSalDeptItem.FindBy(ls => lstGuidSalDep.Contains(ls.SalaryDepartmentID) && ls.IsDelete == null).ToList();

                //Tạo list chứa ds chi tiết lương BP đã tính trước đó => để xóa đi, update mới
                List<Sal_SalaryDepartmentItem> lstItemDelete = new List<Sal_SalaryDepartmentItem>();

                #region ver8 chưa dùng
                //lấy chu kỳ lương theo chế độ lương
                //var responAppconfig = new CustomBaseRepository<Sys_AppConfig>(unitOfWork);
                //List<Sys_AppConfig> lstappConfig = responAppconfig.GetAll().Where(ap => ap.IsDelete == null).ToList();
                //string type = AppConfig.E_RANGE_SALARY_MONTH.ToString();
                //Sys_AppConfig sys_AppConfig = lstappConfig.Where(sy => sy.Info == type).FirstOrDefault();
                //AttendanceService.GetRangeMaxMinGrade(lstGradeCfg, monthYear, out DateStart, out DateEnd);
                #endregion

                //AppConfig
                //var service = new Sys_AttOvertimePermitConfigServices();
                var value52 = Sys_Services.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE52); ; // service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE52);

                /*XỬ LÝ THEO 2 OPTION */
                //sử dụng hệ số từ lương cơ bản, bổ sung NV để tính lương với nhiều trạng thái (XC 1.1)
                if (value52 == AppConfig.E_RATE_BY_BASICSALARY.ToString())
                {
                    var responOrgAll = new CustomBaseRepository<Cat_OrgStructure>(unitOfWork);
                    List<Cat_OrgStructure> listOrgAll = responOrgAll.FindBy(org => org.IsDelete == null).ToList();
                    htSalGroup = ComputeSalGroup(unitOfWork, monthYear, lstSalDep, lstSalDepItem, ref lstItemDelete, DateStart, DateEnd,  listOrgAll);
                }
                //sử dụng hệ số từ màn hình nhập hệ số, nhân viên chi tiết trong table Sal_DepartmentItem(XC 2.1)
                else
                {
                    //Chỉ sử dụng: "lstSalDepItem" để lấy danh sách nhân viên và hệ số của nhân viên
                    htSalGroup = ComputeSalGroup(unitOfWork, monthYear, lstSalDep, lstSalDepItem, ref lstItemDelete, DateStart, DateEnd);
                }
                BaseService service = new BaseService();
                service.Delete<Sal_SalaryDepartmentItem>(lstItemDelete);
                //EntityService.SaveChanges(Guid.Empty);
                unitOfWork.SaveChanges();
                return htSalGroup;
            }
        }
Exemplo n.º 23
0
        public List<Sal_SalaryDepartmentItem> CalSalaryLineItemProfile(Sal_SalaryDepartment salDepartment, List<Att_AttendanceTableItem> lstAttItemPro, Hre_Profile pro,
                                                                             List<Sal_BasicSalary> lstBasicSalPro, List<Att_Roster> lstRosterPro, DateTime dfrom, DateTime dto, DateTime monthYear,
                                                                             Sal_SalaryDepartmentItem itemProAdd)
        {
            List<Sal_SalaryDepartmentItem> lstItem = new List<Sal_SalaryDepartmentItem>();
            Double ratePer = 0;

            //Lấy hệ số trong lương cơ bản
            Sal_BasicSalary basSal = new Sal_BasicSalary();
            if (lstBasicSalPro.Count == 2)
                basSal = lstBasicSalPro[1];
            else if (lstBasicSalPro.Count == 1)
                basSal = lstBasicSalPro[0];

            if (ratePer != basSal.PersonalRate)
            {
                ratePer = basSal.PersonalRate != null ? basSal.PersonalRate.Value : 0;
                Sal_SalaryDepartmentItem depItem = null;

                string stFIX = EnumDropDown.StatusLoadEnumSalDepartItem.E_FIX.ToString();
                string stEDIT_FIX = EnumDropDown.StatusLoadEnumSalDepartItem.E_EDIT_FIX.ToString();
                if (itemProAdd != null && itemProAdd.ID.ToString() != Guid.Empty.ToString() && itemProAdd.Status != stFIX && itemProAdd.Status != stEDIT_FIX)
                {
                    depItem = itemProAdd;
                }
                else
                {
                    depItem = new Sal_SalaryDepartmentItem();
                }
                depItem.Sal_SalaryDepartment = salDepartment;
                depItem.DateFrom = dfrom;
                depItem.DateTo = dto;
                depItem.ProfileID = pro.ID;
                depItem.Rate = ratePer;
                if (itemProAdd != null)
                    depItem.Status = itemProAdd.Status;

                for (DateTime idx = dfrom; idx <= dto; idx = idx.AddDays(1))
                {
                    //(3.Use general: Insert chi tiết --> Gần Finished)
                    depItem = SetItemSalDep(depItem, lstAttItemPro, idx);
                }

                //AppConfig
                var service = new Sys_AttOvertimePermitConfigServices();
                var value56 =  service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE56);
                var value57 =  service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE57);
                var value58 =  service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE58);

                //Nếu có check áp dụng trừ số giờ cho nữ
                string gender = EnumDropDown.Gender.E_FEMALE.ToString();
                if (value56.ToLower() == true.ToString().ToLower() && pro.Gender == gender)
                {
                    if (!value57.IsNullOrEmpty() && !value58.IsNullOrEmpty())
                    {
                        double hoursub = Convert.ToDouble(value57);
                        double daywork = Convert.ToDouble(value58);
                        if (hoursub > 0 && daywork > 0)
                        {
                            var lstAttItem = lstAttItemPro.Where(p => p.IsHavingPregTreatment == true).ToList();
                            //Nếu nhân viên không có thai sản
                            if (lstAttItem.Count <= 0)
                            {
                                if (depItem.PaidWorkHours / 8 > daywork)
                                    depItem.PaidWorkHours = depItem.PaidWorkHours - hoursub;
                            }
                        }
                    }
                }
                lstItem.Add(depItem);
            }
            return lstItem;
        }
Exemplo n.º 24
0
        public List <Sal_HoldSalaryEntity> ComputeHoldSalary(Guid?cutOffDurationID, Guid[] ProfileIDs, string orgStructureID, Guid TimeAnalyze, string userLoginName)
        {
            using (var context = new VnrHrmDataContext())
            {
                #region Get Data
                string status = string.Empty;
                List <Sal_HoldSalaryEntity> lstHoldSalaryEntity = new List <Sal_HoldSalaryEntity>();

                //ds kỳ công
                var cutOffServies = new Att_CutOffDurationServices();
                var lstObjCutOff  = new List <object>();
                lstObjCutOff.Add(null);
                lstObjCutOff.Add(1);
                lstObjCutOff.Add(int.MaxValue - 1);
                var lstCutOff = cutOffServies.GetData <Att_CutOffDurationEntity>(Common.DotNetToOracle(cutOffDurationID.Value.ToString()), ConstantSql.hrm_att_sp_get_CutOffDurationById, userLoginName, ref status).FirstOrDefault();

                //ds nv
                var           hrService = new Hre_ProfileServices();
                List <object> strOrgIDs = new List <object>();
                strOrgIDs.AddRange(new object[3]);
                strOrgIDs[0] = (object)orgStructureID;
                var lstProfile = hrService.GetData <Hre_ProfileEntity>(strOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLoginName, ref status);

                if (ProfileIDs != null)
                {
                    lstProfile = lstProfile.Where(s => ProfileIDs.Contains(s.ID)).ToList();
                }

                //ds ngày nghỉ
                var leaveDayServices = new Att_LeavedayServices();
                var lstObjLeaveDay   = new List <object>();
                lstObjLeaveDay.AddRange(new object[11]);
                lstObjLeaveDay[4]  = lstCutOff.DateStart;
                lstObjLeaveDay[5]  = lstCutOff.DateEnd;
                lstObjLeaveDay[9]  = 1;
                lstObjLeaveDay[10] = int.MaxValue - 1;
                var lstLeaveDay = leaveDayServices.GetData <Att_LeaveDayEntity>(lstObjLeaveDay, ConstantSql.hrm_att_sp_get_Leaveday, userLoginName, ref status);

                //ds loại ngày nghỉ
                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                var lstObjLeavedayType   = new List <object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(int.MaxValue - 1);
                var lstLeavedayType = leavedayTypeServices.GetData <Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, userLoginName, ref status);

                lstObjLeavedayType = new List <object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(EnumDropDown.EntityType.E_CountAnalyzeHoldSalary.ToString());
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(int.MaxValue - 1);
                var ListNameEntity = leavedayTypeServices.GetData <Cat_NameEntityEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_NameEntityByKPI, userLoginName, ref status);

                ////ds chế độ lương
                //var Sal_GradeServices = new Sal_GradeServices();
                //var lstObjSal_Grade = new List<object>();
                //lstObjSal_Grade.AddRange(new object[7]);
                //lstObjSal_Grade[3] = lstCutOff.DateStart;
                //lstObjSal_Grade[4] = lstCutOff.DateEnd;//sửa lại store lấy lên tất cả các grade mà ko có ngày kết thúc
                //lstObjSal_Grade[5] = 1;
                //lstObjSal_Grade[6] = int.MaxValue - 1;
                //var lstSal_Grade = Sal_GradeServices.GetData<Sal_GradeEntity>(lstObjSal_Grade, ConstantSql.hrm_sal_sp_get_Sal_Grade, ref status).ToList();

                Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
                double DATECLOSE_SALARY = Sys_Services.GetConfigValue <double>(AppConfig.HRM_SAL_DATECLOSE_SALARY);

                foreach (var profile in lstProfile)
                {
                    Sal_HoldSalaryEntity entity = new Sal_HoldSalaryEntity();

                    entity.ProfileID        = profile.ID;
                    entity.CodeEmp          = profile.CodeEmp;
                    entity.ProfileName      = profile.ProfileName;
                    entity.CodeAttendance   = profile.CodeAttendance;
                    entity.EmployeeTypeName = profile.EmployeeTypeName;
                    entity.WorkPlaceName    = profile.WorkPlaceName;
                    entity.IDNo             = profile.IDNo;
                    entity.MonthSalary      = lstCutOff.MonthYear;
                    entity.TimeAnalyzeID    = TimeAnalyze;
                    entity.CatNameEntity    = ListNameEntity.FirstOrDefault(m => m.ID == TimeAnalyze) != null?ListNameEntity.FirstOrDefault(m => m.ID == TimeAnalyze).NameEntityName : "";

                    var lstLeavedayByProfileID = lstLeaveDay.Where(s => profile.ID == s.ProfileID).ToList();

                    #region NV Nghỉ việc trước ngày 18
                    if (profile.DateQuit != null)
                    {
                        if (profile.DateQuit.Value <= lstCutOff.DateEnd && profile.IsSettlement != true)
                        {
                            //if (profile.DateQuit.Value.Day <= 18)
                            //{
                            entity.Terminate = true;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                            //}
                        }
                    }
                    #endregion

                    #region kiểm tra nghỉ quá 12 ngày
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var    lstLeavedayTypeBy12 = lstLeavedayType.Where(m => m.Code == "SP" || m.Code == "SC" || m.Code == "DSP" || m.Code == "DL" || m.Code == "M").ToList();
                        var    _tmp  = lstLeavedayByProfileID.Where(m => !lstLeavedayTypeBy12.Any(t => t.ID == m.LeaveDayTypeID)).ToList();
                        double count = 0;
                        foreach (var i in _tmp)
                        {
                            count += i.LeaveDays != null ? (double)i.LeaveDays : 0;
                        }
                        if (count >= 12)
                        {
                            entity.DayLeave = (int)count;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }
                    #endregion

                    #region trường hợp đăng ký thai sản trước ngày 18
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy12 = lstLeavedayType.Where(m => m.Code == "M").ToList();
                        var _tmp = lstLeavedayByProfileID.FirstOrDefault(m => lstLeavedayTypeBy12.Any(t => t.ID == m.LeaveDayTypeID) && m.DateStart.Day < 18);
                        if (_tmp != null)
                        {
                            entity.IsLeaveM = true;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }
                    #endregion

                    #region Nghỉ liên tục 3 ngày
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy3 = lstLeavedayType.Where(m => m.Code == "D").ToList();
                        //lấy ngày nghỉ theo loại ngày nghỉ D
                        var lstLeavedayByProfileID3 = lstLeavedayByProfileID.Where(m => lstLeavedayTypeBy3.Any(t => t.ID == m.LeaveDayTypeID)).ToList();

                        lstLeavedayByProfileID3 = lstLeavedayByProfileID3.Where(m => m.DateEnd.Day <= DATECLOSE_SALARY).ToList();
                        double count = 0;
                        //còn 1 bug đó là khi đăng ký 3 dòng  liền kế ngày nhau
                        foreach (var i in lstLeavedayByProfileID3)
                        {
                            count = i.LeaveDays != null ? (double)i.LeaveDays : 0;
                            if (count >= 3)
                            {
                                entity.IsLeaveContinuous = true;
                                break;
                            }
                        }
                        if (entity.IsLeaveContinuous != null && entity.IsLeaveContinuous == true)
                        {
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }

                    #endregion
                }
                return(lstHoldSalaryEntity);

                #endregion
            }
        }
Exemplo n.º 25
0
        public Sal_SalaryDepartmentItem SetItemSalDep(Sal_SalaryDepartmentItem depItem, List<Att_AttendanceTableItem> lstAttItemPro, DateTime idx)
        {
            Att_AttendanceTableItem attItem = lstAttItemPro.Where(att => att.WorkDate == idx).FirstOrDefault();
            if (attItem == null)
            {
                return depItem;
            }

            //AppConfig
            var service = new Sys_AttOvertimePermitConfigServices();
            var value52 = service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE52);
            var value59 = service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE59);
            var value8 = service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE8); 
           // OverTimeStatus.E_APPROVED?

            //Lấy giờ công và giờ ca đêm
            if (value52 == AppConfig.E_RATE_BY_ATUALARISING.ToString())
            {
                //Nếu có check cấu hình chung là lấy giờ công trả lương
                if (value59.ToLower() == true.ToString().ToLower())
                {
                    double workPaidHour = attItem.WorkPaidHours;
                    //Nếu có thai sản thì trừ đi 1h
                    if (attItem.IsHavingPregTreatment == true && workPaidHour > 0)
                        workPaidHour = workPaidHour - 1;
                    depItem.PaidWorkHours += workPaidHour;
                }
                else
                {
                    double workpaidhournonpreg = 0; // attItem.WorkPaidHourNonPreg != null ? attItem.WorkPaidHourNonPreg.Value : 0;
                    workpaidhournonpreg = Math.Round(workpaidhournonpreg, 2);
                    depItem.PaidWorkHours += workpaidhournonpreg;
                }

                //(bổ sung lấy giờ ca đêm để tính tiền phụ trội ca đêm)
                double nightshifthour = attItem.NightShiftHours != null ? attItem.NightShiftHours : 0;
                nightshifthour = Math.Round(nightshifthour, 2);
                double nightshifthourDept = depItem.NightShiftHours != null ? depItem.NightShiftHours.Value : 0;
                depItem.NightShiftHours = nightshifthourDept + nightshifthour;
            }
            else
            {
                //Nếu có check cấu hình chung là lấy giờ công trả lương
                if (value59.ToLower() == true.ToString().ToLower())
                {
                    double workPaidHour = attItem.WorkPaidHours;
                    //Nếu có thai sản thì trừ đi 1h
                    if (attItem.IsHavingPregTreatment == true && workPaidHour > 0)
                        workPaidHour = workPaidHour - 1;
                    depItem.PaidWorkHours += workPaidHour;
                }
                else
                {
                    double workpaidhournonpreg = 0; // attItem.WorkPaidHourNonPreg != null ? attItem.WorkPaidHourNonPreg.Value : 0;
                    workpaidhournonpreg = Math.Round(workpaidhournonpreg, 1);
                    depItem.PaidWorkHours += workpaidhournonpreg;
                }
            }

            #region Gan OT
            List<int> lstOT = new List<int>();
            Double rate = 0; //Hệ số tăng ca, kiểm tra nếu = 0 sẽ loại bỏ khỏi việc tính lương BP, vì đây là trường hợp đặc biệt (tăng ca biệt phái)-->theo phongphu.
            Double hourOT = 0;
            lstOT.Add(1);
            lstOT.Add(2);
            lstOT.Add(3);
            lstOT.Add(4);

            #region Tính OT khi được duyệt
            if (value8 == OverTimeStatus.E_APPROVED.ToString())
            {
                foreach (var item in lstOT)
                {
                    switch (item)
                    {
                        #region case 1
                        case 1:
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime1Hours += attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime1Hours = attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime2Hours += attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime2Hours = attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime3Hours += attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime3Hours = attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime4Hours += attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime4Hours = attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime5Hours += attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime5Hours = attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime6Hours += attItem.OvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime6Hours = attItem.OvertimeRegisterHours;
                                break;
                            }
                            break;
                        #endregion
                        #region case 2
                        case 2:
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime1Hours += attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime1Hours = attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime2Hours += attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime2Hours = attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime3Hours += attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime3Hours = attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime4Hours += attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime4Hours = attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime5Hours += attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime5Hours = attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime6Hours += attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime6Hours = attItem.ExtraOvertimeRegisterHours;
                                break;
                            }
                            break;
                        #endregion
                        #region case3
                        case 3:
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime1Hours += attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime1Hours = attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime2Hours += attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime2Hours = attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime3Hours += attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime3Hours = attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime4Hours += attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime4Hours = attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime5Hours += attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime5Hours = attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime6Hours += attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime6Hours = attItem.ExtraOvertimeRegisterHours2;
                                break;
                            }
                            break;
                        #endregion
                        #region case 4
                        case 4:
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime1Hours += attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime1Hours = attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime2Hours += attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime2Hours = attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime3Hours += attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime3Hours = attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime4Hours += attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime4Hours = attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime5Hours += attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime5Hours = attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime6Hours += attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime6Hours = attItem.ExtraOvertimeRegisterHours3;
                                break;
                            }
                            break;
                        #endregion
                    }
                }
            }
            #endregion
            #region Tính OT với các trạng thái khác
            else
            {
                foreach (var item in lstOT)
                {
                    switch (item)
                    {
                        #region case 1
                        case 1:
                            rate = attItem.Cat_OvertimeType != null ? attItem.Cat_OvertimeType.Rate : 0;
                            if (rate == 0)
                                break;
                            hourOT = Math.Round(attItem.OvertimeHours != null ? attItem.OvertimeHours : 0, 2);
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime1Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime1Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime2Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime2Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime3Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime3Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime4Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime4Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime5Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime5Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.OvertimeTypeID)
                            {
                                depItem.Overtime6Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.OvertimeTypeID;
                                depItem.Overtime6Hours = hourOT;
                                break;
                            }
                            break;
                        #endregion
                        #region case 2
                        case 2:
                            rate = attItem.Cat_OvertimeType1 != null ? attItem.Cat_OvertimeType1.Rate : 0;
                            if (rate == 0)
                                break;
                            hourOT = Math.Round(attItem.ExtraOvertimeHours != null ? attItem.ExtraOvertimeHours : 0, 2);
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime1Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime1Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime2Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime2Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime3Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime3Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime4Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime4Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime5Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime5Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.ExtraOvertimeTypeID)
                            {
                                depItem.Overtime6Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.ExtraOvertimeTypeID;
                                depItem.Overtime6Hours = hourOT;
                                break;
                            }
                            break;
                        #endregion
                        #region case3
                        case 3:
                            rate = attItem.Cat_OvertimeType2 != null ? attItem.Cat_OvertimeType2.Rate : 0;
                            if (rate == 0)
                                break;
                            hourOT = Math.Round(attItem.ExtraOvertimeHours2 != null ? attItem.ExtraOvertimeHours2 : 0, 2);
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime1Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime1Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime2Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime2Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime3Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime3Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime4Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime4Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime5Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime5Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.ExtraOvertimeType2ID)
                            {
                                depItem.Overtime6Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.ExtraOvertimeType2ID;
                                depItem.Overtime6Hours = hourOT;
                                break;
                            }
                            break;
                        #endregion
                        #region case 4
                        case 4:
                            rate = attItem.Cat_OvertimeType3 != null ? attItem.Cat_OvertimeType3.Rate : 0;
                            if (rate == 0)
                                break;
                            hourOT = Math.Round(attItem.ExtraOvertimeHours3 != null ? attItem.ExtraOvertimeHours3 : 0, 2);
                            if (depItem.Overtime1TypeID != null && depItem.Overtime1TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime1Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime1TypeID == null)
                            {
                                depItem.Overtime1TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime1Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID != null && depItem.Overtime2TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime2Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime2TypeID == null)
                            {
                                depItem.Overtime2TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime2Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID != null && depItem.Overtime3TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime3Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime3TypeID == null)
                            {
                                depItem.Overtime3TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime3Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID != null && depItem.Overtime4TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime4Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime4TypeID == null)
                            {
                                depItem.Overtime4TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime4Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID != null && depItem.Overtime5TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime5Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime5TypeID == null)
                            {
                                depItem.Overtime5TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime5Hours = hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID != null && depItem.Overtime6TypeID == attItem.ExtraOvertimeType3ID)
                            {
                                depItem.Overtime6Hours += hourOT;
                                break;
                            }
                            else if (depItem.Overtime6TypeID == null)
                            {
                                depItem.Overtime6TypeID = attItem.ExtraOvertimeType3ID;
                                depItem.Overtime6Hours = hourOT;
                                break;
                            }
                            break;
                        #endregion
                    }
                }
            }
            #endregion

            #endregion
            return depItem;
        }
Exemplo n.º 26
0
        public DashboardAlertsModel Get()
        {
            var profileServices = new Hre_ProfileServices();
            Sys_AttOvertimePermitConfigServices sysServices = new Sys_AttOvertimePermitConfigServices();
            DashboardAlertsModel dashboardAlertModel        = new DashboardAlertsModel();
            ActionService        service      = new ActionService(UserLogin);
            BaseService          baseServices = new BaseService();
            string status = string.Empty;


            Boolean ischeck = profileServices.IsShowExConByConResult();

            #region lay cau hinh hien thi hop dong sap den han
            //lay cau hinh hien thi hop dong sap den han
            dashboardAlertModel.ShowValue1 = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_CONTRACT_ALERT_EXPRIDAY);
            if (dashboardAlertModel.ShowValue1 != null && dashboardAlertModel.ShowValue1 == true)
            {
                var      ShowAfterDate1 = service.GetData <Sys_AllSettingEntity>("HRM_HRE_CONTRACT_ALERT_EXPRIDAY_VALUEAFTE", ConstantSql.hrm_sys_sp_get_AllSettingByKey, ref status).FirstOrDefault();
                var      ShowBeforDate1 = service.GetData <Sys_AllSettingEntity>("HRM_HRE_CONTRACT_ALERT_EXPRIDAY_VALUEBEFOR", ConstantSql.hrm_sys_sp_get_AllSettingByKey, ref status).FirstOrDefault();
                DateTime?dateFrom       = null;
                DateTime?dateTo         = null;
                var      count          = 0;
                string   _status        = EnumDropDown.Status.E_APPROVED.ToString();

                if (ischeck == false)
                {
                    dateTo = ShowAfterDate1.Value1 != null?DateTime.Now.AddDays(Convert.ToDouble(ShowAfterDate1.Value1)) : DateTime.Now.AddDays(0);

                    dateFrom = ShowBeforDate1.Value1 != null?DateTime.Now.AddDays(-Convert.ToDouble(ShowBeforDate1.Value1)) : DateTime.Now.AddDays(0);
                }

                #region lstObjExpiryContract
                List <object> lstObjExpiryContract = new List <object>();
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(_status);
                lstObjExpiryContract.Add(dateFrom);
                lstObjExpiryContract.Add(dateTo);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(null);
                lstObjExpiryContract.Add(1);
                lstObjExpiryContract.Add(int.MaxValue - 1);
                #endregion

                #region lstObjContractType
                var lstObjContractType = new List <object>();
                lstObjContractType.Add(null);
                lstObjContractType.Add(null);
                lstObjContractType.Add(null);
                lstObjContractType.Add(null);
                lstObjContractType.Add(1);
                lstObjContractType.Add(int.MaxValue - 1);
                #endregion

                var lstContractType = baseServices.GetData <CatContractTypeModel>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, UserLogin, ref status);

                var lstExpiryContract = baseServices.GetData <Hre_ContractModel>(lstObjExpiryContract, ConstantSql.hrm_hr_sp_get_RptExpireContract, UserLogin, ref status).Where(s => s.StatusEvaluation != WorkdayStatus.E_APPROVED.ToString()).ToList();


                foreach (var item in lstExpiryContract)
                {
                    var dateCheck          = DateTime.Now;
                    var contractTypeEntity = lstContractType.Where(s => item.ContractTypeID == s.ID).FirstOrDefault();
                    if (ischeck == true)
                    {
                        if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                        {
                            var dateExpiry = dateCheck.AddDays(contractTypeEntity.ExpiryContractLoop.Value);

                            if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                            {
                                if (item.DateExtend != null && item.DateExtend <= dateExpiry)
                                {
                                    count++;
                                }
                                if (item.DateExtend == null && item.DateEnd != null && item.DateEnd.Value <= dateExpiry)
                                {
                                    count++;
                                }
                            }
                        }
                    }
                    else
                    {
                        count++;
                    }
                }
                dashboardAlertModel.sumContract = count;
            }

            #endregion

            #region lay cau hinh hien thi sinh nhat trong thang

            dashboardAlertModel.ShowValue5 = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY);
            if (dashboardAlertModel.ShowValue5 != null && dashboardAlertModel.ShowValue5 == true)
            {
                var           Birthfrom      = sysServices.GetConfigValue <double>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY_VALUEBEFOR);
                var           Birthto        = sysServices.GetConfigValue <double>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY_VALUEAFTER);
                var           _DateFrom      = DateTime.Now.AddDays(-Birthfrom);
                var           _DateTo        = DateTime.Now.AddDays(+Birthto);
                List <object> lstObjBirthDay = new List <object>();
                lstObjBirthDay.Add(new DateTime(DateTime.Now.Year, 1, 1));
                lstObjBirthDay.Add(new DateTime(DateTime.Now.Year, 12, 31));
                lstObjBirthDay.Add(null);
                lstObjBirthDay.Add(null);
                lstObjBirthDay.Add(null);
                lstObjBirthDay.Add(null);
                var _lstBirthday = baseServices.GetData <DashboardAlertsModel>(lstObjBirthDay, ConstantSql.hrm_hr_sp_get_RptBirthday, UserLogin, ref status);
                if (_DateFrom != _DateTo)
                {
                    var _kc = Convert.ToInt16((_DateTo - _DateFrom).ToString().Substring(0, (_DateTo - _DateFrom).ToString().IndexOf('.')));
                    if (_kc >= 365)
                    {
                        dashboardAlertModel.sumBirthDay = _lstBirthday.Count();
                    }
                    else
                    {
                        if (_DateFrom.Year < _DateTo.Year)
                        {
                            DateTime _dtf = (new DateTime(_DateTo.Year, 1, 1).AddMilliseconds(-1));
                            DateTime _dtt = (new DateTime(_DateTo.Year, 1, 1));
                            dashboardAlertModel.sumBirthDay = _lstBirthday.Where(s => (s.DateOfBirth >= _DateFrom && s.DateOfBirth <= _dtf) || (s.DateOfBirth >= _dtt && s.DateOfBirth <= _DateTo)).ToList().Count();
                        }
                        else
                        {
                            dashboardAlertModel.sumBirthDay = _lstBirthday.Where(s => (s.DateOfBirth >= _DateFrom && s.DateOfBirth <= _DateTo)).ToList().Count();
                        }
                    }
                }
            }
            #endregion

            #region lay cau hinh hien thi phu luc hop dong den han
            bool?_IsShowContractAppendixExpriday = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_CONTRACT_ALERT_APPENDDIXEXPRIDAY);

            if (_IsShowContractAppendixExpriday != null && _IsShowContractAppendixExpriday == true)
            {
                //lay cau hinh ngay hien thi
                int?_DayShowContractAppendixExpridayFrom = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_CONTRACT_ALERT_DAYAPPENDDIXEXPRIDAYFROM);
                int?_DayShowContractAppendixExpridayTo   = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_CONTRACT_ALERT_DAYAPPENDDIXEXPRIDAYTO);
                if (_DayShowContractAppendixExpridayFrom != null && _DayShowContractAppendixExpridayTo != null)
                {
                    dashboardAlertModel.IsShowContractAppendixExpriday = true;
                    DateTime _dateFrom           = DateTime.Now.AddDays(-_DayShowContractAppendixExpridayTo.Value);
                    DateTime _dateTo             = DateTime.Now.AddDays(_DayShowContractAppendixExpridayFrom.Value);
                    var      ObjAppendixContract = new List <object>();
                    ObjAppendixContract.AddRange(new object[7]);
                    ObjAppendixContract[3] = _dateFrom;
                    ObjAppendixContract[4] = _dateTo;
                    ObjAppendixContract[5] = 1;
                    ObjAppendixContract[6] = int.MaxValue - 1;
                    var sumAppendixContract = baseServices.GetData <Hre_AppendixContractModel>(ObjAppendixContract, ConstantSql.hrm_hr_sp_get_AppendixExpiredContract, UserLogin, ref status);
                    dashboardAlertModel.sumAppendixExpiryContract = sumAppendixContract != null ? sumAppendixContract.Count : 0;
                }
            }
            #endregion



            //lay cau hinh hien thi sinh nhat trong thang
            //dashboardAlertModel.ShowValue5 = sysServices.GetConfigValue<bool>(AppConfig.HRM_HRE_PROFILE_ALERT_BIRTHDAY_NOWDAY);
            //if (dashboardAlertModel.ShowValue5 != null && dashboardAlertModel.ShowValue5 == true)
            //{
            //    dashboardAlertModel.sumBirthDay = baseServices.GetData<DashboardAlertsModel>(lstObjBirthDay, ConstantSql.hrm_hr_sp_get_RptBirthday, UserLogin, ref status).Select(s => s.ID).ToList().Count;
            //}

            List <object> lstObjProfileProbation = new List <object>();
            lstObjProfileProbation.AddRange(new object[22]);
            lstObjProfileProbation[20] = 1;
            lstObjProfileProbation[21] = int.MaxValue - 1;
            //Hre_ProfileProbationSearchModel modelsearch = new Hre_ProfileProbationSearchModel();
            //modelsearch.DateFrom = DateTime.Now;
            //modelsearch.DateTo = dateTo;


            //lay cau hinh hien canh bao trang chu Hết Hạn Thử Việc Trong Tháng hay khong
            dashboardAlertModel.ShowValue2 = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_PROFILE_ALERT_PROBATION_EXPRIDAY);
            if (dashboardAlertModel.ShowValue2 != null && dashboardAlertModel.ShowValue2 == true)
            {
                int ProbationValueBefore = sysServices.GetConfigValue <int>(AppConfig.HRM_HRE_PROFILE_ALERT_PROBATION_EXPRIDAY_VALUEBEFOR);
                int ProbationValueAfter  = sysServices.GetConfigValue <int>(AppConfig.HRM_HRE_PROFILE_ALERT_PROBATION_EXPRIDAY_VALUEAFTER);
                //modelsearch.DateHireFrom = DateTime.Now.Date.AddMonths(-1);
                //modelsearch.DateHireTo = DateTime.Now.Date.AddMonths(1);
                lstObjProfileProbation[10] = DateTime.Now.Date.AddDays(-ProbationValueBefore);
                lstObjProfileProbation[11] = DateTime.Now.Date.AddDays(ProbationValueAfter);
                var sum = baseServices.GetData <DashboardAlertsModel>(lstObjProfileProbation, ConstantSql.hrm_hr_sp_get_ProbationProfile, UserLogin, ref status);
                dashboardAlertModel.sumProbation = sum != null ? sum.Count : 0;
            }


            //lay cau hinh hien thi luong co ban cho duyet
            dashboardAlertModel.IsShowBasicSalaryWaitingAprove = sysServices.GetConfigValue <bool>(AppConfig.HRM_SAL_BASICSALARY_ALERT_WAITINGAPROVE);


            //lay cau hinh hien thi hop dong cho duyet
            dashboardAlertModel.IsShowContractWaitingAprove = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_CONTRACT_ALERT_WAITINGAPROVE);
            if (dashboardAlertModel.IsShowContractWaitingAprove != null && dashboardAlertModel.IsShowContractWaitingAprove == true)
            {
                //sum dh cho duyet
                List <object> paraContractWaiting = new List <object>();
                paraContractWaiting.AddRange(new object[20]);
                paraContractWaiting[18] = 1;
                paraContractWaiting[19] = int.MaxValue - 1;
                var lstContractWaiting = baseServices.GetData <Hre_ContractModel>(paraContractWaiting, ConstantSql.hrm_hr_sp_get_ContractWaiting, UserLogin, ref status);
                if (lstContractWaiting != null)
                {
                    dashboardAlertModel.sumContractWaiting = lstContractWaiting.Count;
                }
            }
            //canh bao so ngay tam hoan den han
            //get so ngay cau hinh
            //string keyDaySuspenseExpiry= AppConfig.HRM_HRE_CONFIG_DAYSUSPENSEEXPIRY.ToString();
            //var objDaySuspenseExpiry=baseServices.GetData<Sys_AllSettingEntity>(keyDaySuspenseExpiry,ConstantSql.hrm_sys_sp_get_AllSettingByKey,ref status).FirstOrDefault();

            #region lay cau hinh hien thi nv sap den ngay tam hoan

            bool?_IsShowDaySuspenseExpiry = sysServices.GetConfigValue <bool?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSUSPENSEEXPIRY);

            if (_IsShowDaySuspenseExpiry != null && _IsShowDaySuspenseExpiry == true)
            {
                //lay cau hinh ngay hien thi
                int?_DayShowDaySuspenseExpiryFrom = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSUSPENSEEXPIRYFROM);
                int?_DayShowDaySuspenseExpiryTo   = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSUSPENSEEXPIRYTO);
                if (_DayShowDaySuspenseExpiryFrom != null && _DayShowDaySuspenseExpiryTo != null)
                {
                    //var valueDaySuspenseExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYSUSPENSEEXPIRY);
                    //if (valueDaySuspenseExpiry >= 0)
                    //{
                    //DateTime _dateFromTemp = DateTime.Now.AddDays(-valueDaySuspenseExpiry);
                    //DateTime _dateFrom = new DateTime(_dateFromTemp.Year, _dateFromTemp.Month, _dateFromTemp.Day, 0, 0, 0);
                    //DateTime _dateTo = DateTime.Now;
                    dashboardAlertModel.IsShowDaySuspenseExpiry = true;
                    string        _status      = EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    DateTime      _dateFrom    = DateTime.Now.AddDays(-_DayShowDaySuspenseExpiryTo.Value);
                    DateTime      _dateTo      = DateTime.Now.AddDays(_DayShowDaySuspenseExpiryFrom.Value);
                    List <object> paraSuspense = new List <object>();
                    paraSuspense.AddRange(new object[13]);
                    paraSuspense[5]  = _dateFrom;
                    paraSuspense[6]  = _dateTo;
                    paraSuspense[8]  = _status;
                    paraSuspense[11] = 1;
                    paraSuspense[12] = int.MaxValue - 1;
                    var lstSuspense = baseServices.GetData <Hre_StopWorkingModel>(paraSuspense, ConstantSql.hrm_hr_sp_get_Suspense, UserLogin, ref status);
                    if (lstSuspense != null)
                    {
                        dashboardAlertModel.sumDaySuspenseExpiry = lstSuspense.Count;
                    }

                    // }
                }
            }
            #endregion

            //canh bao nv sap den ngay nghi viec

            #region lay cau hinh hien thi nv sap den ngay nghi viec
            bool?_IsShowDayStopWorking = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSTOPWORKING);
            if (_IsShowDayStopWorking != null && _IsShowDayStopWorking == true)
            {
                int?_DayShowDayStopWorkingFrom = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSTOPWORKINGFROM);
                int?_DayShowDayStopWorkingTo   = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYSTOPWORKINGTO);
                if (_DayShowDayStopWorkingFrom != null && _DayShowDayStopWorkingTo != null)
                {
                    dashboardAlertModel.IsShowDayStopWorking = true;
                    //get cau hinh
                    //var valueDaytopworkingExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYSTOPWORKINGEXPIRY);
                    //if (valueDaytopworkingExpiry > 0)
                    //{

                    //DateTime _dateFromTemp = DateTime.Now.AddDays(-valueDaytopworkingExpiry);
                    //DateTime _dateFrom = new DateTime(_dateFromTemp.Year, _dateFromTemp.Month, _dateFromTemp.Day, 0, 0, 0);
                    //DateTime _dateTo = DateTime.Now;
                    DateTime      _dateFrom       = DateTime.Now.AddDays(-_DayShowDayStopWorkingTo.Value);
                    DateTime      _dateTo         = DateTime.Now.AddDays(_DayShowDayStopWorkingFrom.Value);
                    string        _status         = EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    List <object> paraStopWorking = new List <object>();
                    paraStopWorking.AddRange(new object[17]);
                    paraStopWorking[0]  = _status;
                    paraStopWorking[6]  = _dateFrom;
                    paraStopWorking[7]  = _dateTo;
                    paraStopWorking[15] = 1;
                    paraStopWorking[16] = int.MaxValue - 1;
                    var lstStopWorking = baseServices.GetData <Hre_StopWorkingModel>(paraStopWorking, ConstantSql.hrm_hr_sp_get_StopWorking, UserLogin, ref status);
                    if (lstStopWorking != null)
                    {
                        dashboardAlertModel.sumDayStopWorking = lstStopWorking.Count;
                    }
                    //}
                }
            }
            #endregion

            #region lay cau hinh hien thi nv sap vao lam lai
            bool?_IsShowDayComeBackExpiry = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYCOMEBACKEXPIRY);
            if (_IsShowDayComeBackExpiry != null && _IsShowDayComeBackExpiry == true)
            {
                //lay cau hinh ngay hien thi
                int?_DayShowDayComeBackExpiryFrom = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYCOMEBACKEXPIRYFROM);
                int?_DayShowDayComeBackExpiryTo   = sysServices.GetConfigValue <int?>(AppConfig.HRM_HRE_PROFILE_ALERT_DAYCOMEBACKEXPIRYTO);
                if (_DayShowDayComeBackExpiryFrom != null && _DayShowDayComeBackExpiryTo != null)
                {
                    dashboardAlertModel.IsShowDayComeBackExpiry = true;

                    //var valueDayComebackExpiry = sysServices.GetConfigValue<int>(AppConfig.HRM_HRE_CONFIG_DAYCOMEBACKEXPIRY);
                    //if (valueDayComebackExpiry > 0)
                    //{
                    //DateTime _dateFromTemp = DateTime.Now.AddDays(-valueDayComebackExpiry);
                    //DateTime _dateFrom = new DateTime(_dateFromTemp.Year, _dateFromTemp.Month, _dateFromTemp.Day, 0, 0, 0);
                    //DateTime _dateTo = DateTime.Now;

                    string        _status     = EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    DateTime      _dateFrom   = DateTime.Now.AddDays(-_DayShowDayComeBackExpiryTo.Value);
                    DateTime      _dateTo     = DateTime.Now.AddDays(_DayShowDayComeBackExpiryFrom.Value);
                    List <object> paraComback = new List <object>();
                    paraComback.AddRange(new object[14]);
                    paraComback[0]  = _status;
                    paraComback[6]  = _dateFrom;
                    paraComback[7]  = _dateTo;
                    paraComback[12] = 1;
                    paraComback[13] = int.MaxValue - 1;
                    var lstStopWorking = baseServices.GetData <Hre_StopWorkingModel>(paraComback, ConstantSql.hrm_hr_sp_get_RegisterComback, UserLogin, ref status).ToList();
                    if (lstStopWorking != null)
                    {
                        dashboardAlertModel.sumDayComeBackExpiry = lstStopWorking.Count;
                    }
                    // }
                }
            }
            #endregion

            //lay cau hinh hien thi nv la, HDT cho duyet
            dashboardAlertModel.IsShowHDTJobWaitingApproved = sysServices.GetConfigValue <bool>(AppConfig.HRM_HRE_PROFILE_ALERT_HDTJOBWAINTINGAPPROVED);
            if (dashboardAlertModel.IsShowHDTJobWaitingApproved != null && dashboardAlertModel.IsShowHDTJobWaitingApproved == true)
            {
                //sum nv vao hdt cho duyet
                List <object> paraHDTJobWaitingApproved = new List <object>();
                paraHDTJobWaitingApproved.AddRange(new object[14]);
                paraHDTJobWaitingApproved[12] = 1;
                paraHDTJobWaitingApproved[13] = int.MaxValue - 1;
                var lstHDTJobWaitingApproved = baseServices.GetData <Hre_ContractModel>(paraHDTJobWaitingApproved, ConstantSql.hrm_hr_sp_get_HDTJobWaiting, UserLogin, ref status).ToList();
                if (lstHDTJobWaitingApproved != null)
                {
                    dashboardAlertModel.sumHDTJobWaitingApproved = lstHDTJobWaitingApproved.Count;
                }
            }
            //lay cau hinh hien thi nguoi cho danh gia
            dashboardAlertModel.IsShowEvalutionWaiting = sysServices.GetConfigValue <bool>(AppConfig.HRM_EVA_PROFILE_ALERT_EVALUTIONWAITING);
            // Giấy Phép LĐ Đến Hạn
            dashboardAlertModel.IsShowExpiryWorkPermit = sysServices.GetConfigValue <bool>(AppConfig.PAPRlABORPHEPSLED);
            if (dashboardAlertModel.IsShowExpiryWorkPermit == true)
            {
                int ValueBefore = sysServices.GetConfigValue <int>(AppConfig.PAPRlABORPHEPSLED_VALUEBEFOR);
                int ValueAfter  = sysServices.GetConfigValue <int>(AppConfig.PAPRlABORPHEPSLED_VALUEAFTER);

                List <object> listObj = new List <object>();
                listObj.Add(DateTime.Now.AddDays(-ValueBefore));
                listObj.Add(DateTime.Now.AddDays(ValueAfter));
                listObj.Add(1);
                listObj.Add(int.MaxValue - 1);

                status = string.Empty;
                var result = baseServices.GetData <Hre_ProfileWorkPermitExpireModel>(listObj, ConstantSql.hrm_hr_sp_get_ProfileByWorkPermitExpiredDate, UserLogin, ref status);
                dashboardAlertModel.sumExpiryWorkPermit = result != null ? result.Count : 0;
            }

            //lấy số nhân viên nghỉ việc mà chưa được quyết toán theo cấu hình
            Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
            bool IsShowSETTLEMENT = Sys_Services.GetConfigValue <bool>(AppConfig.SAL_SETTLEMENT);
            if (IsShowSETTLEMENT)
            {
                dashboardAlertModel.IsShowSumProfileQuitNotSettlement = true;
                double        ValueBeforeSettlement = sysServices.GetConfigValue <double>(AppConfig.SAL_SETTLEMENT_VALUEBEFOR);
                double        ValueAfterSettlement  = sysServices.GetConfigValue <double>(AppConfig.SAL_SETTLEMENT_VALUEAFTER);
                var           DateSettlementFrom    = DateTime.Now.AddDays(-ValueBeforeSettlement);
                var           DateSettlementTo      = DateTime.Now.AddDays(+ValueAfterSettlement);
                List <object> ListMode = new List <object>();
                ListMode.AddRange(new object[19]);
                ListMode[8]  = DateSettlementFrom;
                ListMode[9]  = DateSettlementTo;
                ListMode[17] = 1;
                ListMode[18] = Int32.MaxValue - 1;
                List <Hre_ProfileEntity> ListProfileQuit = baseServices.GetData <Hre_ProfileEntity>(ListMode, ConstantSql.hrm_hr_sp_get_ProfileQuit, UserLogin, ref status)
                                                           .Where(m => m.IsSettlement == null || m.IsSettlement == false).ToList();
                //int SumProfileQuitResult = 0;
                //foreach (var i in ListProfileQuit)
                //{
                //    if (i.DateQuit != null && DateTime.Now.Date.Subtract((DateTime)i.DateQuit.Value.Date).TotalDays >= ValueBeforeSettlement)
                //    {
                //        SumProfileQuitResult++;
                //    }
                //}
                //dashboardAlertModel.SumProfileQuitNotSettlement = SumProfileQuitResult;
                dashboardAlertModel.SumProfileQuitNotSettlement = ListProfileQuit.Count();
            }

            return(dashboardAlertModel);
        }