public Hre_AppendixContractModel Post([Bind]Hre_AppendixContractModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_AppendixContractModel>(model, "Hre_AppendixContract", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            #endregion
            if (model.AppendixCreateBasicSalary == true)
            {
                Sal_BasicSalaryServices salaryservices = new Sal_BasicSalaryServices();
                Sal_BasicSalaryEntity basicSalaryBycontract = new Sal_BasicSalaryEntity();

                basicSalaryBycontract.ProfileID = model.ProfileID.Value;
                basicSalaryBycontract.GrossAmount = model.Salary != null ? model.Salary.ToString() : "0";
                basicSalaryBycontract.CurrencyID = model.CurenncyID != null ? model.CurenncyID.Value : Guid.Empty;
                basicSalaryBycontract.PersonalRate = model.PersonalRate;
                if (model.DateofEffect != null)
                {
                    basicSalaryBycontract.DateOfEffect = model.DateofEffect.Value;
                }

                basicSalaryBycontract.InsuranceAmount = model.InsuranceAmount != null ? model.InsuranceAmount.Value : 0;
                basicSalaryBycontract.CurrencyID1 = model.CurenncyID1;

                basicSalaryBycontract.ClassRateID = model.ClassRateID;
                basicSalaryBycontract.RankRateID = model.RankRateID;

                basicSalaryBycontract.AllowanceType1ID = model.AllowanceID1;
                basicSalaryBycontract.AllowanceAmount1 = model.Allowance1;
                basicSalaryBycontract.CurrencyID2 = model.CurenncyID2;

                basicSalaryBycontract.AllowanceType2ID = model.AllowanceID2;
                basicSalaryBycontract.AllowanceAmount2 = model.Allowance2;
                basicSalaryBycontract.CurrencyID3 = model.CurenncyID3;

                basicSalaryBycontract.AllowanceType3ID = model.AllowanceID3;
                basicSalaryBycontract.AllowanceAmount3 = model.Allowance3;
                basicSalaryBycontract.CurrencyID4 = model.CurenncyIDSalary;

                salaryservices.Add(basicSalaryBycontract);

            }
            var status = string.Empty;
            var contractServices = new Hre_ContractServices();

            var contractEntity = contractServices.GetData<Hre_ContractEntity>(model.ProfileID, ConstantSql.hrm_hr_sp_get_ContractsByProfileId, UserLogin, ref status).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
            if (contractEntity != null)
            {
                model.ContractID = contractEntity.ID;
            }
            else {
                model.ActionStatus = ConstantMessages.WarningProfileHaveNotContract.ToString().TranslateString();
                return model;
            }
         
            ActionService service = new ActionService(UserLogin);
            return service.UpdateOrCreate<Hre_AppendixContractEntity, Hre_AppendixContractModel>(model, model.UserID);
        }
        public DataTable GetReportNotHaveSocial(DateTime? dateFrom, DateTime? dateTo, string OrgStructureID,string userLogin) 
        {
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;

                //string type_COLLECT_SOCIAL_INSURANCE = AppConfig.E_COLLECT_SOCIAL_INSURANCE.ToString();
                //bool _e_PROBATION_NoPay_INSURANCE = false;


                var profileServices = new Hre_ProfileServices();
                DataTable table = GetReportNotHaveSocialSchema();
                var lstObjProfile = new List<object>();
                lstObjProfile.Add(OrgStructureID);
                lstObjProfile.Add(null);
                lstObjProfile.Add(null);
                var lstProfile = profileServices.GetData<Hre_ProfileEntity>(lstObjProfile, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref status).ToList();

                var gradePayrollService = new Cat_GradePayrollServices();
                var lstObjGradePayroll = new List<object>();
                lstObjGradePayroll.Add(null);
                lstObjGradePayroll.Add(null);
                lstObjGradePayroll.Add(1);
                lstObjGradePayroll.Add(int.MaxValue -1);

                var contractServices = new Hre_ContractServices();
                var lstObjContract = new List<object>();
                lstObjContract.AddRange(new object[15]);
                lstObjContract[13] = 1;
                lstObjContract[14] = int.MaxValue -1;


                var provinceServices = new Cat_ProvinceServices();
                var lstObjProvince = new List<object>();
                lstObjProvince.Add(null);
                lstObjProvince.Add(null);
                lstObjProvince.Add(null);
                lstObjProvince.Add(null);
                lstObjProvince.Add(null);
                lstObjProvince.Add(null);
                var lstProvince = provinceServices.GetData<Cat_ProvinceEntity>(lstObjProvince, ConstantSql.hrm_cat_sp_get_Province, userLogin, ref status).ToList();

                foreach (var item in lstProfile)
                {
                    DataRow dr = table.NewRow();
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.ID] = item.ID;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.CodeEmp] = item.CodeEmp == null ? string.Empty : item.CodeEmp;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.ProfileName] = item.ProfileName == null ? string.Empty : item.ProfileName;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_DEPARTMENT] = item.OrgStructureName == null ? string.Empty : item.E_DEPARTMENT;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_DIVISION] = item.OrgStructureName == null ? string.Empty : item.E_DIVISION;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_SECTION] = item.OrgStructureName == null ? string.Empty : item.E_SECTION;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_TEAM] = item.OrgStructureName == null ? string.Empty : item.E_TEAM;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.E_UNIT] = item.OrgStructureName == null ? string.Empty : item.E_UNIT;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.PositionName] = item.PositionName == null ? string.Empty : item.PositionName;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.JobTitleName] = item.JobTitleName == null ? string.Empty : item.JobTitleName;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.EthnicGroupName] = item.EthnicGroupName == null ? string.Empty : item.EthnicGroupName;
                    
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.HealthTreatmentPlace] = item.HealthTreatmentPlace == null ? string.Empty : item.HealthTreatmentPlace;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.HealthTreatmentPlaceCode] = item.HealthTreatmentPlaceCode == null ? string.Empty : item.HealthTreatmentPlaceCode;

                    
                    var province = lstProvince.Where(s => s.ID == item.PlaceOfIssueID).FirstOrDefault();
                    if(province != null)
                    {
                        dr[Ins_ReportNotHaveSocialEntity.FieldNames.IDPOI_Code] = province.Code == null ? string.Empty : province.Code;
                        dr[Ins_ReportNotHaveSocialEntity.FieldNames.IDPOI] = province.ProvinceName == null ? string.Empty : province.ProvinceName;
                    }
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.Origin] = item.Origin == null ? string.Empty : item.Origin;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.PAddress] = item.PAddress == null ? string.Empty : item.PAddress;
                    dr[Ins_ReportNotHaveSocialEntity.FieldNames.TAddress] = item.TAddress == null ? string.Empty : item.TAddress;
                    
                    if (item.DateHire != null)
                    {
                        dr[Ins_ReportNotHaveSocialEntity.FieldNames.DateHire] = item.DateHire.Value;
                    }
                    if (item.DateQuit != null)
                    {
                        dr[Ins_ReportNotHaveSocialEntity.FieldNames.DateHire] = item.DateQuit.Value;
                    }
                    if (item.DateOfBirth != null)
                    {
                        dr[Ins_ReportNotHaveSocialEntity.FieldNames.DateOfBirth] = item.DateOfBirth.Value;
                    }

                    var provinceTreatment = lstProvince.Where(s => s.ID == item.ProvinceInsuranceID).FirstOrDefault();
                    if (provinceTreatment != null)
                    {
                        dr[Ins_ReportNotHaveSocialEntity.FieldNames.PlaceOfTreatmentProvince] = provinceTreatment.Code == null ? string.Empty : provinceTreatment.Code;
                    }
                    table.Rows.Add(dr);

                }
                return table;
            }
            
        }
