TeachingMateriaInventoryController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Web.Controls.Mvc;
  8. using EMIS.CommonLogic.TeachingMaterial;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.TeachingMaterial;
  11. using EMIS.Web.Controls;
  12. using Bowin.Common.Data;
  13. using EMIS.CommonLogic.SystemServices;
  14. namespace EMIS.Web.Controllers.TeachingMaterial
  15. {
  16. [Authorization]
  17. public class TeachingMateriaInventoryController : Controller
  18. {
  19. //库存管理->教材库存
  20. public IStockOutServices StockOutServices { get; set; }
  21. public ISerialNumberServices SerialNumberServices { get; set; }//编号生成
  22. public IStockInDetailServices StockInDetailServices { get; set; }
  23. public IStockInServices StockInServices { get; set; }
  24. public IInventoryServices InventoryServices { get; set; }
  25. public ITeachingMaterialPoolServices TeachingMaterialPoolServices { get; set; }
  26. [HttpGet]
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. [HttpPost]
  32. public ActionResult List(QueryParamsModel pararms)
  33. {
  34. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  35. bool? isLate = null;
  36. if (pararms.getExtraInt("LateDropdown") != null && pararms.getExtraInt("LateDropdown") != DropdownList.SELECT_ALL)
  37. {
  38. isLate = pararms.getExtraInt("LateDropdown") == 1 ? true : false; ;
  39. }
  40. Guid? publishID = pararms.getExtraGuid("PublishDropdown");//书库ID
  41. Guid? teachingMaterialDropdownID = pararms.getExtraGuid("TeachingMaterialDropdown");//教材ID
  42. int? teachingMaterialType = pararms.getExtraInt("TeachingMaterialTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("TeachingMaterialTypeDropdown");
  43. return base.Json(InventoryServices.GetTeachingMateriaInventoryViewGrid(configuretView, null, teachingMaterialDropdownID, publishID, isLate, teachingMaterialType, (int)pararms.page, (int)pararms.rows));
  44. }
  45. #region 2.0 页面数据编辑
  46. [HttpGet]
  47. public ActionResult Edit(Guid? teachingMaterialPoolID)
  48. {
  49. TeachingMaterialPoolView TeachingMaterialPoolView;
  50. if (teachingMaterialPoolID != null && teachingMaterialPoolID != Guid.Empty)
  51. {
  52. TeachingMaterialPoolView = TeachingMaterialPoolServices.GetSingleTeachingMaterialPool(teachingMaterialPoolID.Value);
  53. }
  54. else
  55. {
  56. TeachingMaterialPoolView = new TeachingMaterialPoolView()
  57. {
  58. TeachingMaterialPoolID = Guid.Empty,
  59. IsLate = false
  60. };
  61. }
  62. return View(TeachingMaterialPoolView);
  63. }
  64. [HttpPost]
  65. public ActionResult Edit(TeachingMaterialPoolView TeachingMaterialPoolView)
  66. {
  67. try
  68. {
  69. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  70. TeachingMaterialPoolServices.EditTeachingMateriaInventory(TeachingMaterialPoolView, user.UserID);
  71. return Json(new ReturnMessage()
  72. {
  73. IsSuccess = true,
  74. Message = "保存成功!"
  75. });
  76. }
  77. catch (Exception ex)
  78. {
  79. return Json(new ReturnMessage()
  80. {
  81. IsSuccess = false,
  82. Message = "保存失败,原因:" + ex.Message + "!"
  83. });
  84. }
  85. }
  86. #endregion
  87. #region 3.0 页面数据Excel导出
  88. /// <summary>
  89. /// Excel 导出
  90. /// </summary>
  91. /// <returns></returns>
  92. [HttpPost]
  93. public ActionResult Excel()
  94. {
  95. NpoiExcelHelper neh = new NpoiExcelHelper();
  96. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  97. bool? isLate = null;
  98. if (Request.Form["LateDropdown"].ParseStrTo<int>() != null && Request.Form["LateDropdown"].ParseStrTo<int>() != DropdownList.SELECT_ALL)
  99. {
  100. isLate = Request.Form["LateDropdown"].ParseStrTo<int>() == 1 ? true : false;
  101. }
  102. Guid? teachingMaterialDropdownID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  103. Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  104. int? teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>();
  105. var dt = InventoryServices.GetTeachingMateriaInventoryViewList(configuretView, teachingMaterialDropdownID, teachingMaterialDropdownID, publishID, isLate, teachingMaterialType).Select(x => new
  106. {
  107. x.TeachingMaterialCode,
  108. x.TeachingMaterialName,
  109. x.CoursematerialCode,
  110. x.CoursematerialName,
  111. x.ISBN,
  112. x.PublishTime,
  113. x.PublishName,
  114. x.Author,
  115. x.MinInventory,
  116. x.PresentInventory,
  117. x.Price,
  118. x.Total,
  119. x.IsLateName,
  120. x.ModifyTime
  121. }).ToTable();
  122. string[] liststring = { "教材编号", "教材名称", "课程代码", "课程名称", "ISBN", "版本时间", "出版单位", "作者", "最小库存量", "当前库存量", "单价", "码洋", "是否过期", "最近响应时间" };
  123. neh.Export(dt, liststring, "教材库存信息");
  124. return RedirectToAction("MsgShow", "Common", new
  125. {
  126. msg = "导出成功!",
  127. url = Url.Content("~/TeachingMateriaInventory/List").AddMenuParameter()
  128. });
  129. }
  130. #endregion
  131. }
  132. }