Example #1
0
        public JsonResult CreatePersonalInfo(Hre_ProfileModel model, string userLogin)
        {
            var id = Session[SessionObjects.ProfileID];
            var serv = new Hre_ProfileServices();
            string status = string.Empty;
            var profile = serv.GetData<Hre_ProfileModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();

            bool change = false;
            #region check change
            if (profile.NameEnglish != model.NameEnglish)
                change = true;
            if (profile.Gender != model.Gender)
                change = true;
            if (profile.DayOfBirth != model.DayOfBirth)
                change = true;
            if (profile.MonthOfBirth != model.MonthOfBirth)
                change = true;
            if (profile.YearOfBirth != model.YearOfBirth)
                change = true;
            if (profile.NationalityID != model.NationalityID)
                change = true;
            if (profile.PlaceOfBirth != model.PlaceOfBirth)
                change = true;
            if (profile.MarriageStatus != model.MarriageStatus)
                change = true;
            if (profile.IDNo != model.IDNo)
                change = true;
            if (profile.IDDateOfIssue != model.IDDateOfIssue)
                change = true;
            if (profile.IDPlaceOfIssue != model.IDPlaceOfIssue)
                change = true;
            if (profile.Origin != model.Origin)
                change = true;
            //if (profile.TypeOfVehicle != model.TypeOfVehicle)
            //    change = true;
            //if (profile.LockerName != model.LockerName)
            //    change = true;
            if (profile.EducationLevelID != model.EducationLevelID)
                change = true;
            if (profile.EthnicID != model.EthnicID)
                change = true;
            if (profile.Notes != model.Notes)
                change = true;
            if (profile.BloodType != model.BloodType)
                change = true;
            if (profile.Height != model.Height)
                change = true;
            if (profile.Weight != model.Weight)
                change = true;
            if (profile.PassportNo != model.PassportNo)
                change = true;
            if (profile.PassportPlaceOfIssue != model.PassportPlaceOfIssue)
                change = true;
            if (profile.PassportDateOfIssue != model.PassportDateOfIssue)
                change = true;
            if (profile.PassportDateOfExpiry != model.PassportDateOfExpiry)
                change = true;

           
            
            #endregion
            if (!change)
            {
                profile.ActionStatus = "Success";
                return Json(profile);
            }
            if (profile.ID == model.ID)
            {

                profile.ActionStatus = model.ActionStatus;
                profile.NameEnglish = model.NameEnglish;
                profile.Gender = model.Gender;
                profile.DayOfBirth = model.DayOfBirth;
                profile.MonthOfBirth = model.MonthOfBirth;
                profile.YearOfBirth = model.YearOfBirth;
                profile.NationalityID = model.NationalityID;
                profile.PlaceOfBirth = model.PlaceOfBirth;
                profile.MarriageStatus = model.MarriageStatus;
                profile.IDNo = model.IDNo;
                profile.IDDateOfIssue = model.IDDateOfIssue;
                profile.IDPlaceOfIssue = model.IDPlaceOfIssue;
                profile.Origin = model.Origin;
                profile.EducationLevelID = model.EducationLevelID;
                profile.EthnicID = model.EthnicID;
                profile.Notes = model.Notes;
                profile.BloodType = model.BloodType;
                profile.Height = model.Height;
                profile.Weight = model.Weight;
                profile.PassportNo = model.PassportNo;
                profile.PassportPlaceOfIssue = model.PassportPlaceOfIssue;
                profile.PassportDateOfIssue = model.PassportDateOfIssue;
                profile.PassportDateOfExpiry = model.PassportDateOfExpiry;

            
            }

            var service = new RestServiceClient<Hre_ProfileModel>(UserLogin);
            service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
            var result = service.Post(_Hrm_Hre_Service, "api/Hre_Profile/", profile);
            return Json(result);
        }
Example #2
0
        public JsonResult CreateContactInfo(Hre_ProfileModel model, string userLogin)
        {
            var id = Session[SessionObjects.ProfileID];
            var serv = new Hre_ProfileServices();
            string status = string.Empty;
            var profile = serv.GetData<Hre_ProfileModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();

            bool change = false;
            #region check change
            if (profile.Email != model.Email)
                change = true;
            if (profile.Email2 != model.Email2)
                change = true;
            if (profile.Cellphone != model.Cellphone)
                change = true;
            if (profile.HomePhone != model.HomePhone)
                change = true;

            if (profile.TCountryID != model.TCountryID)
                change = true;
            if (profile.TDistrictID != model.TDistrictID)
                change = true;

            if (profile.TProvinceID != model.TProvinceID)
                change = true;

            if (profile.TAVillageID != model.TAVillageID)
                change = true;

            if (profile.TAddress != model.TAddress)
                change = true;



            if (profile.PCountryID != model.PCountryID)
                change = true;
            if (profile.PDistrictID != model.PDistrictID)
                change = true;

            if (profile.PProvinceID != model.PProvinceID)
                change = true;

            if (profile.VillageID != model.VillageID)
                change = true;

            if (profile.PAddress != model.PAddress)
                change = true;

            if (profile.AddressEmergency != model.AddressEmergency)
                change = true;
            
            #endregion

            if (!change)
            {
                profile.ActionStatus = "Success";
                return Json(profile);
            }
            if (profile.ID == model.ID)
            {
                profile.ActionStatus = model.ActionStatus;
                profile.Email = model.Email;
                profile.Email2 = model.Email2;
                profile.Cellphone = model.Cellphone;
                profile.HomePhone = model.HomePhone;
                profile.TCountryID = model.TCountryID;
                profile.TDistrictID = model.TDistrictID;
                profile.TProvinceID = model.TProvinceID;
                profile.TAVillageID = model.TAVillageID;
                profile.TAddress = model.TAddress;
                profile.PCountryID = model.PCountryID;
                profile.PDistrictID = model.PDistrictID;
                profile.PProvinceID = model.PProvinceID;
                profile.VillageID = model.VillageID;
                profile.PAddress = model.PAddress;
                profile.AddressEmergency = model.AddressEmergency;
            }

            var service = new RestServiceClient<Hre_ProfileModel>(UserLogin);
            service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
            var result = service.Post(_Hrm_Hre_Service, "api/Hre_Profile/", profile);
            return Json(result);
        }