Exemple #3
0
        public ActionResult SaveProfileIDs([Bind]Hre_ContractModel model)
        {
            #region Validate

            string message_Error = string.Empty;

            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ContractModel>(model, "Hre_Contract", ref message_Error);
            if (!checkValidate)
            {
                model.ActionStatus = message_Error;
                return Json(message_Error, JsonRequestBehavior.AllowGet);
            }
            if (model.ContractEvaType == "E_ANNUAL_EVALUATION")
            {
                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ContractModel>(model, "EvaContractinfo", "Hre_Contract", ref message_Error);
                if (!checkValidate)
                {
                    model.ActionStatus = message_Error;
                    return Json(message_Error, JsonRequestBehavior.AllowGet);
                }
            }

            #endregion
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            List<Guid> lstProfileID = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var ContractServices = new Hre_ContractServices();
            var hrService = new Hre_ProfileServices();
            var actionService = new ActionService(UserLogin);
            if (model.ID == Guid.Empty)
            {
                model.DateExtend = model.DateEnd;
            }

            if (model.ProfileIDs != null && model.ProfileIDs.IndexOf(',') > 1)
            {
                var lstID = model.ProfileIDs.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstProfileID.Add(convertProfileID);
                }
            }

            else
            {
                convertProfileID = Common.ConvertToGuid(model.ProfileIDs);
                lstProfileID.Add(convertProfileID);
            }

            var lstProfile = new List<Hre_ProfileEntity>();
            if (model.ProfileIDs != null)
            {
                lstProfile = actionService.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(model.ProfileIDs), ConstantSql.hrm_hr_sp_get_ProfileByIds, ref status).ToList();
            }
            if (!string.IsNullOrEmpty(model.OrgStructureIDs))
            {
                List<Guid> listGuid = new List<Guid>();
                if (model.ProfileIDs != null)
                {
                    var listStr = model.ProfileIDs.Split(',');

                    if (listStr[0] != "")
                    {

                        foreach (var item in listStr)
                        {
                            listGuid.Add(Guid.Parse(item));
                        }
                    }
                }
                string strIDs = string.Empty;
                List<object> listObj = new List<object>();
                listObj.Add(model.OrgStructureIDs);
                listObj.Add(string.Empty);
                listObj.Add(string.Empty);
                var lstProfileids = actionService.GetData<Hre_ProfileIdEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, ref status).Select(s => s.ID).ToList();
                if (listGuid != null)
                {
                    lstProfileids = lstProfileids.Where(s => !listGuid.Contains(s)).ToList();

                    foreach (var item in lstProfileids)
                    {
                        strIDs += Common.DotNetToOracle(item.ToString()) + ",";
                    }
                    if (strIDs.IndexOf(",") > 0)
                        strIDs = strIDs.Substring(0, strIDs.Length - 1);
                    var lstProfileadd = actionService.GetData<Hre_ProfileEntity>(strIDs, ConstantSql.hrm_hr_sp_get_ProfileByIds, ref status);
                    lstProfile.AddRange(lstProfileadd);
                }
                if (lstProfileids.Count == 0 && model.ProfileID == Guid.Empty)
                {
                    model.ActionStatus = ConstantDisplay.HRM_Common_NotEmployee.TranslateString();
                    return Json(model.ActionStatus, JsonRequestBehavior.AllowGet);
                    lstProfile = lstProfile.Where(s => lstProfileids.Contains(s.ID)).ToList();
                }
            }

            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();

            foreach (var profile in lstProfile)
            {
                model.ProfileID = profile.ID;
                var objContract = new List<object>();
                objContract.Add(model.ProfileID);
                var lstContractByProfileID = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_ContractsByProfileId, ref status);
                var contractTypeEntity = lstContractType.Where(s => s.ID == model.ContractTypeID).FirstOrDefault();
                #region Xử Lý Lương BHXH

                if (contractTypeEntity != null && contractTypeEntity.NoneTypeInsuarance == true)
                {
                    var insuranceEntity = new Sal_InsuranceSalaryEntity
                    {
                        ProfileID = model.ProfileID,
                        InsuranceAmount = model.InsuranceAmount,
                        DateEffect = model.DateStart,
                        IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                        IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                        IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                        CurrencyID = model.CurenncyID1
                    };
                    message = insuranceServices.Add(insuranceEntity);
                }
                if (contractTypeEntity != null && contractTypeEntity.NoneTypeInsuarance == false)
                {
                    var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID == model.ContractTypeID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    if (insuranceConfigEntity != null)
                    {
                        var insuranceEntity = new Sal_InsuranceSalaryEntity
                        {
                            ProfileID = model.ProfileID,
                            InsuranceAmount = model.InsuranceAmount,
                            DateEffect = model.DateStart,
                            IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                            IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                            IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                            CurrencyID = model.CurenncyID1
                        };
                        message = insuranceServices.Add(insuranceEntity);
                    }
                }
                #endregion
                if (model.CreateBasicSalary == true)
                {
                    Sal_BasicSalaryServices salaryservices = new Sal_BasicSalaryServices();
                    Sal_BasicSalaryEntity basicSalaryBycontract = new Sal_BasicSalaryEntity();

                    basicSalaryBycontract.ProfileID = profile.ID;
                    basicSalaryBycontract.GrossAmount = model.Salary != null ? model.Salary.ToString() : "0";
                    basicSalaryBycontract.CurrencyID = model.CurenncyID != null ? model.CurenncyID.Value : Guid.Empty;
                    basicSalaryBycontract.PersonalRate = model.PersonalRate;
                    basicSalaryBycontract.DateOfEffect = model.DateStart;

                    basicSalaryBycontract.InsuranceAmount = model.InsuranceAmount != null ? model.InsuranceAmount.Value : 0;
                    basicSalaryBycontract.CurrencyID1 = model.CurenncyID1;

                    basicSalaryBycontract.ClassRateID = model.ClassRateID;
                    basicSalaryBycontract.RankRateID = model.RankRateID;

                    basicSalaryBycontract.AllowanceType1ID = model.AllowanceID1;
                    basicSalaryBycontract.AllowanceAmount1 = model.Allowance1;
                    basicSalaryBycontract.CurrencyID2 = model.CurenncyID2;

                    basicSalaryBycontract.AllowanceType2ID = model.AllowanceID2;
                    basicSalaryBycontract.AllowanceAmount2 = model.Allowance2;
                    basicSalaryBycontract.CurrencyID3 = model.CurenncyID3;

                    basicSalaryBycontract.AllowanceType3ID = model.AllowanceID3;
                    basicSalaryBycontract.AllowanceAmount3 = model.Allowance3;
                    basicSalaryBycontract.CurrencyID4 = model.CurenncyIDSalary;

                    salaryservices.Add(basicSalaryBycontract);
                }

                if (model.BasicSalaryForPerson == true)
                {
                    List<object> listObj = new List<object>();
                    listObj.Add(1);
                    listObj.Add(1000);
                    var BasicSalaryServices = new Sal_BasicSalaryServices();
                    var basicSalaryByProfile = actionService.GetData<Sal_BasicSalaryEntity>(Common.DotNetToOracle(profile.ID.ToString()), ConstantSql.hrm_sal_sp_get_BasicSalaryByProfileIds, ref status).FirstOrDefault();
                    Hre_ContractEntity contractgetNo = new Hre_ContractEntity();
                    model.CopyData(contractgetNo);
                    Hre_ContractEntity contract = new Hre_ContractEntity();

                    contract.Allowance = model.Allowance;
                    contract.Allowance1 = model.Allowance1;
                    contract.Allowance2 = model.Allowance2;
                    contract.Allowance3 = model.Allowance3;
                    contract.Allowance4 = model.Allowance4;
                    if (basicSalaryByProfile != null)
                    {
                        contract.AllowanceID1 = basicSalaryByProfile.AllowanceType1ID != null ? basicSalaryByProfile.AllowanceType1ID : null;
                        contract.AllowanceID2 = basicSalaryByProfile.AllowanceType2ID != null ? basicSalaryByProfile.AllowanceType2ID : null;
                        contract.AllowanceID3 = basicSalaryByProfile.AllowanceType3ID != null ? basicSalaryByProfile.AllowanceType3ID : null;
                        contract.AllowanceID4 = basicSalaryByProfile.AllowanceType4ID != null ? basicSalaryByProfile.AllowanceType4ID : null;
                        contract.ClassRateID = basicSalaryByProfile.ClassRateID != null ? basicSalaryByProfile.ClassRateID : null;
                        contract.CurenncyID = basicSalaryByProfile.CurrencyID;
                        contract.CurenncyID1 = basicSalaryByProfile.CurrencyID1 != null ? basicSalaryByProfile.CurrencyID1 : null;
                        contract.CurenncyID2 = basicSalaryByProfile.CurrencyID2 != null ? basicSalaryByProfile.CurrencyID2 : null;
                        contract.CurenncyID3 = basicSalaryByProfile.CurrencyID3 != null ? basicSalaryByProfile.CurrencyID3 : null;
                        contract.CurenncyID4 = basicSalaryByProfile.CurrencyID4 != null ? basicSalaryByProfile.CurrencyID4 : null;
                        contract.CurenncyID5 = basicSalaryByProfile.CurrencyID5 != null ? basicSalaryByProfile.CurrencyID5 : null;
                    }
                    contract.Code = model.Code;
                    contract.CodeEmp = model.CodeEmp;
                    contract.ContractTypeID = model.ContractTypeID;
                    contract.CurenncyIDSalary = model.CurenncyIDSalary;
                    contract.CurenncyInsName = model.CurenncyInsName;
                    contract.CurenncyOAllowanceName = model.CurenncyOAllowanceName;
                    contract.CurrencySalName = model.CurrencySalName;
                    contract.DateAuthorize = model.DateAuthorize;
                    contract.DateCreate = model.DateCreate;
                    contract.DateUpdate = DateTime.Now;
                    contract.DateEnd = model.DateEnd;
                    contract.DateSigned = model.DateSigned;
                    contract.DateStart = model.DateStart;
                    contract.FollowNo = model.FollowNo;
                    contract.FormPaySalary = model.FormPaySalary;
                    contract.HourWorkInMonth = model.HourWorkInMonth;
                    contract.InsuranceAmount = model.InsuranceAmount;
                    contract.IPCreate = model.IPCreate;
                    contract.IPUpdate = model.IPUpdate;
                    contract.JobTitleID = model.JobTitleID;
                    contract.PersonalRate = model.PersonalRate;
                    contract.PositionID = model.PositionID;
                    contract.ProfileID = model.ProfileID;
                    contract.ProfileSingID = model.ProfileSingID;
                    contract.ProfileName = model.ProfileName;
                    contract.ProfileSingName = model.ProfileSingName;
                    contract.QualificationID = model.QualificationID;
                    contract.RankRateID = basicSalaryByProfile.RankRateID;
                    contract.Salary = basicSalaryByProfile == null ? (double?)null : Convert.ToDouble(basicSalaryByProfile.GrossAmount);
                    contract.ClassRateID = basicSalaryByProfile.ClassRateID;
                    contract.SalaryClassTypeID = model.SalaryClassTypeID;
                    contract.ServerCreate = model.ServerCreate;
                    contract.ServerUpdate = model.ServerUpdate;
                    contract.WorkPlaceID = model.WorkPlaceID;
                    contract.NextContractTypeID = model.NextContractTypeID;
                    contract.Remark = model.Remark;
                    contract.RankDetailForNextContract = model.RankDetailForNextContract;
                    contract.ContractEvaType = model.ContractEvaType;
                    contract.DateOfContractEva = model.DateOfContractEva;
                    contract.EvaluationResult = model.EvaluationResult;
                    contract.ContractResult = model.ContractResult;
                    contract.TypeOfPass = model.TypeOfPass;
                    contract.DateEndNextContract = model.DateEndNextContract;
                    contract.DateExtend = model.DateEnd;
                    contract.Status = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_WAITING.ToString();

                    if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                    {
                        contract = SetNewDateEndContract(contract);
                    }
                    //Tạo mã cho hợp đồng
                    //   contract = SetNewCodeContract(contract, listIdContract);
                    if (contract.ID == Guid.Empty)
                    {
                        contract.ActionStatus = ContractServices.Add(contract);
                    }
                    else
                    {
                        contract.ActionStatus = ContractServices.Edit(contract);
                    }

                    return Json(contract, JsonRequestBehavior.AllowGet);
                }

                Hre_ContractEntity contractgetNoGetBasicSalary = new Hre_ContractEntity();
                model.CopyData(contractgetNoGetBasicSalary);
                Hre_ContractEntity contractNoGetBasicSalary = new Hre_ContractEntity();
                contractNoGetBasicSalary.Allowance = model.Allowance;
                contractNoGetBasicSalary.Allowance1 = model.Allowance1;
                contractNoGetBasicSalary.Allowance3 = model.Allowance3;
                contractNoGetBasicSalary.Allowance2 = model.Allowance2;
                contractNoGetBasicSalary.Allowance4 = model.Allowance4;
                contractNoGetBasicSalary.AllowanceID1 = model.AllowanceID1;
                contractNoGetBasicSalary.AllowanceID2 = model.AllowanceID2;
                contractNoGetBasicSalary.AllowanceID3 = model.AllowanceID3;
                contractNoGetBasicSalary.AllowanceID4 = model.AllowanceID4;
                contractNoGetBasicSalary.ClassRateID = model.ClassRateID;
                contractNoGetBasicSalary.ClassRateName = model.ClassRateName;
                contractNoGetBasicSalary.Code = model.Code;
                contractNoGetBasicSalary.CodeEmp = model.CodeEmp;
                contractNoGetBasicSalary.ContractTypeID = model.ContractTypeID;
                contractNoGetBasicSalary.CurenncyID = model.CurenncyID;
                contractNoGetBasicSalary.CurenncyID1 = model.CurenncyID1;
                contractNoGetBasicSalary.CurenncyID2 = model.CurenncyID2;
                contractNoGetBasicSalary.CurenncyID3 = model.CurenncyID3;
                contractNoGetBasicSalary.CurenncyID4 = model.CurenncyID4;
                contractNoGetBasicSalary.CurenncyID5 = model.CurenncyID5;
                contractNoGetBasicSalary.CurenncyIDSalary = model.CurenncyIDSalary;
                contractNoGetBasicSalary.CurenncyInsName = model.CurenncyInsName;
                contractNoGetBasicSalary.CurenncyOAllowanceName = model.CurenncyOAllowanceName;
                contractNoGetBasicSalary.CurrencySalName = model.CurrencySalName;
                contractNoGetBasicSalary.DateAuthorize = model.DateAuthorize;
                contractNoGetBasicSalary.DateCreate = model.DateCreate;
                contractNoGetBasicSalary.DateEnd = model.DateEnd;
                contractNoGetBasicSalary.DateSigned = model.DateSigned;
                contractNoGetBasicSalary.DateStart = model.DateStart;
                contractNoGetBasicSalary.DateUpdate = DateTime.Now;
                contractNoGetBasicSalary.FollowNo = model.FollowNo;
                contractNoGetBasicSalary.FormPaySalary = model.FormPaySalary;
                contractNoGetBasicSalary.HourWorkInMonth = model.HourWorkInMonth;
                contractNoGetBasicSalary.InsuranceAmount = model.InsuranceAmount;
                contractNoGetBasicSalary.IPCreate = model.IPCreate;
                contractNoGetBasicSalary.IPUpdate = model.IPUpdate;
                contractNoGetBasicSalary.JobTitleID = model.JobTitleID;
                contractNoGetBasicSalary.PersonalRate = model.PersonalRate;
                contractNoGetBasicSalary.PositionID = model.PositionID;
                contractNoGetBasicSalary.ProfileID = model.ProfileID;
                contractNoGetBasicSalary.ProfileSingID = model.ProfileSingID;
                contractNoGetBasicSalary.ProfileName = model.ProfileName;
                contractNoGetBasicSalary.ProfileSingName = model.ProfileSingName;
                contractNoGetBasicSalary.QualificationID = model.QualificationID;
                contractNoGetBasicSalary.RankRateID = model.RankRateID;
                contractNoGetBasicSalary.Salary = model.Salary;
                contractNoGetBasicSalary.SalaryClassTypeID = model.SalaryClassTypeID;
                contractNoGetBasicSalary.ServerCreate = model.ServerCreate;
                contractNoGetBasicSalary.ServerUpdate = model.ServerUpdate;
                contractNoGetBasicSalary.WorkPlaceID = model.WorkPlaceID;
                contractNoGetBasicSalary.NextContractTypeID = model.NextContractTypeID;
                contractNoGetBasicSalary.Remark = model.Remark;
                contractNoGetBasicSalary.RankDetailForNextContract = model.RankDetailForNextContract;
                contractNoGetBasicSalary.ContractEvaType = model.ContractEvaType;
                contractNoGetBasicSalary.DateOfContractEva = model.DateOfContractEva;
                contractNoGetBasicSalary.EvaluationResult = model.EvaluationResult;
                contractNoGetBasicSalary.ContractResult = model.ContractResult;
                contractNoGetBasicSalary.TypeOfPass = model.TypeOfPass;
                contractNoGetBasicSalary.DateEndNextContract = model.DateEndNextContract;
                contractNoGetBasicSalary.DateExtend = model.DateEnd;
                contractNoGetBasicSalary.Status = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_WAITING.ToString();


                if (!string.IsNullOrEmpty(contractTypeEntity.Formula))
                {
                    contractNoGetBasicSalary = SetNewDateEndContract(contractNoGetBasicSalary);
                }
                //Tạo mã cho hợp đồng
                // contractNoGetBasicSalary = SetNewCodeContract(contractNoGetBasicSalary, listIdContract);
                if (contractNoGetBasicSalary.ID == Guid.Empty)
                {
                    contractNoGetBasicSalary.ActionStatus = ContractServices.Add(contractNoGetBasicSalary);
                }
                else
                {
                    contractNoGetBasicSalary.ActionStatus = ContractServices.Edit(contractNoGetBasicSalary);
                }

                message = contractNoGetBasicSalary.ActionStatus;
                return Json(contractNoGetBasicSalary, JsonRequestBehavior.AllowGet);

            }
            return Json(null, JsonRequestBehavior.AllowGet);
        }
