Beispiel #1
0
        public Hre_WorkHistoryModel Post([Bind] Hre_WorkHistoryModel model)
        {
            #region Validate
            BaseService BaseService   = new BaseService();
            string      status        = string.Empty;
            string      message       = string.Empty;
            var         checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Hre_WorkHistoryModel>(model, "Hre_WorkHistory", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return(model);
            }
            #endregion
            var WorkHistoryServices  = new Hre_WorkHistoryServices();
            var SalaryClassServices  = new Cat_SalaryClassServices();
            var OrgStructureServices = new Cat_OrgStructureServices();
            var JobTitleServices     = new Cat_JobTitleServices();
            var PositionServices     = new Cat_PositionServices();
            var WorkHistoryOld       = BaseService.GetData <Hre_WorkHistoryEntity>(Common.DotNetToOracle(model.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_WorkHistoryByProfileId, UserLogin, ref status).OrderByDescending(s => s.DateEffective).FirstOrDefault();
            if (WorkHistoryOld != null)
            {
                model.SalaryClassNameOld = WorkHistoryOld.SalaryClassName;
                model.JobTitleOld        = WorkHistoryOld.JobTitleName;
                model.PositionOld        = WorkHistoryOld.PositionName;
                model.OrgStructureOldID  = WorkHistoryOld.OrganizationStructureID;
                model.WorkLocationOld    = WorkHistoryOld.WorkLocation;
            }

            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;
                }
            }
            // Son.Vo - 20140107 - Xử lý cập nhật ngược lại bảng profile
            if (model.Status == WorkHistoryStatus.E_APPROVED.ToString() && model.DateEffective != null && model.DateEffective <= DateTime.Now.Date)
            {
                Hre_ProfileServices profileServices = new Hre_ProfileServices();
                Hre_ProfileEntity   profile         = BaseService.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(model.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault();
                if (profile != null)
                {
                    profile.OrgStructureID = model.OrganizationStructureID;
                    profile.JobTitleID     = model.JobTitleID;
                    profile.PositionID     = model.PositionID;
                    profile.DateOfEffect   = model.DateEffective;
                    profile.LaborType      = model.LaborType;
                    profile.CostCentreID   = model.CostCentreID;
                    profile.FormType       = model.FormType;
                    profile.EmpTypeID      = model.EmployeeTypeID;
                    profile.WorkingPlace   = model.WorkLocation;
                    profile.AbilityTileID  = model.AbilityTileID;
                    profileServices.Edit(profile);
                }
            }

            ActionService service = new ActionService(UserLogin);
            return(service.UpdateOrCreate <Hre_WorkHistoryEntity, Hre_WorkHistoryModel>(model));
        }
Beispiel #2
0
        /// <summary>
        /// Lay DS luong hieu luc cua toan cong ty. Moi nhan vien chi co 1 muc luong trong danh sach.
        /// </summary>
        /// <param name="lstSalaryAll">get all Salary</param>
        /// <param name="monthEffect"></param>
        /// <returns></returns>


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

                foreach (var holdSalary in lstHoldSalary)
                {
                    holdSalary.Status = status;
                    var profileByID = lstProfile.Where(s => s.ID == holdSalary.ProfileID.Value).FirstOrDefault();
                    profileByID.MonthHoldSal = holdSalary.MonthSalary;
                    profileByID.IsHoldSal    = true;
                }
                repoHoldSalary.SaveChanges();
                repoProfile.SaveChanges();
            }
        }
Beispiel #3
0
        /// <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 void EditProfle()
        {
            var model = new Hre_Profile
            {
                Id                = 1,
                ProfileName       = "Nguyễn Ngọc Chúc Test Edit",
                DateHire          = DateTime.Now,
                OrgStructureID    = 3,
                PositionID        = 1,
                DateOfEffect      = DateTime.Now,
                CostCentreID      = 1,
                NationalityID     = 1,
                EthnicID          = 1,
                ReligionID        = 1,
                JobTitleID        = 1,
                EmpTypeID         = 1,
                SupervisiorID     = 1,
                HighSupervisiorID = 1,
                DateQuit          = DateTime.Now
            };
            var service = new Hre_ProfileServices();
            var repo    = service.Edit(model);

            Console.Write("Result: " + repo);
        }