Example #3
0
        public ActionResult ExportProfileAllListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_ProfileAllSearchModel model)
        {
            string status = string.Empty;
            var isDataTable = false;
            var service = new BaseService();
            object obj = new Hre_ProfileModel();
            ListQueryModel lstModel = new ListQueryModel
            {
                PageSize = int.MaxValue - 1,
                PageIndex = 1,
                Filters = ExtractFilterAttributes(request),
                Sorts = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            var result = GetListData<Hre_ProfileModel, Hre_ProfileEntity, Hre_ProfileAllSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_ProfileAll, ref status);


            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = result;
                isDataTable = false;
            }
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

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

            if (model.ExportId != Guid.Empty)
            {

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));
        }
Example #4
0
        public JsonResult CreateBasicInfo(Hre_ProfileModel model, string userLogin)
        {
            var id = Session[SessionObjects.ProfileID];
            var serv = new Hre_ProfileServices();
            string status = string.Empty;
            var profile = serv.GetData<Hre_ProfileModel>(HRM.Infrastructure.Utilities.Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();

            bool change = false;
            #region check change
            if (profile.ProfileName != model.ProfileName)
                change = true;
            if (profile.CodeAttendance != model.CodeAttendance)
                change = true;
            if (profile.CodeEmp != model.CodeEmp)
                change = true;
            if (profile.DateApplyAttendanceCode != model.DateApplyAttendanceCode)
                change = true;
            if (profile.WorkPlaceName != model.WorkPlaceName)
                change = true;
            if (profile.CodeTax != model.CodeTax)
                change = true;
            if (profile.DateOfIssuedTaxCode != model.DateOfIssuedTaxCode)
                change = true;
            if (profile.DateHire != model.DateHire)
                change = true;
            if (profile.DateEndProbation != model.DateEndProbation)
                change = true;
            if (profile.JobTitleID != model.JobTitleID)
                change = true;
            if (profile.PositionID != model.PositionID)
                change = true;
            if (profile.EmpTypeID != model.EmpTypeID)
                change = true;
            if (profile.PayrollGroupID != model.PayrollGroupID)
                change = true;
            if (profile.JobTitleID != model.JobTitleID)
                change = true;
            if (profile.PositionID != model.PositionID)
                change = true;
            if (profile.EmpTypeID != model.EmpTypeID)
                change = true;
            if (profile.PayrollGroupID != model.PayrollGroupID)
                change = true;
            if (profile.DateOfEffect != model.DateOfEffect)
                change = true;
            if (profile.LaborType != model.LaborType)
                change = true;
            if (profile.WorkPlaceID != model.WorkPlaceID)
                change = true;
            if (profile.SupervisorID != model.SupervisorID)
                change = true;
            if (profile.HighSupervisorID != model.HighSupervisorID)
                change = true;
            #endregion
            if (!change)
            {
                profile.ActionStatus = "Success";
                return Json(profile);
            }
            if (profile.ID == model.ID)
            {
                profile.ActionStatus = model.ActionStatus;
                profile.ProfileName = model.ProfileName;
                profile.CodeAttendance = model.CodeAttendance;
                profile.CodeEmp = model.CodeEmp;
                profile.DateApplyAttendanceCode = model.DateApplyAttendanceCode;
                profile.LocationCode = model.LocationCode;
                profile.WorkPlaceName = model.WorkPlaceName;
                profile.CodeTax = model.CodeTax;
                profile.DateOfIssuedTaxCode = model.DateOfIssuedTaxCode;
                profile.DateHire = model.DateHire;
                //profile.PromotionCondition = model.PromotionCondition;
                profile.DateEndProbation = model.DateEndProbation;
                profile.JobTitleID = model.JobTitleID;
                profile.PositionID = model.PositionID;
                profile.EmpTypeID = model.EmpTypeID;
                profile.PayrollGroupID = model.PayrollGroupID;
                profile.DateOfEffect = model.DateOfEffect;
                profile.LaborType = model.LaborType;
                profile.WorkPlaceID = model.WorkPlaceID;
                profile.SupervisorID = model.SupervisorID;
                profile.HighSupervisorID = model.HighSupervisorID;
            }

            var service = new RestServiceClient<Hre_ProfileModel>(UserLogin);
            service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
            var result = service.Post(_Hrm_Hre_Service, "api/Hre_Profile/", profile);
            
            return Json(result);
        }
Example #5
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));
        }
Example #6
0
        public ActionResult ExportHDTJobListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_HDTJobSearchModel model)
        {
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom == null ? DateTime.Now : model.DateFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo == null ? DateTime.Now : model.DateTo };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            string status = string.Empty;
            var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var actionServices = new ActionService(UserLogin);
            List<object> lstObjSearch = new List<object>();
            lstObjSearch.Add(model.ProfileName);
            lstObjSearch.Add(model.CodeEmp);
            lstObjSearch.Add(model.HDTJobTypeID);
            lstObjSearch.Add(model.JobTitleID);
            lstObjSearch.Add(model.PositionID);
            lstObjSearch.Add(model.OrgStructureID);
            lstObjSearch.Add(model.DateFrom);
            lstObjSearch.Add(model.DateTo);
            lstObjSearch.Add(model.Price);
            lstObjSearch.Add(model.IsCreateTemplate);
            lstObjSearch.Add(model.ExportId);
            lstObjSearch.Add(model.ExportType);
            lstObjSearch.Add(1);
            lstObjSearch.Add(int.MaxValue - 1);
            var result = actionServices.GetData<Hre_HDTJobEntity>(lstObjSearch, ConstantSql.hrm_hr_sp_get_HDTJob, ref status);
            var profileServices = new Hre_ProfileServices();
            var listResult = profileServices.getHDTJobByPrice(result, model.DateFrom, model.DateTo).Translate<Hre_HDTJobModel>();
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_HDTJobModel(),
                    FileName = "Hre_HDTJob",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportId != Guid.Empty)
            {
                if (model.DateFrom != null && model.DateTo != null)
                {
                    var fullPath = ExportService.Export(model.ExportId, listResult, listHeaderInfo, model.ExportType);
                    return Json(fullPath);
                }
                else
                {
                    var fullPath = ExportService.Export(model.ExportId, listResult, null, model.ExportType);
                    return Json(fullPath);
                }

            }
            return Json(result.ToDataSourceResult(request));
        }