Exemple #4
0
        public ActionResult SaveContractAndBasicSalary([Bind]Hre_ContractModel model)
        {
            #region Validate

            string message_Error = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ContractModel>(model, "Hre_Contract", ref message_Error);
            if (!checkValidate)
            {
                model.ActionStatus = message_Error;
                return Json(message_Error, JsonRequestBehavior.AllowGet);
            }

            #endregion
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            var insuranceServices = new Sal_InsuranceSalaryServices();
            string message = string.Empty;
            List<Guid> lstProfileID = new List<Guid>();
            var ContractServices = new Hre_ContractServices();

            if (model.ProfileIDs != null && model.ProfileIDs.IndexOf(',') > 1)
            {
                var lstID = model.ProfileIDs.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstProfileID.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.ProfileIDs);
                lstProfileID.Add(convertProfileID);
            }
            List<object> lstObjProfile = new List<object>();
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(1);
            lstObjProfile.Add(int.MaxValue - 1);
            var actionService = new ActionService(UserLogin);
            var lstProfile = actionService.GetData<Hre_ProfileEntity>(lstObjProfile, ConstantSql.hrm_hr_sp_get_ProfileAll, ref status).ToList();
            lstProfile = lstProfile.Where(s => lstProfileID.Contains(s.ID) && s.IsDelete == null).ToList();

            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();

            foreach (var profile in lstProfile)
            {
                model.ProfileID = profile.ID;
                var contractTypeEntity = lstContractType.Where(s => s.ID == model.ContractTypeID).FirstOrDefault();
                #region Xử Lý Lương BHXH

                if (contractTypeEntity != null && contractTypeEntity.NoneTypeInsuarance == true)
                {
                    var insuranceEntity = new Sal_InsuranceSalaryEntity
                    {
                        ProfileID = model.ProfileID,
                        InsuranceAmount = model.InsuranceAmount,
                        DateEffect = model.DateStart,
                        IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                        IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                        IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                        CurrencyID = model.CurenncyID1
                    };
                    message = insuranceServices.Add(insuranceEntity);
                }
                #endregion
                if (model.CreateBasicSalary == true)
                {
                    Sal_BasicSalaryServices salaryservices = new Sal_BasicSalaryServices();
                    Sal_BasicSalaryEntity basicSalaryBycontract = new Sal_BasicSalaryEntity();

                    basicSalaryBycontract.ProfileID = profile.ID;
                    basicSalaryBycontract.GrossAmount = model.Salary != null ? model.Salary.ToString() : "0";
                    basicSalaryBycontract.CurrencyID = model.CurenncyID != null ? model.CurenncyID.Value : Guid.Empty;
                    basicSalaryBycontract.PersonalRate = model.PersonalRate;
                    basicSalaryBycontract.DateOfEffect = model.DateStart;

                    basicSalaryBycontract.InsuranceAmount = model.InsuranceAmount != null ? model.InsuranceAmount.Value : 0;
                    basicSalaryBycontract.CurrencyID1 = model.CurenncyID1;

                    basicSalaryBycontract.ClassRateID = model.ClassRateID;
                    basicSalaryBycontract.RankRateID = model.RankRateID;

                    basicSalaryBycontract.AllowanceType1ID = model.AllowanceID1;
                    basicSalaryBycontract.AllowanceAmount1 = model.Allowance1;
                    basicSalaryBycontract.CurrencyID2 = model.CurenncyID2;

                    basicSalaryBycontract.AllowanceType2ID = model.AllowanceID2;
                    basicSalaryBycontract.AllowanceAmount2 = model.Allowance2;
                    basicSalaryBycontract.CurrencyID3 = model.CurenncyID3;

                    basicSalaryBycontract.AllowanceType3ID = model.AllowanceID3;
                    basicSalaryBycontract.AllowanceAmount3 = model.Allowance3;
                    basicSalaryBycontract.CurrencyID4 = model.CurenncyIDSalary;

                    salaryservices.Add(basicSalaryBycontract);

                }

                if (model.BasicSalaryForPerson == true)
                {
                    List<object> listObj = new List<object>();
                    listObj.Add(1);
                    listObj.Add(1000);
                    var BasicSalaryServices = new Sal_BasicSalaryServices();
                    var lstBasicSalary = actionService.GetData<Sal_BasicSalaryEntity>(listObj, ConstantSql.hrm_sal_sp_get_BasicPayrollGetAll, ref status).Where(s => s.ProfileID == profile.ID && s.DateOfEffect != null).FirstOrDefault();
                    Hre_ContractEntity contractgetNo = new Hre_ContractEntity();
                    model.CopyData(contractgetNo);
                    Hre_ContractEntity contract = new Hre_ContractEntity
                    {
                        ID = model.ID,
                        Allowance = model.Allowance,
                        Allowance1 = model.Allowance1,
                        Allowance3 = model.Allowance3,
                        Allowance2 = model.Allowance2,
                        Allowance4 = model.Allowance4,
                        AllowanceID1 = lstBasicSalary.AllowanceType1ID,
                        AllowanceID2 = lstBasicSalary.AllowanceType2ID,
                        AllowanceID3 = lstBasicSalary.AllowanceType3ID,
                        AllowanceID4 = lstBasicSalary.AllowanceType4ID,
                        ClassRateID = lstBasicSalary.ClassRateID,
                        Code = model.Code,
                        CodeEmp = model.CodeEmp,
                        //ContractNo = getContractNo(contractgetNo, contractgetNo.DateSigned),
                        ContractTypeID = model.ContractTypeID,
                        CurenncyID = lstBasicSalary.CurrencyID,
                        CurenncyID1 = lstBasicSalary.CurrencyID1,
                        CurenncyID2 = lstBasicSalary.CurrencyID2,
                        CurenncyID3 = lstBasicSalary.CurrencyID3,
                        CurenncyID4 = lstBasicSalary.CurrencyID4,
                        CurenncyID5 = lstBasicSalary.CurrencyID5,
                        CurenncyIDSalary = model.CurenncyIDSalary,
                        CurenncyInsName = model.CurenncyInsName,
                        CurenncyOAllowanceName = model.CurenncyOAllowanceName,
                        CurrencySalName = model.CurrencySalName,
                        DateAuthorize = model.DateAuthorize,
                        DateCreate = model.DateCreate,
                        DateUpdate = DateTime.Now,
                        DateEnd = model.DateEnd,
                        DateSigned = model.DateSigned,
                        DateStart = model.DateStart,
                        FollowNo = model.FollowNo,
                        FormPaySalary = model.FormPaySalary,
                        HourWorkInMonth = model.HourWorkInMonth,
                        InsuranceAmount = model.InsuranceAmount,
                        IPCreate = model.IPCreate,
                        IPUpdate = model.IPUpdate,
                        JobTitleID = model.JobTitleID,
                        PersonalRate = model.PersonalRate,
                        PositionID = model.PositionID,
                        ProfileID = model.ProfileID,
                        ProfileSingID = model.ProfileSingID,
                        ProfileName = model.ProfileName,
                        ProfileSingName = model.ProfileSingName,
                        QualificationID = model.QualificationID,
                        RankRateID = lstBasicSalary.RankRateID,
                        Salary = lstBasicSalary == null ? (double?)null : Convert.ToDouble(lstBasicSalary.GrossAmount),
                        SalaryClassTypeID = lstBasicSalary.ClassRateID,
                        ServerCreate = model.ServerCreate,
                        ServerUpdate = model.ServerUpdate,
                        WorkPlaceID = model.WorkPlaceID,
                    };
                    if (contract.ID == Guid.Empty)
                    {
                        contract.ActionStatus = ContractServices.Add(contract);
                    }
                    else
                    {
                        contract.ActionStatus = ContractServices.Edit(contract);
                    }

                    return Json(contract, JsonRequestBehavior.AllowGet);
                }

                Hre_ContractEntity contractgetNoGetBasicSalary = new Hre_ContractEntity();
                model.CopyData(contractgetNoGetBasicSalary);
                Hre_ContractEntity contractNoGetBasicSalary = new Hre_ContractEntity
                {
                    ID = model.ID,
                    Allowance = model.Allowance,
                    Allowance1 = model.Allowance1,
                    Allowance3 = model.Allowance3,
                    Allowance2 = model.Allowance2,
                    Allowance4 = model.Allowance4,
                    AllowanceID1 = model.AllowanceID1,
                    AllowanceID2 = model.AllowanceID2,
                    AllowanceID3 = model.AllowanceID3,
                    AllowanceID4 = model.AllowanceID4,
                    ClassRateID = model.ClassRateID,
                    ClassRateName = model.ClassRateName,
                    Code = model.Code,
                    CodeEmp = model.CodeEmp,
                    // ContractNo = getContractNo(contractgetNoGetBasicSalary, contractgetNoGetBasicSalary.DateSigned),
                    ContractTypeID = model.ContractTypeID,
                    CurenncyID = model.CurenncyID,
                    CurenncyID1 = model.CurenncyID1,
                    CurenncyID2 = model.CurenncyID2,
                    CurenncyID3 = model.CurenncyID3,
                    CurenncyID4 = model.CurenncyID4,
                    CurenncyID5 = model.CurenncyID5,
                    CurenncyIDSalary = model.CurenncyIDSalary,
                    CurenncyInsName = model.CurenncyInsName,
                    CurenncyOAllowanceName = model.CurenncyOAllowanceName,
                    CurrencySalName = model.CurrencySalName,
                    DateAuthorize = model.DateAuthorize,
                    DateCreate = model.DateCreate,
                    DateEnd = model.DateEnd,
                    DateSigned = model.DateSigned,
                    DateStart = model.DateStart,
                    DateUpdate = DateTime.Now,
                    FollowNo = model.FollowNo,
                    FormPaySalary = model.FormPaySalary,
                    HourWorkInMonth = model.HourWorkInMonth,
                    InsuranceAmount = model.InsuranceAmount,
                    IPCreate = model.IPCreate,
                    IPUpdate = model.IPUpdate,
                    JobTitleID = model.JobTitleID,
                    PersonalRate = model.PersonalRate,
                    PositionID = model.PositionID,
                    ProfileID = model.ProfileID,
                    ProfileSingID = model.ProfileSingID,
                    ProfileName = model.ProfileName,
                    ProfileSingName = model.ProfileSingName,
                    QualificationID = model.QualificationID,
                    RankRateID = model.RankRateID,
                    Salary = model.Salary,
                    SalaryClassTypeID = model.SalaryClassTypeID,
                    ServerCreate = model.ServerCreate,
                    ServerUpdate = model.ServerUpdate,
                    WorkPlaceID = model.WorkPlaceID,
                };

                if (contractNoGetBasicSalary.ID == Guid.Empty)
                {
                    contractNoGetBasicSalary.ActionStatus = ContractServices.Add(contractNoGetBasicSalary);
                }
                else
                {
                    contractNoGetBasicSalary.ActionStatus = ContractServices.Edit(contractNoGetBasicSalary);
                }

                return Json(contractNoGetBasicSalary, JsonRequestBehavior.AllowGet);
            }
            return Json(message, JsonRequestBehavior.AllowGet);
        }
