/// <summary>
        /// Edit comment Trung.le 20120529
        /// Them thuoc tinh Khong cat Overtime qua ngày E_STANDARD_WORKDAY - Value37 Trung.le 20120529
        /// </summary>
        /// <param name="overtime"></param>
        /// <param name="lstDayOff"></param>
        /// <param name="_LstPregnancy"></param>
        /// <param name="GuidContext"></param>
        /// <param name="_userId"></param>
        /// <param name="isByShift">Lấy theo ca làm việc của từng người</param>
        /// <returns></returns>
        public List <Att_OvertimeEntity> AnalysisOvertime(Att_OvertimeEntity overtime, List <Cat_DayOff> lstDayOff,
                                                          List <Att_Pregnancy> _LstPregnancy, bool isByShift, bool isAllowCutBreakHour, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork    = (IUnitOfWork)(new UnitOfWork(context));
                var repoCat_Shift = new CustomBaseRepository <Cat_Shift>(unitOfWork);

                Cat_Shift ShiftOfOT = repoCat_Shift.FindBy(s => s.ID == overtime.ShiftID).FirstOrDefault();


                string status = string.Empty;

                Att_OvertimeEntity baseOT = null;
                if (overtime != null)
                {
                    //overtime.SerialCode = overtime.Workdate.ToString("ddMMyyyy");
                }

                List <Att_OvertimeEntity> listOvertimeInsert = new List <Att_OvertimeEntity>();
                Hre_Profile profile = new Hre_Profile();
                profile.ID = overtime.ProfileID;
                DateTime _workDate    = overtime.WorkDate;
                DateTime dateWorkDate = _workDate;

                string        key      = "HRM_ATT_OT";
                List <object> lstSysOT = new List <object>();
                lstSysOT.Add(key);
                lstSysOT.Add(null);
                lstSysOT.Add(null);
                var config = GetData <Sys_AllSettingEntity>(lstSysOT, ConstantSql.hrm_sys_sp_get_AllSetting, UserLogin, ref status);
                if (config == null)
                {
                    return(listOvertimeInsert);
                }
                var  NoCutOvertimePassDay   = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_NOCUTOVERTIMEPASSDAY.ToString()).FirstOrDefault();
                var  ByPeriodOfTime         = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_BYPERIODOFTIME.ToString()).FirstOrDefault();
                var  nightShiftFrom         = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_NIGHTSHIFTFROM.ToString()).FirstOrDefault();
                var  nightShiftTo           = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_NIGHTSHIFTTO.ToString()).FirstOrDefault();
                bool isNocutOvertimePassDay = Convert.ToBoolean(NoCutOvertimePassDay.Value1);//Không cắt Overtime qua ngày


                List <Hre_Profile> lstProfile = new List <Hre_Profile>()
                {
                    profile
                };
                List <Guid>            lstProfileIDs      = lstProfile.Select(m => m.ID).ToList();
                List <Att_Roster>      lstRosterTypeGroup = new List <Att_Roster>();
                List <Att_RosterGroup> lstRosterGroup     = new List <Att_RosterGroup>();
                Att_RosterServices.GetRosterGroup(lstProfileIDs, _workDate.Date, _workDate.Date, out lstRosterTypeGroup, out lstRosterGroup);

                string registryCode  = "OT_" + overtime.CodeEmp + "_" + overtime.WorkDate.ToString("ddMMyyyyHHmmss");
                double basicHours    = overtime.RegisterHours;
                double durationHours = overtime.RegisterHours;
                //overtime.BasicHours = basicHours;
                //overtime.RegisterCode = registryCode;
                bool                isWorkDay       = true;
                DateTime            dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                Att_Grade           grade           = Att_GradeServices.GetGrade(profile, _workDate.Date);
                Cat_GradeAttendance gradeCfg        = grade == null ? null : grade.Cat_GradeAttendance;
                if (gradeCfg == null)
                {
                    return(listOvertimeInsert);
                }
                Hashtable htable = null;
                htable    = Att_RosterServices.GetRosterTable(false, profile, _workDate.Date, _workDate.Date, lstRosterGroup, lstRosterTypeGroup);
                isWorkDay = Att_AttendanceServices.IsWorkDay(gradeCfg, htable, lstDayOff, _workDate.Date);
                if (isByShift)//Lấy theo ca làm việc của từng người
                {
                    #region Lấy theo ca làm việc của từng người

                    Cat_Shift ship = Att_AttendanceServices.GetShift(gradeCfg, htable, _workDate.Date);
                    if (ship != null)
                    {
                        if (isWorkDay)
                        {
                            if (overtime.DurationType == EnumDropDown.OvertimeDurationType.E_OT_LATE.ToString() && ship != null)
                            {
                                DateTime timeOut = ship.InTime.AddHours(ship.CoOut);
                                dateWorkDate    = _workDate.Date.AddHours(timeOut.Hour).AddMinutes(timeOut.Minute);
                                dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                            }
                            else if (overtime.DurationType == EnumDropDown.OvertimeDurationType.E_OT_EARLY.ToString() && ship != null)
                            {
                                DateTime timeIn = ship.InTime;
                                dateWorkDate    = _workDate.Date.AddHours(timeIn.Hour).AddMinutes(timeIn.Minute);
                                dateWorkDateEnd = dateWorkDate;
                                dateWorkDate    = dateWorkDate.AddHours(-durationHours);
                            }
                        }
                        else
                        {
                            DateTime timeIn = ship.InTime;
                            dateWorkDate = _workDate.Date.AddHours(timeIn.Hour).AddMinutes(timeIn.Minute);
                        }
                    }
                    else
                    {
                        dateWorkDate    = dateWorkDate.Date;
                        dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                    }
                    ShiftOfOT = ship;


                    htable    = Att_RosterServices.GetRosterTable(false, profile, dateWorkDate, dateWorkDate.AddHours(durationHours), lstRosterGroup, lstRosterTypeGroup);
                    isWorkDay = Att_AttendanceServices.IsWorkDay(gradeCfg, htable, lstDayOff, dateWorkDate.AddHours(durationHours));

                    #endregion
                }

                //Kiem tra xem co trong thoi gian nghi thai san khong?
                if (isWorkDay && overtime.DurationType == EnumDropDown.OvertimeDurationType.E_OT_LATE.ToString() &&
                    _LstPregnancy != null && _LstPregnancy.Exists(pc => pc.ProfileID == profile.ID && pc.DateEnd >= dateWorkDate && pc.DateStart <= dateWorkDateEnd))
                {
                    dateWorkDate    = dateWorkDate.AddHours(-1);
                    dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                }
                overtime.WorkDate = dateWorkDate;



                string strHoursNightFrom = string.Empty;
                string strHoursNightTo   = string.Empty;


                if (!Att_AttendanceServices.IsNightShiftByConfig(ByPeriodOfTime) && ShiftOfOT != null &&
                    ShiftOfOT.NightTimeStart != null &&
                    ShiftOfOT.NightTimeEnd != null)
                {
                    strHoursNightFrom = ShiftOfOT.NightTimeStart.Value.ToString("HH:mm:ss");
                    strHoursNightTo   = ShiftOfOT.NightTimeEnd.Value.ToString("HH:mm:ss");
                }
                else
                {
                    strHoursNightFrom = string.IsNullOrEmpty(nightShiftFrom.Value1) == true ? "21:00:00" : nightShiftFrom.Value1 + ":00";
                    strHoursNightTo   = string.IsNullOrEmpty(nightShiftTo.Value1) == true ? "05:00:00" : nightShiftTo.Value1 + ":00";
                }

                DateTime dateNightFrom = Common.ConvertStringToDateTime(dateWorkDate.Date.ToString("MM/dd/yyyy") + " " + strHoursNightFrom, CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern);
                DateTime dateNightTo   = Common.ConvertStringToDateTime(dateWorkDate.Date.AddDays(1).ToString("MM/dd/yyyy") + " " + strHoursNightTo, CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern);


                OvertimeInfo overtimeInfo = new OvertimeInfo(true);
                overtimeInfo.DateFrom   = dateWorkDate;
                overtimeInfo.TotalHours = overtime.RegisterHours;

                overtimeInfo.DayShiftPoints = new DateTime[] { dateNightTo };

                if (isNocutOvertimePassDay)
                {
                    overtimeInfo.NightShiftPoints = new DateTime[] { dateNightFrom };
                }
                else
                {
                    //truong hop cat khi qua ngay hom sau
                    overtimeInfo.NightShiftPoints = new DateTime[] { dateNightFrom, dateNightFrom.Date };
                }

                if (ShiftOfOT != null && isAllowCutBreakHour)
                {
                    Cat_Shift shift      = ShiftOfOT;
                    DateTime  coBreakOut = shift.InTime.AddHours(shift.CoBreakIn);

                    if (shift.CoBreakOut - shift.CoBreakIn > 0)
                    {
                        overtimeInfo.BreaktPoints.Add(coBreakOut, shift.CoBreakOut - shift.CoBreakIn);
                    }
                }
                Hre_Profile temp = new Hre_Profile();
                temp.ID = overtime.ProfileID;

                overtimeInfo.Hre_Profile = temp;
                overtimeInfo.ListDayOff  = lstDayOff;

                listOvertimeInsert = AnalysisOvertime(overtime, overtimeInfo);



                return(listOvertimeInsert);
            }
        }
        public Cat_OvertimeType getOTType(DateTime dateWorkDate, bool isNightShift, Hre_Profile profile, List <Cat_DayOff> list_dayOff, List <Att_RosterGroup> lstRosterGroup, List <Att_Roster> lstRosterTypeGroup)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork           = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_LeaveDay     = new CustomBaseRepository <Att_LeaveDay>(unitOfWork);
                var repoCat_OvertimeType = new CustomBaseRepository <Cat_OvertimeType>(unitOfWork);

                Cat_OvertimeType otType = null;
                try
                {
                    dateWorkDate = dateWorkDate.Date;

                    //LamLe : Them chuc nang neu tang ca vao ngay nghi thi chon loai tang ca phu thuoc vao cau hinh Tang ca trong ngay nghi.
                    List <Att_LeaveDay> lstLeave = repoAtt_LeaveDay
                                                   .FindBy(lv => lv.IsDelete == null && lv.DateStart <= dateWorkDate && lv.DateEnd >= dateWorkDate && lv.ProfileID == profile.ID)
                                                   .ToList();
                    if (lstLeave.Count > 0)
                    {
                        Att_LeaveDay leave = lstLeave[0];
                        if (leave != null && leave.Cat_LeaveDayType != null && leave.Cat_LeaveDayType.Cat_OvertimeType != null)
                        {
                            otType = leave.Cat_LeaveDayType.Cat_OvertimeType;
                            return(otType);
                        }
                    }

                    Att_Grade grade = Att_GradeServices.GetGrade(profile, dateWorkDate);
                    if (grade == null)
                    {
                        string status = OverTimeType.E_WORKDAY.ToString();
                        otType = repoCat_OvertimeType.FindBy(dayoff => dayoff.IsDelete == null && dayoff.Code == status).FirstOrDefault();
                        return(otType);
                    }
                    list_dayOff = list_dayOff.Where(df => df.DateOff.Date == dateWorkDate.Date).ToList();
                    Cat_GradeCfg gradecfg = grade.Cat_GradeCfg;

                    //Check overtime holiday
                    //List<Cat_DayOff> list_dayOff = EntityService.Instance.GetEntityList<Cat_DayOff>(GuidContext, _userId, dayoff => dayoff.DateOff == dateWorkDate);

                    if (list_dayOff.Count > 0)
                    {
                        //Cat_GradeCfg.FieldNames.Cat_OvertimeType1
                        bool isDayOffHollyDay = false;
                        foreach (var item in list_dayOff)
                        {
                            if (item.DateOff.Date == dateWorkDate.Date && item.Type == HolidayType.E_HOLIDAY_HLD.ToString())
                            {
                                isDayOffHollyDay = true;
                            }
                        }
                        //Ca dem ngay le
                        if (isDayOffHollyDay && isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType5;
                        }
                        //Ca dem ngay nghi cuoi tuan
                        else if (!isDayOffHollyDay && isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType4;
                        }
                        ////Ca ngay ngay le
                        else if (isDayOffHollyDay && !isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType2;
                        }
                        ////Ca ngay ngay nghi cuoi tuan
                        else
                        {
                            otType = gradecfg.Cat_OvertimeType1;
                        }
                    }
                    else
                    {
                        Hashtable hsRoster = Att_RosterServices.GetRosterTable(false, profile, dateWorkDate, dateWorkDate, lstRosterGroup, lstRosterTypeGroup);

                        bool isWorkday = Att_AttendanceServices.IsWorkDay(grade.Cat_GradeAttendance, hsRoster, list_dayOff, dateWorkDate);
                        if (isWorkday)
                        {
                            if (isNightShift)
                            {
                                otType = gradecfg.Cat_OvertimeType3;
                            }
                            else
                            {
                                otType = gradecfg.Cat_OvertimeType;
                            }
                            //if (gradecfg.Cat_OvertimeType == null)
                            //{

                            //    string workday = OverTimeType.E_WORKDAY.ToString();
                            //    otType = EntityService.Instance.GetEntity<Cat_OvertimeType>(GuidContext, _userId, dayoff => dayoff.Code == workday);
                            //}
                            //else
                            //    otType = gradecfg.Cat_OvertimeType;
                        }
                        else
                        {
                            if (isNightShift)
                            {
                                otType = gradecfg.Cat_OvertimeType4;
                            }
                            else
                            {
                                otType = gradecfg.Cat_OvertimeType1;
                            }
                            //if (gradecfg.Cat_OvertimeType1 == null)
                            //{
                            //    string workday = OverTimeType.E_WORKDAY.ToString();
                            //    otType = EntityService.Instance.GetEntity<Cat_OvertimeType>(GuidContext, _userId, dayoff => dayoff.Code == workday);
                            //}
                            //else
                            //    otType = gradecfg.Cat_OvertimeType1;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                return(otType);
            }
        }
示例#3
0
        public ActionResult SaveContractAndSaslary(DateTime? dateStart, DateTime? dateEnd, string orgStructureID, string contractTypeID, string RankDetailForNextContract, List<Guid> selectedIds, string statusContract, bool IsEvaluation)
        {
            var hrService = new Hre_ProfileServices();
            string message = string.Empty;
            var actionService = new ActionService(UserLogin);
            string status = string.Empty;
            var lstObjProfile = new List<object>();
            lstObjProfile.AddRange(new object[16]);
            lstObjProfile[14] = 1;
            lstObjProfile[15] = int.MaxValue - 1;
            var lstProfile = actionService.GetData<Hre_ProfileEntity>(lstObjProfile, ConstantSql.hrm_hr_sp_get_Profile, ref status).ToList();

            var salaryRankServices = new Cat_SalaryRankServices();
            var lstObjSalaryRank = new List<object>();
            lstObjSalaryRank.Add(null);
            lstObjSalaryRank.Add(null);
            lstObjSalaryRank.Add(1);
            lstObjSalaryRank.Add(int.MaxValue - 1);
            var lstSalaryRank = actionService.GetData<Cat_SalaryRankEntity>(lstObjSalaryRank, ConstantSql.hrm_cat_sp_get_SalaryRank, ref status).ToList();
            var contractServices = new Hre_ContractServices();
            var lisobjContract = new List<object>();
            string strIDs = string.Empty;
            foreach (var item in selectedIds)
            {
                strIDs += Common.DotNetToOracle(item.ToString()) + ",";
            }
            if (strIDs.IndexOf(",") > 0)
                strIDs = strIDs.Substring(0, strIDs.Length - 1);
            lisobjContract.Add(strIDs);
            var lstContractByProfileID = actionService.GetData<Hre_ContractEntity>(lisobjContract, ConstantSql.hrm_hr_sp_get_ContractsByListId, ref status).ToList();
            var workhistoryService = new Hre_WorkHistoryServices();
            var lstObjWorkhistory = new List<object>();
            lstObjWorkhistory.AddRange(new object[17]);
            lstObjWorkhistory[15] = 1;
            lstObjWorkhistory[16] = int.MaxValue - 1;
            var lstWorkhistory = actionService.GetData<Hre_WorkHistoryEntity>(lstObjWorkhistory, ConstantSql.hrm_hr_sp_get_WorkHistory, ref status).ToList();

            var basicSalaryService = new Sal_BasicSalaryServices();

            var attGradeService = new Att_GradeServices();
            var lstObjAttGrade = new List<object>();
            lstObjAttGrade.AddRange(new object[6]);
            lstObjAttGrade[4] = 1;
            lstObjAttGrade[5] = int.MaxValue - 1;
            var lstAttGrade = actionService.GetData<Att_GradeEntity>(lstObjAttGrade, ConstantSql.hrm_att_sp_get_Att_Grade, ref status).ToList();

            var gradeService = new Sal_GradeServices();
            var lstObjSalGrade = new List<object>();
            lstObjSalGrade.AddRange(new object[7]);
            lstObjSalGrade[5] = 1;
            lstObjSalGrade[6] = int.MaxValue - 1;
            var lstSalGrade = actionService.GetData<Sal_GradeEntity>(lstObjSalGrade, ConstantSql.hrm_sal_sp_get_Sal_Grade, 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 lstGradePayroll = actionService.GetData<Cat_GradePayrollEntity>(lstObjGradePayroll, ConstantSql.hrm_cat_sp_get_GradePayroll, ref status).ToList();

            var gradeAttService = new Cat_GradeAttendanceServices();
            var lstObjGradeAtt = new List<object>();
            lstObjGradeAtt.AddRange(new object[10]);
            lstObjGradeAtt[8] = 1;
            lstObjGradeAtt[9] = int.MaxValue - 1;
            var lstGradeAtt = actionService.GetData<Cat_GradeAttendanceEntity>(lstObjGradeAtt, ConstantSql.hrm_cat_sp_get_Cat_GradeAttendance, ref status).ToList();

            var currencyServices = new Cat_CurrencyServices();
            var lstObjCurrency = new List<object>();
            lstObjCurrency.Add(null);
            lstObjCurrency.Add(null);
            lstObjCurrency.Add(1);
            lstObjCurrency.Add(int.MaxValue - 1);
            var lstCurrency = actionService.GetData<Cat_CurrencyEntity>(lstObjCurrency, ConstantSql.hrm_cat_sp_get_Currency, ref status).ToList();
            var lstCurrencyNew = lstCurrency.Where(s => s.CurrencyName == "VND").FirstOrDefault();

            var contractTypeService = new Cat_ContractTypeServices();
            var lstObjContractType = new List<object>();
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(1);
            lstObjContractType.Add(int.MaxValue - 1);
            var lstContractType = actionService.GetData<Cat_ContractTypeEntity>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, ref status).ToList();

            var insuranceConfigServices = new Cat_InsuranceConfigServices();
            var objInsuranceConfig = new List<object>();
            objInsuranceConfig.Add(1);
            objInsuranceConfig.Add(int.MaxValue - 1);
            var lstInsuranceConfig = actionService.GetData<Cat_InsuranceConfigEntity>(objInsuranceConfig, ConstantSql.hrm_cat_sp_get_InsuranceConfig, ref status).ToList();

            var insuranceServices = new Sal_InsuranceSalaryServices();
            var objInsurance = new List<object>();
            objInsurance.AddRange(new object[9]);
            objInsurance[7] = 1;
            objInsurance[8] = int.MaxValue - 1;
            var lstInsurance = actionService.GetData<Sal_InsuranceSalaryEntity>(objInsurance, ConstantSql.hrm_sal_sp_get_InsuranceSalary, ref status).ToList();

            foreach (var item in lstContractByProfileID)
            {
                var contractTypeEntity = new Cat_ContractTypeEntity();
                var objContract = new List<object>();
                objContract.Add(item.ProfileID);
                var lstContractIdByProfileID = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_ContractsByProfileId, ref status);
                var listIdContract = string.Empty;
                if (lstContractIdByProfileID != null)
                {
                    listIdContract = string.Join(",", lstContractIdByProfileID.Select(d => d.ContractTypeID));
                }

                var profile = lstProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();

                if (item.NextContractTypeID != null)
                {
                    contractTypeEntity = lstContractType.Where(s => item.NextContractTypeID.Value == s.ID).FirstOrDefault();
                }
                else
                {
                    message = ConstantMessages.WarningContractHaveNotNextContract.ToString().TranslateString();
                    return Json(message, JsonRequestBehavior.AllowGet);
                    // contractTypeEntity = lstContractType.Where(s => Guid.Parse(Common.DotNetToOracle(item.ContractNextID.ToString())) == s.ID).FirstOrDefault();
                }


                var workingHistoryEntity = lstWorkhistory.Where(s => s.ProfileID == item.ProfileID).FirstOrDefault();
                var objSalGrade = new List<object>();
                objSalGrade.Add(item.ProfileID);
                objSalGrade.Add(null);
                objSalGrade.Add(1);
                objSalGrade.Add(int.MaxValue - 1);
                var salGradeByProfileIDEntity = actionService.GetData<Sal_GradeEntity>(objSalGrade, ConstantSql.hrm_sal_sp_get_GradeAndAllownaceByProId, ref status).FirstOrDefault();
                var objAttGrade = new List<object>();
                objAttGrade.Add(item.ProfileID);
                objAttGrade.Add(null);
                objAttGrade.Add(1);
                objAttGrade.Add(int.MaxValue - 1);
                var attGradeByProfileIDEntity = actionService.GetData<Att_GradeEntity>(objAttGrade, ConstantSql.hrm_att_sp_get_GradeAttendanceByProIdCutID, ref status).FirstOrDefault();

                if (contractTypeEntity == null)
                {
                    continue;
                }

                if (item.ContractResult == EnumDropDown.ResultContract.PASS.ToString())
                {
                    if (item.ContractEvaType == EnumDropDown.ContractEvaType.E_EXPIRED_APPRENTICE.ToString())
                    {

                        //chưa tìm dc cách xử lý nên hard code 
                        var lstSalaryRankNew = new Cat_SalaryRankEntity();
                        // var lstSalaryRankNew = lstSalaryRank.Where(s => item.RankDetailForNextContract != null && s.ID == item.RankDetailForNextContract.Value).FirstOrDefault();
                        if (item.RankDetailForNextContract != null)
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => item.RankDetailForNextContract != null && s.ID == item.RankDetailForNextContract.Value).FirstOrDefault();
                        }
                        else
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => item.RankRateID != null && s.ID == item.RankRateID.Value).FirstOrDefault();
                        }

                        #region Xử lý Hre_Contract
                        if (item.TypeOfPass == EnumDropDown.TypeOfPass.E_SIGNED_NEXTCONTRACT.ToString())
                        {
                            int month = 0;
                            if (contractTypeEntity != null && contractTypeEntity.ValueTime != null)
                            {
                                month = (int)contractTypeEntity.ValueTime.Value;
                                if (contractTypeEntity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                                {
                                    month = month * 12;
                                }
                                contractTypeEntity.DateStart = item.DateEnd.Value.AddDays(1);

                                //chưa tìm dc cách xử lý nên hard code 
                                //  var nextContractTypeID = Common.ConvertToGuid(contractTypeEntity.ContractNextID).ToString();
                                var contractEntity = new Hre_ContractEntity
                                {
                                    //   ContractNo = getContractNo(item, item.DateSigned),
                                    ProfileID = item.ProfileID,
                                    ProfileName = item.ProfileName,
                                    DateStart = item.DateEnd.Value.AddDays(1),
                                    DateSigned = item.DateEnd.Value.AddDays(1),
                                    JobTitleID = item.JobTitleID,
                                    PositionID = item.PositionID,
                                    DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                    Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                    RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                    ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                    SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                    ContractTypeID = contractTypeEntity.ID
                                };

                                if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                                {
                                    contractEntity = SetNewDateEndContract(contractEntity);
                                }

                                if (item.DateEndNextContract != null)
                                {
                                    contractEntity.DateEnd = item.DateEndNextContract.Value;
                                }
                                if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                                {
                                    return Json(contractEntity, JsonRequestBehavior.AllowGet);
                                }
                                message = contractServices.Add(contractEntity);
                            }
                            else
                            {
                                contractTypeEntity.DateStart = item.DateEnd.Value.AddDays(1);

                                //chưa tìm dc cách xử lý nên hard code 
                                //  var nextContractTypeID = Common.ConvertToGuid(contractTypeEntity.ContractNextID).ToString();
                                var contractEntity = new Hre_ContractEntity
                                {
                                    //  ContractNo = getContractNo(item, item.DateSigned),
                                    ProfileID = item.ProfileID,
                                    ProfileName = item.ProfileName,
                                    DateStart = item.DateEnd.Value.AddDays(1),
                                    DateSigned = item.DateEnd.Value.AddDays(1),
                                    JobTitleID = item.JobTitleID,
                                    PositionID = item.PositionID,
                                    //   DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                    Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                    RankRateID = lstSalaryRankNew == null ? item.RankRateID : lstSalaryRankNew.ID,
                                    ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                    SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                    ContractTypeID = contractTypeEntity.ID
                                };

                                if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                                {
                                    contractEntity = SetNewDateEndContract(contractEntity);
                                }
                                if (item.DateEndNextContract != null)
                                {
                                    contractEntity.DateEnd = item.DateEndNextContract.Value;
                                }
                                if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                                {
                                    return Json(contractEntity, JsonRequestBehavior.AllowGet);
                                }
                                message = contractServices.Add(contractEntity);
                            }
                        }

                        #endregion

                        #region Xử Lý Sal_BasicSalary
                        var salaryEntity = new Sal_BasicSalaryEntity
                        {
                            ProfileID = item.ProfileID,
                            ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                            GrossAmount = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryStandard.ToString(),
                            DateOfEffect = item.DateEnd.Value.AddDays(1),
                            CurrencyID = lstCurrencyNew.ID,
                            Note = item.Remark


                        };
                        message = basicSalaryService.Add(salaryEntity);

                        #endregion

                        #region Xử Lý Hre_Profile
                        var profileEntity = profile.CopyData<Hre_ProfileEntity>();
                        profileEntity.SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID;

                        hrService.Edit(profileEntity);

                        if (workingHistoryEntity != null)
                        {
                            if (workingHistoryEntity.SalaryClassID != lstSalaryRankNew.SalaryClassID)
                            {
                                var workhistoryEntity = new Hre_WorkHistoryEntity
                                {
                                    ProfileID = item.ProfileID,
                                    SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    DateEffective = item.DateEnd.Value.AddDays(1)
                                };
                                message = workhistoryService.Add(workhistoryEntity);
                            }

                        }
                        else
                        {
                            var workhistoryEntity = new Hre_WorkHistoryEntity
                            {
                                ProfileID = item.ProfileID,
                                SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                DateEffective = item.DateEnd.Value.AddDays(1)
                            };
                            message = workhistoryService.Add(workhistoryEntity);
                        }

                        #endregion

                        #region Sal_Grade
                        var lstGradeByProfileID = lstSalGrade.Where(s => item.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradePayrollByProfileID = lstGradePayroll.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (salGradeByProfileIDEntity != null)
                        {
                            if (salGradeByProfileIDEntity.GradePayrollID != lstGradePayrollByProfileID.ID)
                            {
                                var gradeEntity = new Sal_GradeEntity
                                {
                                    //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                    ProfileID = item.ProfileID,
                                    GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                    MonthStart = item.DateEnd.Value.AddDays(1)
                                };
                                message = gradeService.Add(gradeEntity);
                            }

                        }
                        else
                        {
                            var gradeEntity = new Sal_GradeEntity
                            {
                                //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                ProfileID = item.ProfileID,
                                GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                MonthStart = item.DateEnd.Value.AddDays(1)
                            };
                            message = gradeService.Add(gradeEntity);
                        }

                        #endregion

                        #region Att_Grade
                        var lstAttGradeByProfileID = lstAttGrade.Where(s => item.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradeAttByProfileID = lstGradeAtt.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (attGradeByProfileIDEntity != null)
                        {
                            if (attGradeByProfileIDEntity.GradeAttendanceID != lstGradeAttByProfileID.ID)
                            {
                                var gradeAttEntity = new Att_GradeEntity
                                {
                                    // ID = lstGradeAttByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                    ProfileID = item.ProfileID,
                                    GradeAttendanceID = lstAttGradeByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                    MonthStart = item.DateEnd.Value.AddDays(1)
                                };
                                message = attGradeService.Add(gradeAttEntity);
                            }
                        }
                        else
                        {
                            var gradeAttEntity = new Att_GradeEntity
                            {
                                // ID = lstGradeAttByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                ProfileID = item.ProfileID,
                                GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                MonthStart = item.DateEnd.Value.AddDays(1)
                            };
                            message = attGradeService.Add(gradeAttEntity);
                        }


                        #endregion

                        #region Xử Lý Lương BHXH
                        if (contractTypeEntity.NoneTypeInsuarance == true)
                        {
                            var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == item.ProfileID && s.DateEffect == item.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                            var insuranceEntity = new Sal_InsuranceSalaryEntity
                            {
                                ProfileID = item.ProfileID,
                                InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                DateEffect = item.DateEnd.Value.AddDays(1),
                                IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                                IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                                IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                                CurrencyID = lstCurrencyNew.ID
                            };
                            if (insuranceEntityByProfileID != null)
                            {
                                insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                insuranceEntityByProfileID.IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance;
                                insuranceEntityByProfileID.IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance;
                                insuranceEntityByProfileID.IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance;
                                message = insuranceServices.Edit(insuranceEntityByProfileID);
                            }
                            else
                            {
                                message = insuranceServices.Add(insuranceEntity);
                            }


                        }

                        if (contractTypeEntity.NoneTypeInsuarance == false)
                        {

                            var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID != null && s.ContractTypeID.Value == contractTypeEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                            if (insuranceConfigEntity != null)
                            {
                                var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == item.ProfileID && s.DateEffect == item.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                var insuranceEntity = new Sal_InsuranceSalaryEntity
                                {
                                    ProfileID = item.ProfileID,
                                    InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                    DateEffect = item.DateEnd.Value.AddDays(1),
                                    IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                                    IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                                    IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                                    CurrencyID = lstCurrencyNew.ID
                                };

                                if (insuranceEntityByProfileID != null)
                                {
                                    insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                    insuranceEntityByProfileID.IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial;
                                    insuranceEntityByProfileID.IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy;
                                    insuranceEntityByProfileID.IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth;
                                    message = insuranceServices.Edit(insuranceEntityByProfileID);
                                }
                                else
                                {
                                    message = insuranceServices.Add(insuranceEntity);
                                }

                            }
                        }
                        #endregion

                        //  return Json(message, JsonRequestBehavior.AllowGet);
                    }

                    if (item.ContractEvaType == EnumDropDown.ContractEvaType.E_ANNUAL_EVALUATION.ToString() && item.ContractResult == EnumDropDown.ResultContract.PASS.ToString())
                    {

                        var lstSalaryRankNew = new Cat_SalaryRankEntity();
                        // var lstSalaryRankNew = lstSalaryRank.Where(s => item.RankDetailForNextContract != null && s.ID == item.RankDetailForNextContract.Value).FirstOrDefault();
                        if (item.RankDetailForNextContract != null)
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => item.RankDetailForNextContract != null && s.ID == item.RankDetailForNextContract.Value).FirstOrDefault();
                        }
                        else
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => item.RankRateID != null && s.ID == item.RankRateID.Value).FirstOrDefault();
                        }

                        #region Xử lý Hre_Contract
                        int month = 0;
                        if (contractTypeEntity != null && contractTypeEntity.ValueTime != null)
                        {
                            month = (int)contractTypeEntity.ValueTime.Value;
                            if (contractTypeEntity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                            {
                                month = month * 12;
                            }
                            contractTypeEntity.DateStart = item.DateEnd.Value.AddDays(1);

                            //chưa tìm dc cách xử lý nên hard code 

                            var contractEntity = new Hre_ContractEntity
                            {
                                // ContractNo = getContractNo(item, item.DateSigned),
                                ProfileID = item.ProfileID,
                                ProfileName = item.ProfileName,
                                DateStart = new DateTime(DateTime.Now.Year, 6, 1),
                                DateSigned = new DateTime(DateTime.Now.Year, 6, 1),
                                JobTitleID = item.JobTitleID,
                                PositionID = item.PositionID,
                                DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                ContractTypeID = contractTypeEntity.ID
                            };

                            if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                            {
                                contractEntity = SetNewDateEndContract(contractEntity);
                            }
                            if (item.DateEndNextContract != null)
                            {
                                contractEntity.DateEnd = item.DateEndNextContract.Value;
                            }
                            if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                            {
                                return Json(contractEntity, JsonRequestBehavior.AllowGet);
                            }
                            message = contractServices.Add(contractEntity);
                        }
                        else
                        {
                            contractTypeEntity.DateStart = item.DateEnd.Value.AddDays(1);

                            //chưa tìm dc cách xử lý nên hard code 

                            var contractEntity = new Hre_ContractEntity
                            {
                                // ContractNo = getContractNo(item, item.DateSigned),
                                ProfileID = item.ProfileID,
                                ProfileName = item.ProfileName,
                                DateStart = new DateTime(DateTime.Now.Year, 6, 1),
                                DateSigned = new DateTime(DateTime.Now.Year, 6, 1),
                                JobTitleID = item.JobTitleID,
                                PositionID = item.PositionID,
                                // DateEnd = null,
                                Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                ContractTypeID = contractTypeEntity.ID
                            };

                            if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                            {
                                contractEntity = SetNewDateEndContract(contractEntity);
                            }

                            if (item.DateEndNextContract != null)
                            {
                                contractEntity.DateEnd = item.DateEndNextContract.Value;
                            }
                            if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                            {

                                return Json(contractEntity, JsonRequestBehavior.AllowGet);
                            }
                            message = contractServices.Add(contractEntity);
                        }
                        #endregion

                        #region Xử Lý Sal_BasicSalary
                        var salaryEntity = new Sal_BasicSalaryEntity
                        {
                            ProfileID = item.ProfileID,
                            ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                            GrossAmount = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryStandard.ToString(),
                            DateOfEffect = new DateTime(DateTime.Now.Year, 6, 1),
                            CurrencyID = lstCurrencyNew.ID,
                            Note = item.Remark

                        };
                        message = basicSalaryService.Add(salaryEntity);

                        #endregion

                        #region Xử Lý Hre_Profile
                        var profileEntity = profile.CopyData<Hre_ProfileEntity>();
                        profileEntity.SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID;
                        message = hrService.Edit(profileEntity);

                        if (workingHistoryEntity != null)
                        {
                            if (workingHistoryEntity.SalaryClassID != lstSalaryRankNew.SalaryClassID)
                            {
                                var workhistoryEntity = new Hre_WorkHistoryEntity
                                {
                                    ProfileID = item.ProfileID,
                                    SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    DateEffective = new DateTime(DateTime.Now.Year, 6, 1)
                                };
                                message = workhistoryService.Add(workhistoryEntity);
                            }

                        }
                        else
                        {
                            var workhistoryEntity = new Hre_WorkHistoryEntity
                            {
                                ProfileID = item.ProfileID,
                                SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                DateEffective = new DateTime(DateTime.Now.Year, 6, 1)
                            };
                            message = workhistoryService.Add(workhistoryEntity);
                        }
                        #endregion

                        #region Sal_Grade
                        var lstGradeByProfileID = lstSalGrade.Where(s => item.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradePayrollByProfileID = lstGradePayroll.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (salGradeByProfileIDEntity != null)
                        {
                            if (salGradeByProfileIDEntity.GradePayrollID != lstGradePayrollByProfileID.ID)
                            {
                                var gradeEntity = new Sal_GradeEntity
                                {
                                    //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                    ProfileID = item.ProfileID,
                                    GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                    MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                                };
                                message = gradeService.Add(gradeEntity);
                            }
                        }
                        else
                        {
                            var gradeEntity = new Sal_GradeEntity
                            {
                                //  ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                ProfileID = item.ProfileID,
                                GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                            };
                            message = gradeService.Add(gradeEntity);
                        }


                        #endregion

                        #region Att_Grade
                        var lstAttGradeByProfileID = lstAttGrade.Where(s => item.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradeAttByProfileID = lstGradeAtt.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (attGradeByProfileIDEntity != null)
                        {
                            if (attGradeByProfileIDEntity.GradeAttendanceID != lstGradeAttByProfileID.ID)
                            {
                                var gradeAttEntity = new Att_GradeEntity
                                {
                                    //ID = lstAttGradeByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                    ProfileID = item.ProfileID,
                                    GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                    MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                                };
                                message = attGradeService.Add(gradeAttEntity);
                            }
                        }
                        else
                        {
                            var gradeAttEntity = new Att_GradeEntity
                            {
                                //ID = lstAttGradeByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                ProfileID = item.ProfileID,
                                GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                            };
                            message = attGradeService.Add(gradeAttEntity);
                        }


                        #endregion

                        #region Xử Lý Lương BHXH
                        if (contractTypeEntity.NoneTypeInsuarance == true)
                        {
                            var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == item.ProfileID && s.DateEffect == item.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                            var insuranceEntity = new Sal_InsuranceSalaryEntity
                            {
                                ProfileID = item.ProfileID,
                                InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                DateEffect = item.DateEnd.Value.AddDays(1),
                                IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                                IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                                IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                                CurrencyID = lstCurrencyNew.ID
                            };

                            if (insuranceEntityByProfileID != null)
                            {
                                insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                insuranceEntityByProfileID.IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance;
                                insuranceEntityByProfileID.IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance;
                                insuranceEntityByProfileID.IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance;
                                message = insuranceServices.Edit(insuranceEntityByProfileID);
                            }
                            else
                            {
                                message = insuranceServices.Add(insuranceEntity);
                            }
                        }
                        if (contractTypeEntity.NoneTypeInsuarance == false)
                        {
                            var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID != null && s.ContractTypeID.Value == contractTypeEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                            if (insuranceConfigEntity != null)
                            {
                                var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == item.ProfileID && s.DateEffect == item.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                var insuranceEntity = new Sal_InsuranceSalaryEntity
                                {
                                    ProfileID = item.ProfileID,
                                    InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                    DateEffect = item.DateEnd.Value.AddDays(1),
                                    IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                                    IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                                    IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                                    CurrencyID = lstCurrencyNew.ID
                                };
                                if (insuranceEntityByProfileID != null)
                                {
                                    insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                    insuranceEntityByProfileID.IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial;
                                    insuranceEntityByProfileID.IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy;
                                    insuranceEntityByProfileID.IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth;
                                    message = insuranceServices.Edit(insuranceEntityByProfileID);
                                }
                                else
                                {
                                    message = insuranceServices.Add(insuranceEntity);
                                }
                            }
                        }
                        #endregion

                    }
                }
            }
            return Json(message, JsonRequestBehavior.AllowGet);
            //   return null;
        }
