StockInDetailController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. namespace EMIS.Web.Controllers.TeachingMaterial
  14. {
  15. public class StockInDetailController : Controller
  16. {
  17. #region --0.0 定义--
  18. public IStockInDetailServices StockInDetailServices { get; set; }
  19. #endregion
  20. #region 1.0 加载列表数据
  21. [HttpGet]
  22. public ActionResult List()
  23. {
  24. return View();
  25. }
  26. [HttpPost]
  27. public ActionResult List(QueryParamsModel pararms)
  28. {
  29. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  30. Guid? supplierID = pararms.getExtraGuid("PublishDropdown");
  31. Guid? schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  32. Guid? teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
  33. return base.Json(StockInDetailServices.GetStockInDetailViewGrid(configuretView, schoolyearID, supplierID, teachingMaterialID, (int)pararms.page, (int)pararms.rows));
  34. }
  35. #endregion
  36. #region 2.0 编辑数据信息
  37. [HttpGet]
  38. public ActionResult Edit()
  39. {
  40. return View();
  41. }
  42. #endregion
  43. #region 3.0 页面数据Excel导出
  44. /// <summary>
  45. /// Excel 导出
  46. /// </summary>
  47. /// <returns></returns>
  48. [HttpPost]
  49. public ActionResult Excel()
  50. {
  51. NpoiExcelHelper neh = new NpoiExcelHelper();
  52. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  53. Guid? supplierID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  54. Guid? schoolyearID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  55. DateTime? stockInDJTime = DateTime.Now;
  56. var dt = StockInDetailServices.GetStockInDetailViewList(configuretView, schoolyearID, supplierID, stockInDJTime, stockInDJTime).Select(x => new
  57. {
  58. x.SchoolyearName,
  59. x.StockInDocumentNo,
  60. x.StockInType,
  61. x.TeachingMaterialCode,
  62. x.TeachingMaterialName,
  63. x.PublishName,
  64. x.SupplierName,
  65. x.PublishTime,
  66. x.Author,
  67. x.Quantity,
  68. x.Price,
  69. x.DiscountStr,
  70. x.DiscountPriceStr,
  71. x.TotalPriceStr,
  72. x.TotalDollarStr,
  73. x.HandlerUserName,
  74. x.StockInUserName,
  75. x.StockInTime
  76. }).ToTable();
  77. string[] liststring = { "学年学期", "入库单据号", "入库编号", "教材编号", "教材名称", "供应商",
  78. "出版单位", "版本时间", "作者", "数量", "单价", "折扣率", "折合价", "码洋", "总价", "经手人", "入库人", "入库日期" };
  79. neh.Export(dt, liststring, "入库明细信息");
  80. return RedirectToAction("MsgShow", "Common", new
  81. {
  82. msg = "导出成功!",
  83. url = Url.Content("~/StockInDetail/List").AddMenuParameter()
  84. });
  85. }
  86. #endregion
  87. #region 4.0 页面数据删除
  88. [HttpPost]
  89. public ActionResult Delete(string stockInDetailIDs)
  90. {
  91. try
  92. {
  93. var stockInDetailIDList = stockInDetailIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
  94. StockInDetailServices.Delete(stockInDetailIDList);
  95. return base.Json("删除成功");
  96. }
  97. catch (Exception ex)
  98. {
  99. string mge = ex.Message;
  100. return base.Json("删除失败,原因:" + mge + "!");
  101. }
  102. }
  103. #endregion
  104. }
  105. }