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.
 
 
 
 
 
 

213 lines
6.3 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.AssetManagementSystem;
  4. using System.Web.Mvc;
  5. using Learun.Application.TwoDevelopment.LR_CodeDemo;
  6. using System.Collections.Generic;
  7. using Learun.Application.Base.SystemModule;
  8. using System;
  9. using System.IO;
  10. namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  14. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2023-05-05 14:37
  17. /// 描 述:固定资产
  18. /// </summary>
  19. public class Ass_FixAssetsController : MvcControllerBase
  20. {
  21. private Ass_FixAssetsIBLL ass_FixAssetsIBLL = new Ass_FixAssetsBLL();
  22. private CodeRuleIBLL codeRuleIBLL = new CodeRuleBLL();
  23. #region 视图功能
  24. /// <summary>
  25. /// 主页面
  26. /// <summary>
  27. /// <returns></returns>
  28. [HttpGet]
  29. public ActionResult Index()
  30. {
  31. return View();
  32. }
  33. /// <summary>
  34. /// 表单页
  35. /// <summary>
  36. /// <returns></returns>
  37. [HttpGet]
  38. public ActionResult Form()
  39. {
  40. return View();
  41. }
  42. /// <summary>
  43. /// 表单查看页
  44. /// <summary>
  45. /// <returns></returns>
  46. [HttpGet]
  47. public ActionResult FormView()
  48. {
  49. return View();
  50. }
  51. /// <summary>
  52. /// 导入表单页
  53. /// <summary>
  54. /// <returns></returns>
  55. [HttpGet]
  56. public ActionResult ImportForm()
  57. {
  58. return View();
  59. }
  60. /// <summary>
  61. /// 主页面【老师】
  62. /// <summary>
  63. /// <returns></returns>
  64. [HttpGet]
  65. public ActionResult IndexOfTeacher()
  66. {
  67. return View();
  68. }
  69. #endregion
  70. #region 获取数据
  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 = ass_FixAssetsIBLL.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 Ass_FixAssetsData = ass_FixAssetsIBLL.GetAss_FixAssetsEntity(keyValue);
  102. var jsonData = new
  103. {
  104. Ass_FixAssets = Ass_FixAssetsData,
  105. };
  106. return Success(jsonData);
  107. }
  108. /// <summary>
  109. /// 获取表单数据
  110. /// </summary>
  111. /// <param name="processId">流程实例主键</param>
  112. /// <returns></returns>
  113. [HttpGet]
  114. [AjaxOnly]
  115. public ActionResult GetFormDataByProcessId(string processId)
  116. {
  117. var Ass_FixAssetsData = ass_FixAssetsIBLL.GetEntityByProcessId(processId);
  118. var jsonData = new
  119. {
  120. Ass_FixAssets = Ass_FixAssetsData,
  121. };
  122. return Success(jsonData);
  123. }
  124. #endregion
  125. #region 提交数据
  126. /// <summary>
  127. /// 删除实体数据
  128. /// </summary>
  129. /// <param name="keyValue">主键</param>
  130. /// <returns></returns>
  131. [HttpPost]
  132. [AjaxOnly]
  133. public ActionResult DeleteForm(string keyValue)
  134. {
  135. ass_FixAssetsIBLL.DeleteEntity(keyValue);
  136. return Success("删除成功!");
  137. }
  138. /// <summary>
  139. /// 保存实体数据(新增、修改)
  140. /// </summary>
  141. /// <param name="keyValue">主键</param>
  142. /// <param name="strEntity">实体</param>
  143. /// <returns></returns>
  144. [HttpPost]
  145. [ValidateAntiForgeryToken]
  146. [AjaxOnly]
  147. public ActionResult SaveForm(string keyValue, string strEntity)
  148. {
  149. Ass_FixAssetsEntity entity = strEntity.ToObject<Ass_FixAssetsEntity>();
  150. var model = ass_FixAssetsIBLL.GetEntityByCode(entity.FACode);
  151. if (string.IsNullOrEmpty(keyValue))
  152. {
  153. if (model != null)
  154. {
  155. return Fail("资产编号已存在!");
  156. }
  157. }
  158. else
  159. {
  160. if (model != null && model.FAId != keyValue)
  161. {
  162. return Fail("资产编号已存在!");
  163. }
  164. }
  165. ass_FixAssetsIBLL.SaveEntity(keyValue, entity);
  166. return Success("保存成功!");
  167. }
  168. /// <summary>
  169. /// 提交
  170. /// </summary>
  171. /// <param name="keyValue"></param>
  172. /// <returns></returns>
  173. [HttpPost]
  174. [AjaxOnly]
  175. public ActionResult ChangeStatusById(string keyValue, int status, string processId)
  176. {
  177. ass_FixAssetsIBLL.ChangeStatusById(keyValue, status, processId);
  178. return Success("操作成功!");
  179. }
  180. /// <summary>
  181. /// 下载文件
  182. /// </summary>
  183. /// <returns></returns>
  184. public ActionResult DownTemplate()
  185. {
  186. FileStreamResult result = null;
  187. try
  188. {
  189. var path = Server.MapPath("~/Content/excel/");
  190. var pathoffull = path + "AssFixAssetsImport.xls";
  191. FileStream fsread = fsread = new FileStream(pathoffull, FileMode.OpenOrCreate, FileAccess.ReadWrite);
  192. result = File(fsread, "application/ms-excel", "固定资产导入模板.xls");
  193. return result;
  194. }
  195. catch (Exception)
  196. {
  197. return null;
  198. }
  199. }
  200. #endregion
  201. }
  202. }