示例#4
0
        public string SaveContractAndNextSalaryApprovedEvaluation(Hre_ContractEntity contract)
        {

            if (contract.DateEndNextContract == null)
            {
                return string.Empty;
            }

            // Lấy biến Dateend này gắn cho quá trình công tác khi cập nhật quá trinh công tác ở dưới
            DateTime? dateEnd = contract.DateEnd;

            string message = string.Empty;
            var actionService = new ActionService(UserLogin);
            string status = string.Empty;

            var profile = actionService.GetData<Hre_ProfileEntity>(contract.ProfileID, ConstantSql.hrm_hr_sp_get_ProfileById, ref status).FirstOrDefault();
            var hrService = new Hre_ProfileServices();
            var salaryRankServices = new Cat_SalaryRankServices();
            var lstObjSalaryRank = new List<object>();
            lstObjSalaryRank.Add(null);
            lstObjSalaryRank.Add(null);
            lstObjSalaryRank.Add(1);
            lstObjSalaryRank.Add(int.MaxValue - 1);
            var lstSalaryRank = actionService.GetData<Cat_SalaryRankEntity>(lstObjSalaryRank, ConstantSql.hrm_cat_sp_get_SalaryRank, ref status).ToList();

            var contractServices = new Hre_ContractServices();

            var workhistoryService = new Hre_WorkHistoryServices();
            var lstObjWorkhistory = new List<object>();
            lstObjWorkhistory.AddRange(new object[17]);
            lstObjWorkhistory[15] = 1;
            lstObjWorkhistory[16] = int.MaxValue - 1;
            var lstWorkhistory = actionService.GetData<Hre_WorkHistoryEntity>(lstObjWorkhistory, ConstantSql.hrm_hr_sp_get_WorkHistory, ref status).ToList();

            var basicSalaryService = new Sal_BasicSalaryServices();

            var attGradeService = new Att_GradeServices();
            var lstObjAttGrade = new List<object>();
            lstObjAttGrade.AddRange(new object[6]);
            lstObjAttGrade[4] = 1;
            lstObjAttGrade[5] = int.MaxValue - 1;
            var lstAttGrade = actionService.GetData<Att_GradeEntity>(lstObjAttGrade, ConstantSql.hrm_att_sp_get_Att_Grade, ref status).ToList();

            var gradeService = new Sal_GradeServices();
            var lstObjSalGrade = new List<object>();
            lstObjSalGrade.AddRange(new object[7]);
            lstObjSalGrade[5] = 1;
            lstObjSalGrade[6] = int.MaxValue - 1;
            var lstSalGrade = actionService.GetData<Sal_GradeEntity>(lstObjSalGrade, ConstantSql.hrm_sal_sp_get_Sal_Grade, 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 lstGradePayroll = actionService.GetData<Cat_GradePayrollEntity>(lstObjGradePayroll, ConstantSql.hrm_cat_sp_get_GradePayroll, ref status).ToList();

            var gradeAttService = new Cat_GradeAttendanceServices();
            var lstObjGradeAtt = new List<object>();
            lstObjGradeAtt.AddRange(new object[10]);
            lstObjGradeAtt[8] = 1;
            lstObjGradeAtt[9] = int.MaxValue - 1;
            var lstGradeAtt = actionService.GetData<Cat_GradeAttendanceEntity>(lstObjGradeAtt, ConstantSql.hrm_cat_sp_get_Cat_GradeAttendance, ref status).ToList();

            var currencyServices = new Cat_CurrencyServices();
            var lstObjCurrency = new List<object>();
            lstObjCurrency.Add(null);
            lstObjCurrency.Add(null);
            lstObjCurrency.Add(1);
            lstObjCurrency.Add(int.MaxValue - 1);
            var lstCurrency = actionService.GetData<Cat_CurrencyEntity>(lstObjCurrency, ConstantSql.hrm_cat_sp_get_Currency, ref status).ToList();
            var lstCurrencyNew = lstCurrency.Where(s => s.CurrencyName == "VND").FirstOrDefault();

            var contractTypeService = new Cat_ContractTypeServices();
            var lstObjContractType = new List<object>();
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(1);
            lstObjContractType.Add(int.MaxValue - 1);
            var lstContractType = actionService.GetData<Cat_ContractTypeEntity>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, ref status).ToList();

            var insuranceConfigServices = new Cat_InsuranceConfigServices();
            var objInsuranceConfig = new List<object>();
            objInsuranceConfig.Add(1);
            objInsuranceConfig.Add(int.MaxValue - 1);
            var lstInsuranceConfig = actionService.GetData<Cat_InsuranceConfigEntity>(objInsuranceConfig, ConstantSql.hrm_cat_sp_get_InsuranceConfig, ref status).ToList();

            var insuranceServices = new Sal_InsuranceSalaryServices();
            var objInsurance = new List<object>();
            objInsurance.AddRange(new object[9]);
            objInsurance[7] = 1;
            objInsurance[8] = int.MaxValue - 1;
            var lstInsurance = actionService.GetData<Sal_InsuranceSalaryEntity>(objInsurance, ConstantSql.hrm_sal_sp_get_InsuranceSalary, ref status).ToList();


            var contractTypeEntity = new Cat_ContractTypeEntity();
            var objContract = new List<object>();
            objContract.Add(contract.ProfileID);
            var lstContractIdByProfileID = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_ContractsByProfileId, ref status);
            var listIdContract = string.Empty;
            if (lstContractIdByProfileID != null)
            {
                listIdContract = string.Join(",", lstContractIdByProfileID.Select(d => d.ContractTypeID));
            }

            if (contract.NextContractTypeID != null)
            {
                contractTypeEntity = lstContractType.Where(s => contract.NextContractTypeID.Value == s.ID).FirstOrDefault();
            }
            else
            {
                message = ConstantMessages.WarningContractHaveNotNextContract.ToString().TranslateString();
                return message;
            }


            if (contractTypeEntity != null)
            {
                if (contractTypeEntity.Type == EnumDropDown.TypeContract.E_NODURATION.ToString())
                {
                    return string.Empty;
                }
            }

            var workingHistoryEntity = lstWorkhistory.Where(s => s.ProfileID == contract.ProfileID).FirstOrDefault();
            var objSalGrade = new List<object>();
            objSalGrade.Add(contract.ProfileID);
            objSalGrade.Add(null);
            objSalGrade.Add(1);
            objSalGrade.Add(int.MaxValue - 1);
            var salGradeByProfileIDEntity = actionService.GetData<Sal_GradeEntity>(objSalGrade, ConstantSql.hrm_sal_sp_get_GradeAndAllownaceByProId, ref status).FirstOrDefault();
            var objAttGrade = new List<object>();
            objAttGrade.Add(contract.ProfileID);
            objAttGrade.Add(null);
            objAttGrade.Add(1);
            objAttGrade.Add(int.MaxValue - 1);
            var attGradeByProfileIDEntity = actionService.GetData<Att_GradeEntity>(objAttGrade, ConstantSql.hrm_att_sp_get_GradeAttendanceByProIdCutID, ref status).FirstOrDefault();

            if (contractTypeEntity == null)
            {
                return string.Empty;
            }

            var contracttypeByContract = lstContractType.Where(s => s.ID == contract.ContractTypeID).FirstOrDefault();

            if (contract.ContractResult == EnumDropDown.ResultContract.PASS.ToString())
            {
                if (contract.ContractEvaType == EnumDropDown.ContractEvaType.E_EXPIRED_APPRENTICE.ToString())
                {

                    //chưa tìm dc cách xử lý nên hard code 
                    var lstSalaryRankNew = new Cat_SalaryRankEntity();
                    if (contract.RankDetailForNextContract != null)
                    {
                        lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankDetailForNextContract != null && s.ID == contract.RankDetailForNextContract.Value).FirstOrDefault();
                    }
                    else
                    {
                        lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankRateID != null && s.ID == contract.RankRateID.Value).FirstOrDefault();
                    }

                    #region Xử lý Hre_Contract
                    if (contract.TypeOfPass == EnumDropDown.TypeOfPass.E_SIGNED_NEXTCONTRACT.ToString())
                    {
                        int month = 0;
                        if (contractTypeEntity != null && contractTypeEntity.ValueTime != null)
                        {
                            month = (int)contractTypeEntity.ValueTime.Value;
                            if (contractTypeEntity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                            {
                                month = month * 12;
                            }
                            contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                            //chưa tìm dc cách xử lý nên hard code 
                            //  var nextContractTypeID = Common.ConvertToGuid(contractTypeEntity.ContractNextID).ToString();
                            var contractEntity = new Hre_ContractEntity
                            {
                                //   ContractNo = getContractNo(item, item.DateSigned),
                                ProfileID = contract.ProfileID,
                                ProfileName = contract.ProfileName,
                                DateStart = contract.DateEnd.Value.AddDays(1),
                                DateSigned = contract.DateEnd.Value.AddDays(1),
                                JobTitleID = contract.JobTitleID,
                                PositionID = contract.PositionID,
                                DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                ContractTypeID = contractTypeEntity.ID,
                                DateEndNextContract = contract.DateEndNextContract,
                            };
                            if (contract.DateEndNextContract != null)
                            {
                                contractEntity.DateEnd = contract.DateEndNextContract.Value;
                            }
                            contractEntity = SetNewCodeContract(contractEntity, listIdContract);

                            #region Nếu là loại hđ xác định thời hạn thì update lại cột TimesContract theo task 0049731
                            if (contracttypeByContract != null && contracttypeByContract.Type == HRM.Infrastructure.Utilities.EnumDropDown.TypeContract.E_DURATION.ToString())
                            {
                                try
                                {
                                    string times = contractEntity.ContractNo.Substring(contractEntity.ContractNo.Length - 1, 1);
                                    int Year = int.Parse(times);
                                    contractEntity.TimesContract = Year;
                                }
                                catch
                                {
                                }
                            }
                            #endregion
                            contractEntity.Status = "E_APPROVED";
                            contractEntity.StatusEvaluation = "E_APPROVED";
                            contractEntity.DateExtend = contract.DateEnd;
                            if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                            {
                                return string.Empty;
                            }
                            message = contractServices.Add(contractEntity);
                        }
                        else
                        {
                            contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                            //chưa tìm dc cách xử lý nên hard code 
                            //  var nextContractTypeID = Common.ConvertToGuid(contractTypeEntity.ContractNextID).ToString();
                            var contractEntity = new Hre_ContractEntity
                            {
                                //  ContractNo = getContractNo(item, item.DateSigned),
                                ProfileID = contract.ProfileID,
                                ProfileName = contract.ProfileName,
                                DateStart = contract.DateEnd.Value.AddDays(1),
                                DateSigned = contract.DateEnd.Value.AddDays(1),
                                JobTitleID = contract.JobTitleID,
                                PositionID = contract.PositionID,
                                //   DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                RankRateID = lstSalaryRankNew == null ? contract.RankRateID : lstSalaryRankNew.ID,
                                ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                ContractTypeID = contractTypeEntity.ID
                            };

                            //if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                            //{
                            //    contractEntity = SetNewDateEndContract(contractEntity);
                            //}
                            if (contract.DateEndNextContract != null)
                            {
                                contractEntity.DateEnd = contract.DateEndNextContract.Value;
                            }
                            contractEntity.DateExtend = contract.DateEnd;
                            contractEntity.StatusEvaluation = "E_APPROVED";

                            if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                            {
                                return string.Empty;
                            }

                            message = contractServices.Add(contractEntity);
                        }
                    }

                    //Edit lai StatusEvaluation 
                    contract.StatusEvaluation = "E_APPROVED";
                    message = contractServices.Edit(contract);

                    #endregion

                    #region Xử Lý Sal_BasicSalary
                    var salaryEntity = new Sal_BasicSalaryEntity
                    {
                        ProfileID = contract.ProfileID,
                        ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                        RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                        GrossAmount = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryStandard.ToString(),
                        DateOfEffect = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                        CurrencyID = lstCurrencyNew.ID,
                        Note = contract.Remark,
                        Status = "E_APPROVED"
                    };
                    message = basicSalaryService.Add(salaryEntity);

                    #endregion

                    #region Xử Lý Hre_Profile
                    var profileEntity = profile.CopyData<Hre_ProfileEntity>();
                    Guid? _AbilityTileID = null;
                    profileEntity.SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID;
                    if (profileEntity.SalaryClassID != null)
                    {
                        var abilityTitleBySalaryClass = hrService.GetData<Cat_AbilityTileEntity>(Common.DotNetToOracle(profileEntity.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, UserLogin, ref status).FirstOrDefault();
                        if (abilityTitleBySalaryClass != null)
                        {
                            _AbilityTileID = abilityTitleBySalaryClass.ID;
                            profileEntity.AbilityTileID = _AbilityTileID;
                        }
                    }

                    hrService.Edit(profileEntity);

                    if (workingHistoryEntity != null)
                    {
                        if (workingHistoryEntity.SalaryClassID != lstSalaryRankNew.SalaryClassID)
                        {
                            var workhistoryEntity = new Hre_WorkHistoryEntity
                            {
                                ProfileID = contract.ProfileID,
                                SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                                AbilityTileID = _AbilityTileID,
                                Status = "E_APPROVED"

                            };
                            message = workhistoryService.Add(workhistoryEntity);
                        }


                    }
                    else
                    {
                        var workhistoryEntity = new Hre_WorkHistoryEntity
                        {
                            ProfileID = contract.ProfileID,
                            SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                            Status = "E_APPROVED",

                        };
                        message = workhistoryService.Add(workhistoryEntity);
                    }

                    #endregion

                    #region Sal_Grade
                    var lstGradeByProfileID = lstSalGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                    var lstGradePayrollByProfileID = lstGradePayroll.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                    if (salGradeByProfileIDEntity != null)
                    {
                        if (salGradeByProfileIDEntity.GradePayrollID != lstGradePayrollByProfileID.ID)
                        {
                            var gradeEntity = new Sal_GradeEntity
                            {
                                //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                MonthStart = contract.DateSigned.Value,
                            };
                            message = gradeService.Add(gradeEntity);
                        }

                    }
                    else
                    {
                        var gradeEntity = new Sal_GradeEntity
                        {
                            //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                            ProfileID = contract.ProfileID,
                            GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                            MonthStart = contract.DateSigned.Value,
                        };
                        message = gradeService.Add(gradeEntity);
                    }

                    #endregion

                    #region Att_Grade
                    var lstAttGradeByProfileID = lstAttGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                    var lstGradeAttByProfileID = lstGradeAtt.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                    if (attGradeByProfileIDEntity != null)
                    {
                        if (attGradeByProfileIDEntity.GradeAttendanceID != lstGradeAttByProfileID.ID)
                        {
                            var gradeAttEntity = new Att_GradeEntity
                            {
                                // ID = lstGradeAttByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradeAttendanceID = lstAttGradeByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                MonthStart = contract.DateSigned.Value,
                            };
                            message = attGradeService.Add(gradeAttEntity);
                        }
                    }
                    else
                    {
                        var gradeAttEntity = new Att_GradeEntity
                        {
                            // ID = lstGradeAttByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                            ProfileID = contract.ProfileID,
                            GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                            MonthStart = contract.DateSigned.Value,
                        };
                        message = attGradeService.Add(gradeAttEntity);
                    }


                    #endregion

                    #region Xử Lý Lương BHXH
                    if (contractTypeEntity.NoneTypeInsuarance == true)
                    {
                        var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                        var insuranceEntity = new Sal_InsuranceSalaryEntity
                        {
                            ProfileID = contract.ProfileID,
                            InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                            DateEffect = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                            IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                            IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                            IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                            CurrencyID = lstCurrencyNew.ID
                        };
                        if (insuranceEntityByProfileID != null)
                        {
                            insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                            insuranceEntityByProfileID.IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance;
                            insuranceEntityByProfileID.IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance;
                            insuranceEntityByProfileID.IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance;
                            message = insuranceServices.Edit(insuranceEntityByProfileID);
                        }
                        else
                        {
                            message = insuranceServices.Add(insuranceEntity);
                        }


                    }

                    if (contractTypeEntity.NoneTypeInsuarance == false)
                    {

                        var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID != null && s.ContractTypeID.Value == contractTypeEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                        if (insuranceConfigEntity != null)
                        {
                            var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                            var insuranceEntity = new Sal_InsuranceSalaryEntity
                            {
                                ProfileID = contract.ProfileID,
                                InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                DateEffect = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                                IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                                IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                                IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                                CurrencyID = lstCurrencyNew.ID
                            };

                            if (insuranceEntityByProfileID != null)
                            {
                                insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                insuranceEntityByProfileID.IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial;
                                insuranceEntityByProfileID.IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy;
                                insuranceEntityByProfileID.IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth;
                                message = insuranceServices.Edit(insuranceEntityByProfileID);
                            }
                            else
                            {
                                message = insuranceServices.Add(insuranceEntity);
                            }

                        }
                    }
                    #endregion
                }

                if (contract.ContractEvaType == EnumDropDown.ContractEvaType.E_ANNUAL_EVALUATION.ToString() && contract.ContractResult == EnumDropDown.ResultContract.PASS.ToString())
                {
                    var lstSalaryRankNew = new Cat_SalaryRankEntity();
                    if (contract.RankDetailForNextContract != null)
                    {
                        lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankDetailForNextContract != null && s.ID == contract.RankDetailForNextContract.Value).FirstOrDefault();
                    }
                    else
                    {
                        lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankRateID != null && s.ID == contract.RankRateID.Value).FirstOrDefault();
                    }

                    #region Xử lý Hre_Contract
                    int month = 0;
                    if (contractTypeEntity != null && contractTypeEntity.ValueTime != null)
                    {
                        month = (int)contractTypeEntity.ValueTime.Value;
                        if (contractTypeEntity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                        {
                            month = month * 12;
                        }
                        contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                        //chưa tìm dc cách xử lý nên hard code 

                        var contractEntity = new Hre_ContractEntity
                        {
                            // ContractNo = getContractNo(item, item.DateSigned),
                            ProfileID = contract.ProfileID,
                            ProfileName = contract.ProfileName,
                            DateStart = new DateTime(DateTime.Now.Year, 6, 1),
                            DateSigned = new DateTime(DateTime.Now.Year, 6, 1),
                            JobTitleID = contract.JobTitleID,
                            PositionID = contract.PositionID,
                            DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                            Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                            RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                            ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                            SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                            ContractTypeID = contractTypeEntity.ID
                        };

                        //if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                        //{
                        //    contractEntity = SetNewDateEndContract(contractEntity);
                        //}
                        if (contract.DateEndNextContract != null)
                        {
                            contractEntity.DateEnd = contract.DateEndNextContract.Value;
                        }
                        contractEntity = SetNewCodeContract(contractEntity, listIdContract);

                        #region Nếu là loại hđ xác định thời hạn thì update lại cột TimesContract theo task 0049731
                        if (contracttypeByContract != null && contracttypeByContract.Type == HRM.Infrastructure.Utilities.EnumDropDown.TypeContract.E_DURATION.ToString())
                        {
                            try
                            {
                                string times = contractEntity.ContractNo.Substring(contractEntity.ContractNo.Length - 1, 1);
                                int Year = int.Parse(times);
                                contractEntity.TimesContract = Year;
                            }
                            catch
                            {
                            }
                        }
                        #endregion

                        contractEntity.Status = "E_APPROVED";
                        contractEntity.DateExtend = contract.DateEnd;
                        contractEntity.StatusEvaluation = "E_APPROVED";

                        if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                        {
                            return string.Empty;
                        }
                        message = contractServices.Add(contractEntity);
                    }
                    else
                    {
                        contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                        //chưa tìm dc cách xử lý nên hard code 

                        var contractEntity = new Hre_ContractEntity
                        {
                            // ContractNo = getContractNo(item, item.DateSigned),
                            ProfileID = contract.ProfileID,
                            ProfileName = contract.ProfileName,
                            DateStart = new DateTime(DateTime.Now.Year, 6, 1),
                            DateSigned = new DateTime(DateTime.Now.Year, 6, 1),
                            JobTitleID = contract.JobTitleID,
                            PositionID = contract.PositionID,
                            // DateEnd = null,
                            Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                            RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                            ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                            SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                            ContractTypeID = contractTypeEntity.ID
                        };

                        //if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                        //{
                        //    contractEntity = SetNewDateEndContract(contractEntity);
                        //}

                        if (contract.DateEndNextContract != null)
                        {
                            contractEntity.DateEnd = contract.DateEndNextContract.Value;
                        }
                        contractEntity.DateExtend = contract.DateEnd;
                        contractEntity.StatusEvaluation = "E_APPROVED";
                        if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                        {

                            return string.Empty;
                        }
                        message = contractServices.Add(contractEntity);
                    }
                    //Edit lai StatusEvaluation 
                    contract.StatusEvaluation = "E_APPROVED";
                    message = contractServices.Edit(contract);

                    #endregion

                    #region Xử Lý Sal_BasicSalary
                    var salaryEntity = new Sal_BasicSalaryEntity
                    {
                        ProfileID = contract.ProfileID,
                        ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                        RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                        GrossAmount = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryStandard.ToString(),
                        DateOfEffect = new DateTime(DateTime.Now.Year, 6, 1),
                        CurrencyID = lstCurrencyNew.ID,
                        Note = contract.Remark,
                        Status = "E_APPROVED"

                    };
                    message = basicSalaryService.Add(salaryEntity);

                    #endregion

                    #region Xử Lý Hre_Profile
                    var profileEntity = profile.CopyData<Hre_ProfileEntity>();
                    profileEntity.SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID;
                    Guid? _AbilityTileID = null;
                    if (profileEntity.SalaryClassID != null)
                    {
                        var abilityTitleBySalaryClass = actionService.GetData<Cat_AbilityTileEntity>(Common.DotNetToOracle(profileEntity.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, ref status).FirstOrDefault();
                        if (abilityTitleBySalaryClass != null)
                        {
                            _AbilityTileID = abilityTitleBySalaryClass.ID;
                            profileEntity.AbilityTileID = _AbilityTileID;
                        }
                    }
                    message = hrService.Edit(profileEntity);
                    if (workingHistoryEntity != null)
                    {
                        if (workingHistoryEntity.SalaryClassID != lstSalaryRankNew.SalaryClassID)
                        {
                            var workhistoryEntity = new Hre_WorkHistoryEntity
                            {
                                ProfileID = contract.ProfileID,
                                SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                                AbilityTileID = _AbilityTileID,
                                Status = "E_APPROVED"
                            };
                            message = workhistoryService.Add(workhistoryEntity);
                        }
                    }
                    else
                    {
                        var workhistoryEntity = new Hre_WorkHistoryEntity
                        {
                            ProfileID = contract.ProfileID,
                            SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                            Status = "E_APPROVED"

                        };
                        message = workhistoryService.Add(workhistoryEntity);
                    }
                    #endregion

                    #region Sal_Grade
                    var lstGradeByProfileID = lstSalGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                    var lstGradePayrollByProfileID = lstGradePayroll.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                    if (salGradeByProfileIDEntity != null)
                    {
                        if (salGradeByProfileIDEntity.GradePayrollID != lstGradePayrollByProfileID.ID)
                        {
                            var gradeEntity = new Sal_GradeEntity
                            {
                                //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                MonthStart = new DateTime(DateTime.Now.Year, 6, 1),

                            };
                            message = gradeService.Add(gradeEntity);
                        }
                    }
                    else
                    {
                        var gradeEntity = new Sal_GradeEntity
                        {
                            //  ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                            ProfileID = contract.ProfileID,
                            GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                            MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                        };
                        message = gradeService.Add(gradeEntity);
                    }


                    #endregion

                    #region Att_Grade
                    var lstAttGradeByProfileID = lstAttGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                    var lstGradeAttByProfileID = lstGradeAtt.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                    if (attGradeByProfileIDEntity != null)
                    {
                        if (attGradeByProfileIDEntity.GradeAttendanceID != lstGradeAttByProfileID.ID)
                        {
                            var gradeAttEntity = new Att_GradeEntity
                            {
                                //ID = lstAttGradeByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                            };
                            message = attGradeService.Add(gradeAttEntity);
                        }
                    }
                    else
                    {
                        var gradeAttEntity = new Att_GradeEntity
                        {
                            //ID = lstAttGradeByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                            ProfileID = contract.ProfileID,
                            GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                            MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                        };
                        message = attGradeService.Add(gradeAttEntity);
                    }


                    #endregion

                    #region Xử Lý Lương BHXH
                    if (contractTypeEntity.NoneTypeInsuarance == true)
                    {
                        var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                        var insuranceEntity = new Sal_InsuranceSalaryEntity
                        {
                            ProfileID = contract.ProfileID,
                            InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                            DateEffect = contract.DateEnd.Value.AddDays(1),
                            IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                            IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                            IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                            CurrencyID = lstCurrencyNew.ID,

                        };

                        if (insuranceEntityByProfileID != null)
                        {
                            insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                            insuranceEntityByProfileID.IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance;
                            insuranceEntityByProfileID.IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance;
                            insuranceEntityByProfileID.IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance;
                            message = insuranceServices.Edit(insuranceEntityByProfileID);
                        }
                        else
                        {
                            message = insuranceServices.Add(insuranceEntity);
                        }
                    }
                    if (contractTypeEntity.NoneTypeInsuarance == false)
                    {
                        var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID != null && s.ContractTypeID.Value == contractTypeEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                        if (insuranceConfigEntity != null)
                        {
                            var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                            var insuranceEntity = new Sal_InsuranceSalaryEntity
                            {
                                ProfileID = contract.ProfileID,
                                InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                DateEffect = contract.DateEnd.Value.AddDays(1),
                                IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                                IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                                IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                                CurrencyID = lstCurrencyNew.ID
                            };
                            if (insuranceEntityByProfileID != null)
                            {
                                insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                insuranceEntityByProfileID.IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial;
                                insuranceEntityByProfileID.IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy;
                                insuranceEntityByProfileID.IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth;
                                message = insuranceServices.Edit(insuranceEntityByProfileID);
                            }
                            else
                            {
                                message = insuranceServices.Add(insuranceEntity);
                            }
                        }
                    }
                    #endregion

                }
            }

            return message;
            //   return null;
        }
