/// <summary> /// [Son.Vo] - Lấy dữ liệu Contract(Hre_Contract) theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Hre_ContractModel GetById(Guid id) { string status = string.Empty; var model = new Hre_ContractModel(); ActionService service = new ActionService(UserLogin); var entity = service.GetData<Hre_ContractEntity>(Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_ContractById, ref status).FirstOrDefault(); if (entity != null) { model = entity.CopyData<Hre_ContractModel>(); } model.ActionStatus = status; return model; }
public ActionResult UpdateStatusSelected(List<Guid> selectedIds, string status) { Hre_ContractModel model = new Hre_ContractModel(); model.Status = status; model.selecteIds = selectedIds; if (selectedIds.Count >= 0) { var service = new RestServiceClient<Hre_ContractModel>(UserLogin); service.SetCookies(this.Request.Cookies, _hrm_Hr_Service); var dataReturn = service.Put(_hrm_Hr_Service, "api/Hre_Contract/", model); return Json(dataReturn, JsonRequestBehavior.AllowGet); } return Json(null); }
public ActionResult GetDataByContractID(string contractID, string contractTypeID) { string status = string.Empty; if (contractID == null) { return null; } var actionService = new ActionService(UserLogin); var salaryRankServices = new Cat_SalaryRankServices(); var lstObjSalaryRank = new List<object>(); lstObjSalaryRank.Add(null); lstObjSalaryRank.Add(1); lstObjSalaryRank.Add(int.MaxValue - 1); var contractTypeServices = new Cat_ContractTypeServices(); var lstContractType = actionService.GetData<Cat_ContractTypeEntity>(Common.ConvertToGuid(contractTypeID), ConstantSql.hrm_cat_sp_get_ContractTypeById, ref status).FirstOrDefault(); var lstSalaryRank = actionService.GetData<Cat_SalaryRankEntity>(lstObjSalaryRank, ConstantSql.hrm_cat_sp_get_SalaryRank, ref status).ToList(); var result = actionService.GetData<Hre_ContractEntity>(Common.ConvertToGuid(contractID), ConstantSql.hrm_hr_sp_get_ContractById, ref status).FirstOrDefault(); if (result != null) { if (result.ContractEvaType == EnumDropDown.ContractEvaType.E_EXPIRED_APPRENTICE.ToString()) { int month = 0; if (lstContractType.ValueTime != null) { month = (int)lstContractType.ValueTime.Value; if (lstContractType.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString()) { month = month * 12; } lstContractType.DateStart = result.DateEnd.Value.AddDays(1); } //chưa tìm dc cách xử lý nên hard code var lstSalaryRankNew = lstSalaryRank.Where(s => s.SalaryRankName == "R0V08").FirstOrDefault(); var contractModel = new Hre_ContractModel { // ContractNo = getContractNo(result, result.DateSigned), ProfileID = result.ProfileID, DateStart = result.DateEnd.Value.AddDays(1), DateSigned = result.DateEnd.Value.AddDays(1), DateEnd = lstContractType.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 }; return Json(contractModel, JsonRequestBehavior.AllowGet); } if (result.ContractEvaType == EnumDropDown.ContractEvaType.E_ANNUAL_EVALUATION.ToString()) { var contractModel = new Hre_ContractModel { // ContractNo = getContractNo(result, result.DateSigned), ProfileID = result.ProfileID, DateStart = new DateTime(DateTime.Now.Year, 06, 01), }; return Json(contractModel, JsonRequestBehavior.AllowGet); } } return null; }
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)); }
public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Hre_ContractModel Contract) { //var isAccess = CheckPermission(UserId, PrivilegeType.Modify, ConstantPermission.Hre_Contract); //if (!isAccess) //{ // return PartialView("AccessDenied"); //} if (ModelState.IsValid) { var service = new RestServiceClient<Hre_ContractModel>(UserLogin); service.SetCookies(this.Request.Cookies, _hrm_Hr_Service); var result = service.Put(_hrm_Hr_Service, "api/Hre_Contract/", Contract); ViewBag.MsgUpdate = "Update success"; } return View(); }
public ActionResult Create(Hre_ContractModel model) { //var isAccess = CheckPermission(UserId, PrivilegeType.Create, ConstantPermission.Hre_Contract); //if (!isAccess) //{ // return PartialView("AccessDenied"); //} if (ModelState.IsValid) { var service = new RestServiceClient<Hre_ContractModel>(UserLogin); service.SetCookies(this.Request.Cookies, _hrm_Hr_Service); var result = service.Put(_hrm_Hr_Service, "api/Hre_Contract/", model); ViewBag.MsgInsert = "Insert success"; } return View(); }