Exemplo n.º 1
0
        public ActionResult ApprovedEvaContract(string selectedIds)
        {
            var ContractServices = new Hre_ContractServices();
            var profileServices = new Hre_ProfileServices();
            var ContractExtendServices = new Hre_ContractExtendServices();
            string message = string.Empty;
            string status = string.Empty;
            var lstContract = ContractServices.GetData<Hre_ContractEntity>(Common.DotNetToOracle(selectedIds), ConstantSql.hrm_hr_sp_get_ContractByIds, UserLogin, ref status).ToList();
            foreach (var contract in lstContract)
            {
                if (contract.ContractResult == HRM.Infrastructure.Utilities.EnumDropDown.ResultContract.PASS.ToString())
                {
                    if (contract.TypeOfPass == HRM.Infrastructure.Utilities.EnumDropDown.TypeOfPass.E_SIGNED_NEXTCONTRACT.ToString())
                    {
                        if (contract.RankDetailForNextContract == null || contract.DateEndNextContract == null)
                        {
                            message = ConstantDisplay.HRM_HR_Profile_LackOfRequiredInformation.ToString();
                            return Json(message);
                        }
                        contract.StatusEvaluation = "E_APPROVED";
                        message = profileServices.SaveContractAndNextSalaryApprovedEvaluation(contract,UserLogin);

                    }
                    else if (contract.TypeOfPass == HRM.Infrastructure.Utilities.EnumDropDown.TypeOfPass.E_SIGNED_APPENDIXCONTRACT.ToString())
                    {
                        Hre_ContractExtendEntity entity = new Hre_ContractExtendEntity();
                        entity.ContractID = contract.ID;
                        if (contract.DateExtend != null)
                        {
                            entity.DateStart = contract.DateExtend;
                        }
                        else
                        {
                            entity.DateStart = contract.DateEnd;
                        }
                        entity.DateEnd = contract.DateEndNextContract;
                        message = ContractExtendServices.Add(entity);
                        contract.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();
                        contract.DateExtend = contract.DateEndNextContract;
                        contract.DateStart = contract.DateExtend != null ? contract.DateExtend.Value.AddDays(1) : contract.DateEnd.Value;
                        contract.DateExtend = contract.DateEndNextContract;
                        message = ContractServices.Edit(contract);
                    }
                }
                else
                {
                    contract.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();
                    message = ContractServices.Edit(contract);
                }

            }
            return Json(message);
        }
Exemplo n.º 2
0
        public string ActionApprovedComeBack(string selectedIds, string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string message = string.Empty;
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Hre_StopWorkingRepository(unitOfWork);
                var profileServices = new Hre_ProfileServices();
                var contractSevices = new Hre_ContractServices();
                var ContractExtendServices = new Hre_ContractExtendServices();
                var contractTypeSevices = new Cat_ContractTypeServices();

                List<Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
                //   var lstSuspenses = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList();
                var services = new BaseService();
                var lstObj = new List<object>();
                lstObj.AddRange(new object[14]);
                lstObj[12] = 1;
                lstObj[13] = int.MaxValue - 1;
                var lstSuspenses = services.GetData<Hre_StopWorkingEntity>(lstObj, ConstantSql.hrm_hr_sp_get_RegisterComback, userLogin, ref status).ToList().Translate<Hre_StopWorking>();
                lstSuspenses = lstSuspenses.Where(s => lstIds.Contains(s.ID)).ToList();
                var lstSuspense = new List<Hre_StopWorkingEntity>();
                foreach (var Suspense in lstSuspenses)
                {
                    var profile = profileServices.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(Suspense.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();
                    Suspense.Status = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    Suspense.StatusComeBack = HRM.Infrastructure.Utilities.EnumDropDown.StopWorkStatus.E_APPROVED.ToString();
                    profile.StatusSyn = Suspense.LastStatusSyn;
                    profile.RequestDate = null;
                    profile.DateQuit = null;
                    profile.IsHoldSal = false;
                    profile.TypeSuspense = null;
                    profile.StopWorkType = null;
                    profile.ResReasonID = null;
                    profile.TypeOfStop = null;
                    profile.ResignNo = null;
                    profileServices.Edit(profile);
                    var contract = contractSevices.GetData<Hre_ContractEntity>(Common.DotNetToOracle(Suspense.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ContractsByProfileId, userLogin, ref status).OrderByDescending(s => s.DateStart).FirstOrDefault();

                    if (contract != null)
                    {
                        var contractType = contractSevices.GetData<Cat_ContractTypeEntity>(Common.DotNetToOracle(contract.ContractTypeID.ToString()), ConstantSql.hrm_cat_sp_get_ContractTypeById, userLogin, ref status).FirstOrDefault();
                        if (Suspense.TypeSuspense == HRM.Infrastructure.Utilities.EnumDropDown.TypeSuspense.E_MILITARY.ToString())
                        {
                            int month = 0;
                            if (contractType == null)
                            {
                                continue;
                            }

                            if (contractType.ValueTime != null)
                            {
                                month = (int)contractType.ValueTime.Value;
                                if (contractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                                {
                                    month = month * 12;
                                }
                                contract.DayContract = month;
                                if (contract.DateEnd != null)
                                {
                                    if (Suspense.DateComeBack <= contract.DateEnd.Value)
                                    {
                                        if (Suspense.DateStop != null)
                                        {
                                            double daySus = ((Suspense.DateComeBack.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30);
                                            contract.DayExtend = (int)Math.Floor(daySus);
                                            if (contract.DateExtend == null)
                                            {
                                                contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            else
                                            {
                                                contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (Suspense.DateStop != null)
                                        {
                                            double daySus = (contract.DateEnd.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30;
                                            contract.DayExtend = (int)Math.Floor(daySus);
                                            if (contract.DateExtend == null)
                                            {
                                                contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            else
                                            {
                                                contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            Suspense.DateComeBack = Suspense.DateComeBack.Value.AddMonths(contract.DayExtend.Value);
                                        }
                                    }
                                }
                            }
                            contract.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();
                            Hre_ContractExtendEntity contractExtend = new Hre_ContractExtendEntity();
                            contractExtend.ContractID = contract.ID;
                            contractExtend.DateStart = Suspense.DateComeBack;
                            contractExtend.DateEnd = contract.DateExtend;
                            contractSevices.Edit(contract);
                            ContractExtendServices.Add(contractExtend);
                        }
                    }
                    repo.Edit(Suspense);
                }
                repo.SaveChanges();
                message = NotificationType.Success.ToString();
                return message;
            }
        }
Exemplo n.º 3
0
        public ActionResult ExtendContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var ContractServices = new Hre_ContractServices();
            var ExtendContractServices = new Hre_ContractExtendServices();
            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

            var actionService = new ActionService(UserLogin);
            var appendixContractServices = new Hre_AppendixContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContract = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();
            if (lstIDs != null)
            {
                lstContract = lstContract.Where(s => lstIDs.Contains(s.ID)).ToList();
            }

            foreach (var item in lstContract)
            {
                item.DateExtend = model.DateExtendTo;
                ContractServices.Edit(item);
                Hre_ContractExtendEntity Entity = new Hre_ContractExtendEntity();
                Entity.ContractID = item.ID;
                Entity.DateStart = model.DateExtendFrom;
                Entity.DateEnd = model.DateExtendTo;
                message = ExtendContractServices.Add(Entity);
            }

            return Json(message, JsonRequestBehavior.AllowGet);
        }