示例#5
0
        public ActionResult UpdateDataForProfileWaiting(string SalaryClassName, string ProfileIDs, DateTime? DateEndProbation,
            DateTime DateHire, Guid OrgStructureID, Guid? SalaryRankID, Guid? WorkPlaceID, Guid ContractTypeID, string BasicSalary,
            Guid? GradePayrollID, Guid? GradeAttendanceID,

            Guid? jobTitleID, Guid? positionID, Guid? allowanceID1, Guid? allowanceID2, Guid? allowanceID3, Guid? allowanceID4, Guid? allowanceID5,
            double? allowance1, double? allowance2, double? allowance3, double? allowance4, double? allowance5, Guid? currencyID, double? insuranceSalary, string codeEmp)
        {
            var profileSevices = new Hre_ProfileServices();
            string message = string.Empty;
            string status = string.Empty;
            var actionService = new ActionService(UserLogin);
            var workingHistoryServices = new Hre_WorkHistoryServices();
            var basicSalaryServices = new Sal_BasicSalaryServices();
            var insServices = new Sal_InsuranceSalaryServices();
            var attGradeServices = new Att_GradeServices();
            var salGradeServices = new Sal_GradeServices();
            var contractServices = new Hre_ContractServices();
            var contractTypeServices = new Cat_ContractTypeServices();
            var currencyServices = new Cat_CurrencyServices();
            var settingServices = new Sys_AllSettingServices();

            var lstProfiles = actionService.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_hr_sp_get_ProfileByIds, ref status);

            var candidateServices = new Hre_CandidateGeneralServices();
            var lstCandidateGeneral = actionService.GetData<Hre_CandidateGeneralEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_hr_sp_get_CandidateGeneralByProfileIDs, ref status).ToList();

            var salaryRankServices = new Cat_SalaryRankServices();
            var lstObjRank = new List<object>();
            lstObjRank.Add(null);
            lstObjRank.Add(null);
            lstObjRank.Add(1);
            lstObjRank.Add(int.MaxValue - 1);
            var lstRank = actionService.GetData<Cat_SalaryRankEntity>(lstObjRank, ConstantSql.hrm_cat_sp_get_SalaryRank, ref status).ToList();
            var rankEntity = lstRank.Where(s => s.ID == SalaryRankID).FirstOrDefault();

            Cat_SalaryClassEntity salaryClassEntity = null;
            if (rankEntity != null)
            {
                var salaryClassServices = new Cat_SalaryClassServices();
                var lstObjClass = new List<object>();
                lstObjClass.Add(null);
                lstObjClass.Add(1);
                lstObjClass.Add(int.MaxValue - 1);
                var salaryClass = actionService.GetData<Cat_SalaryClassEntity>(lstObjClass, ConstantSql.hrm_cat_sp_get_SalaryClass, ref status).ToList();
                salaryClassEntity = salaryClass.Where(s => rankEntity.SalaryClassID == s.ID).FirstOrDefault();
            }

            var lstObjContractType = new List<object>();
            lstObjContractType.AddRange(new object[6]);
            lstObjContractType[4] = 1;
            lstObjContractType[5] = int.MaxValue - 1;
            var lstContractType = actionService.GetData<Cat_ContractTypeEntity>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, ref status).ToList();

            var lstProfile = new List<Hre_ProfileEntity>();
            var workplaceServices = new Cat_WorkPlaceServices();
            var workplace = actionService.GetData<Cat_WorkPlaceEntity>(Common.DotNetToOracle(WorkPlaceID.ToString()), ConstantSql.hrm_cat_sp_get_WorkPlaceById, ref status).FirstOrDefault();

            var lstAttGrade = actionService.GetData<Att_GradeEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_sal_sp_get_Att_GradeByProfileIds, ref status).ToList();

            var lstSalGrade = actionService.GetData<Sal_GradeEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_sal_sp_get_Sal_GradeByProfileIds, ref status).ToList();

            var lstBasicSalary = actionService.GetData<Sal_BasicSalaryEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_sal_sp_get_BasicSalaryByProfileIds, ref status).ToList();

            var lstInsuranceSalary = actionService.GetData<Sal_InsuranceSalaryEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_sal_sp_get_InsuranceSalaryByProfileIds, ref status).ToList();

            var lstWorkingHistory = actionService.GetData<Hre_WorkHistoryEntity>(Common.DotNetToOracle(ProfileIDs), ConstantSql.hrm_hr_sp_get_WorkHistoryByProfileIds, ref status).ToList();

            foreach (var item in lstProfiles)
            {
                var candidateGeneralByProfile = lstCandidateGeneral.Where(s => s.ProfileID.Value == item.ID).FirstOrDefault();

                var objContract = new List<object>();
                var lstContractByProfileID = actionService.GetData<Hre_ContractEntity>(Common.DotNetToOracle(item.ID.ToString()), ConstantSql.hrm_hr_sp_get_ContractsByProfileId, ref status);
                var listIdContract = string.Empty;
                if (lstContractByProfileID != null)
                {
                    listIdContract = string.Join(",", lstContractByProfileID.Select(d => d.ContractTypeID));
                }
                var contractType = lstContractType.Where(s => s.ID == ContractTypeID).FirstOrDefault();
                DateTime dateEnd = DateHire;
                if (contractType != null)
                {
                    if (contractType.ValueTime != null)
                    {
                        if (contractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_MONTH.ToString())
                        {
                            dateEnd = DateHire.AddMonths(int.Parse(contractType.ValueTime.Value.ToString()));
                        }
                        else if (contractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                        {
                            dateEnd = DateHire.AddYears(int.Parse(contractType.ValueTime.Value.ToString()));
                        }
                    }
                }
                double Salary = 0;
                if (!string.IsNullOrEmpty(BasicSalary))
                    Salary = double.Parse(BasicSalary);
                if (candidateGeneralByProfile == null)
                {
                    #region Add CandidateGeneral
                    Hre_CandidateGeneralEntity candidateGeneral = new Hre_CandidateGeneralEntity();
                    candidateGeneral.ProfileID = item.ID;
                    candidateGeneral.BasicSalary = Salary;
                    candidateGeneral.RankRateID = SalaryRankID;
                    if (salaryClassEntity != null)
                    {
                        candidateGeneral.SalaryClassID = salaryClassEntity.ID;
                    }
                    candidateGeneral.ContractTypeID = ContractTypeID;
                    candidateGeneral.EnteringDate = DateHire;
                    candidateGeneral.OrgStructureID = OrgStructureID;
                    candidateGeneral.GradeAttendanceID = GradeAttendanceID;
                    candidateGeneral.GradePayrollID = GradePayrollID;
                    candidateGeneral.WorkPlaceID = WorkPlaceID;
                    candidateGeneral.JobTitleID = jobTitleID;
                    candidateGeneral.PositionID = positionID;
                    candidateGeneral.AllowanceID1 = allowanceID1;
                    candidateGeneral.AllowanceID2 = allowanceID2;
                    candidateGeneral.AllowanceID3 = allowanceID3;
                    candidateGeneral.AllowanceID4 = allowanceID4;
                    candidateGeneral.AllowanceID5 = allowanceID5;
                    candidateGeneral.Allowance1 = allowance1;
                    candidateGeneral.Allowance2 = allowance2;
                    candidateGeneral.Allowance3 = allowance3;
                    candidateGeneral.Allowance4 = allowance4;
                    candidateGeneral.Allowance5 = allowance5;
                    candidateGeneral.CurrencyID = currencyID;
                    candidateGeneral.CodeEmp = codeEmp;
                    message = candidateServices.Add(candidateGeneral);

                    #endregion

                    #region Add Contract
                    //Add new contract

                    Hre_ContractEntity Contract = new Hre_ContractEntity();
                    Contract.ProfileID = item.ID;
                    Contract.Salary = Salary;
                    Contract.ContractTypeID = ContractTypeID;
                    Contract.DateStart = DateHire;
                    Contract.DateSigned = DateHire;
                    Contract.RankRateID = SalaryRankID;
                    if (salaryClassEntity != null)
                    {
                        Contract.ClassRateID = salaryClassEntity.ID;
                    }

                    Contract.InsuranceAmount = insuranceSalary;
                    Contract.AllowanceID1 = allowanceID1;
                    Contract.AllowanceID2 = allowanceID2;
                    Contract.AllowanceID3 = allowanceID3;
                    Contract.AllowanceID4 = allowanceID4;
                    Contract.Allowance1 = allowance1;
                    Contract.Allowance2 = allowance2;
                    Contract.Allowance3 = allowance3;
                    Contract.Allowance4 = allowance4;
                    Contract.Allowance = allowance5;

                    Contract.CurenncyID = currencyID;
                    Contract.CurenncyID1 = currencyID;
                    Contract.CurenncyID2 = currencyID;
                    Contract.CurenncyID3 = currencyID;
                    Contract.CurenncyIDSalary = currencyID;
                    Contract.CurenncyID4 = currencyID;
                    Contract.CurenncyID5 = currencyID;
                    Contract.Status = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_WAITING.ToString();
                    Contract.JobTitleID = jobTitleID;
                    Contract.PositionID = positionID;

                    if (!string.IsNullOrEmpty(contractType.Formula))
                    {
                        Contract = SetNewDateEndContract(Contract);
                    }
                    Contract.DateExtend = Contract.DateEnd;
                    //   Contract = SetNewCodeContract(Contract, listIdContract);
                    message = contractServices.Add(Contract);
                    #endregion

                    #region Edit Profile
                    //Edit Profile
                    item.OrgStructureID = OrgStructureID;
                    if (salaryClassEntity != null)
                    {
                        item.SalaryClassID = salaryClassEntity.ID;
                    }
                    item.DateOfEffect = DateHire;
                    item.DateHire = DateHire;
                    item.DateEndProbation = Contract.DateEnd.Value;
                    item.WorkPlaceID = WorkPlaceID;
                    item.ContractTypeID = ContractTypeID;
                    item.CodeEmp = codeEmp;
                    item.StatusSyn = ProfileStatusSyn.E_WAITING.ToString();

                    message = profileSevices.Edit(item);
                    #endregion

                    #region Add Sal_Insurance
                    // Add Insurance
                    if (contractType != null && contractType.NoneTypeInsuarance == true)
                    {
                        var insuranceEntity = new Sal_InsuranceSalaryEntity
                        {
                            ProfileID = item.ID,
                            InsuranceAmount = insuranceSalary,
                            DateEffect = DateHire,
                            IsSocialIns = contractType.IsSocialInsurance == null ? null : contractType.IsSocialInsurance,
                            IsUnimploymentIns = contractType.IsUnEmployInsurance == null ? null : contractType.IsUnEmployInsurance,
                            IsMedicalIns = contractType.IsHealthInsurance == null ? null : contractType.IsHealthInsurance,
                            CurrencyID = currencyID
                        };
                        message = insServices.Add(insuranceEntity);
                    }
                    #endregion

                    #region Add Sal_BasicSalary
                    Sal_BasicSalaryEntity basicSalaryEntity = new Sal_BasicSalaryEntity();
                    basicSalaryEntity.ProfileID = item.ID;
                    basicSalaryEntity.GrossAmount = BasicSalary;
                    basicSalaryEntity.Amount = BasicSalary.Encrypt();
                    basicSalaryEntity.DateOfEffect = DateHire;
                    basicSalaryEntity.RankRateID = SalaryRankID;
                    basicSalaryEntity.CurrencyID = currencyID.Value;
                    if (salaryClassEntity != null)
                    {
                        basicSalaryEntity.ClassRateID = salaryClassEntity.ID;
                    }

                    basicSalaryEntity.AllowanceType1ID = allowanceID1;
                    basicSalaryEntity.AllowanceType2ID = allowanceID2;
                    basicSalaryEntity.AllowanceType3ID = allowanceID3;
                    basicSalaryEntity.AllowanceType4ID = allowanceID4;
                    basicSalaryEntity.AllowanceTypeID5 = allowanceID5;

                    basicSalaryEntity.AllowanceAmount1 = allowance1;
                    basicSalaryEntity.AllowanceAmount2 = allowance2;
                    basicSalaryEntity.AllowanceAmount3 = allowance3;
                    basicSalaryEntity.AllowanceAmount4 = allowance4;
                    basicSalaryEntity.AllowanceAmount5 = allowance5;

                    basicSalaryEntity.CurrencyID5 = currencyID;
                    basicSalaryEntity.CurrencyID2 = currencyID;
                    basicSalaryEntity.CurrencyID3 = currencyID;
                    basicSalaryEntity.CurrencyID4 = currencyID;
                    if (insuranceSalary != null)
                    {
                        basicSalaryEntity.InsuranceAmount = insuranceSalary.Value;
                    }

                    message = basicSalaryServices.Add(basicSalaryEntity);
                    #endregion

                    #region Add WorkHistory
                    Hre_WorkHistoryEntity workHistory = new Hre_WorkHistoryEntity();
                    workHistory.ProfileID = item.ID;
                    workHistory.DateEffective = DateHire;
                    if (salaryClassEntity != null)
                    {
                        workHistory.SalaryClassID = salaryClassEntity.ID;
                    }
                    workHistory.OrganizationStructureID = OrgStructureID;
                    workHistory.WorkLocation = workplace != null ? workplace.WorkPlaceName : null;
                    workHistory.JobTitleID = jobTitleID;
                    workHistory.PositionID = positionID;

                    message = workingHistoryServices.Add(workHistory);
                    #endregion

                    #region Add Att_Grade
                    Att_GradeEntity attGradeEntity = new Att_GradeEntity();
                    attGradeEntity.ProfileID = item.ID;
                    attGradeEntity.GradeAttendanceID = GradeAttendanceID;
                    attGradeEntity.MonthStart = DateHire;
                    message = attGradeServices.Add(attGradeEntity);
                    #endregion

                    #region Add Sal_Grade
                    Sal_GradeEntity salGradeEntity = new Sal_GradeEntity();
                    salGradeEntity.ProfileID = item.ID;
                    salGradeEntity.GradePayrollID = GradePayrollID;
                    salGradeEntity.MonthStart = DateHire;
                    message = salGradeServices.Add(salGradeEntity);
                    #endregion

                }
                else
                {
                    #region Edit CandidateGeneral

                    candidateGeneralByProfile.ProfileID = item.ID;
                    candidateGeneralByProfile.BasicSalary = Salary;
                    candidateGeneralByProfile.RankRateID = SalaryRankID;
                    if (salaryClassEntity != null)
                    {
                        candidateGeneralByProfile.SalaryClassID = salaryClassEntity.ID;
                    }
                    candidateGeneralByProfile.ContractTypeID = ContractTypeID;
                    candidateGeneralByProfile.EnteringDate = DateHire;
                    candidateGeneralByProfile.OrgStructureID = OrgStructureID;
                    candidateGeneralByProfile.GradeAttendanceID = GradeAttendanceID;
                    candidateGeneralByProfile.GradePayrollID = GradePayrollID;
                    candidateGeneralByProfile.WorkPlaceID = WorkPlaceID;
                    candidateGeneralByProfile.JobTitleID = jobTitleID;
                    candidateGeneralByProfile.PositionID = positionID;
                    candidateGeneralByProfile.AllowanceID1 = allowanceID1;
                    candidateGeneralByProfile.AllowanceID2 = allowanceID2;
                    candidateGeneralByProfile.AllowanceID3 = allowanceID3;
                    candidateGeneralByProfile.AllowanceID4 = allowanceID4;
                    candidateGeneralByProfile.AllowanceID5 = allowanceID5;
                    candidateGeneralByProfile.Allowance1 = allowance1;
                    candidateGeneralByProfile.Allowance2 = allowance2;
                    candidateGeneralByProfile.Allowance3 = allowance3;
                    candidateGeneralByProfile.Allowance4 = allowance4;
                    candidateGeneralByProfile.Allowance5 = allowance5;
                    candidateGeneralByProfile.CurrencyID = currencyID;
                    candidateGeneralByProfile.CodeEmp = codeEmp;
                    message = candidateServices.Edit(candidateGeneralByProfile);

                    #endregion

                    #region Edit Contract
                    if (lstContractByProfileID != null)
                    {
                        var contractEntityByProfileID = lstContractByProfileID.FirstOrDefault();
                        if (contractEntityByProfileID != null)
                        {
                            contractEntityByProfileID.Salary = Salary;
                            contractEntityByProfileID.ContractTypeID = ContractTypeID;
                            contractEntityByProfileID.DateStart = DateHire;
                            contractEntityByProfileID.DateSigned = DateHire;
                            contractEntityByProfileID.DateEnd = dateEnd;
                            contractEntityByProfileID.RankRateID = SalaryRankID;
                            if (salaryClassEntity != null)
                            {
                                contractEntityByProfileID.ClassRateID = salaryClassEntity.ID;
                            }

                            contractEntityByProfileID.InsuranceAmount = insuranceSalary;
                            contractEntityByProfileID.AllowanceID1 = allowanceID1;
                            contractEntityByProfileID.AllowanceID2 = allowanceID2;
                            contractEntityByProfileID.AllowanceID3 = allowanceID3;
                            contractEntityByProfileID.AllowanceID4 = allowanceID4;
                            contractEntityByProfileID.Allowance1 = allowance1;
                            contractEntityByProfileID.Allowance2 = allowance2;
                            contractEntityByProfileID.Allowance3 = allowance3;
                            contractEntityByProfileID.Allowance4 = allowance4;
                            contractEntityByProfileID.Allowance = allowance5;
                            contractEntityByProfileID.CurenncyID = currencyID;
                            contractEntityByProfileID.CurenncyID1 = currencyID;
                            contractEntityByProfileID.CurenncyID2 = currencyID;
                            contractEntityByProfileID.CurenncyID3 = currencyID;
                            contractEntityByProfileID.CurenncyIDSalary = currencyID;
                            contractEntityByProfileID.CurenncyID4 = currencyID;
                            contractEntityByProfileID.CurenncyID5 = currencyID;
                            contractEntityByProfileID.Status = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_WAITING.ToString();
                            contractEntityByProfileID.JobTitleID = jobTitleID;
                            contractEntityByProfileID.PositionID = positionID;
                            if (!string.IsNullOrEmpty(contractType.Formula))
                            {
                                contractEntityByProfileID = SetNewDateEndContract(contractEntityByProfileID);
                            }
                            if (contractEntityByProfileID.DateExtend == null)
                            {
                                contractEntityByProfileID.DateExtend = dateEnd;
                            }
                            message = contractServices.Edit(contractEntityByProfileID);
                            if (contractEntityByProfileID.DateEnd != null)
                            {
                                item.DateEndProbation = contractEntityByProfileID.DateEnd.Value;
                            }
                        }
                    }

                    #endregion

                    #region Edit Profile
                    //Edit Profile
                    item.OrgStructureID = OrgStructureID;
                    if (salaryClassEntity != null)
                    {
                        item.SalaryClassID = salaryClassEntity.ID;
                    }
                    item.DateOfEffect = DateHire;
                    item.DateHire = DateHire;
                    item.WorkPlaceID = WorkPlaceID;
                    item.ContractTypeID = ContractTypeID;
                    item.StatusSyn = ProfileStatusSyn.E_WAITING.ToString();
                    item.CodeEmp = codeEmp;
                    message = profileSevices.Edit(item);
                    #endregion

                    #region Edit Sal_Insurance
                    var insSalaryEntityByProfileID = lstInsuranceSalary.Where(s => s.ProfileID == item.ID).OrderBy(s => s.DateUpdate).FirstOrDefault();
                    if (insSalaryEntityByProfileID != null)
                    {
                        if (contractType != null && contractType.NoneTypeInsuarance == true)
                        {
                            insSalaryEntityByProfileID.InsuranceAmount = insuranceSalary;
                            insSalaryEntityByProfileID.DateEffect = DateHire;
                            insSalaryEntityByProfileID.IsSocialIns = contractType.IsSocialInsurance == null ? null : contractType.IsSocialInsurance;
                            insSalaryEntityByProfileID.IsUnimploymentIns = contractType.IsUnEmployInsurance == null ? null : contractType.IsUnEmployInsurance;
                            insSalaryEntityByProfileID.IsMedicalIns = contractType.IsHealthInsurance == null ? null : contractType.IsHealthInsurance;
                            insSalaryEntityByProfileID.CurrencyID = currencyID;

                            message = insServices.Edit(insSalaryEntityByProfileID);
                        }
                    }
                    #endregion

                    #region Edit Sal_BasicSalary
                    var basicSalaryEntityByProfileID = lstBasicSalary.Where(s => s.ProfileID == item.ID).FirstOrDefault();
                    if (basicSalaryEntityByProfileID != null)
                    {
                        basicSalaryEntityByProfileID.GrossAmount = BasicSalary;
                        basicSalaryEntityByProfileID.Amount = BasicSalary.Encrypt();
                        basicSalaryEntityByProfileID.DateOfEffect = DateHire;
                        basicSalaryEntityByProfileID.RankRateID = SalaryRankID;
                        if (salaryClassEntity != null)
                        {
                            basicSalaryEntityByProfileID.ClassRateID = salaryClassEntity.ID;
                        }
                        basicSalaryEntityByProfileID.CurrencyID = currencyID.Value;
                        basicSalaryEntityByProfileID.AllowanceType1ID = allowanceID1;
                        basicSalaryEntityByProfileID.AllowanceType2ID = allowanceID2;
                        basicSalaryEntityByProfileID.AllowanceType3ID = allowanceID3;
                        basicSalaryEntityByProfileID.AllowanceType4ID = allowanceID4;
                        basicSalaryEntityByProfileID.AllowanceTypeID5 = allowanceID5;
                        basicSalaryEntityByProfileID.AllowanceAmount1 = allowance1;
                        basicSalaryEntityByProfileID.AllowanceAmount2 = allowance2;
                        basicSalaryEntityByProfileID.AllowanceAmount3 = allowance3;
                        basicSalaryEntityByProfileID.AllowanceAmount4 = allowance4;
                        basicSalaryEntityByProfileID.AllowanceAmount5 = allowance5;
                        basicSalaryEntityByProfileID.CurrencyID5 = currencyID;
                        basicSalaryEntityByProfileID.CurrencyID2 = currencyID;
                        basicSalaryEntityByProfileID.CurrencyID3 = currencyID;
                        basicSalaryEntityByProfileID.CurrencyID4 = currencyID;
                        if (insuranceSalary != null)
                        {
                            basicSalaryEntityByProfileID.InsuranceAmount = insuranceSalary.Value;
                        }
                        message = basicSalaryServices.Edit(basicSalaryEntityByProfileID);
                    }
                    #endregion

                    #region Edit WorkingHistory
                    var workingByProfileID = lstWorkingHistory.Where(s => s.ProfileID == item.ID).FirstOrDefault();
                    if (workingByProfileID != null)
                    {
                        workingByProfileID.DateEffective = DateHire;
                        if (salaryClassEntity != null)
                        {
                            workingByProfileID.SalaryClassID = salaryClassEntity.ID;
                        }
                        workingByProfileID.OrganizationStructureID = OrgStructureID;
                        workingByProfileID.WorkLocation = workplace != null ? workplace.WorkPlaceName : null;
                        workingByProfileID.JobTitleID = jobTitleID;
                        workingByProfileID.PositionID = positionID;
                        message = workingHistoryServices.Edit(workingByProfileID);
                    }
                    #endregion

                    #region Edit Att_Grade
                    var attGradeEntityByProfileID = lstAttGrade.Where(s => s.ProfileID == item.ID).FirstOrDefault();
                    if (attGradeEntityByProfileID != null)
                    {
                        attGradeEntityByProfileID.GradeAttendanceID = GradeAttendanceID;
                        attGradeEntityByProfileID.MonthStart = DateHire;
                        message = attGradeServices.Edit(attGradeEntityByProfileID);
                    }
                    #endregion

                    #region Edit Sal_Grade
                    var salGradeEntityByProfileID = lstSalGrade.Where(s => s.ProfileID == item.ID).FirstOrDefault();
                    if (salGradeEntityByProfileID != null)
                    {
                        salGradeEntityByProfileID.GradePayrollID = GradePayrollID;
                        salGradeEntityByProfileID.MonthStart = DateHire;
                        message = salGradeServices.Edit(salGradeEntityByProfileID);
                    }
                    #endregion
                }
            }


            return Json(message, JsonRequestBehavior.AllowGet);
        }
