public string ActionApproved(string selectedIds, string userLogin) { using (var context = new VnrHrmDataContext()) { string message = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repo = new Hre_StopWorkingRepository(unitOfWork); var profileServices = new Hre_ProfileServices(); string status = string.Empty; List <Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList(); var lstStopWorkings = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList(); foreach (var StopWorking in lstStopWorkings) { if (StopWorking.StopWorkType == HRM.Infrastructure.Utilities.EnumDropDown.StopWorkType.E_STOP.ToString()) { var profile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(StopWorking.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); StopWorking.LastStatusSyn = profile.StatusSyn; profile.StatusSyn = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkType.E_STOP.ToString(); StopWorking.Status = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString(); profile.TypeSuspense = StopWorking.TypeSuspense; profile.RequestDate = StopWorking.RequestDate; profile.StopWorkType = StopWorking.StopWorkType; profile.DateQuit = StopWorking.DateStop; profile.ResReasonID = StopWorking.ResignReasonID; profile.IsHoldSal = StopWorking.IsHoldSal; profile.TypeOfStop = StopWorking.TypeOfStop; profile.ResignNo = StopWorking.DecisionNo; profileServices.Edit(profile); } else if (StopWorking.StopWorkType == HRM.Infrastructure.Utilities.EnumDropDown.StopWorkType.E_SUSPENSE.ToString()) { var profile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(StopWorking.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); profile.StatusSyn = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkType.E_SUSPENSE.ToString(); profile.TypeOfStop = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkType.E_SUSPENSE.ToString(); StopWorking.LastStatusSyn = profile.StatusSyn; StopWorking.Status = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString(); profile.TypeSuspense = StopWorking.TypeSuspense; profile.RequestDate = StopWorking.RequestDate; profile.StopWorkType = StopWorking.StopWorkType; profile.DateQuit = StopWorking.DateStop; profile.ResReasonID = StopWorking.ResignReasonID; profile.ResignNo = StopWorking.DecisionNo; profile.IsHoldSal = null; profileServices.Edit(profile); } } repo.SaveChanges(); message = NotificationType.Success.ToString(); return(message); } }
public ActionResult SaleEvaluation(string userLogin) { if (!CheckPermission()) { return(RedirectToAction("Denied", "Portal")); } var id = Session[SessionObjects.ProfileID]; var service = new Hre_ProfileServices(); string status = string.Empty; List <object> lstObjSaleEvaluation = new List <object>(); lstObjSaleEvaluation.Add(id); // lstObjSaleEvaluation.Add(1); // lstObjSaleEvaluation.Add(1000000000); var listModel = service.GetData <Eva_SaleEvaluationModel>(lstObjSaleEvaluation, ConstantSql.hrm_eva_sp_get_SaleEvaluationByProId, userLogin, ref status); if (listModel != null && listModel.Count > 0) { var model = listModel.FirstOrDefault(); model.ActionStatus = status; return(GetOnlyView(model)); } return(View()); }
/// <summary> /// Lay DS luong hieu luc cua toan cong ty. Moi nhan vien chi co 1 muc luong trong danh sach. /// </summary> /// <param name="lstSalaryAll">get all Salary</param> /// <param name="monthEffect"></param> /// <returns></returns> public void Approved(List <Guid> selectedIds, string status, string userLoginName) { using (var context = new VnrHrmDataContext()) { string statusMessage = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repoProfile = new Hre_ProfileRepository(unitOfWork); var repoHoldSalary = new Sal_HoldSalaryRepository(unitOfWork); var lstHoldSalary = repoHoldSalary.FindBy(s => selectedIds.Contains(s.ID)).ToList(); var lstProfileIDs = lstHoldSalary.Select(s => s.ProfileID).ToList(); var profileServices = new Hre_ProfileServices(); var objProfile = new List <object>(); objProfile.AddRange(new object[17]); objProfile[15] = 1; objProfile[16] = int.MaxValue - 1; var lstProfile = profileServices.GetData <Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileAll, userLoginName, ref statusMessage).ToList().Translate <Hre_Profile>(); //var lstProfiles = repoProfile.FindBy(m => m.ID != null && lstProfileIDs.Contains(m.ID)).ToList(); foreach (var holdSalary in lstHoldSalary) { holdSalary.Status = status; var profileByID = lstProfile.Where(s => s.ID == holdSalary.ProfileID.Value).FirstOrDefault(); profileByID.MonthHoldSal = holdSalary.MonthSalary; profileByID.IsHoldSal = true; } repoHoldSalary.SaveChanges(); repoProfile.SaveChanges(); } }
/// <summary> /// [Chuc.Nguyen] - Lấy dữ liệu Nhân Viên (Hre_Profile) theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Hre_ProfileModel GetById(Guid id) { var service = new Hre_ProfileServices(); string status = string.Empty; var entity = service.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault(); //xu ly tam de lay ten loai nghi viec vi hien tai left join nhiu qa trong store khong chay dc if (entity.TypeOfStopID != null) { var catservice = new Cat_NameEntityServices(); var entityNameEntity = catservice.GetData <Cat_NameEntityEntity>(Common.DotNetToOracle(entity.TypeOfStopID.ToString()), ConstantSql.hrm_cat_sp_get_NameEntityById, UserLogin, ref status).FirstOrDefault(); if (entityNameEntity != null) { entity.TypeOfStopName = entityNameEntity.NameEntityName; } } var model = entity.CopyData <Hre_ProfileModel>(); if (model != null && model.DateOfEffect != null) { model.DateOfEffectOld = model.DateOfEffect; } model.ActionStatus = status; return(model); }
public ActionResult GeneralProfileDetail(string userLogin) { if (!CheckPermission()) { return(RedirectToAction("Denied", "Portal")); } var id = Session[SessionObjects.ProfileID]; var service = new Hre_ProfileServices(); string status = string.Empty; var model = service.GetData <Hre_ProfileModelPortal>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); if (model != null) { Session["ProfileName"] = model.ProfileName; model.ActionStatus = status; var info = new Hre_NotificationModel(); info.ProfileName = model.ProfileName; info.UserLogin = Session[SessionObjects.LoginUserName].ToString(); info.EmployeeTypeName = model.EmployeeTypeName; info.JobTitleName = model.JobTitleName; info.OrgStructureName = model.OrgStructureName; Session["LoginInfo"] = info; } return(GetOnlyView(model)); }
public string UpdateWorkingPosition(string selectedIds, string userLogin) { string message = string.Empty; string status = string.Empty; var profileServices = new Hre_ProfileServices(); var workhistoryServices = new Hre_WorkHistoryServices(); List <Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList(); // var lstSuspenses = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList(); var services = new BaseService(); var lstObj = new List <object>(); lstObj.AddRange(new object[14]); lstObj[12] = 1; lstObj[13] = int.MaxValue - 1; var lstComback = services.GetData <Hre_StopWorkingEntity>(lstObj, ConstantSql.hrm_hr_sp_get_RegisterComback, userLogin, ref status).ToList().Translate <Hre_StopWorking>(); lstComback = lstComback.Where(s => lstIds.Contains(s.ID)).ToList(); Hre_WorkHistoryEntity workHistoryEntity; foreach (var item in lstComback) { var profile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(item.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); profile.DateOfEffect = item.DateComeBack; string supervisor = null; if (profile.SupervisorID != null) { var supervisorbyProfile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(profile.SupervisorID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); if (supervisorbyProfile != null) { supervisor = supervisorbyProfile.ProfileName; } } workHistoryEntity = new Hre_WorkHistoryEntity(); workHistoryEntity.ProfileID = item.ProfileID.Value; workHistoryEntity.DateEffective = item.DateComeBack != null ? item.DateComeBack.Value : DateTime.Now; workHistoryEntity.OrganizationStructureID = profile.OrgStructureID; workHistoryEntity.JobTitleID = profile.JobTitleID; workHistoryEntity.PositionID = profile.PositionID; workHistoryEntity.Supervisor = supervisor; profileServices.Edit(profile); workhistoryServices.Add(workHistoryEntity); } message = NotificationType.Success.ToString(); return(message); }
public ActionResult Home(string userLogin) { //var service = new BaseService(); var service = new Hre_ProfileServices(); var info = new Hre_NotificationModel(); info = (Hre_NotificationModel)Session["LoginInfo"]; //count yeu cau tang ca cho duyet #region Hien thi du lieu tren trang chu string status = string.Empty; //Count ds tang ca cho duyet var userId = Session[SessionObjects.UserId] == null ? Guid.Empty : (Guid)Session[SessionObjects.UserId]; var objOvertime = new List <object>(); objOvertime.AddRange(new object[13]); objOvertime[5] = "E_SUBMIT,E_FIRST_APPROVED"; objOvertime[8] = userId; objOvertime[11] = 1; objOvertime[12] = int.MaxValue - 1; var listOvertimeEntity = service.GetData <Att_OvertimeEntity>(objOvertime, ConstantSql.hrm_att_sp_get_Overtime, userLogin, ref status).ToList(); var listOvertime = listOvertimeEntity.Where(s => !(s.Status == LeaveDayStatus.E_FIRST_APPROVED.ToString() && s.UserApproveID == userId)).ToList(); if (listOvertime != null) { info.CountOvertime = listOvertime.Count(); } //count ds ngay nghi cho duyet var objLeaveday = new List <object>(); objLeaveday.AddRange(new object[11]); objLeaveday[2] = "E_SUBMIT,E_FIRST_APPROVED"; objLeaveday[7] = userId; objLeaveday[9] = 1; objLeaveday[10] = int.MaxValue - 1; var lstLeavedayEntity = service.GetData <Att_LeaveDayEntity>(objLeaveday, ConstantSql.hrm_att_sp_get_Leaveday, userLogin, ref status).ToList(); var listLeaveday = lstLeavedayEntity.Where(s => !(s.Status == OverTimeStatus.E_FIRST_APPROVED.ToString() && s.UserApproveID == userId)).ToList(); if (listLeaveday != null) { info.CountLeaveday = listLeaveday.Count(); } #endregion return(GetView(info)); }
public Hre_DisciplineModel Post([Bind] Hre_DisciplineModel model) { #region Validate string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Hre_DisciplineModel>(model, "Hre_Discipline", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } #endregion #region cột DepartmentName = phòng ban hiện tại của NV string status = string.Empty; var orgServices = new Cat_OrgStructureServices(); var profileServices = new Hre_ProfileServices(); var lstObjOrg = new List <object>(); lstObjOrg.Add(null); lstObjOrg.Add(null); lstObjOrg.Add(null); lstObjOrg.Add(1); lstObjOrg.Add(int.MaxValue - 1); var lstOrg = orgServices.GetData <Cat_OrgStructureEntity>(lstObjOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, UserLogin, ref status).ToList(); var orgTypeService = new Cat_OrgStructureTypeServices(); var lstObjOrgType = new List <object>(); lstObjOrgType.Add(null); lstObjOrgType.Add(null); lstObjOrgType.Add(1); lstObjOrgType.Add(int.MaxValue - 1); var lstOrgType = orgTypeService.GetData <Cat_OrgStructureTypeEntity>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, UserLogin, ref status).ToList(); string orgstructureNameByProfile = string.Empty; if (model.ProfileID != null) { var profilebydis = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(model.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault(); if (profilebydis != null) { Guid?orgId = profilebydis.OrgStructureID; var org = lstOrg.FirstOrDefault(s => s.ID == profilebydis.OrgStructureID); var department = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DEPARTMENT, lstOrg, lstOrgType); orgstructureNameByProfile = department != null ? department.OrgStructureName : string.Empty; } } model.DepartmentName = orgstructureNameByProfile; #endregion ActionService service = new ActionService(UserLogin); return(service.UpdateOrCreate <Hre_DisciplineEntity, Hre_DisciplineModel>(model)); }
/// <summary> /// [Tho.Bui] - Lấy dữ liệu Nhân Viên (Hre_ProfilePartyUnion) theo ProfileId /// </summary> /// <param name="id"></param> /// <returns></returns> public Hre_ProfilePartyUnionModel Put(Hre_ProfilePartyUnionModel model) { var service = new Hre_ProfileServices(); string status = string.Empty; List <object> listObj = new List <object>() { model.ProfileID }; var entity = service.GetData <Hre_ProfilePartyUnionEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfilePartyUnionprofileId, UserLogin, ref status).FirstOrDefault(); var model1 = entity.CopyData <Hre_ProfilePartyUnionModel>(); model.ActionStatus = status; return(model1); }
public ActionResult ProfileAttendanceDetail(string userLogin) { if (!CheckPermission()) { return(RedirectToAction("Denied", "Portal")); } var id = Session[SessionObjects.ProfileID]; var service = new Hre_ProfileServices(); string status = string.Empty; var model = service.GetData <Hre_ProfileModelPortal>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); if (model != null) { Session["ProfileName"] = model.ProfileName; model.ActionStatus = status; } return(GetOnlyView(model)); }
public ActionResult SalaryInfo(string userLogin) { if (!CheckPermission()) { return(RedirectToAction("Denied", "Portal")); } var id = Session[SessionObjects.ProfileID]; var service = new Hre_ProfileServices(); string status = string.Empty; Sal_SalaryInformationModel listModel1 = null; var listModel = service.GetData <Sal_SalaryInformationModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_sal_sp_get_Sal_SalaryInfomationByProfileId, userLogin, ref status); if (listModel != null && listModel.Count > 0) { listModel1 = listModel.FirstOrDefault(); listModel1.ActionStatus = status; } return(GetOnlyView(listModel1)); }
public Sal_GradeModel Post([Bind] Sal_GradeModel model) { #region Validate ActionService service = new ActionService(UserLogin); string message = string.Empty; var checkValidate = false; if (model.IsProfileNotGrade) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_GradeModel>(model, "Sal_Grade", ref message); } else if (model.IsCreateByProfile) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_GradeModel>(model, "Sal_GradeByProfile", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } return(service.UpdateOrCreate <Sal_GradeEntity, Sal_GradeModel>(model)); } else { if (model.OrgStructureID != null && model.OrgStructureID != string.Empty) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_GradeModel>(model, "Sal_GradeOrg", ref message); } else { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_GradeModel>(model, "Sal_Grade", ref message); } } if (!checkValidate) { model.ActionStatus = message; return(model); } #endregion string status = string.Empty; //string message = string.Empty; var hrService = new Hre_ProfileServices(); var gradeServices = new Sal_GradeServices(); if (!string.IsNullOrEmpty(model.OrgStructureID)) { List <Guid> listGuid = new List <Guid>(); if (model.ProfileIDsExclude != null) { var listStr = model.ProfileIDsExclude.Split(','); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } } List <object> listObj = new List <object>(); listObj.Add(model.OrgStructureID); listObj.Add(string.Empty); listObj.Add(string.Empty); var lstProfile = hrService.GetData <Hre_ProfileIdEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, userLogin, ref status).Select(s => s.ID).ToList(); if (listGuid != null) { lstProfile = lstProfile.Where(s => !listGuid.Contains(s)).ToList(); } if (lstProfile.Count == 0 && model.ProfileID == Guid.Empty) { model.ActionStatus = ConstantDisplay.HRM_Common_NotEmployee.TranslateString(); return(model); } List <Sal_GradeEntity> lstGradeEntity = new List <Sal_GradeEntity>(); foreach (var item in lstProfile) { Sal_GradeEntity gradeEntity = new Sal_GradeEntity { ProfileID = item, DateCreate = model.DateCreate, DateLock = model.DateLock, GradeCfgName = model.GradeCfgName, GradePayrollID = model.GradePayrollID, ID = model.ID, MonthEnd = model.MonthEnd, MonthStart = model.MonthStart, IsDelete = model.IsDelete, UserUpdate = model.UserCreate, UserCreate = model.UserCreate, }; //model.ActionStatus = gradeServices.Add(gradeEntity); lstGradeEntity.Add(gradeEntity); } model.ActionStatus = gradeServices.Add(lstGradeEntity); return(model); } if (model.ProfileIDs != null && model.ProfileIDs != string.Empty) { var listStr = model.ProfileIDs.Split(','); List <Guid> listGuid = new List <Guid>(); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } else { model.ActionStatus = ConstantDisplay.HRM_Common_NotEmployee.TranslateString(); return(model); } List <Sal_GradeEntity> lstGradeEntity = new List <Sal_GradeEntity>(); foreach (var item in listGuid) { Sal_GradeEntity gradeEntity = new Sal_GradeEntity { ProfileID = item, DateCreate = model.DateCreate, DateLock = model.DateLock, GradeCfgName = model.GradeCfgName, GradePayrollID = model.GradePayrollID, ID = model.ID, MonthEnd = model.MonthEnd, MonthStart = model.MonthStart, IsDelete = model.IsDelete, UserUpdate = model.UserCreate, UserCreate = model.UserCreate, }; //model.ActionStatus = gradeServices.Add(gradeEntity); lstGradeEntity.Add(gradeEntity); } model.ActionStatus = gradeServices.Add(lstGradeEntity); return(model); } if (model.ProfileID == Guid.Empty) { model.ActionStatus = ConstantDisplay.HRM_Common_NotEmployee.TranslateString(); return(model); } return(service.UpdateOrCreate <Sal_GradeEntity, Sal_GradeModel>(model)); }
public Sal_InsuranceSalaryModel Post([Bind] Sal_InsuranceSalaryModel model) { #region Validate ActionService service = new ActionService(UserLogin); string message = string.Empty; bool checkValidate = true; if (model.IsCreateByProfile != null && model.IsCreateByProfile == true) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_InsuranceSalaryModel>(model, "Sal_InsuranceSalaryByProfile", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } return(service.UpdateOrCreate <Sal_InsuranceSalaryEntity, Sal_InsuranceSalaryModel>(model)); } //var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Sal_InsuranceSalaryModel>(model, "Sal_InsuranceSalary", ref message); if (model.OrgStructureID != null && model.OrgStructureID != string.Empty) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_InsuranceSalaryModel>(model, "Sal_InsuranceSalaryOrgStructure", ref message); } else { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_InsuranceSalaryModel>(model, "Sal_InsuranceSalary", ref message); } if (!checkValidate) { model.ActionStatus = message; return(model); } #endregion string status = string.Empty; var hrService = new Hre_ProfileServices(); var insuranceServices = new Sal_InsuranceSalaryServices(); if (!string.IsNullOrEmpty(model.OrgStructureID)) { List <Guid> listGuid = new List <Guid>(); if (model.ProfileIDsExclude != null) { var listStr = model.ProfileIDsExclude.Split(','); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } } List <object> listObj = new List <object>(); listObj.Add(model.OrgStructureID); listObj.Add(string.Empty); listObj.Add(string.Empty); var lstProfile = hrService.GetData <Hre_ProfileIdEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, userLogin, ref status).Select(s => s.ID).ToList(); if (listGuid != null) { lstProfile = lstProfile.Where(s => !listGuid.Contains(s)).ToList(); } if (lstProfile.Count == 0 && model.ProfileID == Guid.Empty) { model.ActionStatus = ConstantDisplay.HRM_Common_NotEmployee.TranslateString(); return(model); } List <Sal_InsuranceSalaryEntity> lstGradeEntity = new List <Sal_InsuranceSalaryEntity>(); foreach (var item in lstProfile) { Sal_InsuranceSalaryEntity gradeEntity = new Sal_InsuranceSalaryEntity { ProfileID = item, DateCreate = model.DateCreate, DateLock = model.DateLock, CurrencyID = model.CurrencyID, InsuranceAmount = model.InsuranceAmount, ID = model.ID, DateEffect = model.DateEffect, IsSocialIns = model.IsSocialIns, IsMedicalIns = model.IsMedicalIns, IsUnimploymentIns = model.IsUnimploymentIns, IsDelete = model.IsDelete, UserUpdate = model.UserCreate, UserCreate = model.UserCreate, DecisionNo = model.DecisionNo }; //model.ActionStatus = gradeServices.Add(gradeEntity); lstGradeEntity.Add(gradeEntity); } model.ActionStatus = insuranceServices.Add(lstGradeEntity); return(model); } if (!string.IsNullOrEmpty(model.ProfileIDs)) { var listStr = model.ProfileIDs.Split(','); List <Guid> listGuid = new List <Guid>(); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } List <Sal_InsuranceSalaryEntity> lstGradeEntity = new List <Sal_InsuranceSalaryEntity>(); foreach (var item in listGuid) { Sal_InsuranceSalaryEntity gradeEntity = new Sal_InsuranceSalaryEntity { ProfileID = item, DateCreate = model.DateCreate, DateLock = model.DateLock, CurrencyID = model.CurrencyID, InsuranceAmount = model.InsuranceAmount, ID = model.ID, DateEffect = model.DateEffect, IsSocialIns = model.IsSocialIns, IsMedicalIns = model.IsMedicalIns, IsUnimploymentIns = model.IsUnimploymentIns, IsDelete = model.IsDelete, UserUpdate = model.UserCreate, UserCreate = model.UserCreate, DecisionNo = model.DecisionNo }; //model.ActionStatus = gradeServices.Add(gradeEntity); lstGradeEntity.Add(gradeEntity); } model.ActionStatus = insuranceServices.Add(lstGradeEntity); return(model); } return(service.UpdateOrCreate <Sal_InsuranceSalaryEntity, Sal_InsuranceSalaryModel>(model)); }
public Tra_TraineeModel Post([Bind] Tra_TraineeModel model) { #region Validate string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Tra_TraineeModel>(model, "Tra_Trainee", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } #endregion var traineeServices = new Tra_TraineeServices(); ActionService service = new ActionService(UserLogin); var isTraineeInRequireDetail = traineeServices.IsAddTraineeDependOnRequirementDetail(); var traineeTopicServices = new Tra_TraineeTopicServices(); var planServices = new Tra_PlanServices(); var status = string.Empty; var lstObjPlan = new List <object>(); lstObjPlan.Add(null); lstObjPlan.Add(null); lstObjPlan.Add(null); lstObjPlan.Add(null); lstObjPlan.Add(1); lstObjPlan.Add(int.MaxValue - 1); var lstPlan = planServices.GetData <Tra_PlanEntity>(lstObjPlan, ConstantSql.hrm_tra_sp_get_Plan, UserLogin, ref status).ToList(); var planDetailServices = new Tra_PlanDetailServices(); var lstObjPlanDetail = new List <object>(); lstObjPlanDetail.Add(null); lstObjPlanDetail.Add(1); lstObjPlanDetail.Add(int.MaxValue - 1); var lstPlanDetail = planDetailServices.GetData <Tra_PlanDetailEntity>(lstObjPlanDetail, ConstantSql.hrm_tra_sp_get_PlanDetail, UserLogin, ref status).ToList(); var classServices = new Tra_ClassServices(); var lstObjClass = new List <object>(); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(null); lstObjClass.Add(1); lstObjClass.Add(int.MaxValue - 1); var lstClass = classServices.GetData <Tra_ClassEntity>(lstObjClass, ConstantSql.hrm_tra_sp_get_Class, UserLogin, ref status).ToList(); var lstObjTraineeInClass = new List <object>(); lstObjTraineeInClass.Add(model.ClassID); var lstTraineeInClass = classServices.GetData <Tra_ClassEntity>(lstObjTraineeInClass, ConstantSql.hrm_cat_sp_get_TraineeByClassID, UserLogin, ref status).ToList(); var courseTopicServices = new Tra_TraineeTopicServices(); var objCourseTopic = new List <object>(); objCourseTopic.Add(1); objCourseTopic.Add(int.MaxValue - 1); var lstCourseTopic = courseTopicServices.GetData <Tra_CourseTopicEntity>(objCourseTopic, ConstantSql.hrm_tra_sp_get_CourseTopic, UserLogin, ref status); var classEntity = lstClass.Where(s => s.ID == model.ClassID).FirstOrDefault(); var profileServices = new Hre_ProfileServices(); var profileEntity = profileServices.GetData <Hre_ProfileEntity>(model.ProfileID, ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault(); var requirementServices = new Tra_RequirementTrainServices(); var objRequirement = new List <object>(); objRequirement.AddRange(new object[7]); objRequirement[5] = 1; objRequirement[6] = int.MaxValue - 1; var lstRequirement = requirementServices.GetData <Tra_RequirementTrainEntity>(objRequirement, ConstantSql.hrm_tra_sp_get_RequirementTrain, UserLogin, ref status).ToList(); var requirementDetailServices = new Tra_RequirementTrainDetailServices(); var objRequirementDetail = new List <object>(); objRequirementDetail.Add(null); objRequirementDetail.Add(1); objRequirementDetail.Add(int.MaxValue - 1); var lstRequirementDetail = requirementDetailServices.GetData <Tra_RequirementTrainDetailEntity>(objRequirementDetail, ConstantSql.hrm_tra_sp_get_RequirementDetail, UserLogin, ref status).ToList(); var objTrainee = new List <object>(); objTrainee.AddRange(new object[15]); objTrainee[13] = 1; objTrainee[14] = int.MaxValue - 1; var lstObjTrainee = traineeServices.GetData <Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, UserLogin, ref status).ToList(); var traineeEntity = lstObjTrainee.Where(s => s.ClassID == model.ClassID && model.ProfileID == s.ProfileID).ToList(); #region Check Học Viên if (model.ID == Guid.Empty) { if (isTraineeInRequireDetail) { if (traineeEntity.Count > 0) { model.ActionStatus = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString(); return(model); } if (classEntity != null) { if (classEntity.PlanID != null) { var lstRequirementByPlanID = lstRequirement.Where(s => s.PlanID != null && s.PlanID.Value == classEntity.PlanID).ToList(); foreach (var item in lstRequirementByPlanID) { var requirementDetailEntity = lstRequirementDetail.Where(s => item.ID == s.RequirementTrainID && s.CourseID == classEntity.CourseID && s.ProfileID == model.ProfileID).FirstOrDefault(); if (requirementDetailEntity != null) { model = service.UpdateOrCreate <Tra_TraineeEntity, Tra_TraineeModel>(model); var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList(); foreach (var courseTopic in lstCourseTopicByCourseID) { var traineeTopicEntity = new Tra_TraineeTopicEntity(); traineeTopicEntity.TopicID = courseTopic.TopicID; traineeTopicEntity.TraineeID = model.ID; message = traineeTopicServices.Add(traineeTopicEntity); } // edit classID trong RequirementDetail requirementDetailEntity.ClassID = model.ClassID; message = requirementDetailServices.Edit(requirementDetailEntity); } else { model.ActionStatus = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString(); } } } else { model.ActionStatus = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString(); } model.ActionStatus = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString(); } if (message == NotificationType.Success.ToString()) { model.ActionStatus = message; } return(model); //if (classEntity != null) //{ // if (classEntity.PlanID != null) // { // var planEntity = lstPlan.Where(s => s.ID == classEntity.PlanID.Value).FirstOrDefault(); // if (planEntity != null) // { // var lstPlanDetailByPlanID = lstPlanDetail.Where(s => s.PlanID == planEntity.ID).ToList(); // foreach (var item in lstPlanDetailByPlanID) // { // var lstTraineeInClassForOrg = lstTraineeInClass.Where(s => s.OrgStructureID.Value == item.OrgStructureID.Value).ToList(); // //Kiểm tra số lượng của plan detail với sumQuantity của plan // if (planEntity.SumQuantity == lstPlanDetailByPlanID.Sum(s => s.Quantity)) // { // if (lstTraineeInClass.Count < lstPlanDetailByPlanID.Sum(s => s.Quantity)) // { // // Xử Lý kiểm tra nv có thuộc phòng ban trong plan detail ko // if (profileEntity != null) // { // if (lstTraineeInClassForOrg.Count < item.Quantity) // { // if (profileEntity.OrgStructureID.Value == item.OrgStructureID.Value) // { // var traineeEntity = new Tra_TraineeEntity(); // model.OrgStructureID = profileEntity.OrgStructureID != null ? profileEntity.OrgStructureID.Value : profileEntity.OrgStructureID; // model = service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model); // var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList(); // foreach (var courseTopic in lstCourseTopicByCourseID) // { // var traineeTopicEntity = new Tra_TraineeTopicEntity(); // traineeTopicEntity.TopicID = courseTopic.TopicID; // traineeTopicEntity.TraineeID = model.ID; // message = traineeTopicServices.Add(traineeTopicEntity); // } // return model; // } // model.ActionStatus = ConstantMessages.WarningProfileNotDependantOrgStructure.TranslateString(); // } // else // { // model.ActionStatus = ConstantMessages.WarningTraineeOverLimit.TranslateString(); // } // } // } // else // { // model.ActionStatus = ConstantMessages.WarningTraineeOverLimit.TranslateString(); // } // } // if (planEntity.SumQuantity > lstPlanDetailByPlanID.Sum(s => s.Quantity)) // { // model = service.UpdateOrCreate<Tra_TraineeEntity, Tra_TraineeModel>(model); // var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList(); // foreach (var courseTopic in lstCourseTopicByCourseID) // { // var traineeTopicEntity = new Tra_TraineeTopicEntity(); // traineeTopicEntity.TopicID = courseTopic.TopicID; // traineeTopicEntity.TraineeID = model.ID; // message = traineeTopicServices.Add(traineeTopicEntity); // } // return model; // } // } // return model; // } // } //} } if (classEntity != null) { if (traineeEntity.Count > 0) { model.ActionStatus = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString(); return(model); } model = service.UpdateOrCreate <Tra_TraineeEntity, Tra_TraineeModel>(model); var lstCourseTopicByCourseID = lstCourseTopic.Where(s => s.CourseID == classEntity.CourseID).ToList(); if (lstCourseTopicByCourseID.Count == 0) { return(model); } foreach (var courseTopic in lstCourseTopicByCourseID) { var traineeTopicEntity = new Tra_TraineeTopicEntity(); traineeTopicEntity.TopicID = courseTopic.TopicID; traineeTopicEntity.TraineeID = model.ID; model.ActionStatus = traineeTopicServices.Add(traineeTopicEntity); } return(model); } } return(service.UpdateOrCreate <Tra_TraineeEntity, Tra_TraineeModel>(model)); #endregion }
public Att_TimeSheetModel Post([Bind] Att_TimeSheetModel model) { #region Validate string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Att_TimeSheetModel>(model, "Att_TimeSheet", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } #endregion ActionService service = new ActionService(UserLogin); string status = string.Empty; var hrService = new Hre_ProfileServices(); var timeSheetServices = new Att_TimeSheetServices(); if (!string.IsNullOrEmpty(model.OrgStructureID)) { List <Guid> listGuid = new List <Guid>(); if (model.ProfileIDs != null) { var listStr = model.ProfileIDs.Split(','); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } } List <object> listObj = new List <object>(); listObj.Add(model.OrgStructureID); listObj.Add(string.Empty); listObj.Add(string.Empty); var lstProfile = hrService.GetData <Hre_ProfileIdEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, UserLogin, ref status).Select(s => s.ID).ToList(); if (listGuid != null) { lstProfile = lstProfile.Where(s => !listGuid.Contains(s)).ToList(); } List <Att_TimeSheetEntity> lstTimeSheetEntity = new List <Att_TimeSheetEntity>(); foreach (var item in lstProfile) { Att_TimeSheetEntity timeSheetEntity = new Att_TimeSheetEntity { ProfileID = item, DateCreate = model.DateCreate, DateLock = model.DateLock, RoleID = model.RoleID, JobTypeID = model.JobTypeID, ID = model.ID, NoHour = model.NoHour, Date = model.Date, Sector = model.Sector, Note = model.Note, IsDelete = model.IsDelete, UserUpdate = model.UserCreate, UserCreate = model.UserCreate, }; lstTimeSheetEntity.Add(timeSheetEntity); } model.ActionStatus = timeSheetServices.Add(lstTimeSheetEntity); return(model); } if (model.ProfileIDs != null && model.ProfileIDs.IndexOf(',') > 0) { var listStr = model.ProfileIDs.Split(','); List <Guid> listGuid = new List <Guid>(); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } List <Att_TimeSheetEntity> lstTimeSheetEntity = new List <Att_TimeSheetEntity>(); foreach (var item in listGuid) { Att_TimeSheetEntity TimeSheetEntity = new Att_TimeSheetEntity { ProfileID = item, DateCreate = model.DateCreate, DateLock = model.DateLock, RoleID = model.RoleID, JobTypeID = model.JobTypeID, ID = model.ID, NoHour = model.NoHour, Date = model.Date, Note = model.Note, Sector = model.Sector, IsDelete = model.IsDelete, UserUpdate = model.UserCreate, UserCreate = model.UserCreate, }; lstTimeSheetEntity.Add(TimeSheetEntity); } model.ActionStatus = timeSheetServices.Add(lstTimeSheetEntity); return(model); } return(service.UpdateOrCreate <Att_TimeSheetEntity, Att_TimeSheetModel>(model)); }
public DataTable GetReportLateEarlyTotal(Att_ReportLateEarlyTotalEntity model, string userLogin) { DataTable tblData = getSchema(); var service = new Att_ReportLateEarlyTotalServices(); var hrService = new Hre_ProfileServices(); DateTime DateFrom = DateTime.Now; DateTime DateTo = DateTime.Now; List <Guid?> OrgIds = new List <Guid?>(); if (model.SDateFrom != null) { DateFrom = model.SDateFrom.Value; } if (model.SDateTo != null) { DateTo = model.SDateTo.Value; } var From = DateFrom; var To = DateTo; string strOrgIDs = null; if (!string.IsNullOrEmpty(model.OrgStructureID)) { strOrgIDs = model.OrgStructureID; } List <object> listObj = new List <object>(); listObj.Add(strOrgIDs); listObj.Add(string.Empty); listObj.Add(string.Empty); string status = string.Empty; var result = new DataTable(); var lstprofile = hrService.GetData <Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, userLogin, ref status).ToList(); if (lstprofile == null || lstprofile.Count == 0) { return(null); } List <Guid> lstProfileIDs = lstprofile.Select(x => x.ID).ToList(); using (var context = new VnrHrmDataContext()) { var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repoProfile = new Hre_ProfileRepository(unitOfWork); var repoOrgStructure = new Cat_OrgStructureRepository(unitOfWork); var repoOrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork); var repoTAMScanReasonMiss = new Cat_TAMScanReasonMissRepository(unitOfWork); var repoAtt_Workday = new Att_WorkDayRepository(unitOfWork); //var lstprofile=repoProfile.FindBy(x=>lstProfileIDs.Contains(x.ID)).ToList(); var orgs = repoOrgStructure.FindBy(s => s.Code != null).ToList(); var orgTypes = repoOrgStructureType.FindBy(s => s.IsDelete == null).ToList(); Guid ForgetTams = repoTAMScanReasonMiss.FindBy(x => x.Code.Equals("FC")).Select(x => x.ID).FirstOrDefault(); var lstWorkdayQuery = repoAtt_Workday.FindBy(m => m.WorkDate >= From && m.WorkDate <= To && (m.LateEarlyDuration > 0 || m.Type == WorkdayType.E_LATE_EARLY.ToString()) && !(m.Status == WorkdayStatus.E_APPROVED.ToString() && m.LateEarlyDuration == 0)).ToList(); var lstWorkdayFogetTamsQuery = repoAtt_Workday.FindBy(m => m.WorkDate >= From && m.WorkDate <= To && m.MissInOutReason == ForgetTams).ToList(); // var listProfile = repoProfile.FindBy(x => lstProfileIDs.Contains(x.ID)).ToList(); if (lstProfileIDs != null && lstProfileIDs.Count != 0) { lstWorkdayQuery = lstWorkdayQuery.Where(x => lstProfileIDs.Contains(x.ProfileID)).ToList(); lstWorkdayFogetTamsQuery = lstWorkdayFogetTamsQuery.Where(x => lstProfileIDs.Contains(x.ProfileID)).ToList(); } var lstWorkday = lstWorkdayQuery.Select(m => new { m.ID, m.ProfileID, m.WorkDate, m.LateEarlyDuration }).ToList(); var lstWorkdayFogetTams = lstWorkdayFogetTamsQuery.Select(m => new { m.ID, m.ProfileID, m.WorkDate }).ToList(); foreach (var item in lstprofile) { DataRow row = tblData.NewRow(); row[Att_ReportLateEarlyTotalEntity.FieldNames.CodeEmp] = item.CodeEmp; row[Att_ReportLateEarlyTotalEntity.FieldNames.ProfileName] = item.ProfileName; row[Att_ReportLateEarlyTotalEntity.FieldNames.DateFrom] = From; row[Att_ReportLateEarlyTotalEntity.FieldNames.DateTo] = To; row[Att_ReportLateEarlyTotalEntity.FieldNames.UserExport] = model.UserExport; row[Att_ReportLateEarlyTotalEntity.FieldNames.DateExport] = DateTime.Today; if (item.OrgStructureID.HasValue) { Cat_OrgStructure objOrgStructure = orgs.Where(x => x.ID == item.OrgStructureID).FirstOrDefault(); row[Att_ReportLateEarlyTotalEntity.FieldNames.OrgStructureName] = objOrgStructure.OrgStructureName; Guid?orgId = item.OrgStructureID; var orgBrand = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, orgs, orgTypes); var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes); var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, orgs, orgTypes); var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes); row[Att_ReportLateEarlyTotalEntity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.DepartmentName] = orgOrg != null ? orgOrg.OrgStructureName : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.BranchCode] = orgBrand != null ? orgBrand.Code : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.BranchName] = orgBrand != null ? orgBrand.OrgStructureName : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty; row[Att_ReportLateEarlyTotalEntity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty; } for (DateTime MonthCheck = From; MonthCheck <= To; MonthCheck = MonthCheck.AddMonths(1)) { DateTime BeginMonth = new DateTime(MonthCheck.Year, MonthCheck.Month, 1); DateTime EndMonth = BeginMonth.AddMonths(1).AddMinutes(-1); double Less2Hour = lstWorkday.Where(m => m.ProfileID == item.ID && m.WorkDate >= BeginMonth && m.WorkDate <= EndMonth && m.LateEarlyDuration < 2).ToList().Count; double Over2Hour = lstWorkday.Where(m => m.ProfileID == item.ID && m.WorkDate >= BeginMonth && m.WorkDate <= EndMonth && m.LateEarlyDuration >= 2).ToList().Count; double TotalLateEarly = Less2Hour + Over2Hour; double ForgetTamscan = lstWorkdayFogetTams.Where(m => m.ProfileID == item.ID && m.WorkDate >= BeginMonth && m.WorkDate <= EndMonth).ToList().Count; row[Att_ReportLateEarlyTotalEntity.FieldNames.Less2Hour + BeginMonth.Month] = Less2Hour; row[Att_ReportLateEarlyTotalEntity.FieldNames.Over2Hour + BeginMonth.Month] = Over2Hour; row[Att_ReportLateEarlyTotalEntity.FieldNames.TotalLateEarly + BeginMonth.Month] = TotalLateEarly; row[Att_ReportLateEarlyTotalEntity.FieldNames.ForgetTamscan + BeginMonth.Month] = ForgetTamscan; } tblData.Rows.Add(row); } } var configs = new Dictionary <string, Dictionary <string, object> >(); var confighidden = new Dictionary <string, object>(); var configCodeEmp = new Dictionary <string, object>(); configCodeEmp.Add("width", 90); var configProfileName = new Dictionary <string, object>(); configProfileName.Add("width", 125); var configOrgStructureName = new Dictionary <string, object>(); configOrgStructureName.Add("width", 80); var configDepartmentCode = new Dictionary <string, object>(); configDepartmentCode.Add("width", 98); var configSectionCode = new Dictionary <string, object>(); configSectionCode.Add("width", 50); var configBranchCode = new Dictionary <string, object>(); configBranchCode.Add("width", 90); var configBranchName = new Dictionary <string, object>(); configBranchName.Add("width", 77); confighidden.Add("hidden", true); configs.Add("CodeEmp", configCodeEmp); configs.Add("ProfileName", configProfileName); configs.Add("OrgStructureName", configOrgStructureName); configs.Add("DepartmentCode", configDepartmentCode); configs.Add("SectionCode", configSectionCode); configs.Add("BranchCode", configBranchCode); configs.Add("DepartmentName", configOrgStructureName); configs.Add("SectionName", configSectionCode); configs.Add("BranchName", configBranchName); configs.Add("TeamName", configSectionCode); configs.Add("DateFrom", confighidden); configs.Add("DateTo", confighidden); configs.Add("UserExport", confighidden); configs.Add("DateExport", confighidden); return(tblData.ConfigTable(configs)); }
public Att_RosterModel Post([Bind] Att_RosterModel model) { ActionService service = new ActionService(UserLogin); var baseService = new BaseService(); string status = string.Empty; var hrService = new Hre_ProfileServices(); string strMessages = string.Empty; var rosterService = new Att_RosterServices(); var sysAllSetttingService = new Sys_AllSettingServices(); #region Validate string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Att_RosterModel>(model, "Att_Roster", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Att_RosterModel>(model, "Att_ProfileNotRoster", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } if (string.IsNullOrEmpty(model.OrgStructureIDs) && string.IsNullOrEmpty(model.ProfileIds) && model.ProfileID == Guid.Empty) { message = string.Format(ConstantMessages.FieldNotAllowNull.TranslateString(), ("ProfileID").TranslateString()); model.ActionStatus = message; return(model); } #endregion List <Guid> lstProfileIDs = new List <Guid>(); if (!string.IsNullOrEmpty(model.OrgStructureIDs)) { List <object> listObj = new List <object>(); listObj.Add(model.OrgStructureIDs); listObj.Add(string.Empty); listObj.Add(string.Empty); var lstProfile = hrService.GetData <Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, UserLogin, ref status).Select(s => s.ID).ToList(); lstProfileIDs.AddRange(lstProfile); } else if (model.ProfileIds != null && model.ProfileIds != "") { var listGuid = model.ProfileIds.Split(',').Select(s => Guid.Parse(s)).ToArray(); lstProfileIDs.AddRange(listGuid); } var lstRosterEntity_Validate = new List <Att_RosterEntity>(); foreach (var item in lstProfileIDs) { Att_RosterEntity rosterEntity = model.CopyData <Att_RosterEntity>(); rosterEntity.ProfileID = item; if (rosterEntity.ID != null && rosterEntity.ID != Guid.Empty) { } else { rosterEntity.ID = Guid.NewGuid(); } lstRosterEntity_Validate.Add(rosterEntity); } var key = AppConfig.HRM_ATT_ALLOWSAVEDUPLICATE.ToString(); var lstSysAllSetting = sysAllSetttingService.GetData <Sys_AllSettingEntity>(key, ConstantSql.hrm_sys_sp_get_AllSettingByKey, UserLogin, ref status).FirstOrDefault(); var ValidateLess12Hour = AppConfig.HRM_ATT_VALIDATE_ROSTER_NON_CONTINUE_12HOUR.ToString(); var lstSysSetting_ValidateLess12Hour = sysAllSetttingService.GetData <Sys_AllSettingEntity>(ValidateLess12Hour, ConstantSql.hrm_sys_sp_get_AllSettingByKey, UserLogin, ref status).FirstOrDefault(); if (lstSysSetting_ValidateLess12Hour != null && lstSysSetting_ValidateLess12Hour.Value1 == bool.TrueString) { string Err = string.Empty; Err = rosterService.ValidateShiftHourContinue(lstRosterEntity_Validate); if (Err != string.Empty) { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + Err); return(model); } } if (!string.IsNullOrEmpty(model.OrgStructureIDs)) { List <object> listObj = new List <object>(); listObj.Add(model.OrgStructureIDs); listObj.Add(string.Empty); listObj.Add(string.Empty); var lstProfile = hrService.GetData <Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, UserLogin, ref status).Select(s => s.ID).ToList(); if (lstProfile.Count == 0 || lstProfile == null) { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Info + "," + strMessages + ConstantMessages.FieldDuplicate); return(model); } if (lstProfile != null && model.ProfileIds != null) { Guid[] listGuid = null; listGuid = model.ProfileIds.Split(',').Select(s => Guid.Parse(s)).ToArray(); lstProfile = lstProfile.Where(s => !listGuid.Contains(s)).ToList(); } List <Att_RosterEntity> lstRosterEntity = new List <Att_RosterEntity>(); List <object> paraRoster = new List <object>(); paraRoster.AddRange(new object[4]); paraRoster[0] = (object)model.OrgStructureIDs; paraRoster[1] = null; paraRoster[2] = null; paraRoster[3] = null; var listRosterData = rosterService.GetData <Att_RosterEntity>(paraRoster, ConstantSql.hrm_att_getdata_Roster, UserLogin, ref status); foreach (var item in lstProfile) { Att_RosterModel modelSave = model.CopyData <Att_RosterModel>(); var listRoster = listRosterData.Where(s => s.ProfileID == item); if (modelSave.Type != RosterType.E_CHANGE_SHIFT.ToString() && modelSave.Type != RosterType.E_TIME_OFF.ToString() && listRoster != null && listRoster.Any(d => d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart)) { strMessages += listRoster.FirstOrDefault().ProfileName + ", "; continue; } modelSave.ProfileID = item; Att_RosterEntity rosterEntity = modelSave.CopyData <Att_RosterEntity>(); lstRosterEntity.Add(rosterEntity); } if (strMessages == "" && lstRosterEntity.Count > 0) { model.ActionStatus = rosterService.Add(lstRosterEntity); } else { if (lstSysAllSetting != null && lstSysAllSetting.Value1 == bool.TrueString && lstRosterEntity.Count > 0) { model.ActionStatus = rosterService.Add(lstRosterEntity); } else if (lstSysAllSetting.Value1 == bool.FalseString) { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate); return(model); } else if (lstRosterEntity.Count == 0) { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Info + "," + strMessages + ConstantMessages.FieldDuplicate); return(model); } } return(model); } //Xử lý khi chọn nhiều nhân viên if (model.ProfileIds != null && model.ProfileIds.IndexOf(',') > 0 && model.OrgStructureIDs == null) { Guid[] listGuid = null; listGuid = model.ProfileIds.Split(',').Select(s => Guid.Parse(s)).ToArray(); List <Att_RosterEntity> lstRosterEntity = new List <Att_RosterEntity>(); foreach (var item in listGuid) { Att_RosterModel modelSave = model.CopyData <Att_RosterModel>(); var listRoster = service.GetData <Att_RosterEntity>(item, ConstantSql.hrm_att_sp_get_RosterByProfileId, ref status); if (modelSave.Type != RosterType.E_CHANGE_SHIFT.ToString() && modelSave.Type != RosterType.E_TIME_OFF.ToString() && listRoster != null && listRoster.Any(d => d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart)) { strMessages += listRoster.FirstOrDefault().ProfileName + ", "; continue; } modelSave.ProfileID = item; Att_RosterEntity rosterEntity = modelSave.CopyData <Att_RosterEntity>(); lstRosterEntity.Add(rosterEntity); } if (strMessages == "") { model.ActionStatus = rosterService.Add(lstRosterEntity); } else { if (lstSysAllSetting != null && lstSysAllSetting.Value1 == bool.TrueString) { model.ActionStatus = rosterService.Add(lstRosterEntity); } else { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate); return(model); } } return(model); } //Xử lý khi chỉ chọn 1 nhân viên if (model.ID == Guid.Empty) { var lstRoster = service.GetData <Att_RosterEntity>(model.ProfileID, ConstantSql.hrm_att_sp_get_RosterByProfileId, ref status); if (model.Type != RosterType.E_CHANGE_SHIFT.ToString() && model.Type != RosterType.E_TIME_OFF.ToString() && lstRoster != null && lstRoster.Any(d => d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart)) { strMessages = lstRoster.FirstOrDefault().ProfileName + ","; model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate); return(model); } return(service.UpdateOrCreate <Att_RosterEntity, Att_RosterModel>(model)); } return(service.UpdateOrCreate <Att_RosterEntity, Att_RosterModel>(model)); }
public Tra_RequirementTrainModel Post([Bind] Tra_RequirementTrainModel model) { #region Validate if (model.isAnalysis == true) { string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Tra_RequirementTrainModel>(model, "Tra_RequirementTrain_Tab", "Tra_RequirementTrain", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } } #endregion var requirementDetailServices = new Tra_RequirementTrainDetailServices(); var profileServices = new Hre_ProfileServices(); string[] arrCodeEmp = new string[1]; if (!string.IsNullOrEmpty(model.lstCodeEmp) && model.lstCodeEmp.IndexOf(',') > 1) { arrCodeEmp = model.lstCodeEmp.Split(',').ToArray(); } else { arrCodeEmp[0] = model.lstCodeEmp; } ActionService service = new ActionService(UserLogin); string status = string.Empty; //var objProfile = new List<object>(); //objProfile.AddRange(new object[17]); //objProfile[15] = 1; //objProfile[16] = int.MaxValue - 1; //var lstProfile = profileServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileAll, UserLogin, ref status).ToList().Translate<Hre_ProfileModel>(); //if (arrCodeEmp != null) //{ // lstProfile = lstProfile.Where(s => arrCodeEmp.Contains(s.CodeEmp)).ToList(); //} var lstProfile = profileServices.GetData <Hre_ProfileEntity>(model.lstCodeEmp, ConstantSql.hrm_hr_sp_get_ProfileAllByCodeEmps, UserLogin, ref status).ToList().Translate <Hre_ProfileModel>(); model = service.UpdateOrCreate <Tra_RequirementTrainEntity, Tra_RequirementTrainModel>(model); var objRequirementDetail = new List <object>(); objRequirementDetail.Add(null); objRequirementDetail.Add(1); objRequirementDetail.Add(int.MaxValue - 1); var lstRequirementDetail = requirementDetailServices.GetData <Tra_RequirementTrainDetailEntity>(objRequirementDetail, ConstantSql.hrm_tra_sp_get_RequirementDetail, UserLogin, ref status).ToList(); foreach (var item in lstProfile) { var entity = lstRequirementDetail.Where(s => s.ProfileID == item.ID && s.RequirementTrainID == model.ID && s.CourseID == model.CourseID).FirstOrDefault(); var requirementDetailEntity = new Tra_RequirementTrainDetailEntity(); requirementDetailEntity.ProfileID = item.ID; requirementDetailEntity.RequirementTrainID = model.ID; requirementDetailEntity.CourseID = model.CourseID; requirementDetailEntity.YearAnalyze = model.DateSeniority; if (item.DateHire != null && model.DateSeniority != null) { requirementDetailEntity.Seniority = Math.Floor(model.DateSeniority.Value.Subtract(item.DateHire.Value).TotalDays / 30); } if (entity == null) { model.ActionStatus = requirementDetailServices.Add(requirementDetailEntity); } } return(model); //return service.UpdateOrCreate<Tra_RequirementTrainEntity, Tra_RequirementTrainModel>(model); }
public Sal_UnusualAllowanceModel Post([Bind] Sal_UnusualAllowanceModel model) { var hrService = new Hre_ProfileServices(); var UnusualAllowanceServices = new Sal_UnusualAllowanceServices(); string status = string.Empty; #region Validate string message = string.Empty; var checkValidate = false; //kiểm tra xem có phải là đang create ở trang chi tiết nv ko if (model.IsGeneralProfile != null && model.IsGeneralProfile == true) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualEDGeneralProfile", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } ActionService service = new ActionService(UserLogin); return(service.UpdateOrCreate <Sal_UnusualAllowanceEntity, Sal_UnusualAllowanceModel>(model)); } else { if (!string.IsNullOrEmpty(model.OrgStructureIDs)) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualEDOrg", ref message); } else { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualED", ref message); } if (!checkValidate) { model.ActionStatus = message; return(model); } if (!string.IsNullOrEmpty(model.OrgStructureIDs)) { List <Guid> listGuid = new List <Guid>(); if (model.ProfileIDExclusion != null) { var listStr = model.ProfileIDExclusion.Split(','); if (listStr[0] != "") { foreach (var item in listStr) { listGuid.Add(Guid.Parse(item)); } } } List <object> listObj = new List <object>(); listObj.Add(model.OrgStructureID); listObj.Add(string.Empty); listObj.Add(string.Empty); var lstProfile = hrService.GetData <Hre_ProfileIdEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, userLogin, ref status).Select(s => s.ID).ToList(); if (listGuid != null) { lstProfile = lstProfile.Where(s => !listGuid.Contains(s)).ToList(); } List <Sal_UnusualAllowanceEntity> lstUnusualAllowance = new List <Sal_UnusualAllowanceEntity>(); foreach (var i in lstProfile) { Sal_UnusualAllowanceEntity item = new Sal_UnusualAllowanceEntity(); item = model.Copy <Sal_UnusualAllowanceEntity>(); item.ProfileID = i; lstUnusualAllowance.Add(item); } model.ActionStatus = UnusualAllowanceServices.Add(lstUnusualAllowance); return(model); } else { string[] listProfile = model.ProfileIDs.Split(','); List <Sal_UnusualAllowanceEntity> lstUnusualAllowance = new List <Sal_UnusualAllowanceEntity>(); foreach (var i in listProfile) { Sal_UnusualAllowanceEntity item = new Sal_UnusualAllowanceEntity(); item = model.Copy <Sal_UnusualAllowanceEntity>(); item.ProfileID = Guid.Parse(i); lstUnusualAllowance.Add(item); } model.ActionStatus = UnusualAllowanceServices.Add(lstUnusualAllowance); return(model); } } #endregion }
public JsonResult CreateBasicInfo(Hre_ProfileModel model, string userLogin) { var id = Session[SessionObjects.ProfileID]; var serv = new Hre_ProfileServices(); string status = string.Empty; var profile = serv.GetData <Hre_ProfileModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); bool change = false; #region check change if (profile.ProfileName != model.ProfileName) { change = true; } if (profile.CodeAttendance != model.CodeAttendance) { change = true; } if (profile.CodeEmp != model.CodeEmp) { change = true; } if (profile.DateApplyAttendanceCode != model.DateApplyAttendanceCode) { change = true; } if (profile.WorkPlaceName != model.WorkPlaceName) { change = true; } if (profile.CodeTax != model.CodeTax) { change = true; } if (profile.DateOfIssuedTaxCode != model.DateOfIssuedTaxCode) { change = true; } if (profile.DateHire != model.DateHire) { change = true; } if (profile.DateEndProbation != model.DateEndProbation) { change = true; } if (profile.JobTitleID != model.JobTitleID) { change = true; } if (profile.PositionID != model.PositionID) { change = true; } if (profile.EmpTypeID != model.EmpTypeID) { change = true; } if (profile.PayrollGroupID != model.PayrollGroupID) { change = true; } if (profile.JobTitleID != model.JobTitleID) { change = true; } if (profile.PositionID != model.PositionID) { change = true; } if (profile.EmpTypeID != model.EmpTypeID) { change = true; } if (profile.PayrollGroupID != model.PayrollGroupID) { change = true; } if (profile.DateOfEffect != model.DateOfEffect) { change = true; } if (profile.LaborType != model.LaborType) { change = true; } if (profile.WorkPlaceID != model.WorkPlaceID) { change = true; } if (profile.SupervisorID != model.SupervisorID) { change = true; } if (profile.HighSupervisorID != model.HighSupervisorID) { change = true; } #endregion if (!change) { profile.ActionStatus = "Success"; return(Json(profile)); } if (profile.ID == model.ID) { profile.ActionStatus = model.ActionStatus; profile.ProfileName = model.ProfileName; profile.CodeAttendance = model.CodeAttendance; profile.CodeEmp = model.CodeEmp; profile.DateApplyAttendanceCode = model.DateApplyAttendanceCode; profile.LocationCode = model.LocationCode; profile.WorkPlaceName = model.WorkPlaceName; profile.CodeTax = model.CodeTax; profile.DateOfIssuedTaxCode = model.DateOfIssuedTaxCode; profile.DateHire = model.DateHire; //profile.PromotionCondition = model.PromotionCondition; profile.DateEndProbation = model.DateEndProbation; profile.JobTitleID = model.JobTitleID; profile.PositionID = model.PositionID; profile.EmpTypeID = model.EmpTypeID; profile.PayrollGroupID = model.PayrollGroupID; profile.DateOfEffect = model.DateOfEffect; profile.LaborType = model.LaborType; profile.WorkPlaceID = model.WorkPlaceID; profile.SupervisorID = model.SupervisorID; profile.HighSupervisorID = model.HighSupervisorID; } var service = new RestServiceClient <Hre_ProfileModel>(UserLogin); service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service); var result = service.Post(_Hrm_Hre_Service, "api/Hre_Profile/", profile); return(Json(result)); }
public JsonResult CreateContactInfo(Hre_ProfileModel model, string userLogin) { var id = Session[SessionObjects.ProfileID]; var serv = new Hre_ProfileServices(); string status = string.Empty; var profile = serv.GetData <Hre_ProfileModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); bool change = false; #region check change if (profile.Email != model.Email) { change = true; } if (profile.Email2 != model.Email2) { change = true; } if (profile.Cellphone != model.Cellphone) { change = true; } if (profile.HomePhone != model.HomePhone) { change = true; } if (profile.TCountryID != model.TCountryID) { change = true; } if (profile.TDistrictID != model.TDistrictID) { change = true; } if (profile.TProvinceID != model.TProvinceID) { change = true; } if (profile.TAVillageID != model.TAVillageID) { change = true; } if (profile.TAddress != model.TAddress) { change = true; } if (profile.PCountryID != model.PCountryID) { change = true; } if (profile.PDistrictID != model.PDistrictID) { change = true; } if (profile.PProvinceID != model.PProvinceID) { change = true; } if (profile.VillageID != model.VillageID) { change = true; } if (profile.PAddress != model.PAddress) { change = true; } if (profile.AddressEmergency != model.AddressEmergency) { change = true; } #endregion if (!change) { profile.ActionStatus = "Success"; return(Json(profile)); } if (profile.ID == model.ID) { profile.ActionStatus = model.ActionStatus; profile.Email = model.Email; profile.Email2 = model.Email2; profile.Cellphone = model.Cellphone; profile.HomePhone = model.HomePhone; profile.TCountryID = model.TCountryID; profile.TDistrictID = model.TDistrictID; profile.TProvinceID = model.TProvinceID; profile.TAVillageID = model.TAVillageID; profile.TAddress = model.TAddress; profile.PCountryID = model.PCountryID; profile.PDistrictID = model.PDistrictID; profile.PProvinceID = model.PProvinceID; profile.VillageID = model.VillageID; profile.PAddress = model.PAddress; profile.AddressEmergency = model.AddressEmergency; } var service = new RestServiceClient <Hre_ProfileModel>(UserLogin); service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service); var result = service.Post(_Hrm_Hre_Service, "api/Hre_Profile/", profile); return(Json(result)); }
public JsonResult CreatePersonalInfo(Hre_ProfileModel model, string userLogin) { var id = Session[SessionObjects.ProfileID]; var serv = new Hre_ProfileServices(); string status = string.Empty; var profile = serv.GetData <Hre_ProfileModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); bool change = false; #region check change if (profile.NameEnglish != model.NameEnglish) { change = true; } if (profile.Gender != model.Gender) { change = true; } if (profile.DayOfBirth != model.DayOfBirth) { change = true; } if (profile.MonthOfBirth != model.MonthOfBirth) { change = true; } if (profile.YearOfBirth != model.YearOfBirth) { change = true; } if (profile.NationalityID != model.NationalityID) { change = true; } if (profile.PlaceOfBirth != model.PlaceOfBirth) { change = true; } if (profile.MarriageStatus != model.MarriageStatus) { change = true; } if (profile.IDNo != model.IDNo) { change = true; } if (profile.IDDateOfIssue != model.IDDateOfIssue) { change = true; } if (profile.IDPlaceOfIssue != model.IDPlaceOfIssue) { change = true; } if (profile.Origin != model.Origin) { change = true; } //if (profile.TypeOfVehicle != model.TypeOfVehicle) // change = true; //if (profile.LockerName != model.LockerName) // change = true; if (profile.EducationLevelID != model.EducationLevelID) { change = true; } if (profile.EthnicID != model.EthnicID) { change = true; } if (profile.Notes != model.Notes) { change = true; } if (profile.BloodType != model.BloodType) { change = true; } if (profile.Height != model.Height) { change = true; } if (profile.Weight != model.Weight) { change = true; } if (profile.PassportNo != model.PassportNo) { change = true; } if (profile.PassportPlaceOfIssue != model.PassportPlaceOfIssue) { change = true; } if (profile.PassportDateOfIssue != model.PassportDateOfIssue) { change = true; } if (profile.PassportDateOfExpiry != model.PassportDateOfExpiry) { change = true; } #endregion if (!change) { profile.ActionStatus = "Success"; return(Json(profile)); } if (profile.ID == model.ID) { profile.ActionStatus = model.ActionStatus; profile.NameEnglish = model.NameEnglish; profile.Gender = model.Gender; profile.DayOfBirth = model.DayOfBirth; profile.MonthOfBirth = model.MonthOfBirth; profile.YearOfBirth = model.YearOfBirth; profile.NationalityID = model.NationalityID; profile.PlaceOfBirth = model.PlaceOfBirth; profile.MarriageStatus = model.MarriageStatus; profile.IDNo = model.IDNo; profile.IDDateOfIssue = model.IDDateOfIssue; profile.IDPlaceOfIssue = model.IDPlaceOfIssue; profile.Origin = model.Origin; profile.EducationLevelID = model.EducationLevelID; profile.EthnicID = model.EthnicID; profile.Notes = model.Notes; profile.BloodType = model.BloodType; profile.Height = model.Height; profile.Weight = model.Weight; profile.PassportNo = model.PassportNo; profile.PassportPlaceOfIssue = model.PassportPlaceOfIssue; profile.PassportDateOfIssue = model.PassportDateOfIssue; profile.PassportDateOfExpiry = model.PassportDateOfExpiry; } var service = new RestServiceClient <Hre_ProfileModel>(UserLogin); service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service); var result = service.Post(_Hrm_Hre_Service, "api/Hre_Profile/", profile); return(Json(result)); }
public DataTable GetReportNotHaveSocial(DateTime?dateFrom, DateTime?dateTo, string OrgStructureID, string userLogin) { using (var context = new VnrHrmDataContext()) { string status = string.Empty; //string type_COLLECT_SOCIAL_INSURANCE = AppConfig.E_COLLECT_SOCIAL_INSURANCE.ToString(); //bool _e_PROBATION_NoPay_INSURANCE = false; var profileServices = new Hre_ProfileServices(); DataTable table = GetReportNotHaveSocialSchema(); var lstObjProfile = new List <object>(); lstObjProfile.Add(OrgStructureID); lstObjProfile.Add(null); lstObjProfile.Add(null); var lstProfile = profileServices.GetData <Hre_ProfileEntity>(lstObjProfile, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref status).ToList(); var gradePayrollService = new Cat_GradePayrollServices(); var lstObjGradePayroll = new List <object>(); lstObjGradePayroll.Add(null); lstObjGradePayroll.Add(null); lstObjGradePayroll.Add(1); lstObjGradePayroll.Add(int.MaxValue - 1); var contractServices = new Hre_ContractServices(); var lstObjContract = new List <object>(); lstObjContract.AddRange(new object[15]); lstObjContract[13] = 1; lstObjContract[14] = int.MaxValue - 1; var provinceServices = new Cat_ProvinceServices(); var lstObjProvince = new List <object>(); lstObjProvince.Add(null); lstObjProvince.Add(null); lstObjProvince.Add(null); lstObjProvince.Add(null); lstObjProvince.Add(null); lstObjProvince.Add(null); var lstProvince = provinceServices.GetData <Cat_ProvinceEntity>(lstObjProvince, ConstantSql.hrm_cat_sp_get_Province, userLogin, ref status).ToList(); foreach (var item in lstProfile) { DataRow dr = table.NewRow(); dr[Ins_ReportNotHaveSocialEntity.FieldNames.ID] = item.ID; dr[Ins_ReportNotHaveSocialEntity.FieldNames.CodeEmp] = item.CodeEmp == null ? string.Empty : item.CodeEmp; dr[Ins_ReportNotHaveSocialEntity.FieldNames.ProfileName] = item.ProfileName == null ? string.Empty : item.ProfileName; dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_DEPARTMENT] = item.OrgStructureName == null ? string.Empty : item.E_DEPARTMENT; dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_DIVISION] = item.OrgStructureName == null ? string.Empty : item.E_DIVISION; dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_SECTION] = item.OrgStructureName == null ? string.Empty : item.E_SECTION; dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_TEAM] = item.OrgStructureName == null ? string.Empty : item.E_TEAM; dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_UNIT] = item.OrgStructureName == null ? string.Empty : item.E_UNIT; dr[Ins_ReportNotHaveSocialEntity.FieldNames.PositionName] = item.PositionName == null ? string.Empty : item.PositionName; dr[Ins_ReportNotHaveSocialEntity.FieldNames.JobTitleName] = item.JobTitleName == null ? string.Empty : item.JobTitleName; dr[Ins_ReportNotHaveSocialEntity.FieldNames.EthnicGroupName] = item.EthnicGroupName == null ? string.Empty : item.EthnicGroupName; dr[Ins_ReportNotHaveSocialEntity.FieldNames.HealthTreatmentPlace] = item.HealthTreatmentPlace == null ? string.Empty : item.HealthTreatmentPlace; dr[Ins_ReportNotHaveSocialEntity.FieldNames.HealthTreatmentPlaceCode] = item.HealthTreatmentPlaceCode == null ? string.Empty : item.HealthTreatmentPlaceCode; var province = lstProvince.Where(s => s.ID == item.PlaceOfIssueID).FirstOrDefault(); if (province != null) { dr[Ins_ReportNotHaveSocialEntity.FieldNames.IDPOI_Code] = province.Code == null ? string.Empty : province.Code; dr[Ins_ReportNotHaveSocialEntity.FieldNames.IDPOI] = province.ProvinceName == null ? string.Empty : province.ProvinceName; } dr[Ins_ReportNotHaveSocialEntity.FieldNames.Origin] = item.Origin == null ? string.Empty : item.Origin; dr[Ins_ReportNotHaveSocialEntity.FieldNames.PAddress] = item.PAddress == null ? string.Empty : item.PAddress; dr[Ins_ReportNotHaveSocialEntity.FieldNames.TAddress] = item.TAddress == null ? string.Empty : item.TAddress; if (item.DateHire != null) { dr[Ins_ReportNotHaveSocialEntity.FieldNames.DateHire] = item.DateHire.Value; } if (item.DateQuit != null) { dr[Ins_ReportNotHaveSocialEntity.FieldNames.DateHire] = item.DateQuit.Value; } if (item.DateOfBirth != null) { dr[Ins_ReportNotHaveSocialEntity.FieldNames.DateOfBirth] = item.DateOfBirth.Value; } var provinceTreatment = lstProvince.Where(s => s.ID == item.ProvinceInsuranceID).FirstOrDefault(); if (provinceTreatment != null) { dr[Ins_ReportNotHaveSocialEntity.FieldNames.PlaceOfTreatmentProvince] = provinceTreatment.Code == null ? string.Empty : provinceTreatment.Code; } table.Rows.Add(dr); } return(table); } }
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 } }
public Hre_ProfileModel Post([Bind] Hre_ProfileModel model) { string status = string.Empty; if (model != null) { ActionService service = new ActionService(UserLogin); BaseService BaseService = new BaseService(); if (!string.IsNullOrWhiteSpace(model.CodeAttendance)) { model.CodeAttendance = model.CodeAttendance.TrimAll(); } #region Validate string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Hre_ProfileModel>(model, "Hre_Profile", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } if (model.DateOfEffectOld != null) { checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Hre_ProfileModel>(model, "Hre_ProfileCheckDateOfEffect", ref message); if (!checkValidate) { model.ActionStatus = message; return(model); } } #endregion #region Xử lý cập nhật AbilityTitle khi chọn rank if (model.SalaryClassID != null) { var abilityTitleBySalaryClass = BaseService.GetData <Cat_AbilityTileEntity>(Common.DotNetToOracle(model.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, UserLogin, ref status).FirstOrDefault(); if (abilityTitleBySalaryClass != null) { model.AbilityTileID = abilityTitleBySalaryClass.ID; } } #endregion #region Xử Lý Lưu field DateOfBirth var dateOfBirth = string.Empty; if (model.DayOfBirth == 00 && model.MonthOfBirth == 00) { model.ActionStatus = "ErrorDateOfBirth"; return(model); } if (model.DayOfBirth == null && model.MonthOfBirth == null && model.YearOfBirth == null) { dateOfBirth = string.Empty; } else { if (model.DayOfBirth == null) { model.DayOfBirth = DateTime.Now.Day; } if (model.MonthOfBirth == null) { model.MonthOfBirth = DateTime.Now.Month; } if (model.YearOfBirth == null) { model.ActionStatus = "ErrorDateOfBirth"; return(model); } } if (model.DayOfBirth >= 0 || model.MonthOfBirth >= 0 || model.YearOfBirth >= 0) { if (model.DayOfBirth == 30 && model.MonthOfBirth == 2) { model.ActionStatus = "ErrorDateOfBirth"; return(model); } if (model.DayOfBirth == 31 && model.MonthOfBirth == 2) { model.ActionStatus = "ErrorDateOfBirth"; return(model); } if (model.DayOfBirth > 31 || model.MonthOfBirth > 12) { model.ActionStatus = "ErrorDateOfBirth"; return(model); } dateOfBirth = model.MonthOfBirth + "/" + model.DayOfBirth + "/" + model.YearOfBirth; } model.DateOfBirth = string.IsNullOrEmpty(dateOfBirth) ? (DateTime?)null : DateTime.Parse(dateOfBirth); #endregion Hre_ProfileModel HreProfile = new Hre_ProfileModel(); if (model.ID != Guid.Empty) { HreProfile = GetById(model.ID); } if (HreProfile != null && (model.ID == HreProfile.ID) && model.ActionStatus != "1") { string[] listFieldName = new[] { "JobTitleID", "PositionID", "EmpTypeID", "DateOfEffect", "CostCentreID", "OrgStructureID", "WorkPlaceID", "SupervisorID" }; foreach (var item in listFieldName) { var value1 = model.GetPropertyValue(item); var value2 = HreProfile.GetPropertyValue(item); if ((value1 != null && value2 != null) && (value1.ToString() != value2.ToString())) { model.SetPropertyValue(Constant.ActionStatus, NotificationType.Change.ToString()); return(model); } } if (HreProfile.ProfileName != model.ProfileName) { if (model.ProfileName.Contains(' ')) { model.FirstName = model.ProfileName.Substring(model.ProfileName.LastIndexOf(' ') + 1); model.NameFamily = model.ProfileName.Substring(0, model.ProfileName.LastIndexOf(' ')); } else { model.FirstName = model.ProfileName; } } } if (model.ActionStatus == "1" || model.ActionStatus == "Success" || string.IsNullOrEmpty(model.ActionStatus)) { var serviceAddress = new Hre_AddressServices(); var serviceProfile = new Hre_ProfileServices(); var profileEntity = new Hre_ProfileEntity(); if (model.ID != Guid.Empty) { profileEntity = serviceProfile.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault(); } #region Xử lý lưu CardCode Hre_CardHistoryServices cardservices = new Hre_CardHistoryServices(); Hre_WorkHistoryServices workHistoryservices = new Hre_WorkHistoryServices(); if (profileEntity != null && model.CodeAttendance != null && model.DateApplyAttendanceCode != null && (model.CodeAttendance != profileEntity.CodeAttendance || model.DateApplyAttendanceCode != profileEntity.DateApplyAttendanceCode)) { // Chỉ thay đổi mã chấm công if (model.DateApplyAttendanceCode == profileEntity.DateApplyAttendanceCode && model.CodeAttendance != profileEntity.CodeAttendance) { Hre_CardHistoryEntity history = cardservices.GetData <Hre_CardHistoryEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_hr_sp_get_CardHistoryByProfileId, UserLogin, ref status).OrderByDescending(s => s.DateEffect).FirstOrDefault(); if (history != null) { history.CardCode = model.CodeAttendance; cardservices.Edit(history); } else { history = new Hre_CardHistoryEntity(); history.ProfileID = model.ID; history.CardCode = model.CodeAttendance; history.DateEffect = model.DateApplyAttendanceCode; cardservices.Add(history); } } // Chỉ thay đổi Ngày áp dụng mã chấm công else if (model.CodeAttendance == profileEntity.CodeAttendance && model.DateApplyAttendanceCode != profileEntity.DateApplyAttendanceCode) { if (model.DateApplyAttendanceCode < profileEntity.DateApplyAttendanceCode) { model.StatusVerify = "Invalid"; return(model); } Hre_CardHistoryEntity history = cardservices.GetData <Hre_CardHistoryEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_hr_sp_get_CardHistoryByProfileId, UserLogin, ref status).OrderByDescending(s => s.DateEffect).FirstOrDefault(); if (history != null) { history.DateEffect = model.DateApplyAttendanceCode; cardservices.Edit(history); } else { history = new Hre_CardHistoryEntity(); history.ProfileID = model.ID; history.CardCode = model.CodeAttendance; history.DateEffect = model.DateApplyAttendanceCode; cardservices.Add(history); } } } // Tạo mới NV hoặc thay đổi cả 2( mã chấm công + ngày hiệu lực) Hre_CardHistoryEntity cardhistory = null; if (model != null && model.ID == Guid.Empty || (model != null && profileEntity != null && model.CodeAttendance != profileEntity.CodeAttendance && model.DateApplyAttendanceCode != profileEntity.DateApplyAttendanceCode)) { cardhistory = new Hre_CardHistoryEntity(); cardhistory.ProfileID = model.ID; cardhistory.CardCode = model.CodeAttendance; cardhistory.DateEffect = model.DateApplyAttendanceCode; } #endregion #region Xử lý lưu quá trình công tác Hre_WorkHistoryEntity workHistory = null; if (model != null && (model.JobTitleID != profileEntity.JobTitleID || model.PositionID != profileEntity.PositionID || model.EmpTypeID != profileEntity.EmpTypeID || (model.DateOfEffect != null && profileEntity.DateOfEffect != null && model.DateOfEffect.Value.ToString() != profileEntity.DateOfEffect.Value.ToString()) || model.CostCentreID != profileEntity.CostCentreID || model.SupervisorID != profileEntity.SupervisorID || model.OrgStructureID != profileEntity.OrgStructureID || model.WorkPlaceID != profileEntity.WorkPlaceID)) { workHistory = new Hre_WorkHistoryEntity(); var orgService = new Cat_OrgStructureServices(); var jobtitleService = new Cat_JobTitleServices(); var postitionService = new Cat_PositionServices(); var workPlaceService = new Cat_WorkPlaceServices(); workHistory.CostCentreID = model.CostCentreID; workHistory.OrganizationStructureID = model.OrgStructureID; workHistory.PositionID = model.PositionID; workHistory.JobTitleID = model.JobTitleID; workHistory.SalaryClassID = model.SalaryClassID; workHistory.CostSourceID = model.CostSourceID; workHistory.AbilityTileID = model.AbilityTileID; if (profileEntity != null) { var orgStructureOld = new Cat_OrgStructureEntity(); if (profileEntity.OrgStructureID != null && profileEntity.OrgStructureID != Guid.Empty) { orgStructureOld = orgService.GetData <Cat_OrgStructureEntity>(profileEntity.OrgStructureID, ConstantSql.hrm_cat_sp_get_OrgStructureById, UserLogin, ref status).FirstOrDefault(); } var jobtitleOld = new Cat_JobTitleEntity(); if (profileEntity.JobTitleID != null && profileEntity.JobTitleID != Guid.Empty) { jobtitleOld = jobtitleService.GetData <Cat_JobTitleEntity>(profileEntity.JobTitleID, ConstantSql.hrm_cat_sp_get_HDTJobTypeById, UserLogin, ref status).FirstOrDefault(); } var postitionOld = new Cat_PositionEntity(); if (profileEntity.PositionID != null && profileEntity.PositionID != Guid.Empty) { postitionOld = postitionService.GetData <Cat_PositionEntity>(profileEntity.PositionID, ConstantSql.hrm_cat_sp_get_PositionById, UserLogin, ref status).FirstOrDefault(); } var workPlace = new Cat_WorkPlaceEntity(); if (model.WorkPlaceID != null && model.WorkPlaceID != Guid.Empty) { workPlace = workPlaceService.GetData <Cat_WorkPlaceEntity>(model.WorkPlaceID, ConstantSql.hrm_cat_sp_get_WorkPlaceById, UserLogin, ref status).FirstOrDefault(); } var workPlaceOld = new Cat_WorkPlaceEntity(); if (profileEntity.WorkPlaceID != null && profileEntity.WorkPlaceID != Guid.Empty) { workPlaceOld = workPlaceService.GetData <Cat_WorkPlaceEntity>(profileEntity.WorkPlaceID, ConstantSql.hrm_cat_sp_get_WorkPlaceById, UserLogin, ref status).FirstOrDefault(); } workHistory.OrgOld = orgStructureOld != null ? orgStructureOld.OrgStructureName : ""; workHistory.JobTitleOld = jobtitleOld != null ? jobtitleOld.JobTitleName : ""; workHistory.PositionOld = postitionOld != null ? postitionOld.PositionName : ""; workHistory.WorkLocation = workPlace != null ? workPlace.WorkPlaceName : ""; workHistory.WorkLocationOld = workPlaceOld != null ? workPlaceOld.WorkPlaceName : ""; } if (workHistory.ID == Guid.Empty) { if (model.DateOfEffect != null) { workHistory.DateEffective = model.DateOfEffect.Value; } else { workHistory.DateEffective = DateTime.Now; } } if (model.DateQuit != null && (profileEntity == null || profileEntity.DateQuit != model.DateQuit)) { workHistory.DateEffective = model.DateQuit.Value; } } #region Ngày hiệu lực phải <= ngày hiện tại thì mới cập nhật lại quá trình công tác if (model.DateOfEffect > DateTime.Now && profileEntity != null && profileEntity.DateOfEffect != null) { model.DateOfEffect = profileEntity.DateOfEffect; model.OrgStructureID = profileEntity.OrgStructureID; model.ShopID = profileEntity.ShopID; model.JobTitleID = profileEntity.JobTitleID; model.PositionID = profileEntity.PositionID; model.SupervisorID = profileEntity.SupervisorID; model.HighSupervisorID = profileEntity.HighSupervisorID; model.IsHeadDept = profileEntity.IsHeadDept; model.EmpTypeID = profileEntity.EmpTypeID; model.LaborType = profileEntity.LaborType; model.SikillLevel = profileEntity.SikillLevel; model.PayrollGroupID = profileEntity.PayrollGroupID; model.SalaryClassID = profileEntity.SalaryClassID; model.CostCentreID = profileEntity.CostCentreID; model.LocationCode = profileEntity.LocationCode; model.WorkPlaceID = profileEntity.WorkPlaceID; } #endregion #endregion var profileModel = service.UpdateOrCreate <Hre_ProfileEntity, Hre_ProfileModel>(model); if (cardhistory != null && profileModel != null) { cardhistory.ProfileID = profileModel.ID; cardservices.Add(cardhistory); } if (workHistory != null && profileModel != null) { workHistory.EmployeeTypeID = profileModel.EmpTypeID; workHistory.ProfileID = profileModel.ID; workHistoryservices.Add(workHistory); } } } //Xóa cache lưu lại của cây phòng ban HttpContext.Current.Cache.Remove("List_OrgStructureTreeView"); HttpContext.Current.Cache.Remove("List_OrgStructureTreeViewSumProfile"); return(model); }
public string ActionApprovedComeBack(string selectedIds, string userLogin) { using (var context = new VnrHrmDataContext()) { string message = string.Empty; string status = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repo = new Hre_StopWorkingRepository(unitOfWork); var profileServices = new Hre_ProfileServices(); var contractSevices = new Hre_ContractServices(); var ContractExtendServices = new Hre_ContractExtendServices(); var contractTypeSevices = new Cat_ContractTypeServices(); List <Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList(); // var lstSuspenses = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList(); var services = new BaseService(); var lstObj = new List <object>(); lstObj.AddRange(new object[14]); lstObj[12] = 1; lstObj[13] = int.MaxValue - 1; var lstSuspenses = services.GetData <Hre_StopWorkingEntity>(lstObj, ConstantSql.hrm_hr_sp_get_RegisterComback, userLogin, ref status).ToList().Translate <Hre_StopWorking>(); lstSuspenses = lstSuspenses.Where(s => lstIds.Contains(s.ID)).ToList(); var lstSuspense = new List <Hre_StopWorkingEntity>(); foreach (var Suspense in lstSuspenses) { var profile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(Suspense.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault(); Suspense.Status = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString(); Suspense.StatusComeBack = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString(); profile.StatusSyn = Suspense.LastStatusSyn; profile.RequestDate = null; profile.DateQuit = null; profile.IsHoldSal = false; profile.TypeSuspense = null; profile.StopWorkType = null; profile.ResReasonID = null; profile.TypeOfStop = null; profile.ResignNo = null; profileServices.Edit(profile); var contract = contractSevices.GetData <Hre_ContractEntity>(Common.DotNetToOracle(Suspense.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ContractsByProfileId, userLogin, ref status).OrderByDescending(s => s.DateStart).FirstOrDefault(); if (contract != null) { var contractType = contractSevices.GetData <Cat_ContractTypeEntity>(Common.DotNetToOracle(contract.ContractTypeID.ToString()), ConstantSql.hrm_cat_sp_get_ContractTypeById, userLogin, ref status).FirstOrDefault(); if (Suspense.TypeSuspense == HRM.Infrastructure.Utilities.EnumDropDown.TypeSuspense.E_MILITARY.ToString()) { int month = 0; if (contractType == null) { continue; } if (contractType.ValueTime != null) { month = (int)contractType.ValueTime.Value; if (contractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString()) { month = month * 12; } contract.DayContract = month; if (contract.DateEnd != null) { if (Suspense.DateComeBack <= contract.DateEnd.Value) { if (Suspense.DateStop != null) { double daySus = ((Suspense.DateComeBack.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30); contract.DayExtend = (int)Math.Floor(daySus); if (contract.DateExtend == null) { contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value); } else { contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value); } } } else { if (Suspense.DateStop != null) { double daySus = (contract.DateEnd.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30; contract.DayExtend = (int)Math.Floor(daySus); if (contract.DateExtend == null) { contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value); } else { contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value); } Suspense.DateComeBack = Suspense.DateComeBack.Value.AddMonths(contract.DayExtend.Value); } } } } contract.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString(); Hre_ContractExtendEntity contractExtend = new Hre_ContractExtendEntity(); contractExtend.ContractID = contract.ID; contractExtend.DateStart = Suspense.DateComeBack; contractExtend.DateEnd = contract.DateExtend; contractSevices.Edit(contract); ContractExtendServices.Add(contractExtend); } } repo.Edit(Suspense); } repo.SaveChanges(); message = NotificationType.Success.ToString(); return(message); } }