FreeSelectionCourseApplyController.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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.SelectCourse;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Common.Data;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.Mapping;
  12. using EMIS.ViewModel.SelectCourse;
  13. using EMIS.Utility.FormValidate;
  14. using Bowin.Common.Exceptions;
  15. using Bowin.Common.Utility;
  16. using Bowin.Common.Linq.Entity;
  17. using Bowin.Common.JSON;
  18. using EMIS.Utility;
  19. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  20. namespace EMIS.Web.Controllers.SelectCourseManage
  21. {
  22. [Authorization]
  23. public class FreeSelectionCourseApplyController : Controller
  24. {
  25. public IFreeSelectionCourseServices FreeSelectionCourseServices { get; set; }
  26. public IFreeSelectionCourseApplyServices FreeSelectionCourseApplyServices { get; set; }
  27. public IExecutableFreeSelectionCouseServices ExecutableFreeSelectionCouseServices { get; set; }
  28. /// <summary>
  29. /// 开课申请页面
  30. /// </summary>
  31. /// <returns></returns>
  32. public ActionResult List()
  33. {
  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 campusID = pararms.getExtraGuid("CampusDropdown");
  46. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  47. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  48. var schoolyear = pararms.getExtraGuid("SchoolYearDropdown").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraGuid("SchoolYearDropdown");
  49. var schoolyearNum = pararms.getExtraInt("DictionarySchoolyearNum").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraInt("DictionarySchoolyearNum");
  50. var schoolcode = pararms.getExtraInt("DictionarySchoolcode").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraInt("DictionarySchoolcode");
  51. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  52. return this.Json(FreeSelectionCourseApplyServices.GetFreeSelectionCoursePlanViewGrid(configuretView,
  53. schoolyear, campusID, collegeID, departmentID, approvalStatus, (int)pararms.page, (int)pararms.rows));
  54. }
  55. [HttpPost]
  56. public ActionResult Save()
  57. {
  58. try
  59. {
  60. var freeSelectionCourseApplyList = DataGrid.GetTableData<FreeSelectionCourseApplyView>("dgFreeSelectionCourseApplyList");
  61. this.FreeSelectionCourseApplyServices.FreeSelectionCourseApplyUpdate(freeSelectionCourseApplyList);
  62. return RedirectToAction("MsgShow", "Common", new
  63. {
  64. msg = "保存成功!",
  65. url = Url.Content("~/FreeSelectionCourseApply/List").AddMenuParameter()
  66. });
  67. }
  68. catch (Exception ex)
  69. {
  70. return RedirectToAction("MsgShow", "Common", new
  71. {
  72. msg = "保存失败!" + ex.Message,
  73. url = Url.Content("~/FreeSelectionCourseApply/List").AddMenuParameter()
  74. });
  75. }
  76. }
  77. public ActionResult Edit(Guid? freeSelectionCourseApplyID)
  78. {
  79. FreeSelectionCourseApplyView freeSelectCourseApplyView = new FreeSelectionCourseApplyView();
  80. freeSelectCourseApplyView.HandleModeID = (int)EMIS.ViewModel.CF_HandleMode.SelectionCourse;
  81. freeSelectCourseApplyView.DepartmentID = CustomPrincipal.Current.DepartmentID;
  82. ViewBag.LoginID = CustomPrincipal.Current.LoginID;
  83. ViewBag.Name = CustomPrincipal.Current.Name;
  84. ViewBag.UserID = CustomPrincipal.Current.UserID;
  85. ViewBag.StaffCode = "";
  86. if (freeSelectionCourseApplyID.HasValue)
  87. freeSelectCourseApplyView = FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplyView(freeSelectionCourseApplyID);
  88. else
  89. {
  90. var staff = FreeSelectionCourseApplyServices.GetStaff(CustomPrincipal.Current.UserID);
  91. if (staff != null)
  92. {
  93. freeSelectCourseApplyView.DepartmentID = staff.DepartmentID;
  94. ViewBag.DepartmentID = staff.DepartmentID;
  95. ViewBag.StaffCode = staff.StaffCode;
  96. }
  97. freeSelectCourseApplyView.ResultTypeID = (int)CF_ResultType.Percentage;
  98. }
  99. return View(freeSelectCourseApplyView);
  100. }
  101. /// <summary>
  102. /// 编辑
  103. /// </summary>
  104. /// <param name="freeSelectionCourseApply"></param>
  105. /// <returns></returns>
  106. [HttpPost]
  107. public ActionResult Edit(FreeSelectionCourseApplyView freeSelectionCourseApply)
  108. {
  109. int? type = 0;
  110. try
  111. {
  112. var teacherList = DataGrid.GetTableData<FreeSelectionCourseApplyTeacherListView>("dgTeacherList");
  113. var specialtyList = DataGrid.GetTableData<FreeSelectionCourseApplySpecialtyListView>("dgSpecialtyList");
  114. var schedulingList = DataGrid.GetTableData<ExecutableFreeSelectionCouseSchedulingView>("dgSchedulingList");
  115. if (freeSelectionCourseApply.FreeSelectionCouseApplyID == null || freeSelectionCourseApply.FreeSelectionCouseApplyID == Guid.Empty)
  116. {
  117. FreeSelectionCourseApplyServices.FreeSelectionCourseApplyAdd(freeSelectionCourseApply, teacherList, specialtyList, schedulingList, out type);
  118. }
  119. else
  120. {
  121. FreeSelectionCourseApplyServices.FreeSelectionCourseApplyUpdate(freeSelectionCourseApply, teacherList, specialtyList, schedulingList, out type);
  122. }
  123. return Json(new ReturnMessage()
  124. {
  125. IsSuccess = true,
  126. Message = "保存成功!"
  127. });
  128. }
  129. catch (Exception ex)
  130. { //如果验证到排课冲突type返回1,页面js根据type弹出选择框,用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
  131. if (type == 1)
  132. {
  133. return Json(new ReturnMessage()
  134. {
  135. Type = 1,
  136. IsSuccess = false,
  137. Message = "保存失败:" + ex.Message,
  138. });
  139. }
  140. else
  141. return Json(new ReturnMessage()
  142. {
  143. IsSuccess = false,
  144. Type = 2,
  145. Message = "保存失败:" + ex.Message,
  146. });
  147. }
  148. }
  149. /// <summary>
  150. /// 明细
  151. /// </summary>
  152. /// <param name="freeSelectionCourseApplyID"></param>
  153. /// <returns></returns>
  154. public ActionResult Details(Guid? freeSelectionCourseApplyID)
  155. {
  156. FreeSelectionCourseApplyView freeSelectCourseApplyView = new FreeSelectionCourseApplyView();
  157. if (freeSelectionCourseApplyID.HasValue)
  158. freeSelectCourseApplyView = FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplyView(freeSelectionCourseApplyID);
  159. return View(freeSelectCourseApplyView);
  160. }
  161. public ActionResult TeacherEdit(Guid freeSelectionCourseApplyID)
  162. {
  163. return View();
  164. }
  165. /// <summary>
  166. /// 提交
  167. /// </summary>
  168. /// <param name="freeSelectionCourseApplyIDs"></param>
  169. /// <returns></returns>
  170. [HttpPost]
  171. public ActionResult SubmitFreeSelectionCourseApply(string freeSelectionCourseApplyIDs)
  172. {
  173. try
  174. {
  175. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  176. //for (int i = 0; i < freeSelectionCourseApplyIDs.Split(',').Length; i++)
  177. //{
  178. // if (!string.IsNullOrEmpty(freeSelectionCourseApplyIDs.Split(',')[i]))
  179. // {
  180. // Guid freeSelectionCourseApplyID = new Guid(freeSelectionCourseApplyIDs.Split(',')[i]);
  181. // FreeSelectionCourseApplyServices.StartUp(freeSelectionCourseApplyID, user.UserID);
  182. // }
  183. //}
  184. List<Guid> list = new List<Guid>();
  185. for (int i = 0; i < freeSelectionCourseApplyIDs.Split(',').Length; i++)
  186. {
  187. if (!string.IsNullOrEmpty(freeSelectionCourseApplyIDs.Split(',')[i]))
  188. {
  189. Guid planApplicationID = new Guid(freeSelectionCourseApplyIDs.Split(',')[i]);
  190. list.Add(planApplicationID);
  191. }
  192. }
  193. FreeSelectionCourseApplyServices.Submit(list, user.UserID, "");
  194. return this.Json("提交成功!");
  195. }
  196. catch (Exception ex)
  197. {
  198. return this.Json("提交失败,原因:" + ex.Message);
  199. }
  200. }
  201. /// <summary>
  202. /// 删除
  203. /// </summary>
  204. /// <param name="freeSelectionCourseApplyIDs"></param>
  205. /// <returns></returns>
  206. [HttpPost]
  207. public ActionResult Delete(string freeSelectionCourseApplyIDs)
  208. {
  209. try
  210. {
  211. List<Guid?> list = new List<Guid?>();
  212. for (int i = 0; i < freeSelectionCourseApplyIDs.Split(',').Length; i++)
  213. {
  214. string id = freeSelectionCourseApplyIDs.Split(',')[i];
  215. if (!string.IsNullOrEmpty(id))
  216. {
  217. Guid freeSelectionCourseApplyID = new Guid(id);
  218. list.Add(freeSelectionCourseApplyID);
  219. }
  220. }
  221. FreeSelectionCourseApplyServices.FreeSelectionCourseApplyDelete(list);
  222. return base.Json("删除成功!");
  223. }
  224. catch (Exception ex)
  225. {
  226. string mge = ex.Message;
  227. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  228. if (num != null)
  229. {
  230. if (num.Number == 547)
  231. mge = "请先删除所有关联的数据,如:专业计划、选修计划等!";
  232. }
  233. return base.Json("删除失败,原因:" + mge);
  234. }
  235. }
  236. /// <summary>
  237. /// 导出Excel
  238. /// </summary>
  239. /// <returns></returns>
  240. [HttpPost]
  241. public ActionResult Excel()
  242. {
  243. NpoiExcelHelper neh = new NpoiExcelHelper();
  244. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  245. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  246. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  247. var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo<Guid>();
  248. var schoolyear = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  249. //var schoolyearNum = Request.Form["DictionarySchoolyearNum"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["DictionarySchoolyearNum"];
  250. //var schoolcode = Request.Form["DictionarySchoolcode"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["DictionarySchoolcode"];
  251. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  252. var dt = FreeSelectionCourseApplyServices.GetFreeSelectionCoursePlanViewList(configuretView, schoolyear, campusID, collegeID, departmentID, approvalStatus).Select(x => new
  253. {
  254. //x.FreeSelectionCouseNo,
  255. x.SchoolyearCode,
  256. x.DepartmentName,
  257. //x.CollegeName,
  258. x.DefaultClassName,
  259. //x.CourseCode,
  260. //x.CourseName,
  261. //x.CourseCategoryName,
  262. //x.CourseTypeName,
  263. //x.CourseQualityName,
  264. //x.Credit,
  265. //x.Totalhours,
  266. //x.SchoolweeksNum,
  267. //x.SchoolyearNumName,
  268. //x.SchoolcodeName,
  269. //x.StarttermName,
  270. x.TeacherNames,
  271. x.PeopleNumlower,
  272. x.PeopleNumlimit,
  273. x.CourseTypeName,
  274. x.IsNeedMaterialName,
  275. x.ApprovalStatusName
  276. }).ToTable();
  277. string[] liststring = { //"选课编号",
  278. "学年学期", "教研室", //RSL.Get("College"),
  279. "选修任务班名称",
  280. //"课程代码",
  281. //"课程名称", "课程属性", "课程类型", "课程性质", "学分","总学时",
  282. //"上课周数", "学年数", "学期", "开课学期"
  283. "授课教师","人数下限","人数上限","选修类型","是否需要教材","审批状态"};
  284. neh.Export(dt, liststring, "计划申请信息");
  285. return RedirectToAction("MsgShow", "Common", new
  286. {
  287. msg = "导出成功!",
  288. url = Url.Content("~/FreeSelectionCourseApply/List").AddMenuParameter()
  289. });
  290. }
  291. public ActionResult GetFreeSelectionCourseView(Guid? freeSelectionCourseID)
  292. {
  293. FreeSelectionCourseView freeSelectionCourseView = new FreeSelectionCourseView();
  294. if (freeSelectionCourseID.HasValue)
  295. freeSelectionCourseView = FreeSelectionCourseServices.GetFreeSelectionCourseView(freeSelectionCourseID);
  296. return base.Json(freeSelectionCourseView);
  297. }
  298. /// <summary>
  299. /// 获取任选课程已经存在在授课方式
  300. /// </summary>
  301. /// <param name="freeSelectionCourseID"></param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. public ActionResult TeachingModeType(Guid? freeSelectionCourseID)
  305. {
  306. List<int> list = new List<int>();
  307. if (freeSelectionCourseID.HasValue && freeSelectionCourseID != Guid.Empty)
  308. list = FreeSelectionCourseServices.GetTeachingModeType(freeSelectionCourseID);
  309. else
  310. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory));
  311. return base.Json(list.ConvertAll(x => x.ToString()));
  312. }
  313. /// <summary>
  314. /// 获取任选课程申请已经存在在授课方式
  315. /// </summary>
  316. /// <param name="freeSelectionCourseID"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. public ActionResult CourseApplyTeachingModeType(Guid? freeSelectionCourseID)
  320. {
  321. List<int> list = new List<int>();
  322. if (freeSelectionCourseID.HasValue && freeSelectionCourseID != Guid.Empty)
  323. list = FreeSelectionCourseApplyServices.GetCourseApplyTeachingModeType(freeSelectionCourseID);
  324. else
  325. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory));
  326. return base.Json(list.ConvertAll(x => x.ToString()));
  327. }
  328. [HttpPost]
  329. public ActionResult GradeYear(Guid? freeSelectionCourseApplyID)
  330. {
  331. List<int> list = new List<int>();
  332. if (freeSelectionCourseApplyID.HasValue && freeSelectionCourseApplyID != Guid.Empty)
  333. list = FreeSelectionCourseApplyServices.GetCourseApplyGradeYear(freeSelectionCourseApplyID);
  334. return base.Json(list.ConvertAll(x => x.ToString()));
  335. }
  336. /// <summary>
  337. /// 列表查询
  338. /// </summary>
  339. /// <param name="pararms"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. public ActionResult SpecialtyList(Guid freeSelectionCourseApplyID)
  343. {
  344. var specialtyList = this.FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplySpecialtyListView(freeSelectionCourseApplyID);
  345. return base.Json(new GridResultSet<SpecialtyView>() { rows = specialtyList, total = specialtyList.Count });
  346. }
  347. /// <summary>
  348. /// 列表查询
  349. /// </summary>
  350. /// <param name="pararms"></param>
  351. /// <returns></returns>
  352. public ActionResult TeacherList(Guid freeSelectionCourseApplyID)
  353. {
  354. var teacherList = this.FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplyTeacherListView(freeSelectionCourseApplyID);
  355. return base.Json(new GridResultSet<FreeSelectionCourseApplyTeacherListView>() { rows = teacherList, total = teacherList.Count });
  356. }
  357. [HttpPost]
  358. public ActionResult TeacherEdit(Guid freeSelectionCourseApplyID, string addTeacherListJson)
  359. {
  360. try
  361. {
  362. var addTeacherList = addTeacherListJson.JsonToObject<List<FreeSelectionCourseApplyTeacherListView>>();
  363. FreeSelectionCourseServices.SaveFreeSelectionCourseTeachers(freeSelectionCourseApplyID, addTeacherList);
  364. return Json(new ReturnMessage { IsSuccess = true });
  365. }
  366. catch (Exception ex)
  367. {
  368. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  369. }
  370. }
  371. [HttpPost]
  372. public ActionResult DefaultClassNo(Guid SchoolyearID, Guid freeSelectionCourseID, string StartWeeklyNum, string EndWeeklyNum)
  373. {
  374. try
  375. {
  376. var result = FreeSelectionCourseApplyServices.DefaultClassNo(SchoolyearID, freeSelectionCourseID, StartWeeklyNum, EndWeeklyNum);
  377. return base.Json(result);
  378. }
  379. catch (Exception ex)
  380. {
  381. return Json("");
  382. }
  383. }
  384. public ActionResult GetSchedulingViewList(Guid FreeSelectionCouseApplyID)
  385. {
  386. var courseProcessList = FreeSelectionCourseApplyServices.GetSchedulingView(FreeSelectionCouseApplyID);
  387. return Json(new GridResultSet<ExecutableFreeSelectionCouseSchedulingView> { rows = courseProcessList, total = courseProcessList.Count });
  388. }
  389. public ActionResult CourseProcessClassroomList()
  390. {
  391. return View();
  392. }
  393. public ActionResult CoursesTimeList()
  394. {
  395. return View();
  396. }
  397. /// <summary>
  398. /// 列出课程进度中的可选教室
  399. /// </summary>
  400. /// <param name="pararms"></param>
  401. /// <returns></returns>
  402. [HttpPost]
  403. public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms)
  404. {
  405. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  406. int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo<int>();
  407. string schedulingWeek = pararms.getExtraString("schedulingWeek");
  408. int? weekday = pararms.getExtraString("weekDay").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("weekDay").ParseStrTo<int>();
  409. var coursesTimeID = pararms.getExtraGuid("coursesTimeID") ?? Guid.Empty;
  410. //int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo<int>();
  411. //var collegeID = pararms.getExtraGuid("CollegeDropdown") ?? Guid.Empty;
  412. var buildingsID = pararms.getExtraInt("BuildingsDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraGuid("BuildingsDropdown");
  413. return base.Json(ExecutableFreeSelectionCouseServices.GetAvailableClassroom(configuretView, buildingsID, schedulingWeek, weekday, coursesTimeID, classroomType, (int)pararms.page, (int)pararms.rows));
  414. }
  415. }
  416. }