Example #7
0
        public ActionResult ExportProfileListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_ProfileActiveSearchModel model)
        {
            //if(model.ExportId == Guid.Empty)
            //{
            //    return null;
            //}
            var actionService = new ActionService(UserLogin);
            string status = string.Empty;
            var profileServices = new Hre_ProfileServices();

            bool isGroup = profileServices.IsGroupByOrgProfileQuit();
            var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var result = GetListData<Hre_ProfileModel, Hre_ProfileEntity, Hre_ProfileActiveSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_ProfileActive, ref status);

            if (isGroup == true)
            {
                var rptServices = new Hre_ReportServices();
                var orgServices = new Cat_OrgStructureServices();
                var lstObjOrg = new List<object>();
                lstObjOrg.Add(null);
                lstObjOrg.Add(null);
                lstObjOrg.Add(null);
                lstObjOrg.Add(1);
                lstObjOrg.Add(int.MaxValue - 1);
                var lstOrg = actionService.GetData<Cat_OrgStructureEntity>(lstObjOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, ref status).ToList();

                var orgTypeService = new Cat_OrgStructureTypeServices();
                var lstObjOrgType = new List<object>();
                lstObjOrgType.Add(null);
                lstObjOrgType.Add(null);
                lstObjOrgType.Add(1);
                lstObjOrgType.Add(int.MaxValue - 1);
                var lstOrgType = actionService.GetData<Cat_OrgStructureTypeEntity>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, ref status).ToList();

                result = GetListData<Hre_ProfileModel, Hre_ProfileEntity, Hre_ProfileActiveSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_ProfileActive, ref status);
                DataTable table = new DataTable("Hre_ProfileModel");
                table.Columns.Add("CodeEmp");
                table.Columns.Add("ProfileName");
                table.Columns.Add("FirstName");
                table.Columns.Add("NameFamily");
                table.Columns.Add("Channel");
                table.Columns.Add("Region");
                table.Columns.Add("Area");
                table.Columns.Add("IDNo");
                table.Columns.Add("IDDateOfIssue", typeof(DateTime));
                table.Columns.Add("IDPlaceOfIssue");
                table.Columns.Add("DateOfBirth", typeof(DateTime));
                table.Columns.Add("PlaceOfBirth");
                table.Columns.Add("Gender");
                table.Columns.Add("MarriageStatus");
                table.Columns.Add("NationalityName");
                table.Columns.Add("ReligionName");
                table.Columns.Add("EthnicGroupName");
                table.Columns.Add("Email");
                table.Columns.Add("CellPhone");
                table.Columns.Add("CodeTax");
                table.Columns.Add("TDistrictName");
                table.Columns.Add("PDistrictName");
                table.Columns.Add("JobTitleName");
                table.Columns.Add("DateHire", typeof(DateTime));
                table.Columns.Add("ContractNo");
                table.Columns.Add("DateStartContract");
                table.Columns.Add("DateEndContract");
                table.Columns.Add("ContractTypeName");
                table.Columns.Add("TimesOfContract");
                table.Columns.Add("Notes");
                table.Columns.Add("TAddress");
                table.Columns.Add("PAddress");
                table.Columns.Add("BasicSalary", typeof(double));

                var salaryServices = new Sal_BasicSalaryServices();
                var objSalary = new List<object>();
                objSalary.AddRange(new object[10]);
                objSalary[8] = 1;
                objSalary[9] = int.MaxValue - 1;
                var lstBasicSalary = actionService.GetData<Sal_BasicSalaryEntity>(objSalary, ConstantSql.hrm_sal_sp_get_BasicPayroll, ref status).ToList();

                var unuServices = new Sal_UnusualAllowanceServices();
                var objUnu = new List<object>();
                objUnu.AddRange(new object[9]);
                objUnu[7] = 1;
                objUnu[8] = int.MaxValue - 1;
                var lstUnu = actionService.GetData<Sal_UnusualAllowanceEntity>(objUnu, ConstantSql.hrm_sal_sp_get_UnusualED, ref status).ToList();

                foreach (var item in result)
                {
                    var basicSalaryEntity = lstBasicSalary.Where(s => s.ProfileID == item.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    var lstUnuByProfileID = lstUnu.Where(s => s.ProfileID == item.ID).ToList();
                    var orgName = new List<string>();
                    if (item.OrgStructureID != null)
                    {
                        orgName = rptServices.GetParentOrgName(lstOrg, lstOrgType, item.OrgStructureID);
                        if (orgName.Count < 3)
                        {
                            orgName.Insert(0, string.Empty);
                            if (orgName.Count < 3)
                            {
                                orgName.Insert(0, string.Empty);
                            }
                        }
                    }

                    var lstObjPayroll = new List<object>();
                    lstObjPayroll.Add(item.ID);
                    lstObjPayroll.Add(null);
                    lstObjPayroll.Add(null);
                    lstObjPayroll.Add(null);
                    lstObjPayroll.Add(1);
                    lstObjPayroll.Add(int.MaxValue - 1);
                    var payrollTableByProfileID = actionService.GetData<Sal_PayrollTableItemEntity>(lstObjPayroll, ConstantSql.hrm_sal_sp_get_PayrollTableItemByProfile, ref status).OrderByDescending(s => s.DateCreate);

                    var lstObjContract = new List<object>();
                    lstObjContract.Add(item.ID);
                    var lstContract = actionService.GetData<Hre_ContractEntity>(lstObjContract, ConstantSql.hrm_hr_sp_get_ContractsByProfileId, ref status).OrderBy(s => s.DateCreate).ToList();

                    var lstObjRelative = new List<object>();
                    lstObjRelative.Add(item.ID);
                    lstObjRelative.Add(1);
                    lstObjRelative.Add(Int32.MaxValue - 1);
                    var lstDependant = actionService.GetData<Hre_DependantEntity>(lstObjRelative, ConstantSql.hrm_hr_sp_get_DependantByProfileId, ref status).ToList();

                    DataRow dr = table.NewRow();


                    dr["CodeEmp"] = item.CodeEmp;
                    dr["ProfileName"] = item.ProfileName;
                    dr["FirstName"] = item.FirstName;
                    dr["NameFamily"] = item.NameFamily;
                    if (orgName.Count > 0)
                    {
                        dr["Channel"] = orgName[2];
                        dr["Region"] = orgName[1];
                        dr["Area"] = orgName[0];

                    }

                    dr["IDNo"] = item.IDNo;
                    if (item.IDDateOfIssue != null)
                    {
                        dr["IDDateOfIssue"] = item.IDDateOfIssue.Value;
                    }

                    dr["IDPlaceOfIssue"] = item.IDPlaceOfIssue;
                    if (item.DateOfBirth != null)
                    {
                        dr["DateOfBirth"] = item.DateOfBirth;
                    }
                    dr["Gender"] = item.Gender;
                    if (item.Gender == EnumDropDown.Gender.E_FEMALE.ToString())
                    {
                        dr["Gender"] = "Nữ";
                    }
                    if (item.Gender == EnumDropDown.Gender.E_MALE.ToString())
                    {
                        dr["Gender"] = "Nam";
                    }
                    dr["MarriageStatus"] = item.MarriageStatus;
                    dr["NationalityName"] = item.NationalityName;
                    dr["ReligionName"] = item.ReligionName;
                    dr["EthnicGroupName"] = item.EthnicGroupName;
                    dr["Email"] = item.Email;
                    dr["CellPhone"] = item.Cellphone;
                    dr["CodeTax"] = item.CodeTax;
                    dr["TDistrictName"] = item.TDistrictName;
                    dr["PDistrictName"] = item.PDistrictName;
                    dr["JobTitleName"] = item.JobTitleName;
                    dr["Notes"] = item.Notes;
                    dr["TAddress"] = item.TAddress;
                    dr["PAddress"] = item.PAddress;
                    if (basicSalaryEntity != null)
                    {
                        dr["BasicSalary"] = double.Parse(basicSalaryEntity.GrossAmount);
                    }
                    if (item.DateHire != null)
                    {
                        dr["DateHire"] = item.DateHire.Value;
                    }

                    //if (payrollTableByProfileID != null)
                    //{
                    //    foreach (var payroll in payrollTableByProfileID)
                    //    {
                    //        Double value = 0;
                    //        if (!table.Columns.Contains(payroll.Code))
                    //        {
                    //            table.Columns.Add(payroll.Code, typeof(Double));
                    //        }
                    //        if (table.Columns.Contains(payroll.Code))
                    //        {
                    //            if (payroll.ValueType == typeof(Double).Name)
                    //            {
                    //                Double.TryParse(payroll.Value, out value);
                    //            }
                    //            dr[payroll.Code] = value;
                    //        }
                    //    }
                    //}

                    if (lstContract != null && lstContract.Count > 0)
                    {
                        var contractEntity = lstContract.FirstOrDefault();
                        dr["TimesOfContract"] = lstContract.Count;
                        dr["ContractNo"] = contractEntity.ContractNo;
                        dr["ContractTypeName"] = contractEntity.ContractTypeName;
                        dr["DateStartContract"] = contractEntity.DateStart;
                        if (contractEntity.DateEnd != null)
                        {
                            dr["DateStartContract"] = contractEntity.DateEnd.Value;
                        }

                    }
                    if (lstUnuByProfileID.Count > 0 && lstUnuByProfileID != null)
                    {
                        foreach (var unu in lstUnuByProfileID)
                        {
                            var titleName = unu.UnusualEDTypeCode + "|" + unu.UnusualAllowanceCfgName;
                            if (!table.Columns.Contains(titleName))
                            {
                                table.Columns.Add(titleName);
                            }
                            if (table.Columns.Contains(titleName))
                            {
                                dr[titleName] = unu.Amount;
                            }
                        }
                    }

                    if (lstDependant.Count > 0 && lstDependant != null)
                    {
                        foreach (var dependant in lstDependant)
                        {
                            var titleName = dependant.DependantName + "|" + dependant.RelativeTypeName;
                            if (!table.Columns.Contains(titleName))
                            {
                                table.Columns.Add(titleName);
                            }
                            if (table.Columns.Contains(titleName))
                            {
                                dr[titleName] = dependant.DependantName;
                            }
                        }
                    }
                    table.Rows.Add(dr);
                }

                if (model.IsCreateTemplateForDynamicGrid)
                {
                    obj = result;
                    isDataTable = false;
                }
                if (model != null && model.IsCreateTemplate)
                {

                    var path = Common.GetPath("Templates");
                    ExportService exportService = new ExportService();

                    ConfigExport cfgExport = new ConfigExport()
                    {
                        Object = table,
                        FileName = "Hre_ProfileModel",
                        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, table, null, model.ExportType);
                    return Json(fullPath);
                }

                return Json(result.ToDataSourceResult(request));
            }

            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = result;
                isDataTable = false;
            }
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

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

            if (model.ExportId != Guid.Empty)
            {

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));
        }