Exemple #5
0
        public ActionResult GetExpiryContract([DataSourceRequest] DataSourceRequest request, Hre_ReportExpiryContractModel Model)
        {
            string status = string.Empty;
            var service = new Hre_ReportServices();
            var actionServices = new ActionService(UserLogin);
            var profileServices = new Hre_ProfileServices();
            var contractServices = new Hre_ContractServices();
            BaseService baseServices = new BaseService();
            bool isshowloopcontract = profileServices.IsNotUseExpiryContractLoop();

            var ShowAfterDate1 = actionServices.GetData<Sys_AllSettingEntity>("HRM_HRE_CONTRACT_ALERT_EXPRIDAY_VALUEAFTE", ConstantSql.hrm_sys_sp_get_AllSettingByKey, ref status).FirstOrDefault();
            var ShowBeforDate1 = actionServices.GetData<Sys_AllSettingEntity>("HRM_HRE_CONTRACT_ALERT_EXPRIDAY_VALUEBEFOR", ConstantSql.hrm_sys_sp_get_AllSettingByKey, ref status).FirstOrDefault();
            DateTime? dateTo = null;
            DateTime? dateFrom = null;
            if (isshowloopcontract == false)
            {
                dateTo = DateTime.Now.AddDays(Convert.ToDouble(ShowAfterDate1.Value1));
                dateFrom = DateTime.Now.AddDays(-Convert.ToDouble(ShowBeforDate1.Value1));
            }
            var isDataTable = false;
            object obj = new Hre_ReportExpiryContractModel();
         
            //var lstProfile = new List<Hre_ProfileEntity>();
            var objProfile = new List<object>();
            objProfile.AddRange(new object[2]);
            objProfile[0] = 1;
            objProfile[1] = int.MaxValue - 1;
            var lstProfile = actionServices.GetData<Hre_ProfileEntity>(objProfile, ConstantSql.hrm_hr_sp_get_ProfileDataAll, ref status).ToList();

            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 = actionServices.GetData<CatContractTypeModel>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, ref status).ToList();

            List<object> listObj = new List<object>();
            listObj.Add(Model.OrgStructureID);
            listObj.Add(Model.Status);
            listObj.Add(dateFrom);
            listObj.Add(dateTo);
            listObj.Add(Model.CodeEmp);
            listObj.Add(Model.ProfileName);
            listObj.Add(Model.IDNo);
            listObj.Add(Model.WorkPlaceID);
            listObj.Add(Model.DateSignedFrom);
            listObj.Add(Model.DateSignedTo);
            listObj.Add(Model.ContractNo);
            listObj.Add(1);
            listObj.Add(int.MaxValue - 1);

            var result = actionServices.GetData<Hre_ReportExpiryContractEntity>(listObj, ConstantSql.hrm_hr_sp_get_RptExpireContract, ref status).Where(s => s.StatusEvaluation != WorkdayStatus.E_APPROVED.ToString()).ToList().Translate<Hre_ReportExpiryContractModel>();

           var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContracts = actionServices.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();
           
            Guid[] _RankDetailForNextContract = null;
            if (!string.IsNullOrEmpty(Model.RankDetailForNextContractIds))
            {
                _RankDetailForNextContract = Model.RankDetailForNextContractIds.Split(',').Select(s => Guid.Parse(s)).ToArray();
            }
            if (Model.ContractTypeID != null)
            {
                result = result.Where(s => s.ContractTypeID == Model.ContractTypeID).ToList();
            }
            if (!string.IsNullOrEmpty(Model.Status))
            {
                result = result.Where(s => s.Status == Model.Status).ToList();
            }

            var lstModel = new List<Hre_ReportExpiryContractModel>();


            if (_RankDetailForNextContract != null)
            {
                result = result.Where(s => _RankDetailForNextContract.Contains(s.RankDetailForNextContract != null ? s.RankDetailForNextContract.Value : Guid.Empty)).ToList();
            }

            if (Model.EvaType == EnumDropDown.EvaExpiryContract.E_EVA_CONTRACT.ToString())
            {
                result = result.Where(s => s.StatusEvaluation != WorkdayStatus.E_APPROVED.ToString() && s.ContractResult != null).ToList();
                if (isshowloopcontract == false)
                {
                    var model = new Hre_ReportExpiryContractModel();
                    foreach (var item in result)
                    {
                        var ContractByProfileID = lstContracts.Where(s => s.ProfileID == item.ProfileID).OrderByDescending(s => s.DateCreate).FirstOrDefault();
                        if (ContractByProfileID != null)
                        {
                            if (ContractByProfileID.DateCreate != null && ContractByProfileID.DateCreate.Value.ToShortDateString() != DateTime.Now.ToShortDateString())
                            {
                                if (item.DateExtend != null && item.DateExtend >= dateFrom && item.DateExtend <= dateTo)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                                if (item.DateExtend == null && item.DateEnd != null && item.DateEnd >= dateFrom && item.DateEnd <= dateTo)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in result)
                    {
                        var dateSenior = new TimeSpan();
                        double monthSenior = 0;
                        var profileEntity = lstProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();
                        if (profileEntity != null && profileEntity.DateHire != null && Model.DateEnd != null)
                        {
                            dateSenior = Model.DateEnd.Value.Subtract(profileEntity.DateHire.Value);
                            monthSenior = Math.Floor(dateSenior.TotalDays / 30);
                        }

                        item.MonthSenior = (double?)monthSenior;
                        var dateCheck = DateTime.Now;
                        var model = new Hre_ReportExpiryContractModel();
                        var contractTypeEntity = lstContractType.Where(s => item.ContractTypeID == s.ID).FirstOrDefault();
                            if (item.ContractResult == null)
                            {
                                if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                                {
                                    var dateExpiry = dateCheck.AddDays(contractTypeEntity.ExpiryContractLoop.Value);

                                    if (item.DateExtend != null && item.DateExtend <= dateExpiry)
                                    {
                                        model = item;
                                        lstModel.Add(model);
                                    }
                                    if (item.DateExtend == null && item.DateEnd != null && item.DateEnd.Value <= dateExpiry)
                                    {
                                        model = item;
                                        lstModel.Add(model);
                                    }
                                }
                            }
                        
                    }
                }

            }
            else if (Model.EvaType == EnumDropDown.EvaExpiryContract.E_NONEEVA_CONTRACT.ToString()) 
            {
                result = result.Where(s =>  s.ContractResult == null).ToList();
                if (isshowloopcontract == false)
                {
                    var model = new Hre_ReportExpiryContractModel();
                    foreach (var item in result)
                    {
                        var ContractByProfileID = lstContracts.Where(s => s.ProfileID == item.ProfileID).OrderByDescending(s => s.DateCreate).FirstOrDefault();
                        if (ContractByProfileID != null)
                        {
                            if (ContractByProfileID.DateCreate != null && ContractByProfileID.DateCreate.Value.ToShortDateString() != DateTime.Now.ToShortDateString())
                            {
                                if (item.DateExtend != null && item.DateExtend >= dateFrom && item.DateExtend <= dateTo)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                                if (item.DateExtend == null && item.DateEnd != null && item.DateEnd >= dateFrom && item.DateEnd <= dateTo)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in result)
                    {
                        var dateSenior = new TimeSpan();
                        double monthSenior = 0;
                        var profileEntity = lstProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();
                        if (profileEntity != null && profileEntity.DateHire != null && Model.DateEnd != null)
                        {
                            dateSenior = Model.DateEnd.Value.Subtract(profileEntity.DateHire.Value);
                            monthSenior = Math.Floor(dateSenior.TotalDays / 30);
                        }

                        item.MonthSenior = (double?)monthSenior;
                        var dateCheck = DateTime.Now;
                        var model = new Hre_ReportExpiryContractModel();
                        var contractTypeEntity = lstContractType.Where(s => item.ContractTypeID == s.ID).FirstOrDefault();
                        if (item.ContractResult == null)
                        {
                            if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                            {
                                var dateExpiry = dateCheck.AddDays(contractTypeEntity.ExpiryContractLoop.Value);

                                if (item.DateExtend != null && item.DateExtend <= dateExpiry)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                                if (item.DateExtend == null && item.DateEnd != null && item.DateEnd.Value <= dateExpiry)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                            }
                        }

                    }
                }
            }
            else
            {
                if (isshowloopcontract == false)
                {
                    var model = new Hre_ReportExpiryContractModel();
                    foreach (var item in result)
                    {
                        var ContractByProfileID = lstContracts.Where(s => s.ProfileID == item.ProfileID).OrderByDescending(s => s.DateCreate).FirstOrDefault();
                        if (ContractByProfileID != null)
                        {
                            if (ContractByProfileID.DateCreate != null && ContractByProfileID.DateCreate.Value.ToShortDateString() != DateTime.Now.ToShortDateString())
                            {
                                if (item.DateExtend != null && item.DateExtend >= dateFrom && item.DateExtend <= dateTo)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                                if (item.DateExtend == null && item.DateEnd != null && item.DateEnd >= dateFrom && item.DateEnd <= dateTo)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in result)
                    {
                        var dateSenior = new TimeSpan();
                        double monthSenior = 0;
                        var profileEntity = lstProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();
                        if (profileEntity != null && profileEntity.DateHire != null && Model.DateEnd != null)
                        {
                            dateSenior = Model.DateEnd.Value.Subtract(profileEntity.DateHire.Value);
                            monthSenior = Math.Floor(dateSenior.TotalDays / 30);
                        }

                        item.MonthSenior = (double?)monthSenior;
                        var dateCheck = DateTime.Now;
                        var model = new Hre_ReportExpiryContractModel();
                        var contractTypeEntity = lstContractType.Where(s => item.ContractTypeID == s.ID).FirstOrDefault();
                      
                            if (contractTypeEntity != null && contractTypeEntity.ExpiryContractLoop != null)
                            {
                                var dateExpiry = dateCheck.AddDays(contractTypeEntity.ExpiryContractLoop.Value);

                                if (item.DateExtend != null && item.DateExtend <= dateExpiry)
                                {
                                    model = item;
                                    lstModel.Add(model);
                                }
                                if (item.DateExtend == null && item.DateEnd != null && item.DateEnd.Value <= dateExpiry)
                                {
                                    model = item;
                                    lstModel.Add(model); 
                                }
                            }
                    }
                }
            }
            
            #region Lấy phụ lục hợp đông
            var _ReportService = new Hre_ContractServices();
            var lisEntity = result.Translate<Hre_ContractEntity>();
            DataTable tb = _ReportService.GetDataContract(lisEntity, UserLogin);
            #endregion
            #region Xuất template

            if (Model != null && Model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = tb,
                    FileName = "Hre_ContractEntity",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = true
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            #endregion

            if (Model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(Model.ExportID, tb, Model.ExportType);
                return Json(fullPath);
            }
            return Json(lstModel.ToDataSourceResult(request));
        }
Exemple #6
0
        public string getContractNo(Hre_ContractEntity contract, DateTime? DateSigned)
        {
            var profileService = new Hre_ProfileServices();
            var actionService = new ActionService(UserLogin);
            string status = string.Empty;
            List<object> lstObjProfile = new List<object>();
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(null);
            lstObjProfile.Add(1);
            lstObjProfile.Add(100000000);
            var profile = actionService.GetData<Hre_ProfileEntity>(contract.ProfileID, ConstantSql.hrm_hr_sp_get_ProfileById, ref status).FirstOrDefault();

            if (profile == null)
                return "";

            //string contractNo = GetNewCode(contract, Hre_Contract.FieldNames.ContractNo);
            //if (contractNo.IsNotNullOrEmpty())
            //{
            //    return contractNo;
            //}
            var ContractServices = new Hre_ContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContracts = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status);
            string contractNo = "HD/" + profile.CodeEmp + "/" + (DateSigned == null ? string.Empty : DateSigned.Value.Year.ToString());
            int contractNumber = lstContracts.Count(s => s.IsDelete == null);

            if (contractNumber > 1)
            {
                contractNo += "-" + contractNumber;
            }

            return contractNo;
        }
Exemple #7
0
        public ActionResult ExportProfileRetirementByTemplate(List<Guid> selectedIds, string valueFields)
        {
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;
            string messages = string.Empty;
            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var actionService = new ActionService(UserLogin);
            var objs = 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);
            objs.Add(strIDs);
            var lstProfile = actionService.GetData<Hre_ProfileEntity>(objs, ConstantSql.hrm_hr_sp_get_ProfileRetirementByListId, ref status);
            if (lstProfile == null)
                return null;
            int i = 0;
            var lstProfileID = lstProfile.Select(s => s.ID).Distinct().ToList();
            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstProfileID.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var profile in lstProfile)
            {
                if (profile.IDDateOfIssue.HasValue)
                    profile.IDDateOfIssueFormat = profile.IDDateOfIssue.Value.ToString("dd/MM/yyyy");
                if (profile.DateOfBirth.HasValue)
                    profile.DateOfBirthFormat = profile.DateOfBirth.Value.ToString("dd/MM/yyyy");

                if (profile.SocialInsIssueDate.HasValue)
                    profile.SocialInsIssueDateFormat = profile.SocialInsIssueDate.Value.ToString("dd/MM/yyyy");

                if (profile.Salary != null)
                    profile.SalaryFormat = String.Format("{0:0,0}", profile.Salary);
                if (profile.Allowance1 != null)
                    profile.Allowance1Format = String.Format("{0:0,0}", profile.Allowance1);

                if (profile.DayOfBirth > 0 && profile.MonthOfBirth > 0 && profile.YearOfBirth > 0)
                {
                    profile.Birthday = profile.DayOfBirth + "/" + profile.MonthOfBirth + "/" + profile.YearOfBirth;
                }
                if (profile.DateHire.HasValue)
                {
                    profile.DateHireFormat = profile.DateHire.Value.ToString("dd/MM/yyyy");
                }
                profile.DateNow = DateTime.Now.ToString("dd/MM/yyyy");
                if (profile.DateStart.HasValue)
                {
                    profile.DateStartString = "Ngày " + profile.DateStart.Value.Day + " Tháng " + profile.DateStart.Value.Month + " Năm " + profile.DateStart.Value.Year + " ";
                    profile.DateStartFormat = profile.DateStart.Value.ToString("dd/MM/yyyy");
                }

                if (profile.DateEnd.HasValue)
                {
                    profile.DateEndString = "Ngày " + profile.DateEnd.Value.Day + " Tháng " + profile.DateEnd.Value.Month + " Năm " + profile.DateEnd.Value.Year + " ";
                    profile.DateEndFormat = profile.DateEnd.Value.ToString("dd/MM/yyyy");
                }
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);

                if (!string.IsNullOrEmpty(valueFields))
                {
                    template = actionService.GetData<Cat_ExportEntity>(Guid.Parse(valueFields), ConstantSql.hrm_cat_sp_get_ExportById, ref status).FirstOrDefault();
                }

                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                var lstcontract = new List<Hre_ProfileEntity>();
                lstcontract.Add(profile);
                ExportService.ExportWord(outputPath, templatepath, lstcontract);
            }
            if (lstProfileID.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #8
0
        public ActionResult ExportExpiryContractByTemplate(List<Guid> selectedIds, string valueFields)
        {
            string[] valueFieldsExportID = valueFields.Split(',');
            valueFields = valueFieldsExportID[0];
            string _exportID = valueFieldsExportID[1];
            Guid exportID;

            string messages = string.Empty;
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;

            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var actionServices = new ActionService(UserLogin);
            var objs = 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);
            var lstContract = actionServices.GetData<Hre_ContractEntity>(strIDs, ConstantSql.hrm_hr_sp_get_ContractsByListId, ref status);
            if (lstContract == null)
                return null;
            int i = 0;

            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstContract.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var contract in lstContract)
            {
                contract.DateNow = DateTime.Now.ToString("dd/MM/yyyy");
                contract.IDDateOfIssueFormat = contract.IDDateOfIssue.HasValue ? contract.IDDateOfIssue.Value.ToString("dd/MM/yyyy") : null;
                if (contract.DateStart != null)
                {
                    contract.DateStartFormat = contract.DateStart.ToString("dd/MM/yyyy");
                }

                if (contract.DateEnd.HasValue)
                {
                    contract.DateEndFormat = contract.DateEnd.Value.ToString("dd/MM/yyyy");
                    contract.DateEndMonth = contract.DateEnd.Value.Month;
                    contract.DateEndYear = contract.DateEnd.Value.Year;
                    contract.DateEndFormatEN = contract.DateEnd.Value.ToString("dd-MMM-yyyy");
                }
                if (contract.DateHire.HasValue)
                {
                    contract.DateHireFormat = contract.DateHire.Value.ToString("dd/MM/yyyy");
                    contract.DateEndMonth = contract.DateHire.Value.Month;
                    contract.DateEndYear = contract.DateHire.Value.Year;
                    contract.DateHireFormatEN = contract.DateHire.Value.ToString("dd-MMM-yyyy");
                }

                if (contract.DateEndProbation.HasValue)
                    contract.DateEndProbationFormat = contract.DateEndProbation.Value.ToString("dd/MM/yyyy");
                contract.SalaryFormat = contract.Salary.HasValue ? contract.Salary.Value.ToString("N") : "0";
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                //List<object> lstObjExport = new List<object>();
                //lstObjExport.Add(Common.DotNetToOracle(valueFields));

                //template = service.GetData<Cat_ExportEntity>(Common.DotNetToOracle(valueFields), ConstantSql.hrm_cat_sp_get_ExportById, ref status).FirstOrDefault();
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);
                if (_exportID != "")
                {
                    exportID = Guid.Parse(_exportID);
                    template = actionServices.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields && s.ID == exportID).FirstOrDefault();
                }
                else
                {
                    template = actionServices.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields).FirstOrDefault();
                }

                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(contract.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(contract.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                var lstcontract = new List<Hre_ContractEntity>();
                lstcontract.Add(contract);
                ExportService.ExportWord(outputPath, templatepath, lstcontract);
            }
            if (lstContract.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #9
0
        public ActionResult ApprovedEvaContract(string selectedIds)
        {
            var ContractServices = new Hre_ContractServices();
            var profileServices = new Hre_ProfileServices();
            var ContractExtendServices = new Hre_ContractExtendServices();
            string message = string.Empty;
            string status = string.Empty;
            var lstContract = ContractServices.GetData<Hre_ContractEntity>(Common.DotNetToOracle(selectedIds), ConstantSql.hrm_hr_sp_get_ContractByIds, UserLogin, ref status).ToList();
            foreach (var contract in lstContract)
            {
                if (contract.ContractResult == HRM.Infrastructure.Utilities.EnumDropDown.ResultContract.PASS.ToString())
                {
                    if (contract.TypeOfPass == HRM.Infrastructure.Utilities.EnumDropDown.TypeOfPass.E_SIGNED_NEXTCONTRACT.ToString())
                    {
                        if (contract.RankDetailForNextContract == null || contract.DateEndNextContract == null)
                        {
                            message = ConstantDisplay.HRM_HR_Profile_LackOfRequiredInformation.ToString();
                            return Json(message);
                        }
                        contract.StatusEvaluation = "E_APPROVED";
                        message = profileServices.SaveContractAndNextSalaryApprovedEvaluation(contract,UserLogin);

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

            }
            return Json(message);
        }
Exemple #10
0
        public ActionResult ExportProfileQuitByTemplate(List<Guid> selectedIds, string valueFields)
        {
            string messages = string.Empty;
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;
            ActionService ActionService = new ActionService(UserLogin);

            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var baseService = new BaseService();
            var objs = 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);
            objs.Add(strIDs);
            var lstProfile = ActionService.GetData<Hre_ProfileEntity>(objs, ConstantSql.hrm_hr_sp_get_ProfileQuitByListId, ref status);
            if (lstProfile == null || lstProfile.Count == 0)
                return null;

            int i = 0;

            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstProfile.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var profile in lstProfile)
            {

                profile.DateNow = DateTime.Now.ToString("dd/MM/yyyy");
                profile.DateNow_Day = DateTime.Now.Day.ToString();
                profile.DateNow_Month = DateTime.Now.Month.ToString();
                profile.DateNow_Year = DateTime.Now.Year.ToString();
                if (profile.DateStart.HasValue)
                    profile.DateStartFormat = profile.DateStart.Value.ToString("dd/MM/yyyy");
                if (profile.RequestDate.HasValue)
                    profile.RequestDateFormat = profile.RequestDate.Value.ToString("dd/MM/yyyy");
                if (profile.DateQuit.HasValue)
                    profile.DateQuitFormat = profile.DateQuit.Value.ToString("dd/MM/yyyy");
                if (profile.DateHire.HasValue)
                    profile.DateHireFormat = profile.DateHire.Value.ToString("dd/MM/yyyy");

                if (profile.DateOfBirth.HasValue)
                    profile.DateOfBirthFormat = profile.DateOfBirth.Value.ToString("dd/MM/yyyy");
                if (profile.IDDateOfIssue.HasValue)
                    profile.IDDateOfIssueFormat = profile.IDDateOfIssue.Value.ToString("dd/MM/yyyy");
                if (profile.DateSigned.HasValue)
                    profile.DateSignedFormat = profile.DateSigned.Value.ToString("dd/MM/yyyy");
                if (profile.DateQuitSign.HasValue)
                {
                    profile.DateQuitSignFormat = profile.DateQuitSign.Value.ToString("dd/MM/yyyy");
                }

                if (profile.Gender == "E_FEMALE")
                {
                    profile.GraveName = "Ms." + profile.ProfileName.Substring(profile.ProfileName.LastIndexOf(' '));
                }
                else
                {
                    profile.GraveName = "Mr." + profile.ProfileName.Substring(profile.ProfileName.LastIndexOf(' '));
                }
                if (profile.Gender == "E_FEMALE")
                {
                    profile.GenderView = "Chị";
                }
                if (profile.Gender == "E_MALE")
                {
                    profile.GenderView = "Anh";
                }



                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);

                template = ActionService.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields).FirstOrDefault();
                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                var lstProfile1 = new List<Hre_ProfileEntity>();
                lstProfile1.Add(profile);
                ExportService.ExportWord(outputPath, templatepath, lstProfile1);
            }
            if (lstProfile.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #11
0
        public ActionResult SetStatusHire(string selectedIds, string statusPofile, string statusBasicSalary, string statusWorkHistory, string statusContract)
        {
            string status = string.Empty;
            BaseService service = new BaseService();
            ActionService ActionService = new ActionService(UserLogin);
            List<object> lstObj = new List<object>();
            lstObj.Add(Common.DotNetToOracle(selectedIds));
            lstObj.Add(statusPofile);
            lstObj.Add(statusBasicSalary);
            lstObj.Add(statusWorkHistory);
            lstObj.Add(statusContract);
            var rs = service.UpdateData<Hre_ProfileModel>(lstObj, ConstantSql.hrm_hre_sp_Set_ApproveProfile_Status, ref status);

            var contractServices = new Hre_ContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContract = ActionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();

            var lstProfileIDs = selectedIds.Split(',').Select(s => Guid.Parse(s)).ToArray();
            if (lstProfileIDs != null)
            {
                foreach (var item in lstProfileIDs)
                {
                    var lstContractByProfileID = lstContract.Where(s => s.Status == EnumDropDown.Status.E_APPROVED.ToString() && item == s.ProfileID).ToList();

                    var contractEntity = lstContract.Where(s => s.ProfileID == item).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    var listIdContract = string.Empty;
                    if (lstContractByProfileID != null)
                    {
                        listIdContract = string.Join(",", lstContractByProfileID.Select(d => d.ContractTypeID));
                        if (contractEntity != null)
                        {
                            contractEntity = SetNewCodeContract(contractEntity, listIdContract);
                            contractEntity.Status = EnumDropDown.Status.E_APPROVED.ToString();
                            status = contractServices.Edit(contractEntity);
                        }
                    }

                }
            }

            if (status != "")
            {
                return Json(status);
            }
            return Json("");
        }
Exemple #12
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;
        }
Exemple #13
0
        public ActionResult UpdateEvaContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var ContractServices = new Hre_ContractServices();
            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

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

            foreach (var item in lstContract)
            {
                if (model.RankDetailForNextContract != null)
                {
                    item.RankDetailForNextContract = model.RankDetailForNextContract;
                }

                if (model.DateEndNextContract != null)
                {
                    item.DateEndNextContract = model.DateEndNextContract;
                }

                // Son.Vo - 20150613 - theo task 0049393
                if (lstContract.Count == 1 && model.RankDetailForNextContract == null)
                {
                    item.RankDetailForNextContract = item.RankRateID;
                }

                message = ContractServices.Edit(item);
            }

            return Json(message, JsonRequestBehavior.AllowGet);
        }
Exemple #14
0
        public ActionResult ExtendContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var ContractServices = new Hre_ContractServices();
            var ExtendContractServices = new Hre_ContractExtendServices();
            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

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

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

            return Json(message, JsonRequestBehavior.AllowGet);
        }
