StudentDistributeController.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.TeachingMaterial;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using EMIS.ViewModel.TeachingMaterial;
  13. using EMIS.ViewModel.Students;
  14. using EMIS.CommonLogic.Students;
  15. using EMIS.CommonLogic.CalendarManage;
  16. using EMIS.Utility;
  17. using EMIS.CommonLogic.SystemServices;
  18. namespace EMIS.Web.Controllers.TeachingMaterial
  19. {
  20. [Authorization]
  21. public class StudentDistributeController : Controller
  22. {
  23. public IStudentDistributeServices StudentDistributeServices { get; set; }
  24. public IStudentsServices StudentfileServices { get; set; }
  25. public ISchoolYearServices SchoolYearServices { get; set; }
  26. public IStockOutServices StockOutServices { get; set; }
  27. /// <summary>
  28. /// 学生发放页面
  29. /// </summary>
  30. /// <returns></returns>
  31. [HttpGet]
  32. public ActionResult List()
  33. {
  34. //默认当前学年
  35. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  36. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();
  37. return View();
  38. }
  39. /// <summary>
  40. /// 列表查询
  41. /// </summary>
  42. /// <param name="pararms"></param>
  43. /// <returns></returns>
  44. [HttpPost]
  45. public ActionResult List(QueryParamsModel pararms)
  46. {
  47. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  48. var grademajorID = pararms.getExtraGuid("ComboGridGrademajor");
  49. Guid? campusID = pararms.getExtraGuid("CampusDropdown");
  50. Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
  51. int? years = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  52. int? standardID = pararms.getExtraInt("ddlStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlStandard");
  53. Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
  54. int? courseCategoryID = pararms.getExtraInt("CourseTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("CourseTypeDropdown");
  55. Guid? teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
  56. Guid? schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");//学年学期
  57. int? isOrdered = pararms.getExtraInt("OrderedDropdown");
  58. return base.Json(StudentDistributeServices.GetStudentDistributeViewGrid(configuretView, campusID, collegeID, years, grademajorID,
  59. coursematerialID, courseCategoryID, teachingMaterialPoolID, isOrdered, schoolyearID, standardID, (int)pararms.page, (int)pararms.rows));
  60. }
  61. /// <summary>
  62. /// 发放计划生成
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult CreatePlan()
  67. {
  68. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true).SchoolyearID;
  69. ViewData["schoolYear"] = schoolYear;
  70. return View();
  71. }
  72. /// <summary>
  73. /// 发放计划生成
  74. /// </summary>
  75. /// <param name="schoolyearID"></param>
  76. /// <returns></returns>
  77. [HttpPost]
  78. public ActionResult CreatePlan(Guid schoolyearID)
  79. {
  80. try
  81. {
  82. schoolyearID = new Guid(Request.Form["SchoolyearDropdown"]);
  83. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  84. StudentDistributeServices.CreateStudentDistribute(schoolyearID, user.UserID);
  85. return Json(new ReturnMessage()
  86. {
  87. IsSuccess = true,
  88. Message = "生成成功。"
  89. });
  90. }
  91. catch (Exception ex)
  92. {
  93. return Json(new ReturnMessage()
  94. {
  95. IsSuccess = false,
  96. Message = "生成失败,原因:" + ex.Message
  97. });
  98. }
  99. }
  100. /// <summary>
  101. /// 删除
  102. /// </summary>
  103. /// <param name="roleID"></param>
  104. /// <returns></returns>
  105. [HttpPost]
  106. public ActionResult Delete(string studentDistributeIDs)
  107. {
  108. try
  109. {
  110. var studentDistributeIDList = studentDistributeIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
  111. StudentDistributeServices.DeleteStudentDistribute(studentDistributeIDList);
  112. return base.Json("删除成功。");
  113. }
  114. catch (Exception ex)
  115. {
  116. return base.Json("删除失败,原因:" + ex.Message);
  117. }
  118. }
  119. /// <summary>
  120. /// Excel
  121. /// </summary>
  122. /// <returns></returns>
  123. [HttpPost]
  124. public ActionResult Excel()
  125. {
  126. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  127. //避开全选值
  128. int? isOrdered = null;
  129. var grademajorID = Request.Form["ComboGridGrademajor"].ParseStrTo<Guid>();
  130. Guid? campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  131. Guid? collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  132. int? years = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  133. int? standardID = Request.Form["StandardDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropdown"].ParseStrTo<int>();
  134. Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  135. int? courseCategoryID = Request.Form["CourseTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["CourseTypeDropdown"].ParseStrTo<int>();
  136. Guid? schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  137. if (Request.Form["OrderedDropdown"].ParseStrTo<int>() != DropdownList.SELECT_ALL && Request.Form["OrderedDropdown"].ParseStrTo<int>() != null)
  138. {
  139. isOrdered = Request.Form["OrderedDropdown"].ParseStrTo<int>();
  140. }
  141. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  142. Guid? teachingMaterialPoolID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  143. NpoiExcelHelper neh = new NpoiExcelHelper();
  144. var dt = StudentDistributeServices.GetStudentDistributeViewList(configuretView, campusID, collegeID, years, grademajorID,
  145. coursematerialID, courseCategoryID, teachingMaterialPoolID, isOrdered, schoolyearID, standardID).Select(x => new
  146. {
  147. x.SchoolyearCode,
  148. x.CollegeName,
  149. x.GradeSpecialtyName,
  150. x.CourseName,
  151. x.TeachingMaterialName,
  152. x.TeachingMaterialCode,
  153. x.Price,
  154. x.DiscountStr,
  155. x.DiscountPriceStr,
  156. x.StudentQty,
  157. x.OrderQty,
  158. x.PresentInventory,
  159. x.DistributeQty,
  160. x.RemainingQty,
  161. x.IsDistributeName
  162. }).ToTable();
  163. string[] liststring = { "学年学期", RSL.Get("College"), "年级专业", "课程名称", "教材名称", "教材编号","单价",
  164. "折扣率", "折合价","学生人数","征订数量","库存数量","发放人数","未发人数","发放状态"};
  165. neh.Export(dt, liststring, "学生发放信息");
  166. return RedirectToAction("MsgShow", "Common", new
  167. {
  168. msg = "导出成功!",
  169. url = Url.Content("~/StudentDistribute/List").AddMenuParameter()
  170. });
  171. }
  172. /// <summary>
  173. /// 提交
  174. /// </summary>
  175. /// <param name="roleID"></param>
  176. /// <returns></returns>
  177. [HttpPost]
  178. public ActionResult ComfirmOrder(string studentDistributeIDs)
  179. {
  180. try
  181. {
  182. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  183. var studentDistributeIDList = studentDistributeIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
  184. StudentDistributeServices.ComfirmStudentDistribute(studentDistributeIDList, user.UserID);
  185. return base.Json("提交成功。");
  186. }
  187. catch (Exception ex)
  188. {
  189. return base.Json("提交失败,原因:" + ex.Message);
  190. }
  191. }
  192. /// <summary>
  193. /// 学生信息列表查询
  194. /// </summary>
  195. /// <param name="pararms"></param>
  196. /// <returns></returns>
  197. [HttpPost]
  198. public ActionResult StudentList(QueryParamsModel pararms)
  199. {
  200. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  201. //避开全选值
  202. var campusID = pararms.getExtraGuid("CampusDropdown");
  203. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  204. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  205. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  206. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  207. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  208. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  209. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  210. var GrademajorID = Request.Params["GrademajorID"].ParseStrTo<Guid>();
  211. var studentDistributeID = Request.Params["studentDistributeID"].ParseStrTo<Guid>();
  212. return base.Json(StudentDistributeServices.GetStudentDistributeByUserViewList(configuretView, campusID, collegeID, yearID, standardID,
  213. learningformID, studentDistributeID, generalPurposeID, inSchoolStatusID, GrademajorID, (int)pararms.page, (int)pararms.rows));
  214. //ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  215. //var result = StudentDistributeServices.GetStudentViewGrid(configuretView, (int)pararms.page, (int)pararms.rows);
  216. //return Json(result);
  217. }
  218. /// <summary>
  219. /// 编辑
  220. /// </summary>
  221. /// <param name="studentDistributeID"></param>
  222. /// <param name="studentQty"></param>
  223. /// <returns></returns>
  224. [HttpGet]
  225. public ActionResult Edit(Guid? studentDistributeID, string studentQty)
  226. {
  227. StudentDistributeView studentDistributeView = new StudentDistributeView();
  228. if (studentDistributeID != null && studentDistributeID != Guid.Empty)
  229. {
  230. studentDistributeView = StudentDistributeServices.GetSingleStudentDistribute(studentDistributeID.Value);
  231. }
  232. else
  233. {
  234. studentDistributeView = new StudentDistributeView()
  235. {
  236. StudentDistributeID = Guid.Empty
  237. };
  238. }
  239. return View(studentDistributeView);
  240. }
  241. /// <summary>
  242. /// 编辑
  243. /// </summary>
  244. /// <returns></returns>
  245. [HttpPost]
  246. public ActionResult Edit(StudentDistributeView studentDistributeView)
  247. {
  248. try
  249. {
  250. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;//获取当前登录用户信息
  251. var studentList = DataGrid.GetTableData<StudentsView>("dgStudentList");//获取底部列表数据、
  252. StudentDistributeServices.SaveStudentUnpublishedInventory(studentDistributeView, studentList, user.UserID);//保存未发人数信息
  253. return Json(new ReturnMessage()
  254. {
  255. IsSuccess = true,
  256. Message = "保存成功。"
  257. });
  258. }
  259. catch (Exception ex)
  260. {
  261. return Json(new ReturnMessage()
  262. {
  263. IsSuccess = false,
  264. Message = "保存失败:" + ex.Message
  265. });
  266. }
  267. }
  268. /// <summary>
  269. /// 未发放学生信息
  270. /// </summary>
  271. /// <param name="studentDistributeID"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. public ActionResult GetStudentList(Guid? studentDistributeID)
  275. {
  276. if (studentDistributeID.HasValue)
  277. {
  278. var studentList = StudentDistributeServices.GetStudentDistributeByStudentViewList(studentDistributeID.Value);
  279. return Json(new JsonDataGridResult<StudentDistribute_UserView> { rows = studentList, total = studentList.Count });
  280. }
  281. else
  282. {
  283. return Json(new JsonDataGridResult<StudentDistribute_UserView>());
  284. }
  285. }
  286. /// <summary>
  287. /// 提交确定
  288. /// </summary>
  289. /// <param name="studentDistributeID"></param>
  290. /// <returns></returns>
  291. [HttpGet]
  292. public ActionResult SubmitStudentDistribute(Guid? studentDistributeID)
  293. {
  294. StudentDistributeView studentDistributeView = new StudentDistributeView();
  295. if (studentDistributeID != null && studentDistributeID != Guid.Empty)
  296. {
  297. studentDistributeView = StudentDistributeServices.GetSingleStudentDistribute(studentDistributeID.Value);
  298. }
  299. else
  300. {
  301. studentDistributeView = new StudentDistributeView()
  302. {
  303. StudentDistributeID = Guid.Empty
  304. };
  305. }
  306. studentDistributeView.StudentDistributeNo = StockOutServices.GetStockOutNo(CF_StockOutType.StudentBook);
  307. return View(studentDistributeView);
  308. }
  309. /// <summary>
  310. /// 提交确定
  311. /// </summary>
  312. /// <param name="studentDistributeView"></param>
  313. /// <returns></returns>
  314. [HttpPost]
  315. public ActionResult SubmitStudentDistribute(StudentDistributeView studentDistributeView)
  316. {
  317. try
  318. {
  319. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;//获取当前登录用户信息
  320. var studentDistributeIDList = Request.Params["studentDistributeID"].Split(',').Select(x => Guid.Parse(x)).ToList();
  321. StudentDistributeServices.Save(studentDistributeIDList, studentDistributeView);//保存提交
  322. return Json(new ReturnMessage()
  323. {
  324. IsSuccess = true,
  325. Message = "保存成功。"
  326. });
  327. }
  328. catch (Exception ex)
  329. {
  330. return Json(new ReturnMessage()
  331. {
  332. IsSuccess = false,
  333. Message = "保存失败:" + ex.Message
  334. });
  335. }
  336. }
  337. /// <summary>
  338. /// 发放学生信息
  339. /// </summary>
  340. /// <returns></returns>
  341. [HttpGet]
  342. public ActionResult StudentDistributeDetail()
  343. {
  344. ViewBag.StudentDistributeID = Request.Params["StudentDistributeID"];
  345. return View();
  346. }
  347. /// <summary>
  348. /// 发放学生信息列表查询
  349. /// </summary>
  350. /// <param name="pararms"></param>
  351. /// <returns></returns>
  352. [HttpPost]
  353. public ActionResult StudentDistributeDetail(QueryParamsModel pararms)
  354. {
  355. Guid? studentDistributeID = Request.Params["studentDistributeID"].ParseStrTo<Guid>();
  356. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  357. return base.Json(StudentDistributeServices.GetStudentDistributeDetailViewList(studentDistributeID, (int)pararms.page, (int)pararms.rows));
  358. }
  359. /// <summary>
  360. /// 发放学生明细Excel
  361. /// </summary>
  362. /// <param name="pararms"></param>
  363. /// <returns></returns>
  364. [HttpPost]
  365. public ActionResult StudentDistributeDetailExcel()
  366. {
  367. Guid? studentDistributeID = Request.Params["studentDistributeID"].ParseStrTo<Guid>();
  368. NpoiExcelHelper neh = new NpoiExcelHelper();
  369. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  370. var dt = StudentDistributeServices.GetStudentDistributeDetailQuery(studentDistributeID).Select(x => new
  371. {
  372. x.StandardName,
  373. x.TeachingMaterialCode,
  374. x.TeachingMaterialName,
  375. x.StudentDistributeNo,
  376. x.DistributeQty,
  377. x.Price,
  378. x.DiscountStr,
  379. x.DiscountPriceStr,
  380. x.TotalPriceStr,
  381. x.TotalDollarStr,
  382. x.RecipientUser,
  383. ModifyTime = (x.ModifyTime.HasValue ? x.ModifyTime.Value.ToString("yyyy-MM-dd") : ""),
  384. x.StockOutUserName,
  385. CreateTime = (x.CreateTime.HasValue ? x.CreateTime.Value.ToString("yyyy-MM-dd") : ""),
  386. x.Remark
  387. }).ToTable();
  388. string[] liststring = { "学号", "教材编号", "教材名称", "出库编号", "数量", "单价",
  389. "折扣率", "折合价","码洋","总价","签收人","签收日期","出库人","出库日期","备注"};
  390. neh.Export(dt, liststring, "学生发放明细信息");
  391. return RedirectToAction("MsgShow", "Common", new
  392. {
  393. msg = "导出成功!",
  394. url = Url.Content("~/StudentDistribute/List").AddMenuParameter()
  395. });
  396. }
  397. }
  398. }