Example #8
0
        public ActionResult ExportGetAccidentListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_AccidentSearchModel model)
        {
            string status = string.Empty;
            var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var result = GetListData<Hre_AccidentModel, Hre_AccidentEntity, Hre_AccidentSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_Accident, ref status);
            //if (model.IsCreateTemplateForDynamicGrid)
            //{
            //    obj = result;
            //    isDataTable = false;
            //}
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_AccidentModel(),

                    FileName = "Hre_Accident",
                    OutPutPath = path,
                    // HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }


            if (model.ExportId != Guid.Empty)
            {

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));
        }
Example #9
0
        public ActionResult ExportWorkHistoryByListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_WorkHistorySearchModel model)
        {
            string status = string.Empty;
            var actionService = new ActionService(UserLogin);
            var isDataTable = false;
            object obj = new Hre_ProfileModel();

            ListQueryModel lstModel = new ListQueryModel
            {
                PageSize = int.MaxValue - 1,
                PageIndex = 1,
                Filters = ExtractFilterAttributes(request),
                Sorts = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            var result = actionService.GetData<Hre_WorkHistoryModel>(lstModel, ConstantSql.hrm_hr_sp_get_WorkHistory, ref status);
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom != null ? model.DateFrom : DateTime.Now };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo != null ? model.DateTo : DateTime.Now };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_WorkHistoryModel(),
                    FileName = "Hre_WorkHistory",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            if (model.ExportId != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }
Example #10
0
        public ActionResult ExportProfileDisciplineListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_DisciplineSearchModel model)
        {
            var ActionService = new ActionService(UserLogin);
            string status = string.Empty;
            var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var result = GetListData<Hre_DisciplineModel, Hre_DisciplineEntity, Hre_DisciplineSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_Discipline, ref status);
            if (result != null && result.Count > 0)
            {
                #region lấy Org và OrgType

                var orgServices = new Cat_OrgStructureServices();
                var lstObjOrg = new List<object>();
                lstObjOrg.Add(null);
                lstObjOrg.Add(null);
                lstObjOrg.Add(null);
                lstObjOrg.Add(1);
                lstObjOrg.Add(int.MaxValue - 1);
                var lstOrg = ActionService.GetData<Cat_OrgStructureEntity>(lstObjOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, ref status).ToList();

                var orgTypeService = new Cat_OrgStructureTypeServices();
                var lstObjOrgType = new List<object>();
                lstObjOrgType.Add(null);
                lstObjOrgType.Add(null);
                lstObjOrgType.Add(1);
                lstObjOrgType.Add(int.MaxValue - 1);
                var lstOrgType = ActionService.GetData<Cat_OrgStructureTypeEntity>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, ref status).ToList();
                #endregion

                foreach (var item in result)
                {
                    Guid? orgId = item.OrgStructureID1;
                    var org = lstOrg.FirstOrDefault(s => s.ID == item.OrgStructureID1);
                    var orgBranch = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_BRANCH, lstOrg, lstOrgType);
                    var orgGroup = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_GROUP, lstOrg, lstOrgType);
                    var orgOrg = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DEPARTMENT, lstOrg, lstOrgType);
                    var orgTeam = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_TEAM, lstOrg, lstOrgType);
                    var orgSection = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_SECTION, lstOrg, lstOrgType);
                    var orgDivision = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DIVISION, lstOrg, lstOrgType);

                    item.BranchName = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
                    item.GroupName = orgGroup != null ? orgGroup.OrgStructureName : string.Empty;
                    item.DepartmentName = orgOrg != null ? orgOrg.OrgStructureName : string.Empty;
                    item.TeamName = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
                    item.SectionName = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                    item.DivisionName = orgDivision != null ? orgDivision.OrgStructureName : string.Empty;

                    item.DisciplineCount = result.Where(s => s.ProfileID == item.ProfileID).Count();
                }

            }
            //if (model.IsCreateTemplateForDynamicGrid)
            //{
            //    obj = result;
            //    isDataTable = false;
            //}
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

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


            if (model.ExportId != Guid.Empty)
            {

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));
        }
Example #11
0
 public string ValidateProfile([DataSourceRequest] DataSourceRequest request, Hre_ProfileModel model)
 {
     string message = string.Empty;
     var checkValidate = ValidatorService.OnValidateData<Hre_ProfileModel>(model, "Hre_Profile", ref message);
     if (!checkValidate)
     {
         return message;
     }
     else
     {
         return null;
     }
 }