Exemple #15
0
        public ActionResult ExportWordProfileByTemplate(Guid selectedIds, string valueFields)
        {
            var actionService = new ActionService(UserLogin);
            string messages = string.Empty;
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;

            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var baseService = new BaseService();
            var lstProfile = actionService.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(selectedIds.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, ref status);
            if (lstProfile == null || lstProfile.Count == 0)
                return null;

            int i = 0;

            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstProfile.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var profile in lstProfile)
            {

                profile.DateNow = DateTime.Now.ToString("dd/MM/yyyy");
                if (profile.DateStart.HasValue)
                    profile.DateStartFormat = profile.DateStart.Value.ToString("dd/MM/yyyy");
                if (profile.RequestDate.HasValue)
                    profile.RequestDateFormat = profile.RequestDate.Value.ToString("dd/MM/yyyy");
                if (profile.DateQuit.HasValue)
                    profile.DateQuitFormat = profile.DateQuit.Value.ToString("dd/MM/yyyy");

                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;

                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);

                template = actionService.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields).FirstOrDefault();
                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                var lstProfile1 = new List<Hre_ProfileEntity>();
                lstProfile1.Add(profile);
                ExportService.ExportWord(outputPath, templatepath, lstProfile1);
            }
            if (lstProfile.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #16
0
        public ActionResult ExportContractWaitingByTemplate(List<Guid> selectedIds, string valueFields)
        {
            string messages = string.Empty;
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;

            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var actionServices = new ActionService(UserLogin);
            var objs = 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);
            objs.Add(strIDs);
            var lstContract = actionServices.GetData<Hre_ContractEntity>(objs, ConstantSql.hrm_hr_sp_get_ContractsByListId, ref status);
            if (lstContract == null)
                return null;
            int i = 0;

            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstContract.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var contract in lstContract)
            {
                contract.DateNow = DateTime.Now.ToString("dd/MM/yyyy");
                contract.DateNow_Day = DateTime.Now.Day.ToString();
                contract.DateNow_Month = DateTime.Now.Month.ToString();
                contract.DateNow_Year = DateTime.Now.Year.ToString();

                contract.IDDateOfIssueFormat = contract.IDDateOfIssue.HasValue ? contract.IDDateOfIssue.Value.ToString("dd/MM/yyyy") : null;
                if (contract.DateStart != null)
                    contract.DateStartFormat = contract.DateStart.ToString("dd/MM/yyyy");
                if (contract.DateEnd.HasValue)
                    contract.DateEndFormat = contract.DateEnd.Value.ToString("dd/MM/yyyy");
                if (contract.DateHire.HasValue)
                    contract.DateHireFormat = contract.DateHire.Value.ToString("dd/MM/yyyy");
                if (contract.DateEndProbation.HasValue)
                    contract.DateEndProbationFormat = contract.DateEndProbation.Value.ToString("dd/MM/yyyy");
                contract.SalaryFormat = contract.Salary.HasValue ? contract.Salary.Value.ToString("N") : "0";
                if (contract.DateOfEffect.HasValue)
                {
                    contract.DateOfEffectFormat = contract.DateOfEffect.Value.ToString("dd MMM yyyy");
                    contract.DateOfEffectMoreTwoMonthFormat = contract.DateOfEffect.Value.AddMonths(+2).ToString("dd MMM yyyy");

                }
                if (contract.Gender == "E_FEMALE")
                {
                    contract.GraveName = "Ms." + contract.ProfileName.Substring(contract.ProfileName.LastIndexOf(' '));
                }
                else
                {
                    contract.GraveName = "Mr." + contract.ProfileName.Substring(contract.ProfileName.LastIndexOf(' '));
                }
                if (contract.DateQuit.HasValue)
                {
                    if (contract.DateHire.HasValue)
                    {
                        contract.MonthWorking = Math.Floor(contract.DateQuit.Value.Subtract(contract.DateHire.Value).TotalDays / 30);
                        contract.YearWorking = Math.Floor(contract.MonthWorking.Value / 12);
                        if (contract.YearWorking > 0)
                        {
                            contract.MonthWorking = contract.MonthWorking - (contract.YearWorking * 12);
                        }
                    }
                }
                else
                {
                    contract.MonthWorking = Math.Floor(DateTime.Now.Subtract(contract.DateHire.Value).TotalDays / 30);
                    contract.YearWorking = Math.Floor(contract.MonthWorking.Value / 12);
                    if (contract.YearWorking > 0)
                    {
                        contract.MonthWorking = contract.MonthWorking - (contract.YearWorking * 12);
                    }
                }
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                if (!string.IsNullOrEmpty(valueFields))
                    template = actionServices.GetData<Cat_ExportEntity>(Common.DotNetToOracle(valueFields), ConstantSql.hrm_cat_sp_get_ExportById, ref status).FirstOrDefault();
                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                //if (!System.IO.File.Exists(templatepath))
                //{
                //    messages = "NotTemplate";
                //    return Json(messages, JsonRequestBehavior.AllowGet);
                //}
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(contract.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(contract.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                var lstcontract = new List<Hre_ContractEntity>();
                lstcontract.Add(contract);
                ExportService.ExportWord(outputPath, templatepath, lstcontract);
            }
            if (lstContract.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #17
0
        public ActionResult ExportProfileWorkingByTemplate(List<Guid> selectedIds, string valueFields)
        {
            var actionService = new ActionService(UserLogin);
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;
            string messages = string.Empty;
            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var ActionService = new ActionService(UserLogin);
            var baseService = new BaseService();
            var objs = 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);
            objs.Add(strIDs);
            var lstProfile = baseService.GetData<Hre_ProfileEntity>(objs, ConstantSql.hrm_hr_sp_get_ProfileWorkingByListId, UserLogin, ref status);
            if (lstProfile == null)
                return null;
            int i = 0;
            var lstProfileID = lstProfile.Select(s => s.ID).Distinct().ToList();
            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstProfileID.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            #region ds nguoi than cua nhan vien duoc chon
            string strProfileIDs = "";
            if (lstProfileID != null)
            {
                foreach (var ProfileID in lstProfileID)
                {
                    string _strProfileID = Common.DotNetToOracle(ProfileID.ToString());
                    strProfileIDs += _strProfileID + ",";
                }
            }
            var lstRelativeByProfileIDs = ActionService.GetData<Hre_RelativesEntity>(strProfileIDs, ConstantSql.hrm_hr_sp_get_RelativeByProfileIds, ref status);
            #endregion

            foreach (var profile in lstProfile)
            {
                if (profile.IDDateOfIssue.HasValue)
                    profile.IDDateOfIssueFormat = profile.IDDateOfIssue.Value.ToString("dd/MM/yyyy");
                if (profile.DateOfBirth.HasValue)
                    profile.DateOfBirthFormat = profile.DateOfBirth.Value.ToString("dd/MM/yyyy");
                if (profile.Salary != null)
                    profile.SalaryFormat = String.Format("{0:0,0}", profile.Salary);
                if (profile.Allowance1 != null)
                    profile.Allowance1Format = String.Format("{0:0,0}", profile.Allowance1);

                if (profile.DayOfBirth > 0 && profile.MonthOfBirth > 0 && profile.YearOfBirth > 0)
                {
                    profile.Birthday = profile.DayOfBirth + "/" + profile.MonthOfBirth + "/" + profile.YearOfBirth;
                }
                if (profile.DateHire.HasValue)
                {
                    profile.DateHireFormat = profile.DateHire.Value.ToString("dd/MM/yyyy");
                }
                profile.DateNow = DateTime.Now.ToString("dd/MM/yyyy");
                if (profile.DateStart.HasValue)
                {
                    profile.DateStartString = "Ngày " + profile.DateStart.Value.Day + " Tháng " + profile.DateStart.Value.Month + " Năm " + profile.DateStart.Value.Year + " ";
                    profile.DateStartFormat = profile.DateStart.Value.ToString("dd/MM/yyyy");
                }
                if (profile.DateEnd.HasValue)
                {
                    profile.DateEndString = "Ngày " + profile.DateEnd.Value.Day + " Tháng " + profile.DateEnd.Value.Month + " Năm " + profile.DateEnd.Value.Year + " ";
                    profile.DateEndFormat = profile.DateEnd.Value.ToString("dd/MM/yyyy");
                }
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);

                if (!string.IsNullOrEmpty(valueFields))
                {
                    template = actionService.GetData<Cat_ExportEntity>(Guid.Parse(valueFields), ConstantSql.hrm_cat_sp_get_ExportById, ref status).FirstOrDefault();
                }

                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                #region lay nguoi than cua tung nhan vien
                List<Hre_RelativesEntity> lstRelativeByProfileID = new List<Hre_RelativesEntity>();
                if (lstRelativeByProfileIDs != null)
                {
                    lstRelativeByProfileID = lstRelativeByProfileIDs.Where(s => s.ProfileID == profile.ID).ToList();
                }

                #endregion

                var lstcontract = new List<Hre_ProfileEntity>();
                lstcontract.Add(profile);
                Hre_ProfileEntity objProfile = new Hre_ProfileEntity();
                //string[] FieldtblProfiles = new string[] { "ProfileName","ID"};
                //DataTable tblProfiles = Common.ConvertIListToDataTable(lstcontract, FieldtblProfiles);
                DataTable tblProfiles = new DataTable();
                tblProfiles = lstcontract.Translate();
                DataTable tblRelatives = new DataTable();
                tblRelatives = lstRelativeByProfileID.Translate();
                //Common.ConvertIListToDataTable(lstRelativeByProfileID, FieldtblRelatives);
                DataSet dsData = new DataSet();
                dsData.Tables.Add(tblProfiles);
                dsData.Tables.Add(tblRelatives);
                dsData.Tables[0].TableName = "tblProfiles";
                dsData.Tables[1].TableName = "tblRelatives";

                //ExportService.ExportWord(outputPath, templatepath, dsData);
                ExportService.ExportWithRegions(outputPath, templatepath, dsData);
            }
            if (lstProfileID.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #18
0
        public ActionResult GetReportProfileComeBack([DataSourceRequest] DataSourceRequest request, Hre_ReportProfileComeBackModel Model)
        {
            string status = string.Empty;
            var actionServices = new ActionService(UserLogin);
            var contractServices = new Hre_ContractServices();
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = Model.DateFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = Model.DateTo };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };

            #region Validate
            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Hre_ReportProfileComeBackModel>(Model, "Hre_ReportProfileComeBack", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }
            #endregion
            List<object> lstpara = new List<object>();
            lstpara.Add(Model.DateFrom);
            lstpara.Add(Model.DateTo);
            lstpara.Add(Model.OrgStructureIDs);
            lstpara.Add(Model.ProfileName);
            lstpara.Add(Model.CodeEmp);
            lstpara.Add(Model.RankID);
            lstpara.Add(Model.WorkPlaceID);
            var result = actionServices.GetData<Hre_ReportProfileComeBackModel>(lstpara, ConstantSql.hrm_hr_sp_get_RptProfileComBack, ref status);

            var lstResultEntity = result.Translate<Hre_ReportProfileComeBackEntity>();

            var dataResult = contractServices.GetDataContractByProfileID(lstResultEntity, UserLogin);

            var isDataTable = false;
            DataTable obj = null;
            if (Model.IsCreateTemplateForDynamicGrid)
            {
                obj = dataResult;
                isDataTable = true;
            }


            if (Model != null && Model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Hre_ReportProfileComeBackEntity",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = true
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (Model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(Model.ExportID, dataResult, listHeaderInfo, Model.ExportType);
                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }
Exemple #19
0
        public ActionResult ExportWorkHistoryByTemplate(List<Guid> selectedIds, string valueFields)
        {
            string[] valueFieldsExportID = valueFields.Split(',');
            valueFields = valueFieldsExportID[0];
            string _exportID = valueFieldsExportID[1];
            Guid exportID;

            string messages = string.Empty;
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;

            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var actionService = new ActionService(UserLogin);
            var workhistoryService = new Hre_WorkHistoryServices();
            var objs = 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);
            objs.Add(strIDs);
            var lstProfile = actionService.GetData<Hre_WorkHistoryEntity>(objs, ConstantSql.hrm_hr_sp_get_ExportWorkHistoryByIds, ref status);
            if (lstProfile == null)
                return null;
            int i = 0;

            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstProfile.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var profile in lstProfile)
            {
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);

                if (_exportID != "")
                {
                    exportID = Guid.Parse(_exportID);
                    template = actionService.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields && s.ID == exportID).FirstOrDefault();
                }
                else
                {
                    template = actionService.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields).FirstOrDefault();
                }
                //template = exportService.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields).FirstOrDefault();
                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(profile.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                var lstWorkHistory = new List<Hre_WorkHistoryEntity>();
                lstWorkHistory.Add(profile);
                ExportService.ExportWord(outputPath, templatepath, lstWorkHistory);
            }
            if (lstProfile.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #20
0
        public ActionResult CheckAddNextContract(string ContractTypeID, string ContractID)
        {
            string status = string.Empty;
            var contractTypeID = Guid.Empty;
            Guid convertContractID = Guid.Empty;
            string AddMessage = string.Empty;
            List<Guid> lstContractID = new List<Guid>();
            if (!string.IsNullOrEmpty(ContractTypeID))
            {
                contractTypeID = Guid.Parse(ContractTypeID);
            }
            if (ContractID.IndexOf(",") > 1)
            {
                var lstID = ContractID.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertContractID = Common.ConvertToGuid(lstID[i]);
                    lstContractID.Add(convertContractID);
                }
            }
            else
            {
                convertContractID = Common.ConvertToGuid(ContractID);
                lstContractID.Add(convertContractID);
            }

            ActionService service = new ActionService(UserLogin);
            var actionServices = new ActionService(UserLogin);
            var contractServices = new Hre_ContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContracts = actionServices.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).Where(s => lstContractID.Contains(s.ID)).ToList();
            var lstContract = service.GetData<Hre_ContractEntity>(convertContractID, ConstantSql.hrm_hr_sp_get_ContractById, ref status).FirstOrDefault();

            var contractTypeServices = new Cat_ContractTypeServices();
            List<object> lstObjContractType = new List<object>();
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(1);
            lstObjContractType.Add(10000000);
            var lstContractType = actionServices.GetData<Cat_ContractTypeEntity>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, ref status);

            List<object> listObj = new List<object>();

            listObj.Add(1);
            listObj.Add(1000);
            var BasicSalaryServices = new Sal_BasicSalaryServices();
            var lstBasicSalary = actionServices.GetData<Sal_BasicSalaryEntity>(listObj, ConstantSql.hrm_sal_sp_get_BasicPayrollGetAll, ref status).Where(s => s.ProfileID == lstContract.ProfileID && s.DateOfEffect <= lstContract.DateEnd).OrderByDescending(s => s.DateOfEffect).FirstOrDefault();

            foreach (var hreContract in lstContracts)
            {
                //   lstContractType = lstContractType.Where( s=> s.ID == hreContract.ContractTypeID).ToList();
                string contractnextID = lstContractType.Where(s => s.ID == hreContract.ContractTypeID).Select(s => s.ContractNextID).FirstOrDefault();
                if (contractnextID == null)
                {
                    AddMessage = "Error";
                    return Json(AddMessage);
                }
                else
                {
                    Guid contractTypeIDbyContractnext = Common.OracleToDotNet(contractnextID);
                    Hre_ContractEntity contract = new Hre_ContractEntity();
                    hreContract.CopyData(contract);

                    contract.ContractTypeID = contractTypeIDbyContractnext;
                    // contract.ContractNo = getContractNo(contract, contract.DateSigned ?? DateTime.Now);
                    if (contract.DateEnd != null)
                    {
                        contract.DateSigned = contract.DateStart = contract.DateEnd.Value.AddDays(1);
                    }
                    Cat_ContractTypeEntity catContractType = new Cat_ContractTypeEntity();

                    catContractType = lstContractType.Where(s => s.ID == contractTypeIDbyContractnext).FirstOrDefault();

                    if (catContractType != null)
                    {
                        int month = 0;
                        if (catContractType.ValueTime != null)
                        {
                            month = (int)catContractType.ValueTime.Value;
                        }
                        if (catContractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                        {
                            month = month * 12;
                        }

                        if (hreContract.DateEnd != null)
                        {
                            contract.DateStart = hreContract.DateEnd.Value.AddDays(1);

                            contract.DateEnd = contract.DateStart.AddMonths(month);
                        }
                    }
                    else
                    {
                        contract.DateEnd = null;
                    }
                    if (lstBasicSalary != null)
                    {
                        contract.InsuranceAmount = lstBasicSalary.InsuranceAmount;
                        contract.CurenncyID1 = lstBasicSalary.CurrencyID1;
                        contract.ClassRateID = lstBasicSalary.ClassRateID;
                        contract.RankRateID = lstBasicSalary.RankRateID;
                    }
                    //Add new
                    AddMessage = contractServices.Add(contract);
                    //AddMessage = "Success";
                }

            }
            return Json(AddMessage);

        }