Beispiel #5
0
 public string ActionCancel(string selectedIds, string userLogin)
 {
     using (var context = new VnrHrmDataContext())
     {
         string      message         = string.Empty;
         var         unitOfWork      = (IUnitOfWork)(new UnitOfWork(context));
         var         repo            = new Hre_StopWorkingRepository(unitOfWork);
         var         profileServices = new Hre_ProfileServices();
         string      status          = string.Empty;
         List <Guid> lstIds          = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
         var         lstStopWorkings = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList();
         foreach (var StopWorking in lstStopWorkings)
         {
             var profile = profileServices.GetData <Hre_ProfileEntity>(Common.DotNetToOracle(StopWorking.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();
             profile.StatusSyn    = StopWorking.LastStatusSyn;
             StopWorking.Status   = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_CANCEL.ToString();
             profile.StopWorkType = null;
             profile.TypeSuspense = null;
             profile.RequestDate  = null;
             profile.DateQuit     = null;
             profile.ResReasonID  = null;
             profile.IsHoldSal    = false;
             profile.ResignNo     = null;
             profile.TypeOfStop   = null;
             profileServices.Edit(profile);
         }
         repo.SaveChanges();
         message = NotificationType.Success.ToString();
         return(message);
     }
 }
Beispiel #6
0
        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());
        }
Beispiel #7
0
        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 void GetProfle()
        {
            string status = string.Empty;
            Hre_ProfileServices service = new Hre_ProfileServices();
            var repo = service.GetAllUseEntity<Hre_ProfileEntity>(ref status);
            Console.Write("Total Record: " + repo.Count());

        }
        public void RemoveProfle()
        {
            const int id      = 2;
            var       service = new Hre_ProfileServices();
            var       repo    = service.Remove <Hre_ProfileEntity>(id);

            Console.Write("Result: " + repo);
        }
        public void GetProfle()
        {
            string status = string.Empty;
            Hre_ProfileServices service = new Hre_ProfileServices();
            var repo = service.GetAllUseEntity <Hre_ProfileEntity>(ref status);

            Console.Write("Total Record: " + repo.Count());
        }