Example #12
0
        public ActionResult ExportProfileSuspenseListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_SuspenseSearchModel model)
        {
            #region Tao template
            
            
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom == null ? DateTime.Now : model.DateFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo == null ? DateTime.Now : model.DateTo };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_StopWorkingModel(),
                    FileName = "Hre_StopWorking",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            #endregion
            string status = string.Empty;
           // var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var actionService = new ActionService(UserLogin);

            var lstObj = new List<object>();
            lstObj.Add(model.ProfileName);
            lstObj.Add(model.CodeEmp);
            lstObj.Add(model.JobTitleID);
            lstObj.Add(model.PositionID);
            lstObj.Add(model.OrgStructureID);
            lstObj.Add(model.DateFrom);
            lstObj.Add(model.DateTo);
            lstObj.Add(model.TypeSuspense);
            lstObj.Add(model.Status);
            lstObj.Add(model.StatusComeBack);
            lstObj.Add(model.RequestDateComebackFrom);
            lstObj.Add(model.RequestDateComebackTo);
            lstObj.Add(model.DateComebackFrom);
            lstObj.Add(model.DateComebackTo);
            lstObj.Add(model.RankID);
            lstObj.Add(model.IsCreateTemplate);
            lstObj.Add(model.ExportId);
            lstObj.Add(model.ExportType);
            lstObj.Add(1);
            lstObj.Add(int.MaxValue - 1);

            var lisObjClas = new List<object>();
            lisObjClas.AddRange(new object[3]);
            lisObjClas[1] = 1;
            lisObjClas[2] = int.MaxValue - 1;
            var lisObjRank = new List<object>();
            lisObjRank.AddRange(new object[4]);
            lisObjRank[2] = 1;
            lisObjRank[3] = int.MaxValue - 1;
            var listResult = actionService.GetData<Hre_StopWorkingEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileSuspense, ref status).Translate<Hre_StopWorkingModel>();
            var lisClass = actionService.GetData<Cat_SalaryClassEntity>(lisObjClas,ConstantSql.hrm_cat_sp_get_SalaryClass, ref status);
            var lisRank = actionService.GetData<Cat_SalaryRankEntity>(lisObjRank, ConstantSql.hrm_cat_sp_get_SalaryRank, ref status);
            foreach (var item in listResult)
            {
               
                var lisClassbyproid = lisClass.Where(s => s.ID == item.SalaryClassID).FirstOrDefault();
                var lisRankbyclassid = lisRank.Where(s => lisClassbyproid !=null && s.SalaryClassID == lisClassbyproid.ID).FirstOrDefault();
                item.SalaryRankName = lisRankbyclassid != null ? lisRankbyclassid.SalaryRankName : string.Empty;
            }
            var profileServices = new Hre_ProfileServices();
           

            if (model.ExportId != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportId, listResult, listHeaderInfo, model.ExportType);
                return Json(fullPath);
            }
            return Json(listResult.ToDataSourceResult(request));
        }
Example #13
0
        public ActionResult Get_Sal_ProfileNotGrade([DataSourceRequest] DataSourceRequest request, Hre_ProfileModel model)
        {

            string status = string.Empty;
            var actionService = new ActionService(UserLogin);
            List<object> objs = new List<object>();
            objs.AddRange(new object[4]);
            objs[0] = model.ProfileName;
            objs[1] = model.CodeEmp;
            objs[2] = 1;
            objs[3] = Int32.MaxValue - 1;
            var result = actionService.GetData<Hre_ProfileEntity>(objs, ConstantSql.hrm_hr_sp_get_PFNG_sal, ref status);
            return Json(result.ToDataSourceResult(request));
        }
Example #14
0
 public ActionResult Create(Hre_ProfileModel model)
 {
     //var isAccess = CheckPermission(UserId, PrivilegeType.Create, ConstantPermission.Hre_Profile);
     //if (!isAccess)
     //{
     //    return PartialView("AccessDenied");
     //}
     if (ModelState.IsValid)
     {
         var service = new RestServiceClient<Hre_ProfileModel>(UserLogin);
         service.SetCookies(this.Request.Cookies, _hrm_Hr_Service);
         var result = service.Put(_hrm_Hr_Service, "api/Hre_Profile/", model);
        
         ViewBag.MsgInsert = "Insert success";
     }
     return View();
 }
