/// <summary> /// [Chuc.Nguyen] - Lấy dữ liệu bảng Tai Nạn(Hre_Accident) theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Hre_AccidentModel GetById(Guid id) { string status = string.Empty; var model = new Hre_AccidentModel(); ActionService service = new ActionService(UserLogin); var entity = service.GetByIdUseStore<Hre_AccidentEntity>(id, ConstantSql.hrm_hr_sp_get_AccidentById, ref status); //var entity = service.GetData<Hre_AccidentEntity>(Common.DotNetToOracle(id.ToString()), ConstantSql.hrm_hr_sp_get_AccidentById, ref status).FirstOrDefault(); if (entity != null) { model = entity.CopyData<Hre_AccidentModel>(); } model.ActionStatus = status; return model; }
public ActionResult ExportDateEndAccidentList([DataSourceRequest] DataSourceRequest request, Hre_AccidentModel model) { var ActionService = new ActionService(UserLogin); List<object> listObj = new List<object>(); DateTime? From = SqlDateTime.MinValue.Value; DateTime? To = SqlDateTime.MaxValue.Value; List<Guid?> OrgIds = new List<Guid?>(); if (model.DateFrom != null) { From = model.DateFrom.Value; } if (model.DateTo != null) { To = model.DateTo.Value; } listObj.Add(From); listObj.Add(To); string strOrgIDs = null; if (!string.IsNullOrEmpty(model.OrgStructureID)) { strOrgIDs = model.OrgStructureID; } listObj.Add(strOrgIDs); Guid? Acctype = Guid.Empty; if (model.AccidentTypeID != Guid.Empty) { Acctype = model.AccidentTypeID; } listObj.Add(Acctype); string status = string.Empty; var result = ActionService.GetData<Hre_AccidentEntity>(listObj, ConstantSql.hrm_hr_sp_get_DateEndAccidentTypeList, ref status).ToList().Translate<Hre_AccidentModel>(); if (model.ExportID != Guid.Empty) { var fullPath = ExportService.Export(model.ExportID, result, model.ExportType); return Json(fullPath); } return Json(result.ToDataSourceResult(request)); }
public ActionResult Create(Hre_AccidentModel model) { //var isAccess = CheckPermission(UserId, PrivilegeType.Create, ConstantPermission.Hre_Accident); //if (!isAccess) //{ // return PartialView("AccessDenied"); //} if (ModelState.IsValid) { var service = new RestServiceClient<Hre_AccidentModel>(UserLogin); service.SetCookies(this.Request.Cookies, _hrm_Hr_Service); var result = service.Put(_hrm_Hr_Service, "api/Hre_Accident/", model); ViewBag.MsgInsert = ConstantDisplay.HRM_HR_Accident_InsertSuccess.TranslateString(); } return View(); }
public ActionResult GetDateEndAccidentTypeList([DataSourceRequest] DataSourceRequest request, Hre_AccidentModel model) { #region Validate string message = string.Empty; var checkValidate = ValidatorService.OnValidateData<Hre_AccidentModel>(model, "Hre_ReportAccident", ref message); if (!checkValidate) { return Json(message); } //DateTime From = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); //DateTime To = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1); #endregion HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom != null ? model.DateFrom.Value : DateTime.Now }; HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo != null ? model.DateTo.Value : DateTime.Now }; List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 }; var service = new ActionService(UserLogin); List<object> listObj = new List<object>(); DateTime? From = SqlDateTime.MinValue.Value; DateTime? To = SqlDateTime.MaxValue.Value; List<Guid?> OrgIds = new List<Guid?>(); if (model.DateFrom != null) { From = model.DateFrom.Value; } if (model.DateTo != null) { To = model.DateTo.Value; } listObj.Add(From); listObj.Add(To); string strOrgIDs = null; if (!string.IsNullOrEmpty(model.OrgStructureID)) { strOrgIDs = model.OrgStructureID; } listObj.Add(strOrgIDs); Guid? Acctype = Guid.Empty; if (model.AccidentTypeID != Guid.Empty) { Acctype = model.AccidentTypeID; } listObj.Add(Acctype); string status = string.Empty; var result = service.GetData<Hre_AccidentEntity>(listObj, ConstantSql.hrm_hr_sp_get_DateEndAccidentTypeList, ref status).ToList().Translate<Hre_AccidentModel>(); if (model != null && model.IsCreateTemplate) { var path = Common.GetPath("Templates"); ExportService exportService = new ExportService(); ConfigExport cfgExport = new ConfigExport() { Object = new Hre_AccidentModel(), FileName = "Hre_ReportAccident", OutPutPath = path, HeaderInfo = listHeaderInfo, DownloadPath = Hrm_Main_Web + "Templates", IsDataTable = false }; var str = exportService.CreateTemplate(cfgExport); return Json(str); } if (model.ExportID != Guid.Empty) { var fullPath = ExportService.Export(model.ExportID, result, listHeaderInfo, model.ExportType); return Json(fullPath); } return Json(result.ToDataSourceResult(request)); //return GetListDataAndReturn<Hre_AccidentModel, Hre_AccidentEntity, Hre_ReportAccidentSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_DateEndAccidentTypeList); }
public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Hre_AccidentModel Accident) { //var isAccess = CheckPermission(UserId, PrivilegeType.Modify, ConstantPermission.Hre_Accident); //if (!isAccess) //{ // return PartialView("AccessDenied"); //} if (ModelState.IsValid) { var service = new RestServiceClient<Hre_AccidentModel>(UserLogin); service.SetCookies(this.Request.Cookies, _hrm_Hr_Service); var result = service.Put(_hrm_Hr_Service, "api/Hre_Accident/", Accident); //return Json(result); ViewBag.MsgUpdate = ConstantDisplay.HRM_HR_Accident_UpdateSuccess.TranslateString(); } return View(); }