MinorSpecialtyPlanController.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.MinorManage.MinorPlanManage;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.MinorManage.MinorPlanManage;
  11. using Bowin.Common.Exceptions;
  12. using Bowin.Common.Utility;
  13. using EMIS.Utility;
  14. using Bowin.Common.Data;
  15. using Bowin.Common.JSON;
  16. namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage
  17. {
  18. [Authorization]
  19. public class MinorSpecialtyPlanController : Controller
  20. {
  21. public IMinorSpecialtyPlanServices minorSpecialtyPlanServices { get; set; }
  22. //
  23. // GET: /MinorSpecialtyPlan/
  24. public ActionResult List()
  25. {
  26. return View();
  27. }
  28. [HttpPost]
  29. public ActionResult List(QueryParamsModel pararms)
  30. {
  31. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  32. var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
  33. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  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 coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  37. var Schoolyear = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  38. var schoolcodeID = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode");
  39. var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  40. return this.Json(minorSpecialtyPlanServices.GetMinorSpecialtyViewGrid(configuretView, schoolYearID, collegeID, yearID, standardID, coursematerialID, Schoolyear, schoolcodeID, (int)pararms.page, (int)pararms.rows));
  41. }
  42. public ActionResult Add()
  43. {
  44. return View();
  45. }
  46. /// <summary>
  47. /// 批量添加
  48. /// </summary>
  49. /// <param name="planApplicationView"></param>
  50. /// <returns></returns>
  51. [HttpPost]
  52. public ActionResult Add(MinorSpecialtyPlanView minorSpecialtyPlanView)
  53. {
  54. try
  55. {
  56. var minorSpecialCourseViewList = Request["MinorSpecialtyCourse"].JsonToObject<List<MinorSpecialtyPlanView>>();
  57. if (minorSpecialCourseViewList.Count > 0)
  58. {
  59. minorSpecialtyPlanServices.MinorPlanAdd(minorSpecialtyPlanView, minorSpecialCourseViewList);
  60. }
  61. else
  62. {
  63. return Json(new ReturnMessage()
  64. {
  65. IsSuccess = false,
  66. Message = "保存失败,请选择要添加的专业课程。"
  67. });
  68. }
  69. return Json(new ReturnMessage()
  70. {
  71. IsSuccess = true,
  72. Message = "保存成功!"
  73. });
  74. }
  75. catch (Exception ex)
  76. {
  77. return Json(new ReturnMessage()
  78. {
  79. IsSuccess = false,
  80. Message = "保存失败:" + ex.Message
  81. });
  82. }
  83. }
  84. [HttpPost]
  85. public ActionResult MinorSpecialtyPlanStandardIDList(QueryParamsModel pararms)
  86. {
  87. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  88. var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID");
  89. var list = minorSpecialtyPlanServices.GetStandardIDList(configuretView, yearID).Select(x => new
  90. {
  91. x.StandardID,
  92. x.SpecialtyCode,
  93. x.StandardName,
  94. x.StandardNameStr
  95. }).ToList();
  96. return Json(new { total = list.Count, rows = list });
  97. }
  98. /// <summary>
  99. /// 获取未申请过的辅修课程
  100. /// </summary>
  101. /// <param name="pararms"></param>
  102. /// <returns></returns>
  103. [HttpPost]
  104. public ActionResult StandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms)
  105. {
  106. var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID");
  107. var standardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID");
  108. return this.Json(minorSpecialtyPlanServices.StandardAndMinorSpecialtyCourseViewGrid(yearID, standardID, (int)pararms.page, (int)pararms.rows));
  109. }
  110. /// <summary>
  111. /// 编辑
  112. /// </summary>
  113. /// <param name="MinorCourseID"></param>
  114. /// <returns></returns>
  115. public ActionResult Edit(Guid? MinorPlanID)
  116. {
  117. MinorSpecialtyPlanView minorSpecialtyPlanView = new MinorSpecialtyPlanView();
  118. if (MinorPlanID.HasValue)
  119. {
  120. minorSpecialtyPlanView = minorSpecialtyPlanServices.GetMinorSpecialtyView(MinorPlanID);
  121. }
  122. else
  123. {
  124. minorSpecialtyPlanView.ResultTypeID = (int)CF_ResultType.Percentage;
  125. minorSpecialtyPlanView.Credit = 0;
  126. minorSpecialtyPlanView.TheoryCourse = 0;
  127. minorSpecialtyPlanView.Practicehours = 0;
  128. minorSpecialtyPlanView.Trialhours = 0;
  129. minorSpecialtyPlanView.Totalhours = 0;
  130. minorSpecialtyPlanView.TheoryWeeklyNum = 0;
  131. minorSpecialtyPlanView.PracticeWeeklyNum = 0;
  132. minorSpecialtyPlanView.TrialWeeklyNum = 0;
  133. minorSpecialtyPlanView.SchoolweeksNum = 0;
  134. minorSpecialtyPlanView.WeeklyHours = 0;
  135. minorSpecialtyPlanView.WeeklyNum = 0;
  136. minorSpecialtyPlanView.IsEnable = true;
  137. }
  138. return View(minorSpecialtyPlanView);
  139. }
  140. /// <summary>
  141. /// 编辑
  142. /// </summary>
  143. /// <param name="minorSpecialtyCourseView"></param>
  144. /// <returns></returns>
  145. [HttpPost]
  146. public ActionResult Edit(MinorSpecialtyPlanView minorSpecialtyPlanView)
  147. {
  148. try
  149. {
  150. minorSpecialtyPlanServices.MinorSpecialtyCourseEdit(minorSpecialtyPlanView);
  151. return Json(new ReturnMessage()
  152. {
  153. IsSuccess = true,
  154. Message = "保存成功。"
  155. });
  156. }
  157. catch (Exception ex)
  158. {
  159. return Json(new ReturnMessage()
  160. {
  161. IsSuccess = false,
  162. Message = "保存失败:" + ex.Message
  163. });
  164. }
  165. }
  166. /// <summary>
  167. /// 获取已经存在在授课方式
  168. /// </summary>
  169. /// <param name="MinorCourseID"></param>
  170. /// <returns></returns>
  171. [HttpPost]
  172. public ActionResult TeachingModeType(Guid? MinorPlanID)
  173. {
  174. List<string> list = new List<string>();
  175. if (MinorPlanID.HasValue && MinorPlanID != Guid.Empty)
  176. list = minorSpecialtyPlanServices.GetTeachingModeType(MinorPlanID);
  177. else
  178. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  179. return base.Json(list);
  180. }
  181. /// <summary>
  182. /// 获取已经存在在授课地点
  183. /// </summary>
  184. /// <param name="MinorCourseID"></param>
  185. /// <returns></returns>
  186. [HttpPost]
  187. public ActionResult TeachingPlace(Guid? MinorPlanID)
  188. {
  189. List<string> list = new List<string>();
  190. if (MinorPlanID.HasValue && MinorPlanID != Guid.Empty)
  191. list = minorSpecialtyPlanServices.GetTeachingPlace(MinorPlanID);
  192. return base.Json(list);
  193. }
  194. /// <summary>
  195. /// 删除
  196. /// </summary>
  197. /// <param name="MinorCourseIDs"></param>
  198. /// <returns></returns>
  199. [HttpPost]
  200. public ActionResult Delete(string MinorPlanIDs)
  201. {
  202. try
  203. {
  204. List<Guid?> list = new List<Guid?>();
  205. for (int i = 0; i < MinorPlanIDs.Split(',').Length; i++)
  206. {
  207. string id = MinorPlanIDs.Split(',')[i];
  208. if (!string.IsNullOrEmpty(id))
  209. {
  210. Guid MinorPlanID = new Guid(id);
  211. list.Add(MinorPlanID);
  212. }
  213. }
  214. minorSpecialtyPlanServices.MinorPlanDelete(list);
  215. return base.Json("删除成功");
  216. }
  217. catch (Exception ex)
  218. {
  219. string mge = ex.Message;
  220. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  221. if (num != null)
  222. {
  223. if (num.Number == 547)
  224. mge = "请先删除所有关联的数据,如:计划申请、专业计划、选修计划等!";
  225. }
  226. return base.Json("删除失败,原因:" + mge);
  227. }
  228. }
  229. /// <summary>
  230. /// 导出Excel
  231. /// </summary>
  232. /// <returns></returns>
  233. [HttpPost]
  234. public ActionResult Excel()
  235. {
  236. NpoiExcelHelper neh = new NpoiExcelHelper();
  237. var MinorPlanID = Request.Form["MinorPlanID"];
  238. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  239. var schoolYearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  240. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  241. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  242. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  243. var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
  244. var Schoolyear = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  245. var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo<int>();
  246. List<Guid?> MinorPlanIDList = new List<Guid?>();
  247. if (MinorPlanID != "")
  248. {
  249. MinorPlanIDList = MinorPlanID.SplitIDString();
  250. }
  251. else
  252. {
  253. MinorPlanIDList = null;
  254. }
  255. var dt = minorSpecialtyPlanServices.GetMinorSpecialtyViewList(configuretView, schoolYearID, collegeID, yearID, standardID, coursematerialID, Schoolyear, schoolcodeID, MinorPlanIDList).Select(x => new
  256. {
  257. x.SchoolcodeStr,
  258. x.YearID,
  259. x.SpecialtyCode,
  260. x.StandardName,
  261. x.CourseCode,
  262. x.CourseName,
  263. x.CourseTypeName,
  264. x.Credit,
  265. x.TheoryCourse,
  266. x.Practicehours,
  267. x.Trialhours,
  268. x.Totalhours,
  269. x.SchoolyearNumName,
  270. x.SchoolcodeName,
  271. x.DepartmentName,
  272. x.CollegeName
  273. }).ToTable();
  274. string[] liststring = { "学年学期", "年级", "专业代码", "专业名称", "课程代码","课程名称",
  275. "课程类型","学分","理论学时","实践学时","实验学时","总学时","开课学年","开课学期","开课教研室","开课"+RSL.Get("College")};
  276. neh.Export(dt, liststring, "辅修计划信息");
  277. return Json(new ReturnMessage()
  278. {
  279. IsSuccess = true,
  280. Message = "导出成功。"
  281. });
  282. }
  283. [HttpPost]
  284. public ActionResult GetListByMinorSpecialtyID(QueryParamsModel pararms)
  285. {
  286. var MinorSpecialtyID = Request["MinorSpecialtyID"].ParseStrTo<Guid>();
  287. return this.Json(minorSpecialtyPlanServices.GetMinorSpecialtyViewByMinorSpecialtyIDGrid(MinorSpecialtyID, (int)pararms.page, (int)pararms.rows));
  288. }
  289. }
  290. }