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.
 
 
 
 
 
 

202 lines
6.1 KiB

  1. using System;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Learun.Util;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web.Mvc;
  7. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  11. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2022-03-02 10:37
  14. /// 描 述:教材库存表
  15. /// </summary>
  16. public class TextBookInOutController : MvcControllerBase
  17. {
  18. private TextBookInOutIBLL textbookInOutIBLL = new TextbookInOutBLL();
  19. #region 视图功能
  20. /// <summary>
  21. /// 主页面
  22. /// </summary>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public ActionResult Index()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 表单页
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpGet]
  34. public ActionResult Form()
  35. {
  36. ViewBag.BookCode = "KC" + DateTime.Now.ToString("yyyyMMddHHmmss");
  37. return View();
  38. }
  39. /// <summary>
  40. /// 表单页
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. public ActionResult FormUse()
  45. {
  46. return View();
  47. }
  48. /// <summary>
  49. /// 主页面
  50. /// </summary>
  51. /// <returns></returns>
  52. [HttpGet]
  53. public ActionResult IndexInOut()
  54. {
  55. return View();
  56. }
  57. #endregion
  58. #region 获取数据
  59. /// <summary>
  60. /// 获取列表数据
  61. /// </summary>
  62. /// <param name="queryJson">查询参数</param>
  63. /// <returns></returns>
  64. [HttpGet]
  65. [AjaxOnly]
  66. public ActionResult GetList(string queryJson)
  67. {
  68. var data = textbookInOutIBLL.GetList(queryJson);
  69. return Success(data);
  70. }
  71. /// <summary>
  72. /// 获取列表分页数据
  73. /// </summary>
  74. /// <param name="pagination">分页参数</param>
  75. /// <param name="queryJson">查询参数</param>
  76. /// <returns></returns>
  77. [HttpGet]
  78. [AjaxOnly]
  79. public ActionResult GetPageList(string pagination, string queryJson)
  80. {
  81. Pagination paginationobj = pagination.ToObject<Pagination>();
  82. var data = textbookInOutIBLL.GetPageList(paginationobj, queryJson);
  83. var jsonData = new
  84. {
  85. rows = data,
  86. total = paginationobj.total,
  87. page = paginationobj.page,
  88. records = paginationobj.records
  89. };
  90. return Success(jsonData);
  91. }
  92. /// <summary>
  93. /// 获取表单数据
  94. /// </summary>
  95. /// <param name="keyValue">主键</param>
  96. /// <returns></returns>
  97. [HttpGet]
  98. [AjaxOnly]
  99. public ActionResult GetFormData(string keyValue)
  100. {
  101. var TextBookInOutData = textbookInOutIBLL.GetEntity(keyValue);
  102. var jsonData = new
  103. {
  104. TextBookInOut = TextBookInOutData,
  105. };
  106. return Success(jsonData);
  107. }
  108. /// <summary>
  109. /// 获取表单数据
  110. /// </summary>
  111. /// <param name="keyValue">主键</param>
  112. /// <returns></returns>
  113. [HttpGet]
  114. [AjaxOnly]
  115. public ActionResult GetFormUseData(string keyValue)
  116. {
  117. var TextBookInOutData = textbookInOutIBLL.GetEntity(keyValue);
  118. var TextBookInOutDetailData = textbookInOutIBLL.GetInOrOutEntity(TextBookInOutData.BookCode).OrderBy(x => x.CreateTime);
  119. var jsonData = new
  120. {
  121. TextBookInOut = TextBookInOutData,
  122. TextBookInOrOut = TextBookInOutDetailData,
  123. };
  124. return Success(jsonData);
  125. }
  126. #endregion
  127. #region 提交数据
  128. /// <summary>
  129. /// 删除实体数据
  130. /// </summary>
  131. /// <param name="keyValue">主键</param>
  132. /// <returns></returns>
  133. [HttpPost]
  134. [AjaxOnly]
  135. public ActionResult DeleteForm(string keyValue)
  136. {
  137. textbookInOutIBLL.DeleteEntity(keyValue);
  138. return Success("删除成功!");
  139. }
  140. /// <summary>
  141. /// 保存实体数据(新增、修改)
  142. /// </summary>
  143. /// <param name="keyValue">主键</param>
  144. /// <param name="entity">实体</param>
  145. /// <returns></returns>
  146. [HttpPost]
  147. [ValidateAntiForgeryToken]
  148. [AjaxOnly]
  149. public ActionResult SaveForm(string keyValue, string strEntity)
  150. {
  151. var loginUserInfo = LoginUserInfo.Get();
  152. TextbookInOutEntity entity = strEntity.ToObject<TextbookInOutEntity>();
  153. if (string.IsNullOrEmpty(keyValue))
  154. {
  155. entity.IsDel = 0;
  156. entity.IsSubmit = 0;
  157. entity.CreateTime = DateTime.Now;
  158. entity.CrateUserID = loginUserInfo.userId;
  159. }
  160. else
  161. {
  162. entity.UpTime = DateTime.Now;
  163. entity.UpUserID = loginUserInfo.userId;
  164. }
  165. int RepetitionList = textbookInOutIBLL.GetRepetitions(entity.ID,entity.LessonNo, entity.TextBookNo, entity.TextBookName, entity.PublishNo, entity.Publisher, entity.Edition, entity.Impression);
  166. if (RepetitionList > 0)
  167. {
  168. return Fail("已存在相同库存单,请使用教材入库功能!");
  169. }
  170. else
  171. {
  172. textbookInOutIBLL.SaveEntity(keyValue, entity);
  173. return Success("保存成功!");
  174. }
  175. }
  176. /// <summary>
  177. /// 提交
  178. /// </summary>
  179. /// <param name="keyValue"></param>
  180. /// <returns></returns>
  181. [HttpPost]
  182. [AjaxOnly]
  183. public ActionResult SubmitForm(string keyValue)
  184. {
  185. textbookInOutIBLL.SubmitEntity(keyValue);
  186. return Success("提交成功!");
  187. }
  188. #endregion
  189. }
  190. }