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.
 
 
 
 
 
 

178 lines
5.3 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System;
  7. using System.Linq;
  8. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-03-05 11:17
  15. /// 描 述:TextBookOut
  16. /// </summary>
  17. public class TextBookOutController : MvcControllerBase
  18. {
  19. private TextBookOutIBLL textBookOutIBLL = new TextBookOutBLL();
  20. private TextBookInOutIBLL textBookInOutIBLL = new TextbookInOutBLL();
  21. #region 视图功能
  22. /// <summary>
  23. /// 主页面
  24. /// <summary>
  25. /// <returns></returns>
  26. [HttpGet]
  27. public ActionResult Index()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 表单页
  33. /// <summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. public ActionResult Form()
  37. {
  38. return View();
  39. }
  40. /// <summary>
  41. /// 入库表单页
  42. /// <summary>
  43. /// <returns></returns>
  44. [HttpGet]
  45. public ActionResult FormOut()
  46. {
  47. ViewBag.BookCode = "CK" + DateTime.Now.ToString("yyyyMMddHHmmss");
  48. return View();
  49. }
  50. /// <summary>
  51. /// 明细查看
  52. /// <summary>
  53. /// <returns></returns>
  54. [HttpGet]
  55. public ActionResult FormView()
  56. {
  57. return View();
  58. }
  59. /// <summary>
  60. /// 明细删除
  61. /// <summary>
  62. /// <returns></returns>
  63. [HttpGet]
  64. public ActionResult FormDelete()
  65. {
  66. return View();
  67. }
  68. #endregion
  69. #region 获取数据
  70. /// <summary>
  71. /// 获取页面显示列表数据
  72. /// </summary>
  73. /// <param name="pagination">分页参数</param>
  74. /// <param name="queryJson">查询参数</param>
  75. /// <returns></returns>
  76. [HttpGet]
  77. [AjaxOnly]
  78. public ActionResult GetPageList(string pagination, string queryJson)
  79. {
  80. Pagination paginationobj = pagination.ToObject<Pagination>();
  81. var data = textBookOutIBLL.GetPageList(paginationobj, queryJson);
  82. var jsonData = new
  83. {
  84. rows = data,
  85. total = paginationobj.total,
  86. page = paginationobj.page,
  87. records = paginationobj.records
  88. };
  89. return Success(jsonData);
  90. }
  91. /// <summary>
  92. /// 获取表单数据
  93. /// </summary>
  94. /// <param name="keyValue">主键</param>
  95. /// <returns></returns>
  96. [HttpGet]
  97. [AjaxOnly]
  98. public ActionResult GetFormData(string keyValue)
  99. {
  100. var TextBookInOutData = textBookInOutIBLL.GetKCEntity(keyValue);
  101. var TextBookOutData = textBookOutIBLL.GetListByCode(TextBookInOutData.BookCode);
  102. var jsonData = new
  103. {
  104. TextBookInOut = TextBookInOutData,
  105. TextBookOut = TextBookOutData,
  106. };
  107. return Success(jsonData);
  108. }
  109. /// <summary>
  110. /// 获取表单数据
  111. /// </summary>
  112. /// <param name="keyValue">主键</param>
  113. /// <returns></returns>
  114. [HttpGet]
  115. [AjaxOnly]
  116. public ActionResult GetFormDataEdit(string keyValue)
  117. {
  118. var TextBookInOutData = textBookInOutIBLL.GetKCEntity(keyValue);
  119. var jsonData = new
  120. {
  121. TextBookInOut = TextBookInOutData,
  122. };
  123. return Success(jsonData);
  124. }
  125. #endregion
  126. #region 提交数据
  127. /// <summary>
  128. /// 删除实体数据
  129. /// </summary>
  130. /// <param name="keyValue">主键</param>
  131. /// <returns></returns>
  132. [HttpPost]
  133. [AjaxOnly]
  134. public ActionResult DeleteForm(string keyValue)
  135. {
  136. textBookOutIBLL.DeleteEntity(keyValue);
  137. return Success("删除成功!");
  138. }
  139. /// <summary>
  140. /// 保存实体数据(新增、修改)
  141. /// </summary>
  142. /// <param name="keyValue">主键</param>
  143. /// <param name="strEntity">实体</param>
  144. /// <returns></returns>
  145. [HttpPost]
  146. [ValidateAntiForgeryToken]
  147. [AjaxOnly]
  148. public ActionResult SaveForm(string keyValue, string strEntity, string strTextBookOutList)
  149. {
  150. TextbookInOutEntity entity = strEntity.ToObject<TextbookInOutEntity>();
  151. List<TextBookOutEntity> textBookOutList = strTextBookOutList.ToObject<List<TextBookOutEntity>>();
  152. if (!textBookOutList.Any())
  153. {
  154. return Fail("请添加出库单!");
  155. }
  156. if (entity.FinallyNum < textBookOutList.Select(x => x.Variate).Sum())//当前库存<出库单数量之和
  157. {
  158. return Fail("当前库存小于出库单总数量!");
  159. }
  160. textBookOutIBLL.SaveEntity(keyValue, entity, textBookOutList);
  161. if (keyValue != null)
  162. {
  163. }
  164. return Success("保存成功!");
  165. }
  166. #endregion
  167. }
  168. }