Beispiel #11
0
        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 void AddProfleNoneReference()
 {
     for (int i = 21; i < 10000; i++)
     {
         var model = new Hre_Profile
         {
             ProfileName = " Văn Thiên Hiếu 00" + i.ToString(),
             LastName = "Hiếu 00" + i.ToString(),
             FirstName = "Văn Thiên",
             NameEnglish = "Kenptk 00" + i.ToString(),
             ImagePath = "",
             CodeEmp = "NV-IT-00" + i.ToString(),
             CodeTax = "MST-NV-00" + i.ToString(),
             CodeAttendance = "MTT-00" + i.ToString(),
             DateHire = DateTime.Now,
             DateEndProbation = DateTime.Now,
             DateOfEffect = DateTime.Now,
             WorkingPlace = "TP. Hồ Chí Minh",
             OrgStructureID = 2,
             JobTitleID = 4,
             PositionID = 2,
             EmpTypeID = 1,
             Gender = "E_MALE",
             MarriageStatus = "E_SINGLE",
             DayOfBirth = 9,
             MonthOfBirth = 7,
             YearOfBirth = 1991,
             PlaceOfBirth = "QT",
             BloodType = "O",
             Height = 170,
             Weight = 59,
             IDNo = "2014" + i,
             IDDateOfIssue = DateTime.Now,
             IDPlaceOfIssue = "TP. Hồ Chí Minh",
             PassportNo = "20140100" + i,
             Email = "*****@*****.**",
             CellPhone = "01207666444",
             Notes = "Công ty VnResource, test chương trình quản lý nhân sự version 8.0 đang trong quá trình phát triển và xây dựng  năm 2014",
         };
         var service = new Hre_ProfileServices();
         var repo = false;
         if (service.Add(model)=="0")
         {
             repo = true;
         }
         NUnit.Framework.Assert.IsTrue(repo);
         Console.Write("Record: " + model.ProfileName);
     }
 }
 public void AddProfleNoneReference()
 {
     for (int i = 21; i < 10000; i++)
     {
         var model = new Hre_Profile
         {
             ProfileName      = " Văn Thiên Hiếu 00" + i.ToString(),
             LastName         = "Hiếu 00" + i.ToString(),
             FirstName        = "Văn Thiên",
             NameEnglish      = "Kenptk 00" + i.ToString(),
             ImagePath        = "",
             CodeEmp          = "NV-IT-00" + i.ToString(),
             CodeTax          = "MST-NV-00" + i.ToString(),
             CodeAttendance   = "MTT-00" + i.ToString(),
             DateHire         = DateTime.Now,
             DateEndProbation = DateTime.Now,
             DateOfEffect     = DateTime.Now,
             WorkingPlace     = "TP. Hồ Chí Minh",
             OrgStructureID   = 2,
             JobTitleID       = 4,
             PositionID       = 2,
             EmpTypeID        = 1,
             Gender           = "E_MALE",
             MarriageStatus   = "E_SINGLE",
             DayOfBirth       = 9,
             MonthOfBirth     = 7,
             YearOfBirth      = 1991,
             PlaceOfBirth     = "QT",
             BloodType        = "O",
             Height           = 170,
             Weight           = 59,
             IDNo             = "2014" + i,
             IDDateOfIssue    = DateTime.Now,
             IDPlaceOfIssue   = "TP. Hồ Chí Minh",
             PassportNo       = "20140100" + i,
             Email            = "*****@*****.**",
             CellPhone        = "01207666444",
             Notes            = "Công ty VnResource, test chương trình quản lý nhân sự version 8.0 đang trong quá trình phát triển và xây dựng  năm 2014",
         };
         var service = new Hre_ProfileServices();
         var repo    = false;
         if (service.Add(model) == "0")
         {
             repo = true;
         }
         NUnit.Framework.Assert.IsTrue(repo);
         Console.Write("Record: " + model.ProfileName);
     }
 }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        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));
        }
Beispiel #17
0
        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));
        }
Beispiel #18
0
        public Ins_InsuranceSalaryPaybackModel Post([Bind] Ins_InsuranceSalaryPaybackModel model)
        {
            var    hrService   = new Hre_ProfileServices();
            var    baseService = new BaseService();
            string status      = string.Empty;

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

            ActionService service = new ActionService(UserLogin);
            return(service.UpdateOrCreate <Ins_InsuranceSalaryPaybackEntity, Ins_InsuranceSalaryPaybackModel>(model));
        }
Beispiel #19
0
        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));
        }
Beispiel #20
0
 public string ActionCancelComback(string selectedIds)
 {
     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         lstSuspenses    = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList();
         foreach (var Suspense in lstSuspenses)
         {
             Suspense.DateComeBack        = null;
             Suspense.RequestDateComeBack = null;
             Suspense.Status = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
         }
         repo.SaveChanges();
         message = NotificationType.Success.ToString();
         return(message);
     }
 }
        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);
            }
        }
Beispiel #22
0
        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));
        }
Beispiel #23
0
        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 void EditProfle()
        {
            var model = new Hre_Profile
            {
                Id = 1,
                ProfileName = "Nguyễn Ngọc Chúc Test Edit",
                DateHire = DateTime.Now,
                OrgStructureID = 3,
                PositionID = 1,
                DateOfEffect = DateTime.Now,
                CostCentreID = 1,
                NationalityID = 1,
                EthnicID = 1,
                ReligionID = 1,
                JobTitleID = 1,
                EmpTypeID = 1,
                SupervisiorID = 1,
                HighSupervisiorID = 1,
                DateQuit = DateTime.Now

            };
            var service = new Hre_ProfileServices();
            var repo = service.Edit(model);
            Console.Write("Result: " + repo);

        }
        public void RemoveProfle()
        {
            const int id = 2;
            var service = new Hre_ProfileServices();
            var repo = service.Remove<Hre_ProfileEntity>(id);
            Console.Write("Result: " + repo);


        }
        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));
        }