Example #15
0
        public Hre_ProfileModel Post([Bind]Hre_ProfileModel model)
        {
            string status = string.Empty;
            if (model != null)
            {
                ActionService service = new ActionService(UserLogin);
                BaseService BaseService = new BaseService();

                if (!string.IsNullOrWhiteSpace(model.CodeAttendance))
                {
                    model.CodeAttendance = model.CodeAttendance.TrimAll();
                }

                #region Validate

                string message = string.Empty;

                var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ProfileModel>(model, "Hre_Profile", ref message);
                if (!checkValidate)
                {
                    model.ActionStatus = message;
                    return model;
                }
                if (model.DateOfEffectOld != null)
                {
                    checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ProfileModel>(model, "Hre_ProfileCheckDateOfEffect", ref message);
                    if (!checkValidate)
                    {
                        model.ActionStatus = message;
                        return model;
                    }
                }
                #endregion

                #region Xử lý cập nhật AbilityTitle khi chọn rank

                if (model.SalaryClassID != null)
                {
                    var abilityTitleBySalaryClass = BaseService.GetData<Cat_AbilityTileEntity>(Common.DotNetToOracle(model.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, UserLogin, ref status).FirstOrDefault();
                    if (abilityTitleBySalaryClass != null)
                    {
                        model.AbilityTileID = abilityTitleBySalaryClass.ID;
                    }
                }

                #endregion

                #region Xử Lý Lưu field DateOfBirth
                var dateOfBirth = string.Empty;
                if (model.DayOfBirth == 00 && model.MonthOfBirth == 00)
                {
                    model.ActionStatus = "ErrorDateOfBirth";
                    return model;
                }
                if (model.DayOfBirth == null && model.MonthOfBirth == null && model.YearOfBirth == null)
                {
                    dateOfBirth = string.Empty;

                }
                else
                {
                    if (model.DayOfBirth == null)
                    {
                        model.DayOfBirth = DateTime.Now.Day;
                    }
                    if (model.MonthOfBirth == null)
                    {
                        model.MonthOfBirth = DateTime.Now.Month;
                    }
                    if (model.YearOfBirth == null)
                    {
                        model.ActionStatus = "ErrorDateOfBirth";
                        return model;
                    }
                }


                if (model.DayOfBirth >= 0 || model.MonthOfBirth >= 0 || model.YearOfBirth >= 0)
                {
                    if (model.DayOfBirth == 30 && model.MonthOfBirth == 2)
                    {
                        model.ActionStatus = "ErrorDateOfBirth";
                        return model;
                    }
                    if (model.DayOfBirth == 31 && model.MonthOfBirth == 2)
                    {
                        model.ActionStatus = "ErrorDateOfBirth";
                        return model;
                    }
                    if (model.DayOfBirth > 31 || model.MonthOfBirth > 12)
                    {
                        model.ActionStatus = "ErrorDateOfBirth";
                        return model;
                    }
                    dateOfBirth = model.MonthOfBirth + "/" + model.DayOfBirth + "/" + model.YearOfBirth;

                }

                model.DateOfBirth = string.IsNullOrEmpty(dateOfBirth) ? (DateTime?)null : DateTime.Parse(dateOfBirth);
                #endregion
                Hre_ProfileModel HreProfile = new Hre_ProfileModel();
                if (model.ID != Guid.Empty)
                {
                    HreProfile = GetById(model.ID);
                }
                if (HreProfile != null && (model.ID == HreProfile.ID) && model.ActionStatus != "1")
                {
                    string[] listFieldName = new[] { "JobTitleID", "PositionID", "EmpTypeID", "DateOfEffect", "CostCentreID", "OrgStructureID", "WorkPlaceID", "SupervisorID" };
                    foreach (var item in listFieldName)
                    {
                        var value1 = model.GetPropertyValue(item);
                        var value2 = HreProfile.GetPropertyValue(item);
                        if ((value1 != null && value2 != null) && (value1.ToString() != value2.ToString()))
                        {
                            model.SetPropertyValue(Constant.ActionStatus, NotificationType.Change.ToString());
                            return model;
                        }
                    }
                    if (HreProfile.ProfileName != model.ProfileName)
                    {
                        if (model.ProfileName.Contains(' '))
                        {
                            model.FirstName = model.ProfileName.Substring(model.ProfileName.LastIndexOf(' ') + 1);
                            model.NameFamily = model.ProfileName.Substring(0, model.ProfileName.LastIndexOf(' '));
                        }
                        else
                        {
                            model.FirstName = model.ProfileName;
                        }
                    }
                }
                if (model.ActionStatus == "1" || model.ActionStatus == "Success" || string.IsNullOrEmpty(model.ActionStatus))
                {

                    var serviceAddress = new Hre_AddressServices();
                    var serviceProfile = new Hre_ProfileServices();
                    var profileEntity = new Hre_ProfileEntity();
                    if (model.ID != Guid.Empty)
                    {
                        profileEntity = serviceProfile.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref status).FirstOrDefault();
                    }

                    #region Xử lý lưu CardCode
                    Hre_CardHistoryServices cardservices = new Hre_CardHistoryServices();
                    Hre_WorkHistoryServices workHistoryservices = new Hre_WorkHistoryServices();

                    if (profileEntity != null && model.CodeAttendance != null && model.DateApplyAttendanceCode != null && (model.CodeAttendance != profileEntity.CodeAttendance
                    || model.DateApplyAttendanceCode != profileEntity.DateApplyAttendanceCode))
                    {
                        // Chỉ thay đổi mã chấm công
                        if (model.DateApplyAttendanceCode == profileEntity.DateApplyAttendanceCode && model.CodeAttendance != profileEntity.CodeAttendance)
                        {
                            Hre_CardHistoryEntity history = cardservices.GetData<Hre_CardHistoryEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_hr_sp_get_CardHistoryByProfileId, UserLogin, ref status).OrderByDescending(s => s.DateEffect).FirstOrDefault();
                            if (history != null)
                            {
                                history.CardCode = model.CodeAttendance;
                                cardservices.Edit(history);
                            }
                            else
                            {
                                history = new Hre_CardHistoryEntity();
                                history.ProfileID = model.ID;
                                history.CardCode = model.CodeAttendance;
                                history.DateEffect = model.DateApplyAttendanceCode;
                                cardservices.Add(history);
                            }
                        }
                        // Chỉ thay đổi Ngày áp dụng mã chấm công

                        else if (model.CodeAttendance == profileEntity.CodeAttendance && model.DateApplyAttendanceCode != profileEntity.DateApplyAttendanceCode)
                        {
                            if (model.DateApplyAttendanceCode < profileEntity.DateApplyAttendanceCode)
                            {
                                model.StatusVerify = "Invalid";
                                return model;
                            }
                            Hre_CardHistoryEntity history = cardservices.GetData<Hre_CardHistoryEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_hr_sp_get_CardHistoryByProfileId, UserLogin, ref status).OrderByDescending(s => s.DateEffect).FirstOrDefault();
                            if (history != null)
                            {
                                history.DateEffect = model.DateApplyAttendanceCode;
                                cardservices.Edit(history);
                            }
                            else
                            {
                                history = new Hre_CardHistoryEntity();
                                history.ProfileID = model.ID;
                                history.CardCode = model.CodeAttendance;
                                history.DateEffect = model.DateApplyAttendanceCode;
                                cardservices.Add(history);
                            }
                        }
                    }
                    // Tạo mới NV hoặc thay đổi cả 2( mã chấm công + ngày hiệu lực)
                    Hre_CardHistoryEntity cardhistory = null;
                    if (model != null && model.ID == Guid.Empty || (model != null && profileEntity != null && model.CodeAttendance != profileEntity.CodeAttendance
                                && model.DateApplyAttendanceCode != profileEntity.DateApplyAttendanceCode))
                    {
                        cardhistory = new Hre_CardHistoryEntity();
                        cardhistory.ProfileID = model.ID;
                        cardhistory.CardCode = model.CodeAttendance;
                        cardhistory.DateEffect = model.DateApplyAttendanceCode;
                    }
                    #endregion

                    #region Xử lý lưu quá trình công tác
                    Hre_WorkHistoryEntity workHistory = null;
                    if (model != null && (model.JobTitleID != profileEntity.JobTitleID || model.PositionID != profileEntity.PositionID || model.EmpTypeID != profileEntity.EmpTypeID ||
                        (model.DateOfEffect != null && profileEntity.DateOfEffect != null &&
                        model.DateOfEffect.Value.ToString() != profileEntity.DateOfEffect.Value.ToString())
                        || model.CostCentreID != profileEntity.CostCentreID || model.SupervisorID != profileEntity.SupervisorID
                        || model.OrgStructureID != profileEntity.OrgStructureID || model.WorkPlaceID != profileEntity.WorkPlaceID))
                    {

                        workHistory = new Hre_WorkHistoryEntity();
                        var orgService = new Cat_OrgStructureServices();
                        var jobtitleService = new Cat_JobTitleServices();
                        var postitionService = new Cat_PositionServices();
                        var workPlaceService = new Cat_WorkPlaceServices();

                        workHistory.CostCentreID = model.CostCentreID;
                        workHistory.OrganizationStructureID = model.OrgStructureID;
                        workHistory.PositionID = model.PositionID;
                        workHistory.JobTitleID = model.JobTitleID;
                        workHistory.SalaryClassID = model.SalaryClassID;
                        workHistory.CostSourceID = model.CostSourceID;
                        workHistory.AbilityTileID = model.AbilityTileID;
                        if (profileEntity != null)
                        {
                            var orgStructureOld = new Cat_OrgStructureEntity();
                            if (profileEntity.OrgStructureID != null && profileEntity.OrgStructureID != Guid.Empty)
                            {
                                orgStructureOld = orgService.GetData<Cat_OrgStructureEntity>(profileEntity.OrgStructureID, ConstantSql.hrm_cat_sp_get_OrgStructureById, UserLogin, ref status).FirstOrDefault();
                            }
                            var jobtitleOld = new Cat_JobTitleEntity();
                            if (profileEntity.JobTitleID != null && profileEntity.JobTitleID != Guid.Empty)
                            {
                                jobtitleOld = jobtitleService.GetData<Cat_JobTitleEntity>(profileEntity.JobTitleID, ConstantSql.hrm_cat_sp_get_HDTJobTypeById, UserLogin, ref status).FirstOrDefault();
                            }
                            var postitionOld = new Cat_PositionEntity();
                            if (profileEntity.PositionID != null && profileEntity.PositionID != Guid.Empty)
                            {
                                postitionOld = postitionService.GetData<Cat_PositionEntity>(profileEntity.PositionID, ConstantSql.hrm_cat_sp_get_PositionById, UserLogin, ref status).FirstOrDefault();
                            }
                            var workPlace = new Cat_WorkPlaceEntity();
                            if (model.WorkPlaceID != null && model.WorkPlaceID != Guid.Empty)
                            {
                                workPlace = workPlaceService.GetData<Cat_WorkPlaceEntity>(model.WorkPlaceID, ConstantSql.hrm_cat_sp_get_WorkPlaceById, UserLogin, ref status).FirstOrDefault();
                            }
                            var workPlaceOld = new Cat_WorkPlaceEntity();
                            if (profileEntity.WorkPlaceID != null && profileEntity.WorkPlaceID != Guid.Empty)
                            {
                                workPlaceOld = workPlaceService.GetData<Cat_WorkPlaceEntity>(profileEntity.WorkPlaceID, ConstantSql.hrm_cat_sp_get_WorkPlaceById, UserLogin, ref status).FirstOrDefault();
                            }
                            workHistory.OrgOld = orgStructureOld != null ? orgStructureOld.OrgStructureName : "";
                            workHistory.JobTitleOld = jobtitleOld != null ? jobtitleOld.JobTitleName : "";
                            workHistory.PositionOld = postitionOld != null ? postitionOld.PositionName : "";
                            workHistory.WorkLocation = workPlace != null ? workPlace.WorkPlaceName : "";
                            workHistory.WorkLocationOld = workPlaceOld != null ? workPlaceOld.WorkPlaceName : "";
                        }
                        if (workHistory.ID == Guid.Empty)
                        {
                            if (model.DateOfEffect != null)
                            {
                                workHistory.DateEffective = model.DateOfEffect.Value;
                            }
                            else
                            {
                                workHistory.DateEffective = DateTime.Now;
                            }
                        }

                        if (model.DateQuit != null && (profileEntity == null || profileEntity.DateQuit != model.DateQuit))
                        {
                            workHistory.DateEffective = model.DateQuit.Value;
                        }
                    }

                    #region Ngày hiệu lực phải <= ngày hiện tại thì mới cập nhật lại quá trình công tác
                    if (model.DateOfEffect > DateTime.Now && profileEntity != null && profileEntity.DateOfEffect != null)
                    {
                        model.DateOfEffect = profileEntity.DateOfEffect;
                        model.OrgStructureID = profileEntity.OrgStructureID;
                        model.ShopID = profileEntity.ShopID;
                        model.JobTitleID = profileEntity.JobTitleID;
                        model.PositionID = profileEntity.PositionID;
                        model.SupervisorID = profileEntity.SupervisorID;
                        model.HighSupervisorID = profileEntity.HighSupervisorID;
                        model.IsHeadDept = profileEntity.IsHeadDept;
                        model.EmpTypeID = profileEntity.EmpTypeID;
                        model.LaborType = profileEntity.LaborType;
                        model.SikillLevel = profileEntity.SikillLevel;
                        model.PayrollGroupID = profileEntity.PayrollGroupID;
                        model.SalaryClassID = profileEntity.SalaryClassID;
                        model.CostCentreID = profileEntity.CostCentreID;
                        model.LocationCode = profileEntity.LocationCode;
                        model.WorkPlaceID = profileEntity.WorkPlaceID;
                    }
                    #endregion

                    #endregion

                    var profileModel = service.UpdateOrCreate<Hre_ProfileEntity, Hre_ProfileModel>(model);

                    if (cardhistory != null && profileModel != null)
                    {
                        cardhistory.ProfileID = profileModel.ID;
                        cardservices.Add(cardhistory);
                    }

                    if (workHistory != null && profileModel != null)
                    {
                        workHistory.EmployeeTypeID = profileModel.EmpTypeID;
                        workHistory.ProfileID = profileModel.ID;
                        workHistoryservices.Add(workHistory);
                    }
                }
            }

            //Xóa cache lưu lại của cây phòng ban
            HttpContext.Current.Cache.Remove("List_OrgStructureTreeView");
            HttpContext.Current.Cache.Remove("List_OrgStructureTreeViewSumProfile");

            return model;
        }