示例#6
0
        public ActionResult ActionApplyCandidateGeneral(string selectedIds)
        {
            string message = NotificationType.Success.ToString();
            var actionService = new ActionService(UserLogin);
            string status = string.Empty;
            var lstCandidateGeneral = actionService.GetData<Hre_CandidateGeneralEntity>(Common.DotNetToOracle(selectedIds), ConstantSql.hrm_hr_sp_get_GeneralCandidateByIds, ref status);
            var salaryRankServices = new Cat_SalaryRankServices();
            var salaryClassServices = new Cat_SalaryClassServices();
            var profileServices = new Hre_ProfileServices();
            var contracttypeServices = new Cat_ContractTypeServices();
            var workHistoryServices = new Hre_WorkHistoryServices();
            var rankEntity = new Cat_SalaryRankEntity();
            var salaryClass = new Cat_SalaryClassEntity();
            var contractypeentity = new Cat_ContractTypeEntity();
            ActionService service = new ActionService(UserLogin);
            var salgradeServices = new Sal_GradeServices();
            var attgradeservive = new Att_GradeServices();

            foreach (var CandidateGeneral in lstCandidateGeneral)
            {
                #region Code Cũ
                //var datecontract = DateTime.Now;
                //if (CandidateGeneral.EnteringDate != null)
                //{
                //    datecontract = CandidateGeneral.EnteringDate.Value;
                //}
                //if (CandidateGeneral.RankRateID != Guid.Empty)
                //{
                //    rankEntity = service.GetByIdUseStore<Cat_SalaryRankEntity>(CandidateGeneral.RankRateID.Value,
                //                        ConstantSql.hrm_cat_sp_get_SalaryRankById, ref status);
                //}
                //if(CandidateGeneral.ContractTypeID != Guid.Empty)
                //{
                //    contractypeentity = service.GetByIdUseStore<Cat_ContractTypeEntity>(CandidateGeneral.ContractTypeID.Value, ConstantSql.hrm_cat_sp_get_ContractTypeById, ref status);
                //}

                //var profileEntity = profileServices.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(CandidateGeneral.ProfileID.ToString()),
                //        ConstantSql.hrm_hr_sp_get_ProfileById, ref status).FirstOrDefault();

                //if (contractypeentity != null && contractypeentity.ValueTime != null)
                //{
                //    if (contractypeentity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_MONTH.ToString())
                //    {
                //        datecontract = datecontract.AddMonths(int.Parse(contractypeentity.ValueTime.Value.ToString()));
                //    }
                //    else if (contractypeentity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                //    {
                //        datecontract = datecontract.AddYears(int.Parse(contractypeentity.ValueTime.Value.ToString()));
                //    }
                //}

                //if(profileEntity != null)
                //{
                //    profileEntity.OrgStructureID = CandidateGeneral.OrgStructureID;
                //    profileEntity.SalaryClassID = CandidateGeneral.SalaryClassID;
                //    profileEntity.DateHire = CandidateGeneral.EnteringDate;
                //    profileEntity.DateEndProbation = datecontract;
                //    profileEntity.WorkPlaceID = CandidateGeneral.WorkPlaceID;
                //}

                // var workplaceServices = new Cat_WorkPlaceServices();
                // Cat_WorkPlaceEntity workplace = null;
                //if(CandidateGeneral.WorkPlaceID != Guid.Empty)
                //{
                //workplace = workplaceServices.GetData<Cat_WorkPlaceEntity>(Common.DotNetToOracle(CandidateGeneral.WorkPlaceID.ToString()), ConstantSql.hrm_cat_sp_get_WorkPlaceById, ref status).FirstOrDefault();
                //}

                //var WorkHistoryEntity = new Hre_WorkHistoryEntity();
                //    WorkHistoryEntity.ProfileID = CandidateGeneral.ProfileID.Value;
                //    WorkHistoryEntity.DateEffective = CandidateGeneral.EnteringDate != null ? CandidateGeneral.EnteringDate.Value ? DateTime.Now;
                //    WorkHistoryEntity.SalaryClassID = CandidateGeneral.SalaryClassID;
                //    WorkHistoryEntity.OrganizationStructureID = CandidateGeneral.OrgStructureID;
                //    WorkHistoryEntity.WorkLocation = workplace != null ? workplace.WorkPlaceName : null;
                //    workHistoryServices.Add(WorkHistoryEntity);
                //} 
                #endregion

                var datecontract = DateTime.Now;
                if (CandidateGeneral.ContractTypeID != Guid.Empty)
                {
                    contractypeentity = actionService.GetData<Cat_ContractTypeEntity>(Common.DotNetToOracle(CandidateGeneral.ContractTypeID.ToString()),
                        ConstantSql.hrm_cat_sp_get_ContractTypeById, ref status).FirstOrDefault();
                }

                if (contractypeentity != null && contractypeentity.ValueTime != null)
                {
                    if (contractypeentity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_MONTH.ToString())
                    {
                        datecontract = datecontract.AddMonths(int.Parse(contractypeentity.ValueTime.Value.ToString()));
                    }
                    else if (contractypeentity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                    {
                        datecontract = datecontract.AddYears(int.Parse(contractypeentity.ValueTime.Value.ToString()));
                    }
                }
                profileServices.UpdateSalaryClassNameForProfile(null, CandidateGeneral.ProfileID.ToString(), datecontract, CandidateGeneral.EnteringDate.Value,
                    CandidateGeneral.OrgStructureID.Value, CandidateGeneral.RankRateID.Value, CandidateGeneral.WorkPlaceID.Value, CandidateGeneral.ContractTypeID.Value,
                    CandidateGeneral.BasicSalary.ToString(), UserLogin);
                //  profileServices.AddDataForContract(CandidateGeneral.BasicSalary.ToString(), CandidateGeneral.ProfileID.ToString(), CandidateGeneral.ContractTypeID.Value, CandidateGeneral.EnteringDate.Value, CandidateGeneral.RankRateID.Value);
                salgradeServices.AddDataForGrade(CandidateGeneral.ProfileID.ToString(), CandidateGeneral.GradePayrollID.Value, CandidateGeneral.EnteringDate.Value);
                attgradeservive.AddDataForGrade(CandidateGeneral.ProfileID.ToString(), CandidateGeneral.GradeAttendanceID.Value, CandidateGeneral.EnteringDate.Value);
            }
            return Json(message, JsonRequestBehavior.AllowGet);
        }
示例#7
0
 public Att_GradeEntity GetGradeByProfileId(Guid ProfileID,DateTime WorkDate)
 {
     List<Guid> lstProfileID = new List<Guid>();
     lstProfileID.Add(ProfileID);
     Att_GradeServices _grateService = new Att_GradeServices();
  
     var templstGrade = Att_GradeServices.getAllGrade(lstProfileID, WorkDate);
     Att_GradeEntity objGrade = new Att_GradeEntity();
     if (templstGrade != null)
     {
         string status = string.Empty;
         List<Att_GradeEntity> lstGrade = templstGrade.Translate<Att_GradeEntity>();
          objGrade = lstGrade.FirstOrDefault();
     }
     return objGrade;
 }