AdultEducationMissionClassController.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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.CommonLogic.EducationManagement;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.EducationManage;
  11. using Bowin.Common.Linq.Entity;
  12. using Bowin.Common.Utility;
  13. using EMIS.ViewModel.EducationManagement;
  14. using Bowin.Common.Data;
  15. using EMIS.CommonLogic.CalendarManage;
  16. using Bowin.Common.Exceptions;
  17. using Bowin.Common.JSON;
  18. using EMIS.ViewModel.UniversityManage.TeacherManage;
  19. using EMIS.CommonLogic.EducationManage;
  20. namespace EMIS.Web.Controllers.EducationManage
  21. {
  22. [Authorization]
  23. public class AdultEducationMissionClassController : Controller
  24. {
  25. public IAdultEducationMissionClassServices AdulteducationMissionClassServices { get; set; }
  26. public Lazy<IAdultEducationMissionClassServices> staffServices { get; set; }
  27. public EMIS.CommonLogic.EducationManagement.IEducationMissionClassServices EducationMissionClassServices { get;set; }
  28. public ISchoolYearServices schoolYearServices { get; set; }
  29. /// <summary>
  30. /// 教学任务页面(成教)
  31. /// </summary>
  32. /// <returns></returns>
  33. public ActionResult List()
  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 schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  49. var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
  50. var campusID = pararms.getExtraGuid("CampusDropdown");
  51. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  52. var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid");
  53. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  54. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  55. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  56. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  57. var gradeYearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  58. var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList");
  59. var teachingMode = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode");
  60. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  61. var result = AdulteducationMissionClassServices.GetEducationMissionClassViewGrid(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, CoursesTimeID,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows);
  62. return Json(result);
  63. }
  64. /// <summary>
  65. /// 教学安排
  66. /// </summary>
  67. /// <param name="educationMissionClassView"></param>
  68. /// <returns></returns>
  69. public ActionResult Edit(Guid? educationMissionClassID)
  70. {
  71. EducationMissionImportClassView educationMissionClassView = new EducationMissionImportClassView();
  72. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  73. {
  74. educationMissionClassView = AdulteducationMissionClassServices.GetEducationMissionClassView(educationMissionClassID);
  75. if (educationMissionClassView != null)
  76. {
  77. var schoolYear = schoolYearServices.GetSchoolYear(educationMissionClassView.SchoolyearID);
  78. List<ListControlItem> lct = new List<ListControlItem>();
  79. if (schoolYear != null)
  80. {
  81. for (int i = 1; i <= schoolYear.WeeksNum; i++)
  82. {
  83. ListControlItem lt = new ListControlItem { Text = "第" + i + "周", Value = i, IsSelected = true };
  84. lct.Add(lt);
  85. }
  86. }
  87. ViewData["lct"] = lct;
  88. }
  89. }
  90. return View(educationMissionClassView);
  91. }
  92. /// <summary>
  93. /// 修改
  94. /// </summary>
  95. /// <param name="educationMissionClassView"></param>
  96. /// <returns></returns>
  97. [HttpPost]
  98. public ActionResult Edit(EducationMissionClassView educationMissionClassView)
  99. {
  100. try
  101. {
  102. List<int?> list = new List<int?>();
  103. var listWeekNum = Request.Form["WeekNum"];
  104. if (listWeekNum != null)
  105. {
  106. for (int i = 0; i < listWeekNum.Split(',').Length; i++)
  107. {
  108. if (!string.IsNullOrEmpty(listWeekNum.Split(',')[i]))
  109. {
  110. int teachingModeID = Convert.ToInt32(listWeekNum.Split(',')[i]);
  111. list.Add(teachingModeID);
  112. }
  113. }
  114. }
  115. var teacherList = DataGrid.GetTableData<EducationMissionClassTeacherListView>("dgTeacherList");
  116. EducationMissionClassServices.EducationMissionClassUpdate(educationMissionClassView, list, teacherList);
  117. return Json(new ReturnMessage()
  118. {
  119. IsSuccess = true,
  120. Message = "保存成功!"
  121. });
  122. }
  123. catch (Exception ex)
  124. {
  125. return Json(new ReturnMessage()
  126. {
  127. IsSuccess = false,
  128. Message = "保存失败,原因:" + ex.Message
  129. });
  130. }
  131. }
  132. /// <summary>
  133. /// 提交
  134. /// </summary>
  135. /// <param name="educationMissionClassIDs"></param>
  136. /// <returns></returns>
  137. [HttpPost]
  138. public ActionResult EducationMissionClassUpdate(string educationMissionClassIDs)
  139. {
  140. try
  141. {
  142. List<Guid?> list = new List<Guid?>();
  143. var educationMissionClassArray = educationMissionClassIDs.Split(',');
  144. for (int i = 0; i < educationMissionClassArray.Length; i++)
  145. {
  146. if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
  147. {
  148. Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
  149. list.Add(educationMissionClassID);
  150. }
  151. }
  152. AdulteducationMissionClassServices.EducationMissionClassUpdate(list);
  153. return Json("成功");
  154. }
  155. catch (Exception ex)
  156. {
  157. return Json("提交失败,原因:" + ex.Message);
  158. }
  159. }
  160. /// <summary>
  161. /// 撤销提交
  162. /// </summary>
  163. /// <param name="educationMissionClassIDs"></param>
  164. /// <returns></returns>
  165. [HttpPost]
  166. public ActionResult UnSubmit(string educationMissionClassIDs)
  167. {
  168. try
  169. {
  170. List<Guid?> list = new List<Guid?>();
  171. var educationMissionClassArray = educationMissionClassIDs.Split(',');
  172. for (int i = 0; i < educationMissionClassArray.Length; i++)
  173. {
  174. if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
  175. {
  176. Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
  177. list.Add(educationMissionClassID);
  178. }
  179. }
  180. EducationMissionClassServices.UnSubmit(list);
  181. return Json("撤销成功。");
  182. }
  183. catch (Exception ex)
  184. {
  185. return Json("撤销失败,原因:" + ex.Message);
  186. }
  187. }
  188. [HttpPost]
  189. public ActionResult Delete(string educationMissionClassIDs)
  190. {
  191. try
  192. {
  193. List<Guid?> list = new List<Guid?>();
  194. var educationMissionClassArray = educationMissionClassIDs.Split(',');
  195. for (int i = 0; i < educationMissionClassArray.Length; i++)
  196. {
  197. if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
  198. {
  199. Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
  200. list.Add(educationMissionClassID);
  201. }
  202. }
  203. EducationMissionClassServices.Delete(list);
  204. return Json(new ReturnMessage { IsSuccess = true });
  205. }
  206. catch (Exception ex)
  207. {
  208. string mge = ex.Message;
  209. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  210. if (num != null)
  211. {
  212. if (num.Number == 547)
  213. mge = "请先删除所有关联的数据,排课课表,学生成绩,教学评价等";
  214. }
  215. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + mge });
  216. }
  217. }
  218. /// <summary>
  219. /// 导出Excel
  220. /// </summary>
  221. /// <param name="pararms"></param>
  222. /// <returns></returns>
  223. [HttpPost]
  224. public ActionResult Excel()
  225. {
  226. NpoiExcelHelper neh = new NpoiExcelHelper();
  227. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  228. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  229. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  230. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  231. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  232. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  233. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  234. var gradeYearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  235. var approvalStatus = Request.Form["ApprovalStatusDropdownList"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ApprovalStatusDropdownList"].ParseStrTo<int>();
  236. var teachingMode = Request.Form["DictionaryTeachingMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo<int>();
  237. var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  238. var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  239. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  240. var dt = AdulteducationMissionClassServices.GetEducationMissionClassViewList(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, learningformID, education, LearnSystem)
  241. .Select(x => new
  242. {
  243. x.OrderNo,
  244. x.Name,
  245. // x.SchoolyearCode,
  246. x.CourseCode,
  247. x.CourseName,
  248. x.DepartmentName,
  249. // x.CollegeName,
  250. x.ClassroomTypeName,
  251. x.StartStopWeeklyNum,
  252. x.Totalhours,
  253. x.CourseProcessTimes,
  254. // x.SchedulingClassNum,
  255. x.ClassNum,
  256. x.TeacherName,
  257. x.ApprovalStatusName
  258. }).ToTable();
  259. string[] liststring = { "排课序号", "任务班名称","课程代码", "课程名称", "教研室", "教室类型",
  260. "执行周次", "总学时", "执行学时", "班级人数","授课老师", "状态" };
  261. neh.Export(dt, liststring, "教学任务班基础信息");
  262. return Json(new ReturnMessage()
  263. {
  264. IsSuccess = true,
  265. Message = "导出成功!"
  266. });
  267. }
  268. /// <summary>
  269. /// 批量修改课时类别
  270. /// </summary>
  271. public ActionResult BatchUpdate(string educationMissionClassStr)
  272. {
  273. EducationMissionClassView educationMissionClassView = new EducationMissionClassView();
  274. if (!educationMissionClassStr.IsEmpty())
  275. {
  276. educationMissionClassView.EducationMissionClassStr = educationMissionClassStr;
  277. }
  278. return View(educationMissionClassView);
  279. }
  280. /// <summary>
  281. /// 批量修改课时类别
  282. /// </summary>
  283. [HttpPost]
  284. public ActionResult BatchUpdate(EducationMissionClassView educationMissionClassView)
  285. {
  286. try
  287. {
  288. List<Guid?> educationMissionClassid = educationMissionClassView.EducationMissionClassStr.SplitIDString();
  289. AdulteducationMissionClassServices.BatchModifyCoursesTime(educationMissionClassid, educationMissionClassView.CourseTimeID, educationMissionClassView.ClassroomTypeID);
  290. return Json(new ReturnMessage()
  291. {
  292. IsSuccess = true,
  293. Message = "修改成功!"
  294. });
  295. }
  296. catch (Exception ex)
  297. {
  298. return Json(new ReturnMessage()
  299. {
  300. IsSuccess = false,
  301. Message = "修改失败,原因:" + ex.Message
  302. });
  303. }
  304. }
  305. }
  306. }