TeacherRetailController.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. using EMIS.CommonLogic.CalendarManage;
  15. namespace EMIS.Web.Controllers.TeachingMaterial
  16. {
  17. [Authorization]
  18. public class TeacherRetailController : Controller
  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 ISchoolYearServices SchoolYearServices { get; set; }
  25. /// <summary>
  26. /// 教材零售页面
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult List()
  31. {
  32. //默认当前学年
  33. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  34. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();
  35. return View();
  36. }
  37. [HttpPost]
  38. public ActionResult List(QueryParamsModel pararms)
  39. {
  40. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  41. //避开全选值
  42. Guid? supplierID = null;
  43. Guid? schoolyearID = null;
  44. DateTime? startStockInTime = DateTime.Now;
  45. DateTime? endStockInTime = DateTime.Now;
  46. supplierID = pararms.getExtraGuid("LibraryDropdown");//书库ID
  47. schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");//学年
  48. endStockInTime = pararms.getExtraDateTime("EndStockInTime");
  49. startStockInTime = pararms.getExtraDateTime("StartStockInTime");
  50. return base.Json(StockOutServices.GetStockOutViewGrid(configuretView, schoolyearID, new List<int> { (int)CF_StockOutType.TeachingMaterialRetail }, supplierID, startStockInTime, endStockInTime, (int)pararms.page, (int)pararms.rows));
  51. }
  52. /// <summary>
  53. ///
  54. /// </summary>
  55. /// <param name="stockOutID"></param>
  56. /// <returns></returns>
  57. [HttpGet]
  58. public ActionResult Edit(Guid? stockOutID)
  59. {
  60. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  61. StockOutView stockOutView = new StockOutView();
  62. if (stockOutID != null && stockOutID != Guid.Empty)
  63. {
  64. stockOutView = StockOutServices.GetSingleStockOut(stockOutID.Value);
  65. }
  66. else
  67. {
  68. stockOutView = new StockOutView()
  69. {
  70. OutNumber = 1,
  71. StockOutID = Guid.Empty,
  72. StockOutNo = StockOutServices.GetStockOutNo(CF_StockOutType.TeachingMaterialRetail),
  73. SchoolyearID = schoolYear.SchoolyearID,
  74. StockOutTime = DateTime.Now
  75. };
  76. }
  77. return View(stockOutView);
  78. }
  79. /// <summary>
  80. ///
  81. /// </summary>
  82. /// <param name="stockOutView"></param>
  83. /// <returns></returns>
  84. [HttpPost]
  85. public ActionResult Edit(StockOutView stockOutView)
  86. {
  87. try
  88. {
  89. string type = Request.Params["hid_ActionsType"];//0 保存 1 提交
  90. string time = DateTime.Now.ToString("yyyy-MM-dd");
  91. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  92. var TMList = DataGrid.GetTableData<TeachingMaterialPoolView>("dgStockInTMSelectList");//获取底部列表项数据
  93. //string keyValue = SerialNumberServices.SetSN(time);//格式: 2016-3-25-001
  94. if (TMList.Count <= 0)
  95. {
  96. return Json(new ReturnMessage()
  97. {
  98. IsSuccess = false,
  99. Message = "操作失败,原因:教材信息不能为空。"
  100. });
  101. }
  102. else
  103. {
  104. StockOutServices.Save(stockOutView, TMList, user.UserID, type);
  105. }
  106. return Json(new ReturnMessage()
  107. {
  108. IsSuccess = true,
  109. Message = "保存成功。"
  110. });
  111. }
  112. catch (Exception ex)
  113. {
  114. return Json(new ReturnMessage()
  115. {
  116. IsSuccess = false,
  117. Message = "保存失败,原因:" + ex.Message
  118. });
  119. }
  120. }
  121. /// <summary>
  122. /// Excel 导出
  123. /// </summary>
  124. /// <returns></returns>
  125. [HttpPost]
  126. public ActionResult Excel()
  127. {
  128. NpoiExcelHelper neh = new NpoiExcelHelper();
  129. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  130. Guid? supplierID = null;
  131. Guid? schoolyearID = null;
  132. supplierID = Request.Form["SupplierDropdown"].ParseStrTo<Guid>();
  133. schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  134. DateTime? startStockInTime = DateTime.Now;
  135. DateTime? endStockInTime = DateTime.Now;
  136. endStockInTime = DateTime.Parse(Request.Form["EndStockInTime"]);
  137. startStockInTime = DateTime.Parse(Request.Form["StartStockInTime"]);
  138. var dt = StockOutServices.GetStockOutViewList(configuretView, schoolyearID, new List<int> { (int)CF_StockOutType.TeachingMaterialRetail }, supplierID, startStockInTime, endStockInTime).Select(x => new
  139. {
  140. x.StockOutNo,
  141. x.RecordStatusName,
  142. x.SchoolyearName,
  143. x.StockOutTypeName,
  144. x.StockOutSumMoney,
  145. x.RecipientUserName,
  146. x.StockOutUserName,
  147. x.StockOutTime,
  148. x.Desc
  149. }).ToTable();
  150. string[] liststring = { "出库单据号", "是否出库", "学年学期", "出库类型", "单据总金额", "签收人", "经手人", "零售日期", "零售说明" };
  151. neh.Export(dt, liststring, "教材零售信息");
  152. return RedirectToAction("MsgShow", "Common", new
  153. {
  154. msg = "导出成功!",
  155. url = Url.Content("~/TeacherRetail/List").AddMenuParameter()
  156. });
  157. }
  158. /// <summary>
  159. /// 删除
  160. /// </summary>
  161. /// <param name="roleID"></param>
  162. /// <returns></returns>
  163. [HttpPost]
  164. public ActionResult Delete(string stockOutIDs)
  165. {
  166. try
  167. {
  168. var stockOutIDList = stockOutIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
  169. StockOutServices.Delete(stockOutIDList);
  170. return base.Json("删除成功。");
  171. }
  172. catch (Exception ex)
  173. {
  174. string mge = ex.Message;
  175. return base.Json("删除失败,原因:" + mge);
  176. }
  177. }
  178. /// <summary>
  179. /// 添加教材
  180. /// </summary>
  181. /// <returns></returns>
  182. public ActionResult TeachingMaterial()
  183. {
  184. return View();
  185. }
  186. /// <summary>
  187. ///
  188. /// </summary>
  189. /// <returns></returns>
  190. [HttpGet]
  191. public ActionResult GetStockOutByTMList()
  192. {
  193. return View();
  194. }
  195. /// <summary>
  196. ///
  197. /// </summary>
  198. /// <param name="pararms"></param>
  199. /// <returns></returns>
  200. [HttpPost]
  201. public ActionResult GetStockOutByTMList(QueryParamsModel pararms)
  202. {
  203. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  204. //避开全选值
  205. Guid? publishID = null;
  206. Guid? coursematerialID = null;
  207. bool? isLate = false;
  208. var teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
  209. publishID = pararms.getExtraGuid("PublishDropdown");
  210. coursematerialID = pararms.getExtraGuid("CourseDropdown");
  211. var isSelectMax = pararms.getExtraInt("hidIsSelectMax") == 1;
  212. return base.Json(StockOutServices.GetStockInByTeachingMaterialPoolViewGrid(configuretView, isLate, teachingMaterialPoolID, coursematerialID, isSelectMax, (int)pararms.page, (int)pararms.rows));
  213. }
  214. /// <summary>
  215. ///
  216. /// </summary>
  217. /// <param name="stockOutID"></param>
  218. /// <returns></returns>
  219. [HttpPost]
  220. public ActionResult GetTMViewList(Guid? stockOutID)
  221. {
  222. if (stockOutID.HasValue)
  223. {
  224. var resultList = StockOutServices.GetStockOutByTMViewList(stockOutID.Value);
  225. return Json(new JsonDataGridResult<TeachingMaterialPoolView> { rows = resultList, total = resultList.Count });
  226. }
  227. else
  228. {
  229. return Json(new JsonDataGridResult<TeachingMaterialPoolView>());
  230. }
  231. }
  232. /// <summary>
  233. /// 提交
  234. /// </summary>
  235. /// <param name="roleID"></param>
  236. /// <returns></returns>
  237. [HttpPost]
  238. public ActionResult Submit(string stockOutIDs)
  239. {
  240. try
  241. {
  242. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  243. var stockOutIDList = stockOutIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
  244. StockOutServices.Submit(stockOutIDList, user.UserID);
  245. return base.Json("提交出库成功。");
  246. }
  247. catch (Exception ex)
  248. {
  249. string mge = ex.Message;
  250. return base.Json("提交出库失败,原因:" + mge);
  251. }
  252. }
  253. }
  254. }