MinorPlanApplyController.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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.MinorManage.MinorPlanManage;
  10. using EMIS.ViewModel.MinorManage.MinorPlanManage;
  11. using Bowin.Common.JSON;
  12. using Bowin.Common.Utility;
  13. using Bowin.Common.Exceptions;
  14. using EMIS.Utility;
  15. using Bowin.Common.Data;
  16. using EMIS.CommonLogic.Students;
  17. namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage
  18. {
  19. [Authorization]
  20. public class MinorPlanApplyController : Controller
  21. {
  22. //
  23. // GET: /MinorPlanApply/
  24. public IMinorPlanApplyServices minorPlanApplyServices { get; set; }
  25. public Lazy<IStudentsServices> StudentfileServices { get; set; }
  26. public ActionResult List()
  27. {
  28. return View();
  29. }
  30. [HttpPost]
  31. public ActionResult List(QueryParamsModel pararms)
  32. {
  33. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  34. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  35. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  36. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  37. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  38. return this.Json(minorPlanApplyServices.GetMinorPlanApplyViewGrid(configuretView, yearID, standardID, collegeID, approvalStatus,(int)pararms.page, (int)pararms.rows));
  39. }
  40. /// <summary>
  41. /// 获取未申请过的辅修课程
  42. /// </summary>
  43. /// <param name="pararms"></param>
  44. /// <returns></returns>
  45. [HttpPost]
  46. public ActionResult StandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms)
  47. {
  48. var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID");
  49. var standardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID");
  50. return this.Json(minorPlanApplyServices.StandardAndMinorSpecialtyCourseViewGrid(yearID, standardID,(int)pararms.page, (int)pararms.rows));
  51. }
  52. /// <summary>
  53. /// 获取申请过的辅修课程
  54. /// </summary>
  55. /// <param name="pararms"></param>
  56. /// <returns></returns>
  57. [HttpPost]
  58. public ActionResult existStandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms)
  59. {
  60. var GradeMinorApplicationID = Request["GradeMinorApplicationID"].ParseStrTo<Guid>();
  61. return this.Json(minorPlanApplyServices.existStandardAndMinorSpecialtyCourseViewGrid(GradeMinorApplicationID, (int)pararms.page, (int)pararms.rows));
  62. }
  63. /// <summary>
  64. /// 获取不存在辅修计划的课程
  65. /// </summary>
  66. /// <returns></returns>
  67. [HttpGet]
  68. public ActionResult MinorPlanApplyChoiceList()
  69. {
  70. MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView();
  71. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  72. var dataRange = StudentfileServices.Value.GetDataRange();
  73. ViewBag.DataRange = dataRange;
  74. minorPlanApplyView.CollegeID=curUser.CollegeID;
  75. minorPlanApplyView.HandleModeID = 1;
  76. minorPlanApplyView.IsNeedMaterial = true;
  77. return View(minorPlanApplyView);
  78. }
  79. /// <summary>
  80. /// 批量添加
  81. /// </summary>
  82. /// <param name="planApplicationView"></param>
  83. /// <returns></returns>
  84. [HttpPost]
  85. public ActionResult MinorPlanApplyChoiceList(MinorPlanApplyView minorPlanApplyView)
  86. {
  87. try
  88. {
  89. var minorSpecialCourseViewList = Request["MinorSpecialtyCourse"].JsonToObject<List<MinorPlanApplyView>>();
  90. if (minorSpecialCourseViewList.Count > 0)
  91. {
  92. minorPlanApplyServices.MinorPlanAdd(minorPlanApplyView, minorSpecialCourseViewList);
  93. //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList);
  94. }
  95. else
  96. {
  97. return Json(new ReturnMessage()
  98. {
  99. IsSuccess = false,
  100. Message = "保存失败,请选择要添加的专业课程。"
  101. });
  102. }
  103. return Json(new ReturnMessage()
  104. {
  105. IsSuccess = true,
  106. Message = "保存成功!"
  107. });
  108. }
  109. catch (Exception ex)
  110. {
  111. return Json(new ReturnMessage()
  112. {
  113. IsSuccess = false,
  114. Message = "保存失败:" + ex.Message
  115. });
  116. }
  117. }
  118. /// <summary>
  119. /// 修改辅修计划的课程
  120. /// </summary>
  121. /// <returns></returns>
  122. [HttpGet]
  123. public ActionResult Edit(Guid? GradeMinorApplicationIDs)
  124. {
  125. MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView();
  126. minorPlanApplyView=minorPlanApplyServices.GetMinorPlanApplyView(GradeMinorApplicationIDs);
  127. var dataRange = StudentfileServices.Value.GetDataRange();
  128. ViewBag.DataRange = dataRange;
  129. minorPlanApplyView.HandleModeID = 1;
  130. minorPlanApplyView.IsNeedMaterial = true;
  131. return View(minorPlanApplyView);
  132. }
  133. /// <summary>
  134. /// 修改辅修计划的课程
  135. /// </summary>
  136. /// <param name="planApplicationView"></param>
  137. /// <returns></returns>
  138. [HttpPost]
  139. public ActionResult Edit(MinorPlanApplyView minorPlanApplyView)
  140. {
  141. try
  142. {
  143. var minorSpecialCourseViewList = DataGrid.GetTableData<MinorPlanApplyView>("dgStandardAndMinorSpecialtyCourseViewList");
  144. if (minorSpecialCourseViewList.Count > 0)
  145. {
  146. minorPlanApplyServices.MinorPlanEdit(minorPlanApplyView, minorSpecialCourseViewList);
  147. //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList);
  148. }
  149. else
  150. {
  151. return Json(new ReturnMessage()
  152. {
  153. IsSuccess = false,
  154. Message = "保存失败,请选择要添加的专业课程。"
  155. });
  156. }
  157. return Json(new ReturnMessage()
  158. {
  159. IsSuccess = true,
  160. Message = "保存成功!"
  161. });
  162. }
  163. catch (Exception ex)
  164. {
  165. return Json(new ReturnMessage()
  166. {
  167. IsSuccess = false,
  168. Message = "保存失败:" + ex.Message
  169. });
  170. }
  171. }
  172. /// <summary>
  173. /// 修改辅修计划的课程
  174. /// </summary>
  175. /// <returns></returns>
  176. [HttpGet]
  177. public ActionResult CopyAdd(Guid? GradeMinorApplicationIDs)
  178. {
  179. MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView();
  180. minorPlanApplyView = minorPlanApplyServices.GetMinorPlanApplyView(GradeMinorApplicationIDs);
  181. var dataRange = StudentfileServices.Value.GetDataRange();
  182. ViewBag.DataRange = dataRange;
  183. return View(minorPlanApplyView);
  184. }
  185. /// <summary>
  186. /// 修改辅修计划的课程
  187. /// </summary>
  188. /// <param name="planApplicationView"></param>
  189. /// <returns></returns>
  190. [HttpPost]
  191. public ActionResult CopyAdd(MinorPlanApplyView minorPlanApplyView)
  192. {
  193. try
  194. {
  195. var minorSpecialCourseViewList = DataGrid.GetTableData<MinorPlanApplyView>("dgStandardAndMinorSpecialtyCourseViewList");
  196. if (minorSpecialCourseViewList.Count > 0)
  197. {
  198. minorPlanApplyView.GradeMinorApplicationID = null;
  199. minorPlanApplyServices.MinorPlanEdit(minorPlanApplyView, minorSpecialCourseViewList);
  200. //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList);
  201. }
  202. else
  203. {
  204. return Json(new ReturnMessage()
  205. {
  206. IsSuccess = false,
  207. Message = "保存失败,请选择要添加的专业课程。"
  208. });
  209. }
  210. return Json(new ReturnMessage()
  211. {
  212. IsSuccess = true,
  213. Message = "保存成功!"
  214. });
  215. }
  216. catch (Exception ex)
  217. {
  218. return Json(new ReturnMessage()
  219. {
  220. IsSuccess = false,
  221. Message = "保存失败:" + ex.Message
  222. });
  223. }
  224. }
  225. //年级复制
  226. public ActionResult CopyByGrade()
  227. {
  228. var dataRange = StudentfileServices.Value.GetDataRange();
  229. ViewBag.DataRange = dataRange;
  230. return View();
  231. }
  232. [HttpPost]
  233. public ActionResult CopyByGrade(MinorPlanApplyView minorPlanApplyView)
  234. {
  235. try
  236. {
  237. string Success = minorPlanApplyServices.SpecialtyPlanCopyByGrade(minorPlanApplyView);
  238. return Json(new ReturnMessage()
  239. {
  240. IsSuccess = true,
  241. Message = Success
  242. });
  243. }
  244. catch (Exception ex)
  245. {
  246. return Json(new ReturnMessage()
  247. {
  248. IsSuccess = false,
  249. Message = "复制失败:" + ex.Message
  250. });
  251. }
  252. }
  253. //年级复制
  254. public ActionResult AddCourse(int? YearID, int StandardID)
  255. {
  256. return View();
  257. }
  258. /// <summary>
  259. /// 删除
  260. /// </summary>
  261. /// <param name="MinorCourseIDs"></param>
  262. /// <returns></returns>
  263. [HttpPost]
  264. public ActionResult Delete(string GradeMinorApplicationIDs)
  265. {
  266. try
  267. {
  268. List<Guid?> list = new List<Guid?>();
  269. for (int i = 0; i < GradeMinorApplicationIDs.Split(',').Length; i++)
  270. {
  271. string id = GradeMinorApplicationIDs.Split(',')[i];
  272. if (!string.IsNullOrEmpty(id))
  273. {
  274. Guid GradeMinorApplicationID = new Guid(id);
  275. list.Add(GradeMinorApplicationID);
  276. }
  277. }
  278. minorPlanApplyServices.GradeMinorApplicationDelete(list);
  279. return base.Json("删除成功");
  280. }
  281. catch (Exception ex)
  282. {
  283. string mge = ex.Message;
  284. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  285. if (num != null)
  286. {
  287. if (num.Number == 547)
  288. mge = "请先删除所有关联的数据。";
  289. }
  290. return base.Json("删除失败,原因:" + mge);
  291. }
  292. }
  293. /// <summary>
  294. /// 提交申请
  295. /// </summary>
  296. /// <param name="GradeMinorApplicationIDs"></param>
  297. /// <returns></returns>
  298. [HttpPost]
  299. public ActionResult SubmitPlanApplication(string GradeMinorApplicationIDs, string statusNames)
  300. {
  301. try
  302. {
  303. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  304. List<Guid> list = new List<Guid>();
  305. for (int i = 0; i < GradeMinorApplicationIDs.Split(',').Length; i++)
  306. {
  307. if (!string.IsNullOrEmpty(GradeMinorApplicationIDs.Split(',')[i]))
  308. {
  309. Guid GradeMinorApplicationID = new Guid(GradeMinorApplicationIDs.Split(',')[i]);
  310. list.Add(GradeMinorApplicationID);
  311. }
  312. }
  313. List<string> status = new List<string>();
  314. for (int i = 0; i < statusNames.Split(',').Length; i++)
  315. {
  316. if (!string.IsNullOrEmpty(statusNames.Split(',')[i]))
  317. {
  318. string statusName = statusNames.Split(',')[i];
  319. status.Add(statusName);
  320. }
  321. }
  322. if (minorPlanApplyServices.GetStandardID_MinorPlanApplication_MinorSpecialtyPlanCount(list) > 0)
  323. {
  324. return Json("提交申请失败,请检查您提交的数据是否已存在专业计划不能重复提交申请!");
  325. }
  326. minorPlanApplyServices.SubmitPlanApplicationApply(list, user.UserID, status, "");
  327. return this.Json("成功");
  328. }
  329. catch (Exception ex)
  330. {
  331. return this.Json("提交申请失败,原因:" + ex.Message);
  332. }
  333. }
  334. /// <summary>
  335. /// 导出Excel
  336. /// </summary>
  337. /// <returns></returns>
  338. [HttpPost]
  339. public ActionResult Excel()
  340. {
  341. NpoiExcelHelper neh = new NpoiExcelHelper();
  342. var GradeMinorApplicationID = Request.Form["GradeMinorApplicationID"];
  343. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  344. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  345. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  346. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  347. var approvalStatus = Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo<int>();
  348. List<Guid?> GradeMinorApplicationIDList = new List<Guid?>();
  349. if (GradeMinorApplicationID != "")
  350. {
  351. GradeMinorApplicationIDList = GradeMinorApplicationID.SplitIDString();
  352. }
  353. else
  354. {
  355. GradeMinorApplicationIDList = null;
  356. }
  357. var dt = minorPlanApplyServices.GetMinorPlanApplyViewList(configuretView, yearID, standardID, collegeID, approvalStatus, GradeMinorApplicationIDList).Select(x => new
  358. {
  359. x.YearID,
  360. x.StandardCode,
  361. x.StandardName,
  362. x.CollegeName,
  363. x.StudentLimit,
  364. x.CreateTime,
  365. x.CreateUserName,
  366. x.ApprovalStatusName
  367. }).ToTable();
  368. string[] liststring = { "年级", "专业代码", "专业名称", RSL.Get("College"), "人数上限","申请时间",
  369. "申请人","状态"};
  370. neh.Export(dt, liststring, "辅修申请信息");
  371. return Json(new ReturnMessage()
  372. {
  373. IsSuccess = true,
  374. Message = "导出成功。"
  375. });
  376. }
  377. }
  378. }