You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

137 lines
4.4 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using Learun.Application.Organization;
  10. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  11. {
  12. public class EmpInfoEnternalController : Controller
  13. {
  14. // GET: EducationalAdministration/EmpInfoEnternal
  15. DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
  16. DataItemIBLL dataItemIBLL = new DataItemBLL();
  17. UserIBLL userIBLL = new UserBLL();
  18. EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
  19. AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  20. public ActionResult FormAdd()
  21. {
  22. return View();
  23. }
  24. /// <summary>
  25. /// 获取数据源数据
  26. /// </summary>
  27. /// <param name="code">数据源编号</param>
  28. /// <param name="strWhere">sql查询条件语句</param>
  29. /// <param name="queryJson">数据源请求条件字串</param>
  30. /// <returns></returns>
  31. [HttpGet]
  32. [AjaxOnly]
  33. public ActionResult GetMap(string code, string ver, string where)
  34. {
  35. var data = dataSourceIBLL.GetDataTable(code, where);
  36. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  37. if (md5 == ver)
  38. {
  39. return Success("no update");
  40. }
  41. else
  42. {
  43. var jsondata = new
  44. {
  45. data = data,
  46. ver = md5
  47. };
  48. return JsonResult(jsondata);
  49. }
  50. }
  51. /// <summary>
  52. /// 获取数据字典数据
  53. /// </summary>
  54. /// <param name="code">数据源编号</param>
  55. /// <param name="strWhere">sql查询条件语句</param>
  56. /// <param name="queryJson">数据源请求条件字串</param>
  57. /// <returns></returns>
  58. [HttpGet]
  59. [AjaxOnly]
  60. public ActionResult GetDataItemMap(string code, string ver)
  61. {
  62. var data = dataItemIBLL.GetDetailList(code, null);
  63. return JsonResult(data);
  64. }
  65. public ActionResult UploadImg(HttpPostedFileBase Filedata)
  66. {
  67. //没有文件上传,直接返回
  68. if (Filedata == null || string.IsNullOrEmpty(Filedata.FileName) || Filedata.ContentLength == 0)
  69. {
  70. if (Request.Files.Count > 0)
  71. {
  72. return Success(new { folderId = annexesFileIBLL.SaveAnnexesInfo(Request.Files[0]) });
  73. }
  74. else
  75. {
  76. return HttpNotFound();
  77. }
  78. }
  79. return Success("保存成功");
  80. }
  81. protected virtual ActionResult Success(string info)
  82. {
  83. return Content(new ResParameter { code = ResponseCode.success, info = info, data = new object { } }.ToJson());
  84. }
  85. protected virtual ActionResult Success(object data)
  86. {
  87. return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
  88. }
  89. protected virtual ActionResult JsonResult(object data)
  90. {
  91. return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
  92. }
  93. /// <summary>
  94. /// 保存实体数据(新增、修改)
  95. /// <param name="keyValue">主键</param>
  96. /// <summary>
  97. /// <returns></returns>
  98. [HttpPost]
  99. [AjaxOnly]
  100. public ActionResult SaveForm(string keyValue, string strEntity)
  101. {
  102. EmpInfoEntity entity = strEntity.ToObject<EmpInfoEntity>();
  103. if (!string.IsNullOrEmpty(entity.EmpNo))
  104. {
  105. var empentity = empInfoIBLL.GetEmpInfoEntityByEmpNo(entity.EmpNo);
  106. var userEntity = userIBLL.GetEntityByAccount(entity.EmpNo);
  107. if (null != empentity || null != userEntity)
  108. {
  109. return Success(new { data = entity, info = "有重复的职工编号" });
  110. }
  111. }
  112. entity.EmpId = Guid.NewGuid().ToString();
  113. empInfoIBLL.SaveEntity(keyValue, entity);
  114. return Success(new { data = entity, info = "保存成功" });
  115. }
  116. }
  117. }