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.

EmpInfoEnternalController.cs 3.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. UserIBLL userIBLL = new UserBLL();
  17. EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
  18. AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  19. public ActionResult FormAdd()
  20. {
  21. return View();
  22. }
  23. /// <summary>
  24. /// 获取数据源数据
  25. /// </summary>
  26. /// <param name="code">数据源编号</param>
  27. /// <param name="strWhere">sql查询条件语句</param>
  28. /// <param name="queryJson">数据源请求条件字串</param>
  29. /// <returns></returns>
  30. [HttpGet]
  31. [AjaxOnly]
  32. public ActionResult GetMap(string code, string ver, string where)
  33. {
  34. var data = dataSourceIBLL.GetDataTable(code, where);
  35. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  36. if (md5 == ver)
  37. {
  38. return Success("no update");
  39. }
  40. else
  41. {
  42. var jsondata = new
  43. {
  44. data = data,
  45. ver = md5
  46. };
  47. return JsonResult(jsondata);
  48. }
  49. }
  50. public ActionResult UploadImg(HttpPostedFileBase Filedata)
  51. {
  52. //没有文件上传,直接返回
  53. if (Filedata == null || string.IsNullOrEmpty(Filedata.FileName) || Filedata.ContentLength == 0)
  54. {
  55. if (Request.Files.Count > 0)
  56. {
  57. return Success(new { folderId = annexesFileIBLL.SaveAnnexesInfo(Request.Files[0]) });
  58. }
  59. else
  60. {
  61. return HttpNotFound();
  62. }
  63. }
  64. return Success("保存成功");
  65. }
  66. protected virtual ActionResult Success(string info)
  67. {
  68. return Content(new ResParameter { code = ResponseCode.success, info = info, data = new object { } }.ToJson());
  69. }
  70. protected virtual ActionResult Success(object data)
  71. {
  72. return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
  73. }
  74. protected virtual ActionResult JsonResult(object data)
  75. {
  76. return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
  77. }
  78. /// <summary>
  79. /// 保存实体数据(新增、修改)
  80. /// <param name="keyValue">主键</param>
  81. /// <summary>
  82. /// <returns></returns>
  83. [HttpPost]
  84. [AjaxOnly]
  85. public ActionResult SaveForm(string keyValue, string strEntity)
  86. {
  87. EmpInfoEntity entity = strEntity.ToObject<EmpInfoEntity>();
  88. if (!string.IsNullOrEmpty(entity.EmpNo))
  89. {
  90. var empentity = empInfoIBLL.GetEmpInfoEntityByEmpNo(entity.EmpNo);
  91. var userEntity = userIBLL.GetEntityByAccount(entity.EmpNo);
  92. if (null != empentity || null != userEntity)
  93. {
  94. return Success(new { data = entity, info = "有重复的职工编号" });
  95. }
  96. }
  97. entity.EmpId = Guid.NewGuid().ToString();
  98. empInfoIBLL.SaveEntity(keyValue, entity);
  99. return Success(new { data = entity, info = "保存成功" });
  100. }
  101. }
  102. }