StudentsOrderController.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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 Bowin.Web.Controls.Mvc;
  10. using EMIS.CommonLogic.TeachingMaterial;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. using EMIS.ViewModel.TeachingMaterial;
  14. using EMIS.CommonLogic.CalendarManage;
  15. using EMIS.Utility;
  16. namespace EMIS.Web.Controllers.TeachingMaterial
  17. {
  18. [Authorization]
  19. public class StudentsOrderController : Controller
  20. {
  21. public IStudentsOrderServices StudentsOrderServices { get; set; }
  22. public ISchoolYearServices SchoolYearServices { get; set; }
  23. [HttpGet]
  24. public ActionResult List()
  25. {
  26. //默认当前学年
  27. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  28. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();
  29. return View();
  30. }
  31. /// <summary>
  32. /// 列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. var teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
  41. var grademajorID = pararms.getExtraGuid("ComboGridGrademajor");
  42. Guid? campusID = pararms.getExtraGuid("CampusDropdown");
  43. Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
  44. int? years = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  45. int? standardID = pararms.getExtraInt("StandardDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDropdown");
  46. Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
  47. int? courseCategoryID = pararms.getExtraInt("CourseTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("CourseTypeDropdown");
  48. Guid? schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");//学年学期
  49. int? isOrdered = pararms.getExtraInt("OrderedDropdown");
  50. return base.Json(StudentsOrderServices.GetStudentsOrderViewGrid(configuretView, campusID, collegeID, years, grademajorID,
  51. coursematerialID, courseCategoryID, isOrdered, schoolyearID,teachingMaterialID, (int)pararms.page, (int)pararms.rows));
  52. }
  53. [HttpGet]
  54. public ActionResult EditTeachingMaterialPool()
  55. {
  56. ViewData["IsOrdered"] = Request.Params["IsOrdered"].ToString();
  57. return View();
  58. }
  59. [HttpPost]
  60. public ActionResult EditTeachingMaterialPool(EditTeachingMaterPoolView jsonData)
  61. {
  62. try
  63. {
  64. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  65. var studentsOrderIDs = jsonData.StudentsOrderID.Split(',').Select(x => Guid.Parse(x)).ToList();
  66. var teachingMaterialPoolIDs = jsonData.TeachingMaterialPoolID.Split(',').Select(x => Guid.Parse(x)).ToList();
  67. var specialtyPlanIDs = jsonData.SpecialtyPlanID.Split(',').Select(x => Guid.Parse(x)).ToList();
  68. StudentsOrderServices.SpecifiedTeachingMaterialPool(studentsOrderIDs, teachingMaterialPoolIDs, specialtyPlanIDs, user.UserID);
  69. return base.Json("指定成功");
  70. }
  71. catch (Exception ex)
  72. {
  73. return base.Json("指定失败,原因:" + ex.Message);
  74. }
  75. }
  76. [HttpGet]
  77. public ActionResult CreatePlan()
  78. {
  79. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true).SchoolyearID;
  80. ViewData["schoolYear"] = schoolYear;
  81. return View();
  82. }
  83. [HttpPost]
  84. public ActionResult CreatePlan(Guid schoolyearID)
  85. {
  86. try
  87. {
  88. schoolyearID = new Guid(Request.Form["SchoolyearDropdown"]);
  89. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  90. StudentsOrderServices.CreateStudentOrder(schoolyearID, user.UserID);
  91. return Json(new ReturnMessage()
  92. {
  93. IsSuccess = true,
  94. Message = "生成成功!"
  95. });
  96. }
  97. catch (Exception ex)
  98. {
  99. return Json(new ReturnMessage()
  100. {
  101. IsSuccess = false,
  102. Message = "生成失败,原因:" + ex.Message + "!"
  103. });
  104. }
  105. }
  106. /// <summary>
  107. /// 删除
  108. /// </summary>
  109. /// <param name="roleID"></param>
  110. /// <returns></returns>
  111. [HttpPost]
  112. public ActionResult Delete(string specialtyPlanIDs)
  113. {
  114. try
  115. {
  116. var specialtyPlanIDList = specialtyPlanIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
  117. StudentsOrderServices.DeleteStudentsOrders(specialtyPlanIDList);
  118. return base.Json("删除成功");
  119. }
  120. catch (Exception ex)
  121. {
  122. return base.Json("删除失败,原因:" + ex.Message + "!");
  123. }
  124. }
  125. /// <summary>
  126. /// 确认征订
  127. /// </summary>
  128. /// <param name="roleID"></param>
  129. /// <returns></returns>
  130. [HttpPost]
  131. public ActionResult ComfirmOrder(string specialtyPlanIDs)
  132. {
  133. try
  134. {
  135. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  136. var specialtyPlanIDList = specialtyPlanIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
  137. StudentsOrderServices.ComfirmStudentOrder(specialtyPlanIDList, user.UserID);
  138. return base.Json("征订成功");
  139. }
  140. catch (Exception ex)
  141. {
  142. return base.Json("征订失败,原因:" + ex.Message + "!");
  143. }
  144. }
  145. /// <summary>
  146. /// 预加设置
  147. /// </summary>
  148. /// <returns></returns>
  149. [HttpGet]
  150. public ActionResult BatchSetPreAddedValue()
  151. {
  152. StudentsOrderView studentsOrderView;
  153. studentsOrderView = new StudentsOrderView()
  154. {
  155. PreIncreaseQty = 5
  156. };
  157. return View(studentsOrderView);
  158. }
  159. /// <summary>
  160. /// 预加设置
  161. /// </summary>
  162. /// <param name="orderJsonStr"></param>
  163. /// <returns></returns>
  164. [HttpPost]
  165. public ActionResult BatchSetPreAddedValue(string orderJsonStr)
  166. {
  167. try
  168. {
  169. orderJsonStr = Request.Form["hid_JsonStr"];
  170. string PreIncreaseQty = Request.Form["PreIncreaseQty"];
  171. if (orderJsonStr != null)
  172. {
  173. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  174. var addTeacherList = orderJsonStr.JsonToObject<List<StudentsOrderView>>();
  175. StudentsOrderServices.BatchUpdatePreAddedValue(addTeacherList, Convert.ToInt32(PreIncreaseQty), user.UserID);
  176. }
  177. return Json(new ReturnMessage()
  178. {
  179. IsSuccess = true,
  180. Message = "保存成功!"
  181. });
  182. }
  183. catch (Exception ex)
  184. {
  185. return Json(new ReturnMessage()
  186. {
  187. IsSuccess = true,
  188. Message = "保存失败,原因:" + ex.Message + "!"
  189. });
  190. }
  191. }
  192. /// <summary>
  193. /// 征订设置
  194. /// </summary>
  195. /// <returns></returns>
  196. [HttpGet]
  197. public ActionResult ChangeOrderQty()
  198. {
  199. StudentsOrderView studentsOrderView;
  200. studentsOrderView = new StudentsOrderView()
  201. {
  202. OrderQty = 0
  203. };
  204. return View(studentsOrderView);
  205. }
  206. [HttpPost]
  207. public ActionResult ChangeOrderQty(string orderJsonStr)
  208. {
  209. try
  210. {
  211. orderJsonStr = Request.Form["hid_JsonStr"];
  212. string OrderQty = Request.Form["OrderQty"];
  213. if (orderJsonStr != null)
  214. {
  215. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  216. var sutdentsOrderQtylist = orderJsonStr.JsonToObject<List<StudentsOrderView>>();
  217. StudentsOrderServices.UpdateOrderQty(sutdentsOrderQtylist, Convert.ToInt32(OrderQty), user.UserID);
  218. }
  219. return Json(new ReturnMessage()
  220. {
  221. IsSuccess = true,
  222. Message = "保存成功!"
  223. });
  224. }
  225. catch (Exception ex)
  226. {
  227. return Json(new ReturnMessage()
  228. {
  229. IsSuccess = true,
  230. Message = "保存失败,原因:" + ex.Message + "!"
  231. });
  232. }
  233. }
  234. [HttpPost]
  235. public ActionResult Excel(QueryParamsModel pararms)
  236. {
  237. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  238. //避开全选值
  239. var teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  240. var grademajorID = Request.Form["ComboGridGrademajor"].ParseStrTo<Guid>();
  241. Guid? campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  242. Guid? collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  243. int? years = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  244. int? standardID = Request.Form["StandardDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropdown"].ParseStrTo<int>();
  245. Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  246. int? courseCategoryID = Request.Form["CourseTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["CourseTypeDropdown"].ParseStrTo<int>();
  247. Guid? schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  248. int? isOrdered = Request.Form["OrderedDropdown"].ParseStrTo<int>();
  249. NpoiExcelHelper neh = new NpoiExcelHelper();
  250. if (Request.Form["ExcelType"] == "1")
  251. {
  252. var dt = StudentsOrderServices.GetStudentsOrderViewExcle(configuretView, campusID, collegeID, years, grademajorID,
  253. coursematerialID, courseCategoryID, isOrdered, schoolyearID, teachingMaterialID).Select(x => new
  254. {
  255. x.SchoolyearCode,
  256. x.CollegeName,
  257. x.Years,
  258. x.GrademajorCode,
  259. x.GrademajorName,
  260. x.ClassNum,
  261. x.OrderQty,
  262. x.PreIncreaseQty,
  263. x.Count,
  264. x.StandardName,
  265. x.CourseCode,
  266. x.CourseName,
  267. x.CourseCategoryName,
  268. x.CourseTypeName,
  269. x.CourseQualityName,
  270. x.TeachingMaterialCode,
  271. x.TeachingMaterialName,
  272. x.IsOrderedName,
  273. x.CreateUserName,
  274. x.CreateTime
  275. }).ToTable();
  276. string[] liststring = { "学年学期", RSL.Get("College"), "年级", "年级专业代码", "年级专业", "学生人数", "征订数量","增加数量","总数",
  277. "专业名称","课程代码","课程名称","课程属性","课程类型","课程性质","教材编号",
  278. "教材名称","是否征订","创建人","创建时间"};
  279. neh.Export(dt, liststring, "学生征订计划");
  280. }
  281. else
  282. {
  283. var dt = StudentsOrderServices.GetStudentsOrderViewAggregateExcle(configuretView, campusID, collegeID, years, grademajorID,
  284. coursematerialID, courseCategoryID, isOrdered, schoolyearID,teachingMaterialID).Select(x => new
  285. {
  286. x.SchoolyearCode,
  287. x.CollegeName,
  288. x.GrademajorName,
  289. x.ClassNum,
  290. x.CourseName,
  291. x.TeachingMaterialCode,
  292. x.TeachingMaterialName,
  293. x.PublishTime,
  294. x.PublishName,
  295. x.Author,
  296. x.ISBN,
  297. x.Price,
  298. x.OrderQty,
  299. x.PreIncreaseQty,
  300. x.Count,
  301. x.TeachingMaterialTypeName
  302. }).ToTable();
  303. string[] liststring = { "学年学期", RSL.Get("College"), "年级专业", "学生数", "课程名称","教材编号", "教材名称", "版本时间",
  304. "出版单位","作者","ISBN","单价","征订数","预加数量","需用数","教材类型"};
  305. neh.Export(dt, liststring, "预订汇总");
  306. }
  307. return RedirectToAction("MsgShow", "Common", new
  308. {
  309. msg = "导出成功!",
  310. url = Url.Content("~/StudentsOrder/List").AddMenuParameter()
  311. });
  312. }
  313. /// <summary>
  314. /// 学生统计页面
  315. /// </summary>
  316. /// <returns></returns>
  317. [HttpGet]
  318. public ActionResult StusdentStatisticalList()
  319. {
  320. return View();
  321. }
  322. /// <summary>
  323. /// 学生统计查询
  324. /// </summary>
  325. /// <param name="pararms"></param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. public ActionResult StusdentStatisticalList(QueryParamsModel pararms)
  329. {
  330. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  331. Guid? campusID = pararms.getExtraGuid("CampusDropdown");
  332. Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
  333. Guid? schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  334. Guid? grademajorID = pararms.getExtraGuid("GrademajorDropdown");
  335. Guid? teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
  336. Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
  337. Guid? publishID = pararms.getExtraGuid("PublishDropdown");
  338. return base.Json(StudentsOrderServices.GetStudentsOrderStatisticalViewGrid(configuretView, schoolyearID, campusID, collegeID,
  339. grademajorID, teachingMaterialPoolID, coursematerialID, publishID, (int)pararms.page, (int)pararms.rows));
  340. }
  341. [HttpPost]
  342. public ActionResult StatisticalExcel(QueryParamsModel pararms)
  343. {
  344. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  345. //Guid? campusID = pararms.getExtraGuid("CampusDropdown");
  346. //Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
  347. //Guid? schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  348. //Guid? grademajorID = pararms.getExtraGuid("GrademajorDropdown");
  349. //Guid? teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
  350. //Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
  351. //Guid? publishID = pararms.getExtraGuid("PublishDropdown");
  352. Guid? campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  353. Guid? collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  354. Guid? schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  355. Guid? grademajorID = Request.Form["GrademajorDropdown"].ParseStrTo<Guid>();
  356. Guid? teachingMaterialPoolID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  357. Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  358. Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  359. int? isOrdered = Request.Form["OrderedDropdown"].ParseStrTo<int>();
  360. NpoiExcelHelper neh = new NpoiExcelHelper();
  361. var dt = StudentsOrderServices.GetStudentsOrderStatisticalExcel(configuretView, schoolyearID, campusID, collegeID,
  362. grademajorID, teachingMaterialPoolID, coursematerialID, publishID).Select(x => new
  363. {
  364. x.SchoolyearCode,
  365. x.CollegeName,
  366. x.GrademajorName,
  367. x.ClassNum,
  368. x.TeachingMaterialCode,
  369. x.CourseName,
  370. x.ISBN,
  371. x.TeachingMaterialName,
  372. x.Price,
  373. x.PublishTime,
  374. x.PublishName,
  375. x.Author,
  376. x.OrderQty,
  377. x.PreIncreaseQty,
  378. x.Count
  379. }).ToTable();
  380. string[] liststring = { "学年学期", RSL.Get("College"), "年级专业", "学生人数","教材编号","课程名称",
  381. "ISBN","教材名称","单价","版本时间","出版单位","作者","征订数量","预加数量","总计"};
  382. neh.Export(dt, liststring, "学生征订统计");
  383. return RedirectToAction("MsgShow", "Common", new
  384. {
  385. msg = "导出成功!",
  386. url = Url.Content("~/StudentsOrder/List").AddMenuParameter()
  387. });
  388. }
  389. }
  390. }