TeachersConfirmOrderController.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.JSON;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using EMIS.CommonLogic.TeachingMaterial;
  10. using Bowin.Web.Controls.Mvc;
  11. using EMIS.ViewModel.TeachingMaterial;
  12. using Bowin.Common.Utility;
  13. using Bowin.Common.Data;
  14. using EMIS.Utility;
  15. using EMIS.CommonLogic.CalendarManage;
  16. namespace EMIS.Web.Controllers.TeachingMaterial
  17. {
  18. [Authorization]
  19. public class TeachersConfirmOrderController : Controller
  20. {
  21. public ITeachersConfirmOrderServices TeachersConfirmOrderServices { get; set; }
  22. public ISchoolYearServices schoolYearServices { get; set; }
  23. /// <summary>
  24. /// 页面列表查询
  25. /// </summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public ActionResult List()
  29. {
  30. //默认加载当前校历下学年学期的下一个学期
  31. var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
  32. var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
  33. ViewBag.SchoolYearID = schoolyear.SchoolYearID;
  34. return View();
  35. }
  36. /// <summary>
  37. /// 列表查询
  38. /// </summary>
  39. /// <param name="pararms"></param>
  40. /// <returns></returns>
  41. [HttpPost]
  42. public ActionResult List(QueryParamsModel pararms)
  43. {
  44. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  45. //避开全选值
  46. Guid? publishID = pararms.getExtraGuid("PublishDropdown");
  47. Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
  48. var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown");
  49. Guid? teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
  50. var approvalStatus = pararms.getExtraInt("StatusDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  51. return base.Json(TeachersConfirmOrderServices.GetTeachersOrderViewGrid(configuretView, schoolYearID, teachingMaterialID, coursematerialID, publishID, approvalStatus, (int)pararms.page, (int)pararms.rows));
  52. }
  53. #region 2.0 加载清单明细列表
  54. /// <summary>
  55. /// 明细页面
  56. /// </summary>
  57. /// <returns></returns>
  58. [HttpGet]
  59. public ActionResult Detail(string teachersOrderID)
  60. {
  61. string yearIds = Request.QueryString["schoolYearID"];
  62. if (yearIds != null)
  63. {
  64. ViewData["schoolYearID"] = yearIds;
  65. ViewData["teachingMaterialPoolID"] = Request.QueryString["teachingMaterialPoolID"];
  66. }
  67. return View();
  68. }
  69. /// <summary>
  70. /// 清单征订明细查看
  71. /// </summary>
  72. /// <param name="pararms"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. public ActionResult Detail(QueryParamsModel pararms)
  76. {
  77. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  78. //避开全选值
  79. var schoolYearID = Request.Params["schoolYearID"] == null ? Guid.Empty.ToString() : Request.Params["schoolYearID"].ToString();
  80. var teachingMaterialID = Request.Params["teachingMaterialPoolID"] == null ? Guid.Empty.ToString() : Request.Params["teachingMaterialPoolID"].ToString();
  81. Guid? collegeID = user.CollegeID;
  82. Guid? teachingMaterialPoolIDs = new Guid(teachingMaterialID);
  83. Guid? schoolYearIDs = new Guid(schoolYearID);
  84. return base.Json(TeachersConfirmOrderServices.GetTeachersOrderDetailViewGrid(schoolYearIDs, collegeID, teachingMaterialPoolIDs, (int)pararms.page, (int)pararms.rows));
  85. }
  86. #endregion
  87. #region 3.0 获取预加窗口
  88. /// <summary>
  89. /// 获取下一步动作
  90. /// </summary>
  91. /// <param name="planApplicationIDs"></param>
  92. /// <returns></returns>
  93. [HttpGet]
  94. public ActionResult BatchSetPreAddedValue()
  95. {
  96. TeachersConfirmOrderView teachersConfirmOrderView;
  97. teachersConfirmOrderView = new TeachersConfirmOrderView()
  98. {
  99. PreAddedValue = 5
  100. };
  101. return View(teachersConfirmOrderView);
  102. }
  103. #endregion
  104. #region 4.0 待定
  105. #endregion
  106. #region 5.0 批量设置值
  107. /// <summary>
  108. /// 批量设置预加值
  109. /// </summary>
  110. /// <returns></returns>
  111. [HttpPost]
  112. public ActionResult BatchSetPreAddedValue(string orderJsonStr)
  113. {
  114. try
  115. {
  116. orderJsonStr = Request.Form["hid_JsonStr"];
  117. string PreAddedValue = Request.Form["PreAddedValue"];
  118. if (orderJsonStr != null)
  119. {
  120. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  121. var addTeacherList = orderJsonStr.JsonToObject<List<TeachersOrderView>>();
  122. TeachersConfirmOrderServices.BatchUpdatePreAddedValue(addTeacherList, Convert.ToInt32(PreAddedValue), user.UserID);
  123. }
  124. return Json(new ReturnMessage()
  125. {
  126. IsSuccess = true,
  127. Message = "保存成功!"
  128. });
  129. }
  130. catch (Exception ex)
  131. {
  132. return Json(new ReturnMessage()
  133. {
  134. IsSuccess = true,
  135. Message = "保存失败,原因:" + ex.Message + "!"
  136. });
  137. }
  138. }
  139. #endregion
  140. #region 6.0 页面Excel表格导出
  141. [HttpPost]
  142. public ActionResult Excel(QueryParamsModel pararms)
  143. {
  144. //避开全选值
  145. bool? isLate = null;
  146. Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  147. Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  148. var schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  149. var teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  150. NpoiExcelHelper neh = new NpoiExcelHelper();
  151. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  152. var dt = TeachersConfirmOrderServices.GetTeachersConfirmOrderViewExcel(configuretView, schoolYearID, teachingMaterialID, coursematerialID, publishID).Select(x => new
  153. {
  154. x.SchoolyearName,
  155. x.TeachingMaterialCode,
  156. x.CoursematerialName,
  157. x.ISBN,
  158. x.TeachingMaterialName,
  159. x.Price,
  160. x.PublishTime,
  161. x.PublishName,
  162. x.Author,
  163. x.OrderQty,
  164. x.PreAddedValue,
  165. x.CountNumber
  166. }).ToTable();
  167. string[] liststring = { "学年学期","教材编号","课程名称","ISBN","教材名称","单价"
  168. ,"版本时间","出版单位","作者","征订数量","增加数量","总数量"};
  169. neh.Export(dt, liststring, "征订统计信息");
  170. return RedirectToAction("MsgShow", "Common", new
  171. {
  172. msg = "导出成功!",
  173. url = Url.Content("~/TeachersConfirmOrder/List").AddMenuParameter()
  174. });
  175. }
  176. #endregion
  177. #region 6.0 明细Excel表格导出
  178. [HttpPost]
  179. public ActionResult DetailExcel(QueryParamsModel pararms)
  180. {
  181. //避开全选值
  182. Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo<Guid>();
  183. Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo<Guid>();
  184. NpoiExcelHelper neh = new NpoiExcelHelper();
  185. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  186. var dt = TeachersConfirmOrderServices.GetTeachersConfirmOrderViewDetailExcel(schoolyearID, teachingMaterialPoolID).Select(x => new
  187. {
  188. x.SchoolyearName,
  189. x.CollegeName,
  190. x.TeachingMaterialCode,
  191. x.CoursematerialName,
  192. x.ISBN,
  193. x.TeachingMaterialName,
  194. x.PublishTime,
  195. x.PublishName,
  196. x.Author,
  197. x.OrderQty,
  198. x.OrderUserName,
  199. x.OrderDate,
  200. x.OrderDesc,
  201. x.Desc
  202. }).ToTable();
  203. string[] liststring = { "学年学期",RSL.Get("College"),"教材编号","课程名称","ISBN","教材名称"
  204. ,"版本时间","出版单位","作者","征订数量","征订人","征订日期","征订说明","备注"};
  205. neh.Export(dt, liststring, "教师征订清单明细信息");
  206. return RedirectToAction("MsgShow", "Common", new
  207. {
  208. msg = "导出成功!",
  209. url = Url.Content("~/TeachersConfirmOrder/List").AddMenuParameter()
  210. });
  211. }
  212. #endregion
  213. }
  214. }