Exemple #21
0
        public ActionResult ExportAppendixContractByTemplate(List<Guid> selectedIds, string valueFields)
        {
            string messages = string.Empty;
            //string folderStore = DateTime.Now.ToString("ddMMyyyyHHmmss");
            DateTime DateStart = DateTime.Now;

            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var ActionService = new ActionService(UserLogin);
            var objs = 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);
            objs.Add(strIDs);
            var lstAppendixContract = ActionService.GetData<Hre_AppendixContractEntity>(objs, ConstantSql.hrm_hr_sp_get_AppendixContractByListId, ref status);
            if (lstAppendixContract == null)
                return null;
            int i = 0;

            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_AppendixContract" + suffix;
            if (lstAppendixContract.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            int count = 0;

            List<object> lstObjAppendixContractType = new List<object>();
            lstObjAppendixContractType.Add(null);
            lstObjAppendixContractType.Add(1);
            lstObjAppendixContractType.Add(int.MaxValue - 1);
            var lstAppendixContractType = ActionService.GetData<Cat_AppendixContractTypeEntity>(lstObjAppendixContractType, ConstantSql.hrm_cat_sp_get_AppendixContractType, ref status);
            foreach (var objAppendixContract in lstAppendixContract)
            {
                var AppendixContractType = lstAppendixContractType.Where(s => s.ID == objAppendixContract.AppendixContractTypeID).FirstOrDefault();
                count++;
                ActionService services = new ActionService(UserLogin);
                List<object> listObj = new List<object>();
                listObj.Add(objAppendixContract.ContractID);
                var ResultEntity = services.GetData<Hre_AppendixContractEntity>(listObj, ConstantSql.hrm_hr_sp_get_AppendixContractByIdContractID, ref status);
                if (ResultEntity != null && ResultEntity.Count > 0)
                {
                    if (ResultEntity.Count > 2)
                    {
                        ResultEntity = ResultEntity.Where(s => s.DateSignedAppendixContract < objAppendixContract.DateSignedAppendixContract).ToList();
                        ResultEntity = ResultEntity.OrderByDescending(s => s.DateSignedAppendixContract).ToList();
                        objAppendixContract.CurrentSalary = ResultEntity[0].Salary;
                        objAppendixContract.CurrentAllowance1 = ResultEntity[0].Allowance1;
                        objAppendixContract.CurrentAllowance2 = ResultEntity[0].Allowance2;
                        objAppendixContract.CurrentAllowance3 = ResultEntity[0].Allowance3;
                        objAppendixContract.CurrentAllowance4 = ResultEntity[0].Allowance4;

                    }
                    else
                    {
                        var ResultProfile = services.GetByIdUseStore<Hre_ContractEntity>(objAppendixContract.ContractID, ConstantSql.hrm_hr_sp_get_ContractById, ref status);
                        if (ResultProfile != null)
                        {
                            objAppendixContract.CurrentSalary = ResultProfile.Salary;
                            objAppendixContract.CurrentAllowance1 = ResultProfile.Allowance1;
                            objAppendixContract.CurrentAllowance2 = ResultProfile.Allowance2;
                            objAppendixContract.CurrentAllowance3 = ResultProfile.Allowance3;
                            objAppendixContract.CurrentAllowance4 = ResultProfile.Allowance4;
                        }
                    }
                }
                if (objAppendixContract.DateSignedAppendixContract.HasValue)
                {
                    objAppendixContract.DateSignedAppendixContractFormat = objAppendixContract.DateSignedAppendixContract.Value.ToString("dd/MM/yyyy");
                    objAppendixContract.DateSignedAppendixContract_Day = objAppendixContract.DateSignedAppendixContract.Value.Day.ToString();
                    objAppendixContract.DateSignedAppendixContract_Month = objAppendixContract.DateSignedAppendixContract.Value.Month.ToString();
                    objAppendixContract.DateSignedAppendixContract_Year = objAppendixContract.DateSignedAppendixContract.Value.Year.ToString();
                    objAppendixContract.PLDateSign = objAppendixContract.DateSignedAppendixContract.Value.ToString("dd-MMM-yyyy");
                }

                if (objAppendixContract.DateofEffect.HasValue)
                {
                    objAppendixContract.DateofEffectFormat = objAppendixContract.DateofEffect.Value.ToString("dd/MM/yyyy");
                    objAppendixContract.DateofEffect_Day = objAppendixContract.DateofEffect.Value.Day.ToString();
                    objAppendixContract.DateofEffect_Month = objAppendixContract.DateofEffect.Value.Month.ToString();
                    objAppendixContract.DateofEffect_Year = objAppendixContract.DateofEffect.Value.Year.ToString();
                    objAppendixContract.PLDateStart = objAppendixContract.DateofEffect.Value.ToString("dd-MMM-yyyy");
                }

                if (objAppendixContract.DateEndAppendixContract.HasValue)
                {
                    objAppendixContract.DateEndAppendixContractFormat = objAppendixContract.DateEndAppendixContract.Value.ToString("dd/MM/yyyy");
                    objAppendixContract.DateEndAppendixContract_Day = objAppendixContract.DateEndAppendixContract.Value.Day.ToString();
                    objAppendixContract.DateEndAppendixContract_Month = objAppendixContract.DateEndAppendixContract.Value.Month.ToString();
                    objAppendixContract.DateEndAppendixContract_Year = objAppendixContract.DateEndAppendixContract.Value.Year.ToString();
                    objAppendixContract.PLDateEnd = objAppendixContract.DateEndAppendixContract.Value.ToString("dd-MMM-yyyy");
                }

                if (objAppendixContract.DateOfBirth.HasValue)
                {
                    objAppendixContract.DayOfBirthFormat = objAppendixContract.DateOfBirth.Value.ToString("dd/MM/yyyy");
                    objAppendixContract.DayOfBirth_Day = objAppendixContract.DateOfBirth.Value.Day.ToString();
                    objAppendixContract.DayOfBirth_Month = objAppendixContract.DateOfBirth.Value.Month.ToString();
                    objAppendixContract.DayOfBirth_Year = objAppendixContract.DateOfBirth.Value.Year.ToString();
                }
                if (objAppendixContract.IDDateOfIssue.HasValue)
                {
                    objAppendixContract.IDDateOfIssueFormat = objAppendixContract.IDDateOfIssue.Value.ToString("dd/MM/yyyy");
                    objAppendixContract.IDDateOfIssue_Day = objAppendixContract.IDDateOfIssue.Value.Day.ToString();
                    objAppendixContract.IDDateOfIssue_Month = objAppendixContract.IDDateOfIssue.Value.Month.ToString();
                    objAppendixContract.IDDateOfIssue_Year = objAppendixContract.IDDateOfIssue.Value.Year.ToString();
                }

                if (objAppendixContract.DateSign.HasValue)
                {
                    objAppendixContract.HDDateSign = objAppendixContract.DateSign.Value.ToString("dd-MMM-yyyy");
                }

                if (objAppendixContract.DateStart.HasValue)
                {
                    objAppendixContract.HDStarDate = objAppendixContract.DateStart.Value.ToString("dd-MMM-yyyy");
                }
                if (objAppendixContract.DateSigned.HasValue)
                {
                    objAppendixContract.DateSignedFormat = objAppendixContract.DateSigned.Value.ToString("dd/MM/yyyy");
                    objAppendixContract.DateSigned_Day = objAppendixContract.DateSigned.Value.Day.ToString();
                    objAppendixContract.DateSigned_Month = objAppendixContract.DateSigned.Value.Month.ToString();
                    objAppendixContract.DateSigned_Year = objAppendixContract.DateSigned.Value.Year.ToString();
                }
                objAppendixContract.ContractSalaryFormat = String.Format("{0:0,0}", objAppendixContract.ContractSalary);
                objAppendixContract.Allowance1Format = String.Format("{0:0,0}", objAppendixContract.Allowance1);
                if (objAppendixContract.Gender == "E_FEMALE")
                {
                    objAppendixContract.GenderView = "Nữ";
                }
                if (objAppendixContract.Gender == "E_MALE")
                {
                    objAppendixContract.GenderView = "Name";
                }

                objAppendixContract.PLSalary = String.Format("{0:0,0}", objAppendixContract.Salary);
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                if (AppendixContractType != null)
                {
                    template = ActionService.GetData<Cat_ExportEntity>(Common.DotNetToOracle(AppendixContractType.ExportID.ToString()), ConstantSql.hrm_cat_sp_get_ExportById, ref status).FirstOrDefault();
                }

                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);
                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(objAppendixContract.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(objAppendixContract.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                if (count == lstAppendixContract.Count)
                {
                    ExportService.ExportWord(outputPath, templatepath, lstAppendixContract);
                }
            }
            if (lstAppendixContract.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Exemple #22
0
        public ActionResult GetContractTypeByID(string ContractTypeID, string ProfileID)
        {
            string status = string.Empty;
            var contractTypeID = Guid.Empty;
            var profileID = Guid.Empty;

            if (!string.IsNullOrEmpty(ContractTypeID))
            {
                contractTypeID = Common.ConvertToGuid(ContractTypeID);
            }
            if (!string.IsNullOrEmpty(ProfileID))
            {
                if (ProfileID.IndexOf(',') > 1)
                {
                    var profileIDs = ProfileID.Split(',');
                    profileID = Common.ConvertToGuid(profileIDs[0]);
                }
                else
                {
                    profileID = Common.ConvertToGuid(ProfileID);
                }
            }

            var actionService = new ActionService(UserLogin);
            var lstContractType = actionService.GetData<Cat_ContractTypeEntity>(contractTypeID, ConstantSql.hrm_cat_sp_get_ContractTypeById, ref status).FirstOrDefault();

            var profileServices = new Hre_ProfileServices();
            var profile = actionService.GetData<Hre_ProfileEntity>(profileID, ConstantSql.hrm_hr_sp_get_ProfileById, ref status).FirstOrDefault();

            var contractServices = new Hre_ContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContracts = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status);

            var contractByprofile = lstContracts.Where(s => s.ProfileID == profileID).OrderByDescending(s => s.DateEnd).FirstOrDefault();

            if (lstContractType != null)
            {
                int month = 0;
                if (lstContractType.Type == EnumDropDown.TypeContract.E_PROBATION.ToString() && profile != null)
                {
                    if (profile.DateEndProbation != null)
                    {
                        lstContractType.DateStart = profile.DateHire;
                        lstContractType.DateSigned = profile.DateHire;
                        lstContractType.DateEnd = profile.DateEndProbation;
                    }
                    else
                    {
                        lstContractType.DateStart = DateTime.Now;
                    }
                }

                else
                {
                    if (contractByprofile != null && contractByprofile.DateEnd != null)
                    {
                        lstContractType.DateStart = contractByprofile.DateEnd.Value.Date.AddDays(1);
                        lstContractType.DateSigned = lstContractType.DateStart;
                    }
                    else
                    {
                        lstContractType.DateStart = profile.DateHire;
                        lstContractType.DateSigned = profile.DateHire;

                    }
                }

                if (lstContractType.ValueTime != null)
                {
                    month = (int)lstContractType.ValueTime.Value;
                    if (lstContractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                    {
                        month = month * 12;
                    }
                    lstContractType.DateEnd = lstContractType.DateStart.Value.AddMonths(month);

                }
                if (!string.IsNullOrEmpty(lstContractType.Formula))
                {
                    if (contractByprofile != null)
                    {
                        contractByprofile = SetNewDateEndContract(contractByprofile);
                        lstContractType.DateEnd = contractByprofile.DateEnd;
                    }
                    else
                    {
                        Hre_ContractEntity contractEntity = new Hre_ContractEntity();
                        contractEntity.DateStart = profile.DateHire.Value;
                        contractEntity.ContractTypeID = lstContractType.ID;
                        contractEntity = SetNewDateEndContract(contractEntity);
                        lstContractType.DateEnd = contractEntity.DateEnd;
                    }
                }

            }

            return Json(lstContractType, JsonRequestBehavior.AllowGet);
        }
Exemple #23
0
        public ActionResult ExportAllContractWaitingList([DataSourceRequest] DataSourceRequest request, Hre_ContractWaitingSearchModel model)
        {
            var contractServices = new Hre_ContractServices();
            string status = string.Empty;
            var result = GetListData<Hre_ContractEntity, Hre_ContractModel, Hre_ContractWaitingSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_ContractWaiting, ref status);
            DataTable tableData = contractServices.GetDataContract(result, UserLogin);
            var isDataTable = false;

            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = tableData,
                    FileName = "Hre_ContractEntity",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = true
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, tableData, null, model.ExportType);

                return Json(fullPath);
            }
            var listModel = new List<Hre_ContractModel>();
            if (result != null)
            {
                request.Page = 1;
                foreach (var item in result)
                {
                    var newModle = (Hre_ContractModel)typeof(Hre_ContractModel).CreateInstance();
                    foreach (var property in item.GetType().GetProperties())
                    {
                        newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name));
                    }
                    listModel.Add(newModle);
                }
                var dataSourceResult = listModel.ToDataSourceResult(request);
                if (listModel.FirstOrDefault().GetPropertyValue("TotalRow") != null)
                {
                    dataSourceResult.Total = listModel.Count() <= 0 ? 0 : (int)listModel.FirstOrDefault().GetPropertyValue("TotalRow");
                }
                return Json(dataSourceResult, JsonRequestBehavior.AllowGet);
            }
            return Json(result.ToDataSourceResult(request));

        }