Beispiel #27
0
        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));
        }
Beispiel #28
0
        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));
        }
Beispiel #29
0
        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 void AddProfle()
        {
            for (int i = 0; i < 20; i++)
            {
                var model = new Hre_Profile
                {
                    ProfileName = "Nguyễn Ngọc Chúc "+i,
                    LastName = "Công ty VnResource",
                    FirstName = "Công ty VnResource",
                    NameEnglish = "Công ty VnResource",
                    ImagePath = "andrew.jpg",
                    CodeEmp = "NV00000"+i,
                    CodeTax = "T00000"+i,
                    CodeAttendance = "A00000"+i,
                    DateHire = DateTime.Now,
                    DateEndProbation = DateTime.Now,
                    OrgStructureID = 3,
                    PositionID = 1,
                    DateOfEffect = DateTime.Now,
                    CostCentreID = 1,
                    WorkingPlace = "TP. Hồ Chí Minh",
                    Gender = "male",
                    DayOfBirth = 10,
                    MonthOfBirth = 11,
                    YearOfBirth = 2014,
                    PlaceOfBirth = "TP. Hồ Chí Minh",
                    NationalityID = 1,
                    EthnicID = 1,
                    ReligionID = 1,
                    BloodType = "o",
                    Height = 170,
                    Weight = 59,
                    IDNo = "24110128"+i,
                    IDDateOfIssue = DateTime.Now,
                    IDPlaceOfIssue = "TP. Hồ Chí Minh",
                    PassportNo = "20001210"+i,
                    PassportDateOfExpiry = DateTime.Now,
                    PassportDateOfIssue = DateTime.Now,
                    PassportPlaceOfIssue = "TP. Hồ Chí Minh",
                    Email = "*****@*****.**",
                    CellPhone = "0989199212",
                    HomePhone = "09121212",
                    BusinessPhone = "38006223",
                    PAddressID = 1,
                    TAddressID = 1,
                    JobTitleID = 1,
                    EmpTypeID = 1,
                    SupervisiorID = 1,
                    HighSupervisiorID = 1,
                    DateQuit = DateTime.Now,
                    Notes = "Công ty VnResource, test chương trình quản lý nhân sự version 8.0 đang trong quá trình phát triển và xây dựng  năm 2014",

                };
                var service = new Hre_ProfileServices();
                var repo = false;
                if (service.Add(model) == "0")
                {
                    repo = true;
                }
                NUnit.Framework.Assert.IsTrue(repo);
                Console.Write("Record: " + repo);
            }
        }
