OptionalCourseSettingController.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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.CultureplanManage.PlanManagement;
  10. using EMIS.ViewModel.SelectCourse;
  11. using Bowin.Common.Linq.Entity;
  12. using Bowin.Common.JSON;
  13. using Bowin.Common.Utility;
  14. using Bowin.Common.Data;
  15. using EMIS.CommonLogic.SelectCourse;
  16. using Bowin.Common.Exceptions;
  17. using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
  18. namespace EMIS.Web.Controllers.SelectCourseManage
  19. {
  20. [Authorization]
  21. public class OptionalCourseSettingController : Controller
  22. {
  23. public IConditionServices ConditionServices { get; set; }
  24. public IClassmajorServices ClassmajorServices { get; set; }
  25. public IOptionalCourseSettingServices optionalCourseSettingServices { get; set; }
  26. /// <summary>
  27. /// 限选设定页面
  28. /// </summary>
  29. /// <returns></returns>
  30. public ActionResult List()
  31. {
  32. var conditionView = ConditionServices.GetSelectCourseConditionView();
  33. ViewBag.SelectSchoolYearID = conditionView.Schoolyear;
  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. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  46. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  47. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  48. //var schoolYearNumID = pararms.getExtraInt("DictionarySchoolYearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolYearNum");
  49. var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
  50. //var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode");
  51. //var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  52. var Years = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  53. var Status = pararms.getExtraInt("DictionaryStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStatus");
  54. var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
  55. return this.Json(optionalCourseSettingServices.GetOptionalCourseSettingViewGrid(configuretView, collegeID, standardID, coursematerialID, schoolYearID, Years, Status, isOpen, (int)pararms.page, (int)pararms.rows));
  56. }
  57. /// <summary>
  58. ///
  59. /// </summary>
  60. /// <param name="pararms"></param>
  61. /// <param name="GrademajorID"></param>
  62. /// <returns></returns>
  63. public ActionResult Class(QueryParamsModel pararms, Guid GrademajorID)
  64. {
  65. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  66. var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
  67. var campusID = pararms.getExtraGuid("CampusDropdown");
  68. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  69. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  70. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  71. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  72. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  73. var schoolyear = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  74. return base.Json(ClassmajorServices.GetClassmajorViewGrid(configuretView, campusID, collegeID, schoolyear, standardID, educationID, learningformID, null , GrademajorID, null, null, (int)pararms.page, (int)pararms.rows));
  75. }
  76. /// <summary>
  77. /// 获取任务班授课老师
  78. /// </summary>
  79. /// <param name="educationMissionClassID"></param>
  80. /// <returns></returns>
  81. [HttpPost]
  82. public ActionResult TeacherList(Guid executableOptionalCourseID)
  83. {
  84. var teacherList = optionalCourseSettingServices.GetEducationMissionClassTeacherListViewList(executableOptionalCourseID);
  85. return Json(new GridResultSet<OptionalCourseTeacherListView>() { rows = teacherList, total = teacherList.Count });
  86. }
  87. public ActionResult ClassList(Guid executableOptionalCourseID, string Type)
  88. {
  89. ViewBag.ID = executableOptionalCourseID;
  90. ViewBag.Type = Type;
  91. return View();
  92. }
  93. /// <summary>
  94. /// 获取可选课的班级
  95. /// </summary>
  96. /// <param name="educationMissionClassID"></param>
  97. /// <returns></returns>
  98. [HttpPost]
  99. public ActionResult ClassList(Guid executableOptionalCourseID)
  100. {
  101. var classList = optionalCourseSettingServices.GetClassmajorList(executableOptionalCourseID);
  102. return Json(new GridResultSet<OptionalCourseClassListView>() { rows = classList, total = classList.Count });
  103. }
  104. /// <summary>
  105. /// 限选任务生成弹出页面
  106. /// </summary>
  107. /// <returns></returns>
  108. public ActionResult Create()
  109. {
  110. var conditionView = ConditionServices.GetSelectCourseConditionView();
  111. ViewBag.SelectSchoolYearID = conditionView.Schoolyear;
  112. return View(new OptionalCourseSettingCreateView());
  113. }
  114. /// <summary>
  115. /// 限选任务生成
  116. /// </summary>
  117. /// <param name="optionalCourseSettingView"></param>
  118. /// <returns></returns>
  119. [HttpPost]
  120. public ActionResult Create(OptionalCourseSettingCreateView optionalCourseSettingView)
  121. {
  122. try
  123. {
  124. optionalCourseSettingServices.OptionalCourseSettingCreate(optionalCourseSettingView);
  125. return Json(new ReturnMessage()
  126. {
  127. IsSuccess = true,
  128. Message = "保存成功。"
  129. });
  130. }
  131. catch (SuccessException ex)
  132. {
  133. return Json(new ReturnMessage()
  134. {
  135. IsSuccess = true,
  136. Message = ex.Message
  137. });
  138. }
  139. catch (Exception ex)
  140. {
  141. return Json(new ReturnMessage()
  142. {
  143. IsSuccess = false,
  144. Message = "保存失败," + ex.Message
  145. });
  146. }
  147. }
  148. /// <summary>
  149. /// 编辑
  150. /// </summary>
  151. /// <returns></returns>
  152. public ActionResult Edit(Guid? ExecutableOptionalCourseIDs,string type)
  153. {
  154. OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView();
  155. if (ExecutableOptionalCourseIDs.HasValue && ExecutableOptionalCourseIDs != Guid.Empty)
  156. optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ExecutableOptionalCourseIDs);
  157. if (type == "add" && optionalCourseSettingView!=null)
  158. {
  159. optionalCourseSettingView.ExecutableOptionalCourseID = null;
  160. }
  161. ViewBag.RecordStatus = optionalCourseSettingView.RecordStatus;
  162. return View(optionalCourseSettingView);
  163. }
  164. /// <summary>
  165. /// 保存修改
  166. /// </summary>
  167. /// <param name="optionalCourseSettingView"></param>
  168. /// <returns></returns>
  169. [HttpPost]
  170. public ActionResult Edit(OptionalCourseSettingView optionalCourseSettingView)
  171. {
  172. try
  173. {
  174. var teacherList = DataGrid.GetTableData<OptionalCourseTeacherListView>("dgTeacherList");
  175. var classList = DataGrid.GetTableData<OptionalCourseClassListView>("dgClassList");
  176. optionalCourseSettingServices.OptionalCourseSettingUpdate(optionalCourseSettingView, teacherList, classList);
  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 = false,
  188. Message = "保存失败:" + ex.Message
  189. });
  190. }
  191. }
  192. /// <summary>
  193. /// 删除
  194. /// </summary>
  195. /// <param name="optionalCourseIDs"></param>
  196. /// <returns></returns>
  197. [HttpPost]
  198. public ActionResult Delete(string optionalCourseSettingIDs)
  199. {
  200. try
  201. {
  202. List<Guid> list = new List<Guid>();
  203. for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++)
  204. {
  205. if (!string.IsNullOrEmpty(optionalCourseSettingIDs.Split(',')[i]))
  206. {
  207. Guid optionalCourseSettingID = new Guid(optionalCourseSettingIDs.Split(',')[i]);
  208. list.Add(optionalCourseSettingID);
  209. }
  210. }
  211. optionalCourseSettingServices.OptionalCourseSettingDelete(list);
  212. return this.Json("删除成功!");
  213. }
  214. catch (Exception ex)
  215. {
  216. string mge = ex.Message;
  217. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  218. if (num != null)
  219. {
  220. if (num.Number == 547)
  221. mge = "请先删除所有关联的数据!";
  222. }
  223. return this.Json("删除失败,原因:" + mge);
  224. }
  225. }
  226. /// <summary>
  227. /// 开放
  228. /// </summary>
  229. /// <param name="optionalCourseSettingIDs"></param>
  230. /// <returns></returns>
  231. [HttpPost]
  232. public ActionResult Submit(string optionalCourseSettingIDs)
  233. {
  234. try
  235. {
  236. List<Guid> list = new List<Guid>();
  237. for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++)
  238. {
  239. if (!string.IsNullOrEmpty(optionalCourseSettingIDs.Split(',')[i]))
  240. {
  241. Guid optionalCourseSettingID = new Guid(optionalCourseSettingIDs.Split(',')[i]);
  242. list.Add(optionalCourseSettingID);
  243. }
  244. }
  245. optionalCourseSettingServices.OptionalCourseSettingSubmit(list);
  246. return this.Json("开放成功!");
  247. }
  248. catch (Exception ex)
  249. {
  250. string mge = ex.Message;
  251. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  252. return this.Json("开放失败,原因:" + mge);
  253. }
  254. }
  255. /// <summary>
  256. /// 取消
  257. /// </summary>
  258. /// <param name="optionalCourseSettingIDs"></param>
  259. /// <returns></returns>
  260. [HttpPost]
  261. public ActionResult Cancel(string optionalCourseSettingIDs)
  262. {
  263. try
  264. {
  265. List<Guid?> list = new List<Guid?>();
  266. for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++)
  267. {
  268. string id = optionalCourseSettingIDs.Split(',')[i];
  269. if (!string.IsNullOrEmpty(id))
  270. {
  271. Guid optionalCourseSettingID = new Guid(id);
  272. list.Add(optionalCourseSettingID);
  273. }
  274. }
  275. optionalCourseSettingServices.OptionalCourseSettingCancel(list);
  276. return base.Json("取消成功!");
  277. }
  278. catch (Exception ex)
  279. {
  280. string mge = ex.Message;
  281. return base.Json("取消失败,原因:" + mge);
  282. }
  283. }
  284. /// <summary>
  285. ///
  286. /// </summary>
  287. /// <returns></returns>
  288. [HttpPost]
  289. public ActionResult Excel()
  290. {
  291. //return View();
  292. NpoiExcelHelper neh = new NpoiExcelHelper();
  293. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  294. //避开全选值
  295. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  296. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  297. var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
  298. var collegeID = Request.Form["ComboGridCollege"].ParseStrTo<Guid>();
  299. //var schoolYearNumID = Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>();
  300. //var schoolCodeID = Request.Form["DictionarySchoolCode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolCode"].ParseStrTo<int>();
  301. //var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
  302. var schoolYearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
  303. //var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode");
  304. //var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  305. var Years = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  306. var Status = Request.Form["DictionaryStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo<int>();
  307. var isOpened = Request.Form["DictionaryIsOpen"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
  308. var dt = optionalCourseSettingServices.GetOptionalCourseSettingViewList(configuretView, collegeID, standardID, coursematerialID, schoolYearID, Years, Status, isOpened)
  309. .Select(x => new
  310. {
  311. x.SchoolYearCode,
  312. //x.GrademajorCode,
  313. x.GrademajorName,
  314. x.DefaultClassName,
  315. //x.CourseCode,
  316. x.CourseName,
  317. //x.CourseTypeName,
  318. //x.CourseCategoryName,
  319. //x.CourseQualityName,
  320. x.SchoolcodeName,
  321. x.SchoolyearNumName,
  322. x.Credit,
  323. x.Totalhours,
  324. //x.DepartmentName,
  325. //x.CollegeName,
  326. //x.IsEnableDesc,
  327. x.IsOpenedDesc,
  328. x.RecordStatusName,
  329. }).ToTable();
  330. string[] liststring = { "学年学期",
  331. //"年级专业代码",
  332. "年级专业名称", "班级名称",
  333. //"课程代码",
  334. "课程名称",
  335. //"课程类型", "课程属性", "课程性质",
  336. "学期", "开课学年",
  337. "学分","总学时",
  338. //"教研室", RSL.Get("College"),
  339. //"是否启用",
  340. "是否开放","状态"};
  341. neh.Export(dt, liststring, "限选设定");
  342. return RedirectToAction("MsgShow", "Common", new
  343. {
  344. msg = "导出成功!",
  345. url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter()
  346. });
  347. }
  348. [HttpPost]
  349. public ActionResult TeachingModeType(Guid? ExecutableOptionalCourseID)
  350. {
  351. List<string> list = new List<string>();
  352. if (ExecutableOptionalCourseID.HasValue && ExecutableOptionalCourseID != Guid.Empty)
  353. list = optionalCourseSettingServices.GetTeachingModeType(ExecutableOptionalCourseID);
  354. else
  355. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  356. return base.Json(list);
  357. }
  358. [HttpPost]
  359. public ActionResult Save()
  360. {
  361. return View();
  362. //try
  363. //{
  364. // var optionalCourseSettingList = DataGrid.GetTableData<OptionalCourseSettingView>("dgOptionalCourseSettingList");
  365. // this.OptionalCoursePlanServices.SaveOptionalCourseSettings(optionalCourseSettingList);
  366. // return RedirectToAction("MsgShow", "Common", new
  367. // {
  368. // msg = "保存成功!",
  369. // url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter()
  370. // });
  371. //}
  372. //catch (Exception ex)
  373. //{
  374. // return RedirectToAction("MsgShow", "Common", new
  375. // {
  376. // msg = "保存失败!" + ex.Message,
  377. // url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter()
  378. // });
  379. //}
  380. }
  381. /// <summary>
  382. /// 编辑页新增班级
  383. /// </summary>
  384. /// <param name="pararms"></param>
  385. /// <returns></returns>
  386. [HttpPost]
  387. public ActionResult ChooseClassList(QueryParamsModel pararms)
  388. {
  389. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  390. var GrademajorID = Request.Params["GrademajorID"].ParseStrTo<Guid>();
  391. //var campusID = pararms.getExtraGuid("CampusDropdown");
  392. //var collegeID = pararms.getExtraGuid("CollegeDropdown");
  393. //var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  394. //var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  395. //var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  396. //var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  397. //var schoolyear = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  398. return base.Json(ClassmajorServices.GetClassmajorViewGrid(configuretView, null, null, null, null, null, null, null, GrademajorID, null, null, (int)pararms.page, (int)pararms.rows));
  399. }
  400. }
  401. }