Exemple #24
0
        public ActionResult EditContractByEvaContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var contractServices = new Hre_ContractServices();

            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

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

            var objAppendixContarct = new List<object>();
            objAppendixContarct.AddRange(new object[7]);
            objAppendixContarct[5] = 1;
            objAppendixContarct[6] = int.MaxValue - 1;
            var lstAppendixContract = actionService.GetData<Hre_AppendixContractEntity>(objAppendixContarct, ConstantSql.hrm_hr_sp_get_AppendixContract, ref status).ToList();

            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();


            foreach (var item in lstContract)
            {
                if (item.DateExtend == null)
                {
                    item.DateExtend = item.DateEnd;
                }

                    item.ContractResult = model.ContractResult;
                    item.ContractEvaType = model.ContractEvaType;
                    item.ContractEvaType = model.ContractEvaType;
                    item.DateOfContractEva = model.DateOfContractEva;
                    item.EvaluationResult = model.EvaluationResult;
                    item.TypeOfPass = model.TypeOfPass;
                    item.RankDetailForNextContract = model.RankDetailForNextContract;
                    item.NextContractTypeID = model.NextContractTypeID;
                    item.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_WAITING.ToString();
                    var nextContracttype = lstContractType.Where(s => s.ID == model.NextContractTypeID).FirstOrDefault();
                    var contractEntity = new Hre_ContractEntity();
                    contractEntity = item.CopyData<Hre_ContractEntity>();
                    if (item.DateEnd != null)
                    {
                        contractEntity.DateStart = item.DateEnd.Value.AddDays(1);
                    }
                    SetNewDateEndNextContractByContractAndNextContractID(contractEntity, model.NextContractTypeID.Value);
                    item.DateEndNextContract = contractEntity.DateEndNextContract;
                    message = contractServices.Edit(item);
            }

            return Json(message, JsonRequestBehavior.AllowGet);
        }
Exemple #25
0
        public ActionResult GetEvaluationContractWaitingList([DataSourceRequest] DataSourceRequest request, Hre_EvaluationContractWaitingApprovedSearchModel model)
        {
            int _page = request.Page;
            var service = new Hre_ReportServices();
            var ActionService = new ActionService(UserLogin);
            var contractServices = new Hre_ContractServices();
            string status = string.Empty;
            request.Page = 1;
            request.PageSize = int.MaxValue - 1;
            var result = GetListData<Hre_ContractModel, Hre_ContractEntity, Hre_EvaluationContractWaitingApprovedSearchModel>(request, model,
                ConstantSql.hrm_hr_sp_get_EvaluationContractWaitingApprove, ref status);
            if (result != null)
            {
                result = result.Where(s => s.StatusEvaluation != "E_APPROVED" && s.ContractResult != null).ToList();
            }
            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);

            if (model.IsMissingInformation == true)
            {
                result = result.Where(s => s.DateEndNextContract == null).ToList();
            }

            var lstContractEntity = result.Translate<Hre_ContractEntity>();
            DataTable tableData = contractServices.GetDataContract(lstContractEntity, UserLogin);
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateStart == null ? DateTime.Now : model.DateStart };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateEnd == null ? DateTime.Now : model.DateEnd };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            var isDataTable = false;
            DataTable obj = null;
            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = tableData;
                isDataTable = true;
            }

            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Hre_ContractEntity",
                    OutPutPath = path,
                    HeaderInfo=listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = true
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, tableData, listHeaderInfo, model.ExportType);

                return Json(fullPath);
            }
            var listModel = new List<Hre_ContractModel>();
            if (result != null)
            {
                request.Page = _page;
                foreach (var item in result)
                {
                    var newModle = (Hre_ContractModel)typeof(Hre_ContractModel).CreateInstance();
                    foreach (var property in item.GetType().GetProperties())
                    {
                        newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name));
                    }
                    listModel.Add(newModle);
                }
                var dataSourceResult = listModel.ToDataSourceResult(request);
                if (listModel.FirstOrDefault().GetPropertyValue("TotalRow") != null)
                {
                    dataSourceResult.Total = result.Count;
                }
                return Json(dataSourceResult, JsonRequestBehavior.AllowGet);
            }
            return Json(result.ToDataSourceResult(request));

        }
Exemple #26
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;
        }
Exemple #27
0
        public ActionResult ExportAllContractEndList([DataSourceRequest] DataSourceRequest request, Hre_ContractEndSearchModel model)
        {
            Hre_ContractServices ActionServices = new Hre_ContractServices();
            string status = string.Empty;
            var result = GetListData<Hre_ContractModel, Hre_ContractEntity, Hre_ContractEndSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_ContractEnd, ref status);
            var lstEntity = result.Translate<Hre_ContractEntity>();
            DataTable tb = ActionServices.GetDataContract(lstEntity, UserLogin);
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = tb,
                    FileName = "Hre_ContractEntity",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = true
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            if (model.ExportId != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportId, tb, null, model.ExportType);
                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }
Exemple #28
0
        public string ActionApprovedComeBack(string selectedIds, string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string message = string.Empty;
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Hre_StopWorkingRepository(unitOfWork);
                var profileServices = new Hre_ProfileServices();
                var contractSevices = new Hre_ContractServices();
                var ContractExtendServices = new Hre_ContractExtendServices();
                var contractTypeSevices = new Cat_ContractTypeServices();

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

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

                            if (contractType.ValueTime != null)
                            {
                                month = (int)contractType.ValueTime.Value;
                                if (contractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                                {
                                    month = month * 12;
                                }
                                contract.DayContract = month;
                                if (contract.DateEnd != null)
                                {
                                    if (Suspense.DateComeBack <= contract.DateEnd.Value)
                                    {
                                        if (Suspense.DateStop != null)
                                        {
                                            double daySus = ((Suspense.DateComeBack.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30);
                                            contract.DayExtend = (int)Math.Floor(daySus);
                                            if (contract.DateExtend == null)
                                            {
                                                contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            else
                                            {
                                                contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (Suspense.DateStop != null)
                                        {
                                            double daySus = (contract.DateEnd.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30;
                                            contract.DayExtend = (int)Math.Floor(daySus);
                                            if (contract.DateExtend == null)
                                            {
                                                contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            else
                                            {
                                                contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            Suspense.DateComeBack = Suspense.DateComeBack.Value.AddMonths(contract.DayExtend.Value);
                                        }
                                    }
                                }
                            }
                            contract.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();
                            Hre_ContractExtendEntity contractExtend = new Hre_ContractExtendEntity();
                            contractExtend.ContractID = contract.ID;
                            contractExtend.DateStart = Suspense.DateComeBack;
                            contractExtend.DateEnd = contract.DateExtend;
                            contractSevices.Edit(contract);
                            ContractExtendServices.Add(contractExtend);
                        }
                    }
                    repo.Edit(Suspense);
                }
                repo.SaveChanges();
                message = NotificationType.Success.ToString();
                return message;
            }
        }
Exemple #29
0
        public ActionResult ExportContractListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_ContractSearchModel model)
        {
            string status = string.Empty;
            var contractServices = new Hre_ContractServices();
            var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var result = GetListData<Hre_ContractModel, Hre_ContractEntity, Hre_ContractSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_ContractList, ref status);
            DataTable tb = new DataTable();
            var actionServices = new ActionService(UserLogin);
            var _ConstractSearchModel = new Hre_ContractSearchModel();
            var _lsContractAll = GetListData<Hre_ContractModel, Hre_ContractEntity, Hre_ContractSearchModel>(request, _ConstractSearchModel, ConstantSql.hrm_hr_sp_get_Contract, ref status);

            var Lstobj = new List<object>();
            Lstobj.AddRange(new object[18]);
            Lstobj[16] = 1;
            Lstobj[17] = (int.MaxValue - 1);
            var _profileAll = actionServices.GetData<Hre_ProfileEntity>(Lstobj, ConstantSql.hrm_hr_sp_get_Profile, ref status);

            #region lay thong tin hop dong
            for (int i = 0; i < result.Count; i++)
            {
                #region Lay thong tin Profile
                var _profile = _profileAll.Where(s => s.ID == result[i].ProfileID && result[i].ProfileID != null).FirstOrDefault();
                if (_profile != null)
                {
                    if (_profile.PAddress != null)
                        result[i].PAddress = _profile.PAddress;

                    if (_profile.PDistrictName != null)
                        result[i].PDistrictName = _profile.PDistrictName;

                    if (_profile.PCountryName != null)
                        result[i].PCountryName = _profile.PCountryName;

                    if (_profile.PProvinceName != null)
                        result[i].PProvinceName = _profile.PProvinceName;

                    if (result[i].ProfileName != null)
                    {
                        var _profilename = result[i].ProfileName.Split(' ');
                        if (_profilename.Count() == 1)
                        {
                            result[i].FristName = result[i].ProfileName;
                        }
                        else
                        {
                            if (_profilename.Count() == 2)
                            {
                                result[i].FristName = _profilename[0];
                                result[i].LastName = _profilename[1];
                            }
                            else
                            {
                                result[i].FristName = _profilename[0];
                                result[i].LastName = _profilename[_profilename.Count() - 1];
                                for (int j = 1; j < _profilename.Count() - 1; j++)
                                {
                                    result[i].TenDem = result[i].TenDem + _profilename[j];
                                }
                            }

                        }
                    }
                }
                #endregion
                #region Lay thong tin hopn dong truoc do
                var _lsContract = _lsContractAll.Where(s => s.ID == result[i].ID && result[i].ID != null).ToList();
                if (_lsContract != null && _lsContract.Count >= 2)
                {
                    _lsContract = _lsContract.Where(m => m.DateSigned <= result[i].DateSigned).ToList();
                    if (_lsContract.Count >= 2)
                    {
                        Hre_ContractModel _contract = new Hre_ContractModel();
                        _lsContract = _lsContract.OrderByDescending(m => m.DateSigned).ToList();
                        _contract = _lsContract[0];
                        if (_contract.DateStart != null)
                        {
                            result[i].DateStartOld = _contract.DateStart;
                            result[i].DateStartOld_Day = _contract.DateStart.Day.ToString();
                            result[i].DateStartOld_Month = _contract.DateStart.Month.ToString();
                            result[i].DateStartOld_Year = _contract.DateStart_Year.ToString();
                        }
                        if (_contract.DateEnd != null)
                        {
                            result[i].DateEndOld = _contract.DateEnd;
                            result[i].DateEndOld_Day = _contract.DateEnd.Value.Day.ToString();
                            result[i].DateEndOld_Month = _contract.DateEnd.Value.Month.ToString();
                            result[i].DateEndOld_Year = _contract.DateEnd.Value.Year.ToString();
                        }
                        if (_contract.DateSigned != null)
                        {
                            result[i].DateSignedOld = _contract.DateSigned;
                            result[i].DateSignedOld_Day = _contract.DateSigned.Value.Day.ToString();
                            result[i].DateSignedOld_Month = _contract.DateSigned.Value.Month.ToString();
                            result[i].DateSignedOld_Year = _contract.DateSigned.Value.Year.ToString();
                        }
                    }

                }
                #endregion
            }

            #endregion


            var lstEntity = result.Translate<Hre_ContractEntity>();
            tb = contractServices.GetDataContract(lstEntity, UserLogin);

            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = tb,
                    FileName = "Hre_Contract",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = true
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            if (model.ExportId != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportId, lstEntity, null, model.ExportType);
                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }
Exemple #30
0
        public DataTable GetReportContractDetail(List<Hre_ProfileEntity> lstProfile, DateTime? _DateSignedStart, DateTime? _DateSignedEnd, string _ContractNo, Guid? _ContractTypeID, bool isCreateTemplate, String nameReport)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCat_ContractType = new CustomBaseRepository<Cat_ContractType>(unitOfWork);
                var repoHre_Contract = new CustomBaseRepository<Hre_Contract>(unitOfWork);
                var repoHre_AppendixContract = new CustomBaseRepository<Hre_AppendixContract>(unitOfWork);
                var repoCat_OrgStructure = new CustomBaseRepository<Cat_OrgStructure>(unitOfWork);
                var repoCat_OrgStructureType = new CustomBaseRepository<Cat_OrgStructureType>(unitOfWork);

                var lstContracType = repoCat_ContractType.FindBy(s => s.IsDelete == null).ToList();
                DataTable tb = GetSchema_ContractDetail(nameReport, lstContracType);

                if (isCreateTemplate)
                {
                    return tb.ConfigTable();
                }

                #region code BC

                //var profileQueryable = unitOfWork.CreateQueryable<Hre_Profile>(Guid.Empty,
                //    d => d.DateHire >= monthStart && d.DateHire <= monthEnd);

                //if (!string.IsNullOrWhiteSpace(codeEmp))
                //{
                //    profileQueryable = profileQueryable.Where(d => d.CodeEmp.Contains(codeEmp));
                //}

                //if (!string.IsNullOrWhiteSpace(profileName))
                //{
                //    profileQueryable = profileQueryable.Where(d => d.ProfileName.Contains(profileName));
                //}

                //if (listOrgID != null && listOrgID.Count() > 0)
                //{
                //    profileQueryable = profileQueryable.Where(d => d.OrgStructureID.HasValue && listOrgID.Contains(d.OrgStructureID.Value));
                //}

                string status = string.Empty;
                //List<object> listModel = new List<object>();

                //listModel = new List<object>();
                //listModel.AddRange(new object[16]);
                //listModel[2] = null;
                //listModel[8] = monthStart;
                //listModel[9] = monthEnd;
                //listModel[14] = null;
                //listModel[15] = Int32.MaxValue - 1;
                //List<Hre_ProfileEntity> lstProfile = GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_Profile, ref status);

                //var profileQueryable = unitOfWork.CreateQueryable<Hre_Profile>(Guid.Empty,
                //    d => d.DateHire >= monthStart && d.DateHire <= monthEnd);

                //if (!string.IsNullOrWhiteSpace(codeEmp))
                //{
                //    lstProfile = lstProfile.Where(d => d.CodeEmp.Contains(codeEmp)).ToList();
                //}

                //if (!string.IsNullOrWhiteSpace(profileName))
                //{
                //    lstProfile = lstProfile.Where(d => d.ProfileName.Contains(profileName)).ToList();
                //}

                //if (listOrgID != null && listOrgID.Count() > 0)
                //{
                //    lstProfile = lstProfile.Where(d => d.OrgStructureID.HasValue && listOrgID.Contains(d.OrgStructureID.Value)).ToList();
                //}

                //List<Hre_ProfileEntity> lstProfile = profileQueryable.Select(d => new Hre_ProfileEntity
                //{
                //    ID = d.ID,
                //    CodeEmp = d.CodeEmp,
                //    CodeAttendance = d.CodeAttendance,
                //    ProfileName = d.ProfileName,
                //    DateOfBirth = d.DateOfBirth,
                //    Gender = d.Gender,
                //    PlaceOfBirth = d.PlaceOfBirth,
                //    PAddress = d.PAddress,
                //    IDNo = d.IDNo,
                //    IDDateOfIssue = d.IDDateOfIssue,
                //    IDPlaceOfIssue = d.IDPlaceOfIssue,
                //    DateHire = d.DateHire,
                //    DateQuit = d.DateQuit,
                //    StatusSyn = d.StatusSyn,
                //    PositionName = d.Cat_Position.PositionName,
                //    SalaryClassName = d.Cat_SalaryClass.SalaryClassName,
                //    OrgStructureID=d.OrgStructureID
                //}).ToList();

                List<Guid> lstProfileIDs = lstProfile.Select(m => m.ID).Distinct().ToList();
                string E_APPROVED = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();

                #region getdata COntract Appendix

                // string status = string.Empty;
                var hreServiceContract = new Hre_ContractServices();
                List<object> paraContract = new List<object>();
                paraContract.AddRange(new object[16]);
                paraContract[13] = E_APPROVED;
                paraContract[14] = 1;
                paraContract[15] = Int32.MaxValue - 1;

                var AppendixServices = new Hre_AppendixContractServices();
                List<object> paraAppendix = new List<object>();
                paraAppendix.AddRange(new object[7]);
                paraAppendix[5] = 1;
                paraAppendix[6] = Int32.MaxValue - 1;

                #endregion

                var lstContractAll = new List<Hre_Contract>().Select(m => new
                {
                    m.ID,
                    m.Status,
                    m.ContractTypeID,
                    m.ProfileID,
                    m.DateStart,
                    m.DateEnd,
                    m.ContractNo,
                    m.DateSigned
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstContractAll.AddRange(unitOfWork.CreateQueryable<Hre_Contract>(Guid.Empty, m => m.Status == E_APPROVED
                        && lstProfileID.Contains(m.ProfileID)).Select(m => new
                        {
                            m.ID,
                            m.Status,
                            m.ContractTypeID,
                            m.ProfileID,
                            m.DateStart,
                            m.DateEnd,
                            m.ContractNo,
                            m.DateSigned
                        }).ToList());
                }
                if (_DateSignedStart != null)
                    lstContractAll = lstContractAll.Where(s => s.DateSigned != null && s.DateSigned >= _DateSignedStart).ToList();
                if (_DateSignedEnd != null)
                    lstContractAll = lstContractAll.Where(s => s.DateSigned != null && s.DateSigned <= _DateSignedEnd).ToList();
                if (_ContractNo != string.Empty && _ContractNo != null)
                    lstContractAll = lstContractAll.Where(s => s.ContractNo != null && s.ContractNo == _ContractNo).ToList();
                if (_ContractTypeID != null && _ContractTypeID != Guid.Empty)
                    lstContractAll = lstContractAll.Where(s => s.ContractTypeID == _ContractTypeID).ToList();

                List<Guid> lstContractIDs = lstContractAll.Select(m => m.ID).ToList();

                var lstAppendixContract = new List<Hre_AppendixContractEntity>().Select(m => new
                {
                    m.ID,
                    m.ContractID,
                    m.Code,
                    m.DateofEffect,
                    m.DateEndAppendixContract
                }).ToList();

                foreach (var lstContractID in lstContractIDs.Chunk(1000))
                {
                    lstAppendixContract.AddRange(unitOfWork.CreateQueryable<Hre_AppendixContract>(Guid.Empty,
                        m => lstContractID.Contains(m.ContractID)).Select(m => new
                        {
                            m.ID,
                            m.ContractID,
                            m.Code,
                            m.DateofEffect,
                            m.DateEndAppendixContract
                        }).ToList());
                }

                var lstOrg = repoCat_OrgStructure.GetAll().ToList();
                var orgTypes = repoCat_OrgStructureType.GetAll().ToList();

                #region Phu luc hd
                var lstContractExtend = new List<Hre_ContractExtend>().Select(s => new
                {
                    s.ContractID,
                    s.AnnexCode,
                    s.DateStart,
                    s.DateEnd
                }).ToList();

                foreach (var lstContractID in lstContractIDs.Chunk(1000))
                {
                    lstContractExtend.AddRange(unitOfWork.CreateQueryable<Hre_ContractExtend>(Guid.Empty, s => lstContractID.Contains(s.ContractID.Value)).Select(s => new
                    {
                        s.ContractID,
                        s.AnnexCode,
                        s.DateStart,
                        s.DateEnd
                    }).ToList());
                }

                #endregion

                int stt = 0;
                foreach (var profile in lstProfile)
                {
                    stt++;
                    DataRow dr = tb.NewRow();
                    dr["Stt"] = stt;
                    dr["CodeEmp"] = profile.CodeEmp;
                    dr["ProfileName"] = profile.ProfileName;

                    //var orgId = profile.OrgStructureID;
                    //var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, lstOrg, orgTypes);
                    //var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, lstOrg, orgTypes);
                    //var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, lstOrg, orgTypes);
                    //var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, lstOrg, orgTypes);
                    //var orgDivision = LibraryService.GetNearestParent(orgId, OrgUnit.E_DIVISION, lstOrg, orgTypes);
                    //var orgUnit = LibraryService.GetNearestParent(orgId, OrgUnit.E_UNIT, lstOrg, orgTypes);


                    dr["E_DIVISION"] = profile.E_DIVISION;

                    dr["E_UNIT"] = profile.E_UNIT;

                    dr["E_DEPARTMENT"] = profile.E_DEPARTMENT;

                    dr["E_TEAM"] = profile.E_TEAM;

                    dr["E_SECTION"] = profile.E_SECTION;

                    //if (orgDivision != null)
                    //{
                    //    dr["E_DIVISION"] = orgDivision.OrgStructureName;
                    //}
                    //if (orgUnit != null)
                    //{
                    //    dr["E_UNIT"] = orgUnit.OrgStructureName;
                    //}
                    //if (orgOrg != null)
                    //{
                    //    dr["E_DEPARTMENT"] = orgOrg.OrgStructureName;
                    //}
                    //if (orgTeam != null)
                    //{
                    //    dr["E_TEAM"] = orgTeam.OrgStructureName;
                    //}
                    //if (orgSection != null)
                    //{
                    //    dr["E_SECTION"] = orgSection.OrgStructureName;
                    //}
                    if (!string.IsNullOrWhiteSpace(profile.PositionName))
                    {
                        dr["Position"] = profile.PositionName;
                    }
                    if (profile.DateOfBirth != null)
                    {
                        dr["DateOfBirth"] = profile.DateOfBirth;
                    }
                    if (profile.Gender != null)
                    {
                        dr["Gender"] = profile.Gender.TranslateString();
                    }

                    if (profile.PlaceOfBirth != null)
                    {
                        dr["PlaceOfBirth"] = profile.PlaceOfBirth;
                    }
                    if (profile.PAddress != null)
                    {
                        dr["PAddress"] = profile.PAddress;
                    }
                    if (profile.IDNo != null)
                    {
                        dr["IDNo"] = profile.IDNo;
                    }
                    if (profile.IDDateOfIssue != null)
                    {
                        dr["IDDateOfIssue"] = profile.IDDateOfIssue;
                    }
                    if (profile.IDPlaceOfIssue != null)
                    {
                        dr["IDPlaceOfIssue"] = profile.IDPlaceOfIssue;
                    }
                    if (profile.DateHire != null)
                    {
                        dr["DateHire"] = profile.DateHire;
                    }

                    if (!string.IsNullOrWhiteSpace(profile.SalaryClassName))
                    {
                        dr["SalaryClass"] = profile.SalaryClassName;
                    }
                    var lstContractByProfile = lstContractAll.Where(m => m.ProfileID == profile.ID).OrderBy(m => m.DateStart).ToList();
                    var lstContractByProfileID = lstContractByProfile.Select(m => m.ID).ToList();
                    var lstAppendixContractByProfile = lstAppendixContract.Where(m => lstContractByProfileID.Contains(m.ContractID)).ToList();

                    foreach (var ContractType in lstContracType)
                    {
                        string ContractCode = ContractType.Code;
                        if (string.IsNullOrEmpty(ContractCode))
                            continue;

                        var ContractOfProfileByType = lstContractByProfile.Where(m => m.ContractTypeID == ContractType.ID).FirstOrDefault();
                        if (ContractOfProfileByType != null)
                        {
                            if (ContractOfProfileByType.ContractNo != null)
                                dr[ContractCode + "_" + "ContractNo"] = ContractOfProfileByType.ContractNo;
                            if (ContractOfProfileByType.DateStart != null)
                                dr[ContractCode + "_" + "DateStart"] = ContractOfProfileByType.DateStart;
                            if (ContractOfProfileByType.DateEnd != null)
                                dr[ContractCode + "_" + "DateEnd"] = ContractOfProfileByType.DateEnd;

                            var lstAppendixContractByContract = lstAppendixContractByProfile.Where(m => m.ContractID == ContractOfProfileByType.ID).OrderBy(m => m.DateofEffect).ToList();
                            int numAppendix = 0;
                            foreach (var AppendixContract in lstAppendixContractByContract)
                            {
                                numAppendix++;
                                if (numAppendix > 3)
                                    continue;
                                if (string.IsNullOrEmpty(AppendixContract.Code))
                                    continue;
                                dr[ContractCode + "_" + numAppendix + "_" + "Code"] = AppendixContract.Code;
                                if (AppendixContract.DateofEffect != null)
                                {
                                    dr[ContractCode + "_" + numAppendix + "_" + "DateofEffect"] = AppendixContract.DateofEffect;
                                }
                                if (AppendixContract.DateEndAppendixContract != null)
                                {
                                    dr[ContractCode + "_" + numAppendix + "_" + "DateEndAppendixContract"] = AppendixContract.DateEndAppendixContract;
                                }
                            }
                            var lstContractExtendByContract = lstContractExtend.Where(s => s.ContractID == ContractOfProfileByType.ID).OrderBy(s => s.DateStart).ToList();
                            int numContractExtend = 0;
                            foreach (var objContractExtend in lstContractExtendByContract)
                            {
                                numContractExtend++;
                                if (numContractExtend > 5)
                                    continue;
                                if (objContractExtend.AnnexCode != null)
                                    dr[ContractCode + "_" + numContractExtend + "_" + "CodeExtend"] = objContractExtend.AnnexCode;
                                if (objContractExtend.DateStart != null)
                                    dr[ContractCode + "_" + numContractExtend + "_" + "DateStartExtend"] = objContractExtend.DateStart;
                                if (objContractExtend.DateEnd != null)
                                    dr[ContractCode + "_" + numContractExtend + "_" + "DateEndExtend"] = objContractExtend.DateEnd;
                            }
                        }
                    }
                    tb.Rows.Add(dr);
                }
                #endregion
                var configs = new Dictionary<string, Dictionary<string, object>>();
                return tb.ConfigTable(configs);
            }
        }
Exemple #31
0
        public string ActionApprovedComeBack(string selectedIds, string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string message                = string.Empty;
                string status                 = string.Empty;
                var    unitOfWork             = (IUnitOfWork)(new UnitOfWork(context));
                var    repo                   = new Hre_StopWorkingRepository(unitOfWork);
                var    profileServices        = new Hre_ProfileServices();
                var    contractSevices        = new Hre_ContractServices();
                var    ContractExtendServices = new Hre_ContractExtendServices();
                var    contractTypeSevices    = new Cat_ContractTypeServices();

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

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

                            if (contractType.ValueTime != null)
                            {
                                month = (int)contractType.ValueTime.Value;
                                if (contractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                                {
                                    month = month * 12;
                                }
                                contract.DayContract = month;
                                if (contract.DateEnd != null)
                                {
                                    if (Suspense.DateComeBack <= contract.DateEnd.Value)
                                    {
                                        if (Suspense.DateStop != null)
                                        {
                                            double daySus = ((Suspense.DateComeBack.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30);
                                            contract.DayExtend = (int)Math.Floor(daySus);
                                            if (contract.DateExtend == null)
                                            {
                                                contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            else
                                            {
                                                contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (Suspense.DateStop != null)
                                        {
                                            double daySus = (contract.DateEnd.Value.Subtract(Suspense.DateStop.Value)).TotalDays / 30;
                                            contract.DayExtend = (int)Math.Floor(daySus);
                                            if (contract.DateExtend == null)
                                            {
                                                contract.DateExtend = contract.DateEnd.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            else
                                            {
                                                contract.DateExtend = contract.DateExtend.Value.AddMonths(contract.DayExtend.Value);
                                            }
                                            Suspense.DateComeBack = Suspense.DateComeBack.Value.AddMonths(contract.DayExtend.Value);
                                        }
                                    }
                                }
                            }
                            contract.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();
                            Hre_ContractExtendEntity contractExtend = new Hre_ContractExtendEntity();
                            contractExtend.ContractID = contract.ID;
                            contractExtend.DateStart  = Suspense.DateComeBack;
                            contractExtend.DateEnd    = contract.DateExtend;
                            contractSevices.Edit(contract);
                            ContractExtendServices.Add(contractExtend);
                        }
                    }
                    repo.Edit(Suspense);
                }
                repo.SaveChanges();
                message = NotificationType.Success.ToString();
                return(message);
            }
        }