Beispiel #31
0
        public string ApprovedTraineeRegister(List <Guid> selectedIds, Guid UserId)
        {
            using (var context = new VnrHrmDataContext())
            {
                var message            = string.Empty;
                var status             = string.Empty;
                var UserLogin          = string.Empty;
                var unitOfWork         = (IUnitOfWork)(new UnitOfWork(context));
                var firstApproved      = EnumDropDown.TraineeRegisterStatus.E_SUBMIT.ToString();
                var approved           = EnumDropDown.TraineeRegisterStatus.E_APPROVED.ToString();
                var objTraineeRegister = new List <object>();
                objTraineeRegister.AddRange(new object[12]);
                objTraineeRegister[10] = 1;
                objTraineeRegister[11] = int.MaxValue - 1;
                var lstTraineeRegister = GetData <Tra_TraineeRegisterEntity>(objTraineeRegister, ConstantSql.hrm_tra_sp_get_TraineeRegister, UserLogin, ref status).ToList();

                var repo_UserApproved = new CustomBaseRepository <Sys_UserApprove>(unitOfWork);
                var lstUserApproved   = repo_UserApproved.GetAll().Where(s => s.IsDelete == null).ToList();

                if (selectedIds.Count > 0)
                {
                    lstTraineeRegister = lstTraineeRegister.Where(s => selectedIds.Contains(s.ID)).ToList();
                }

                var traineeServices          = new Tra_TraineeServices();
                var isTraineeInRequireDetail = traineeServices.IsAddTraineeDependOnRequirementDetail();
                var traineeTopicServices     = new Tra_TraineeTopicServices();
                var planServices             = new Tra_PlanServices();
                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, 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 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();

                foreach (var registerEntity in lstTraineeRegister)
                {
                    var classEntity          = lstClass.Where(s => s.ID == registerEntity.ClassID).FirstOrDefault();
                    var traineeEntityInClass = lstObjTrainee.Where(s => s.ClassID == registerEntity.ClassID && registerEntity.ProfileID == s.ProfileID).ToList();

                    #region người duyệt đầu
                    if (registerEntity.UserApproveID1 != null && registerEntity.UserApproveID1.Value == UserId)
                    {
                        var userApprovedEntity = lstUserApproved.Where(s => registerEntity.UserApproveID1.Value == s.UserApproveID && s.Type == ApproveType.E_TRA_TRAINEEREGISTER.ToString()).FirstOrDefault();
                        if (userApprovedEntity != null)
                        {
                            if (userApprovedEntity.IsMasterApprove == null || userApprovedEntity.IsMasterApprove.Value == false)
                            {
                                registerEntity.Status = firstApproved;
                                message = Edit(registerEntity);
                            }
                        }
                    }
                    #endregion

                    #region người duyệt cuối
                    if (registerEntity.UserApproveID2 != null && registerEntity.UserApproveID2.Value == UserId)
                    {
                        var userApprovedEntity = lstUserApproved.Where(s => registerEntity.UserApproveID2.Value == s.UserApproveID && s.Type == ApproveType.E_TRA_TRAINEEREGISTER.ToString()).FirstOrDefault();
                        if (userApprovedEntity != null)
                        {
                            if (userApprovedEntity.IsMasterApprove != null && userApprovedEntity.IsMasterApprove.Value)
                            {
                                #region Cập Nhập Status lại vào bảng Tra_TraineeRegister
                                registerEntity.Status = approved;
                                message = Edit(registerEntity);
                                #endregion

                                #region Tạo hv vào bảng Tra_Trainee

                                if (isTraineeInRequireDetail)
                                {
                                    if (traineeEntityInClass.Count > 0)
                                    {
                                        message = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString();
                                        return(message);
                                    }
                                    if (registerEntity.ClassID != null)
                                    {
                                        if (classEntity != null && 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 == item.ProfileID).FirstOrDefault();
                                                if (requirementDetailEntity != null)
                                                {
                                                    var traineeEntity = new Tra_TraineeEntity();
                                                    traineeEntity.ProfileID         = registerEntity.ProfileID.Value;
                                                    traineeEntity.ClassID           = registerEntity.ClassID.Value;
                                                    traineeEntity.TraineeRegisterID = (Guid?)registerEntity.ID;
                                                    traineeServices.Add(traineeEntity);

                                                    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 = traineeEntity.ID;
                                                        message = traineeTopicServices.Add(traineeTopicEntity);
                                                    }
                                                }
                                                else
                                                {
                                                    message = ConstantMessages.WarningProfileNotInRequirement.ToString().TranslateString();
                                                }
                                            }
                                        }
                                    }
                                }

                                if (classEntity != null)
                                {
                                    if (traineeEntityInClass.Count > 0)
                                    {
                                        message = ConstantMessages.WarningProfileHaveClass.ToString().TranslateString();
                                        return(message);
                                    }

                                    var traineeEntity = new Tra_TraineeEntity();
                                    traineeEntity.ProfileID         = registerEntity.ProfileID.Value;
                                    traineeEntity.ClassID           = registerEntity.ClassID.Value;
                                    traineeEntity.TraineeRegisterID = (Guid?)registerEntity.ID;
                                    traineeServices.Add(traineeEntity);

                                    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 = traineeEntity.ID;
                                        message = traineeTopicServices.Add(traineeTopicEntity);
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                    #endregion
                }
                return(message);
            }
        }
        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);
        }
Beispiel #33
0
        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));
        }
Beispiel #34
0
        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);
        }
Beispiel #35
0
        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));
        }