EducationMissionClassController.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Web.Controls.Mvc;
  7. using Bowin.Common.Linq.Entity;
  8. using Bowin.Common.Utility;
  9. using Bowin.Common.Data;
  10. using Bowin.Common.Exceptions;
  11. using Bowin.Common.JSON;
  12. using EMIS.Web.Controls;
  13. using EMIS.ViewModel;
  14. using EMIS.ViewModel.EducationManage;
  15. using EMIS.ViewModel.EducationManagement;
  16. using EMIS.ViewModel.UniversityManage.TeacherManage;
  17. using EMIS.CommonLogic.EducationManagement;
  18. using EMIS.CommonLogic.CalendarManage;
  19. using EMIS.CommonLogic.SystemServices;
  20. using EMIS.Utility;
  21. using System.IO;
  22. namespace EMIS.Web.Controllers.TeachingManagement
  23. {
  24. [Authorization]
  25. public class EducationMissionClassController : Controller
  26. {
  27. public IEducationMissionClassServices educationMissionClassServices { get; set; }
  28. public Lazy<IEducationMissionClassServices> staffServices { get; set; }
  29. public ISchoolYearServices schoolYearServices { get; set; }
  30. public IParameterServices parameterServices { get; set; }
  31. /// <summary>
  32. /// 教学任务页面(普教)
  33. /// </summary>
  34. /// <returns></returns>
  35. public ActionResult List()
  36. {
  37. var schoolYear = schoolYearServices.GetSchoolYearIsCurrent(true);
  38. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  39. return View();
  40. }
  41. /// <summary>
  42. /// 查询教学任务班列表
  43. /// </summary>
  44. /// <param name="pararms"></param>
  45. /// <returns></returns>
  46. [HttpPost]
  47. public ActionResult List(QueryParamsModel pararms)
  48. {
  49. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  50. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  51. var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
  52. var campusID = pararms.getExtraGuid("CampusDropdown");
  53. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  54. var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid");
  55. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  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 result = educationMissionClassServices.GetEducationMissionClassViewGrid(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, CoursesTimeID, (int)pararms.page, (int)pararms.rows);
  61. return Json(result);
  62. }
  63. /// <summary>
  64. /// 教学安排
  65. /// </summary>
  66. /// <param name="educationMissionClassView"></param>
  67. /// <returns></returns>
  68. public ActionResult Edit(Guid? educationMissionClassID)
  69. {
  70. EducationMissionClassView educationMissionClassView = new EducationMissionClassView();
  71. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  72. {
  73. educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID);
  74. if (educationMissionClassView != null)
  75. {
  76. var schoolYear = schoolYearServices.GetSchoolYear(educationMissionClassView.SchoolyearID);
  77. List<ListControlItem> lct = new List<ListControlItem>();
  78. if (schoolYear != null)
  79. {
  80. for (int i = 1; i <= schoolYear.WeeksNum; i++)
  81. {
  82. ListControlItem lt = new ListControlItem { Text = "第" + i + "周", Value = i, IsSelected = true };
  83. lct.Add(lt);
  84. }
  85. }
  86. ViewData["lct"] = lct;
  87. }
  88. }
  89. return View(educationMissionClassView);
  90. }
  91. /// <summary>
  92. /// 教学安排
  93. /// </summary>
  94. /// <param name="educationMissionClassView"></param>
  95. /// <returns></returns>
  96. [HttpPost]
  97. public ActionResult Edit(EducationMissionClassView educationMissionClassView)
  98. {
  99. try
  100. {
  101. List<int?> list = new List<int?>();
  102. var listWeekNum = Request.Form["WeekNum"];
  103. if (listWeekNum != null)
  104. {
  105. for (int i = 0; i < listWeekNum.Split(',').Length; i++)
  106. {
  107. if (!string.IsNullOrEmpty(listWeekNum.Split(',')[i]))
  108. {
  109. int teachingModeID = Convert.ToInt32(listWeekNum.Split(',')[i]);
  110. list.Add(teachingModeID);
  111. }
  112. }
  113. }
  114. var teacherList = DataGrid.GetTableData<EducationMissionClassTeacherListView>("dgTeacherList");
  115. educationMissionClassServices.EducationMissionClassUpdate(educationMissionClassView, list, teacherList);
  116. return Json(new ReturnMessage()
  117. {
  118. IsSuccess = true,
  119. Message = "保存成功!"
  120. });
  121. }
  122. catch (Exception ex)
  123. {
  124. return Json(new ReturnMessage()
  125. {
  126. IsSuccess = false,
  127. Message = "保存失败,原因:" + ex.Message
  128. });
  129. }
  130. }
  131. /// <summary>
  132. /// 合班
  133. /// </summary>
  134. /// <returns></returns>
  135. public ActionResult EducationMissionClassConjunctionList()
  136. {
  137. return View();
  138. }
  139. /// <summary>
  140. /// 合班
  141. /// </summary>
  142. /// <param name="pararms"></param>
  143. /// <returns></returns>
  144. [HttpPost]
  145. public ActionResult EducationMissionClassConjunctionList(QueryParamsModel pararms)
  146. {
  147. var educationMissionClassIDs = pararms.getExtraString("hidEducationMissionClassIDs");
  148. var educationMissionClassIDList = educationMissionClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  149. var educationMissionClassList = educationMissionClassServices.GetEducationMissionClassViewList(educationMissionClassIDList);
  150. return Json(new GridResultSet<EducationMissionClassView> { rows = educationMissionClassList, total = educationMissionClassList.Count });
  151. }
  152. /// <summary>
  153. /// 排课分班
  154. /// </summary>
  155. /// <param name="educationMissionClassID"></param>
  156. /// <returns></returns>
  157. public ActionResult DivideIntoClassesEdit(Guid? educationMissionClassID)
  158. {
  159. DivideIntoClassesView divideIntoClassesView = new DivideIntoClassesView();
  160. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  161. divideIntoClassesView = educationMissionClassServices.GetDivideIntoClassesView(educationMissionClassID);
  162. divideIntoClassesView.OrderType = false;
  163. divideIntoClassesView.IsNotBuildEducationMission = true;
  164. return View(divideIntoClassesView);
  165. }
  166. /// <summary>
  167. /// 排课分班
  168. /// </summary>
  169. /// <param name="divideIntoClassesView"></param>
  170. /// <returns></returns>
  171. [HttpPost]
  172. public ActionResult DivideIntoClassesEdit(DivideIntoClassesView divideIntoClassesView)
  173. {
  174. try
  175. {
  176. divideIntoClassesView.GroupNum = Convert.ToInt32(Request.Form["hid_GroupNum"]);
  177. divideIntoClassesView.StudentNum = Convert.ToInt32(Request.Form["hid_StudentNum"]);
  178. educationMissionClassServices.DivideIntoClassesAdd(divideIntoClassesView);
  179. return Json(new ReturnMessage()
  180. {
  181. IsSuccess = true,
  182. Message = "保存成功!"
  183. });
  184. }
  185. catch (Exception ex)
  186. {
  187. return Json(new ReturnMessage()
  188. {
  189. IsSuccess = false,
  190. Message = "保存失败,原因:" + ex.Message + "!"
  191. });
  192. }
  193. }
  194. /// <summary>
  195. /// 更新排课序号
  196. /// </summary>
  197. /// <param name="educationMissionClassIDs"></param>
  198. /// <param name="orderNos"></param>
  199. /// <returns></returns>
  200. [HttpPost]
  201. public ActionResult TeachingScheduleEdit(string educationMissionClassIDs, string orderNos)
  202. {
  203. try
  204. {
  205. List<Guid?> listID = new List<Guid?>();
  206. List<int?> listNo = new List<int?>();
  207. for (int i = 0; i < educationMissionClassIDs.Split(',').Length; i++)
  208. {
  209. if (!string.IsNullOrEmpty(educationMissionClassIDs.Split(',')[i]))
  210. {
  211. Guid educationMissionClassID = new Guid(educationMissionClassIDs.Split(',')[i]);
  212. int orderNo = Convert.ToInt32(orderNos.Split(',')[i]);
  213. listID.Add(educationMissionClassID);
  214. listNo.Add(orderNo);
  215. }
  216. }
  217. educationMissionClassServices.UpdateEducationMissionClassOrderNo(listID, listNo);
  218. return Json("成功");
  219. }
  220. catch (Exception ex)
  221. {
  222. return Json("失败,原因:" + ex.Message);
  223. }
  224. }
  225. public ActionResult CourseProcessSummary()
  226. {
  227. var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
  228. var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Value).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
  229. var ClassScheduleWeekTimeCount = parameterServices.GetParameterValue<int>(ViewModel.CF_ParameterType.ClassScheduleWeekTimeCount);
  230. ViewBag.SchoolYearID = schoolyear.SchoolYearID;
  231. ViewBag.ClassScheduleWeekTimeCount = ClassScheduleWeekTimeCount;
  232. return View();
  233. }
  234. [HttpPost]
  235. public ActionResult GetEducationMissionClassStatus()
  236. {
  237. //List<string> list = new List<string>();
  238. //list = educationMissionClassServices.GetEducationMissionClassStatus().Select(x => x.ToString()).ToList();
  239. var list = educationMissionClassServices.GetEducationMissionClassStatus();
  240. return base.Json(list);
  241. }
  242. public ActionResult CourseProcessClassroomList()
  243. {
  244. return View();
  245. }
  246. [HttpGet]
  247. public ActionResult EductionMissionClassStudentAdd()
  248. {
  249. return View();
  250. }
  251. [HttpPost]
  252. public ActionResult EductionMissionClassStudentDelete(Guid? educationMissionClassID, string userIDs)
  253. {
  254. try
  255. {
  256. List<Guid> list = new List<Guid>();
  257. for (int i = 0; i < userIDs.Split(',').Length; i++)
  258. {
  259. if (!string.IsNullOrEmpty(userIDs.Split(',')[i]))
  260. {
  261. Guid userID = new Guid(userIDs.Split(',')[i]);
  262. list.Add(userID);
  263. }
  264. }
  265. educationMissionClassServices.DeleteStudentbyEducationMissionClassID(educationMissionClassID, list);
  266. return Json("成功");
  267. }
  268. catch (Exception ex)
  269. {
  270. return Json("删除学生失败,原因:" + ex.Message);
  271. }
  272. }
  273. /// <summary>
  274. /// 添加学生
  275. /// </summary>
  276. /// <param name="finalExaminationID"></param>
  277. /// <param name="userIDs"></param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. public ActionResult EductionMissionClassStudentAdd(Guid? educationMissionClassID, string userIDs)
  281. {
  282. try
  283. {
  284. List<Guid> list = new List<Guid>();
  285. for (int i = 0; i < userIDs.Split(',').Length; i++)
  286. {
  287. if (!string.IsNullOrEmpty(userIDs.Split(',')[i]))
  288. {
  289. Guid userID = new Guid(userIDs.Split(',')[i]);
  290. list.Add(userID);
  291. }
  292. }
  293. educationMissionClassServices.AddStudentbyEducationMissionClassID(educationMissionClassID, list);
  294. return Json("成功");
  295. }
  296. catch (Exception ex)
  297. {
  298. return Json("增加学生失败,原因:" + ex.Message);
  299. }
  300. }
  301. [HttpGet]
  302. public ActionResult TeacherSelect()
  303. {
  304. return View();
  305. }
  306. /// <summary>
  307. /// 教师列表查询
  308. /// </summary>
  309. /// <param name="pararms"></param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. public ActionResult ALLTeacherList(QueryParamsModel pararms)
  313. {
  314. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  315. var userID = pararms.getExtraGuid("SaffDropdown");
  316. var campusID = pararms.getExtraGuid("CampusDropdown");
  317. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  318. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  319. var isphotoUrl = pararms.getExtraInt("PhotoUrltmentDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PhotoUrltmentDropdown");
  320. return base.Json(staffServices.Value.GetStaffViewGrid(configuretView, campusID, collegeID, departmentID, isphotoUrl, userID, (int)pararms.page, (int)pararms.rows));
  321. }
  322. //设置教师
  323. public ActionResult SetTeacher(Guid? educationMissionClassID)
  324. {
  325. EducationMissionClassView educationMissionClassView = new EducationMissionClassView();
  326. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  327. {
  328. educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID);
  329. }
  330. return View(educationMissionClassView);
  331. }
  332. [HttpPost]
  333. public ActionResult SetTeacher(EducationMissionClassView educationMissionClassView)
  334. {
  335. try
  336. {
  337. string teacherJson = Request.Form["hid_TeacherJsonStr"];
  338. var teacherList = DataGrid.GetTableData<EducationMissionClassTeacherListView>("dgTeacherList");
  339. // List<StaffView> teacherList = teacherJson.JsonToObject<List<StaffView>>();//Json数据转换
  340. educationMissionClassServices.EducationMissionClassUpdateTeacher(educationMissionClassView, teacherList);
  341. return Json(new ReturnMessage()
  342. {
  343. IsSuccess = true,
  344. Message = "保存成功!"
  345. });
  346. }
  347. catch (Exception ex)
  348. {
  349. return Json(new ReturnMessage()
  350. {
  351. IsSuccess = false,
  352. Message = "保存失败,原因:" + ex.Message + "!"
  353. });
  354. }
  355. }
  356. public ActionResult CourseProcess(Guid? educationMissionClassID)
  357. {
  358. EducationMissionClassView educationMissionClassView = new EducationMissionClassView();
  359. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  360. {
  361. educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID);
  362. }
  363. return View(educationMissionClassView);
  364. }
  365. public ActionResult CourseProcessTeacherEdit(Guid? courseProcessID)
  366. {
  367. return View();
  368. }
  369. [HttpPost]
  370. public ActionResult CourseProcessTeacherList(Guid courseProcessID)
  371. {
  372. var courseProcessTeacherList = educationMissionClassServices.GetCourseProcessTeacherView(courseProcessID);
  373. return Json(new GridResultSet<CourseProcessTeacherView>{ rows = courseProcessTeacherList, total = courseProcessTeacherList.Count });
  374. }
  375. /// <summary>
  376. /// 周次设置
  377. /// </summary>
  378. /// <param name="educationMissionClassID"></param>
  379. /// <returns></returns>
  380. [HttpPost]
  381. public ActionResult CheckEducationMissionClassSettingsList(Guid? educationMissionClassID)
  382. {
  383. List<string> list = new List<string>();
  384. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  385. list = educationMissionClassServices.GetEducationMissionClassSettings(educationMissionClassID);
  386. return Json(list);
  387. }
  388. /// <summary>
  389. /// 获取任务班授课老师
  390. /// </summary>
  391. /// <param name="educationMissionClassID"></param>
  392. /// <returns></returns>
  393. [HttpPost]
  394. public ActionResult TeacherList(Guid? educationMissionClassID)
  395. {
  396. var teacherList = educationMissionClassServices.GetEducationMissionClassTeacherListViewList(educationMissionClassID);
  397. return Json(new GridResultSet<EducationMissionClassTeacherListView>() { rows = teacherList, total = teacherList.Count });
  398. }
  399. /// <summary>
  400. /// 查看排课班信息
  401. /// </summary>
  402. /// <returns></returns>
  403. public ActionResult EducationSchedulingClassList()
  404. {
  405. return View();
  406. }
  407. /// <summary>
  408. /// 查看排课班信息
  409. /// </summary>
  410. /// <returns></returns>
  411. [HttpPost]
  412. public ActionResult EducationSchedulingClassList(QueryParamsModel pararms)
  413. {
  414. Guid? educationMissionClassID = Request["educationMissionClassID"].ParseStrTo<Guid>();
  415. return Json(educationMissionClassServices.GetEducationSchedulingClassViewGrid(educationMissionClassID, (int)pararms.page, (int)pararms.rows));
  416. }
  417. /// <summary>
  418. /// 查看排课班学生信息
  419. /// </summary>
  420. /// <param name="pararms"></param>
  421. /// <returns></returns>
  422. public ActionResult EducationSchedulingClassStudentList()
  423. {
  424. return View();
  425. }
  426. /// <summary>
  427. /// 查看排课班学生信息
  428. /// </summary>
  429. /// <param name="pararms"></param>
  430. /// <returns></returns>
  431. [HttpPost]
  432. public ActionResult EducationSchedulingClassStudentList(QueryParamsModel pararms)
  433. {
  434. Guid? educationSchedulingClassID = Request["educationSchedulingClassID"].ParseStrTo<Guid>();
  435. return Json(educationMissionClassServices.GetEducationMissionClassStudentViewGrid(educationSchedulingClassID, (int)pararms.page, (int)pararms.rows));
  436. }
  437. /// <summary>
  438. /// 统计任务班对应排课班学生总人数
  439. /// </summary>
  440. /// <returns></returns>
  441. public ActionResult EducationSchedulingClassCountStudentList()
  442. {
  443. string approvalStatusName = Request["ApprovalStatusName"];
  444. string mnu = Request["mnu"];
  445. Guid? educationMissionClassID = Request["educationMissionClassID"].ParseStrTo<Guid>();
  446. ViewBag.approvalStatusName = approvalStatusName;
  447. ViewBag.mnu = mnu;
  448. ViewBag.educationMissionClassID = educationMissionClassID;
  449. return View();
  450. }
  451. /// <summary>
  452. /// 统计任务班对应排课班学生总人数
  453. /// </summary>
  454. /// <param name="pararms"></param>
  455. /// <returns></returns>
  456. [HttpPost]
  457. public ActionResult EducationSchedulingClassCountStudentList(QueryParamsModel pararms)
  458. {
  459. Guid? educationMissionClassID = Request["educationMissionClassID"].ParseStrTo<Guid>();
  460. //string approvalStatusName = Request["ApprovalStatusName"];
  461. //string mnu = Request["mnu"];
  462. //ViewBag.approvalStatusName = approvalStatusName;
  463. //ViewBag.mnu = mnu;
  464. return Json(educationMissionClassServices.GetEducationMissionClassSchedulingStudentViewGrid(educationMissionClassID, (int)pararms.page, (int)pararms.rows));
  465. }
  466. /// <summary>
  467. /// 主任务班列表
  468. /// </summary>
  469. /// <returns></returns>
  470. public ActionResult EducationMissionConjunctionList()
  471. {
  472. return View();
  473. }
  474. /// <summary>
  475. /// 合班提交
  476. /// </summary>
  477. /// <returns></returns>
  478. [HttpPost]
  479. public ActionResult EducationMissionClassConjunctionEdit()
  480. {
  481. try
  482. {
  483. var educationMissionClassList = DataGrid.GetTableData<EducationMissionClassView>("dgEducationMissionClassConjunctionList");
  484. Guid? EducationMissionClassID = new Guid(Request.Form["EducationMissionClassID"]);
  485. string Name = Request.Form["Name"];
  486. if (educationMissionClassList.Count > 0)
  487. {
  488. List<Guid?> list = new List<Guid?>();
  489. foreach (var educationMissionClass in educationMissionClassList)
  490. {
  491. list.Add(educationMissionClass.EducationMissionClassID);
  492. }
  493. EducationMissionClassView educationMissionClassView = new EducationMissionClassView();
  494. educationMissionClassView.EducationMissionClassID = EducationMissionClassID;
  495. educationMissionClassView.Name = Name;
  496. educationMissionClassServices.EducationMissionClassConjunctionAdd(educationMissionClassView, list);
  497. }
  498. else
  499. {
  500. return Json(new ReturnMessage()
  501. {
  502. IsSuccess = false,
  503. Message = "保存失败,请选择您要合班的教学任务!"
  504. });
  505. }
  506. return Json(new ReturnMessage()
  507. {
  508. IsSuccess = true,
  509. Message = "保存成功!"
  510. });
  511. }
  512. catch (Exception ex)
  513. {
  514. return Json(new ReturnMessage()
  515. {
  516. IsSuccess = false,
  517. Message = "保存失败,原因:" + ex.Message + "!"
  518. });
  519. }
  520. }
  521. /// <summary>
  522. /// 提交
  523. /// </summary>
  524. /// <param name="educationMissionClassIDs"></param>
  525. /// <returns></returns>
  526. [HttpPost]
  527. public ActionResult EducationMissionClassUpdate(string educationMissionClassIDs)
  528. {
  529. try
  530. {
  531. List<Guid?> list = new List<Guid?>();
  532. var educationMissionClassArray = educationMissionClassIDs.Split(',');
  533. for (int i = 0; i < educationMissionClassArray.Length; i++)
  534. {
  535. if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
  536. {
  537. Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
  538. list.Add(educationMissionClassID);
  539. }
  540. }
  541. educationMissionClassServices.EducationMissionClassUpdate(list);
  542. return Json("成功");
  543. }
  544. catch (Exception ex)
  545. {
  546. return Json("提交失败,原因:" + ex.Message);
  547. }
  548. }
  549. /// <summary>
  550. /// 撤销提交
  551. /// </summary>
  552. /// <param name="educationMissionClassIDs"></param>
  553. /// <returns></returns>
  554. [HttpPost]
  555. public ActionResult UnSubmit(string educationMissionClassIDs)
  556. {
  557. try
  558. {
  559. List<Guid?> list = new List<Guid?>();
  560. var educationMissionClassArray = educationMissionClassIDs.Split(',');
  561. for (int i = 0; i < educationMissionClassArray.Length; i++)
  562. {
  563. if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
  564. {
  565. Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
  566. list.Add(educationMissionClassID);
  567. }
  568. }
  569. educationMissionClassServices.UnSubmit(list);
  570. return Json("撤销成功。");
  571. }
  572. catch (Exception ex)
  573. {
  574. return Json("撤销失败,原因:" + ex.Message);
  575. }
  576. }
  577. [HttpPost]
  578. public ActionResult Delete(string educationMissionClassIDs)
  579. {
  580. try
  581. {
  582. List<Guid?> list = new List<Guid?>();
  583. var educationMissionClassArray = educationMissionClassIDs.Split(',');
  584. for (int i = 0; i < educationMissionClassArray.Length; i++)
  585. {
  586. if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
  587. {
  588. Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
  589. list.Add(educationMissionClassID);
  590. }
  591. }
  592. educationMissionClassServices.Delete(list);
  593. return Json(new ReturnMessage { IsSuccess = true });
  594. }
  595. catch (Exception ex)
  596. {
  597. string mge = ex.Message;
  598. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  599. if (num != null)
  600. {
  601. if (num.Number == 547)
  602. mge = "请先删除所有关联的数据,排课课表,学生成绩,教学评价等";
  603. }
  604. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + mge });
  605. }
  606. }
  607. /// <summary>
  608. /// 导出Excel
  609. /// </summary>
  610. /// <param name="pararms"></param>
  611. /// <returns></returns>
  612. [HttpPost]
  613. public ActionResult Excel()
  614. {
  615. NpoiExcelHelper neh = new NpoiExcelHelper();
  616. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  617. var educationMissionClassIDs = Request.Form["EducationMissionClassIDs"];
  618. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  619. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  620. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  621. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  622. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  623. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  624. var gradeYearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  625. var approvalStatus = Request.Form["ApprovalStatusDropdownList"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ApprovalStatusDropdownList"].ParseStrTo<int>();
  626. var teachingMode = Request.Form["DictionaryTeachingMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo<int>();
  627. List<Guid?> EducationMissionClassIDList = new List<Guid?>();
  628. if (educationMissionClassIDs != "")
  629. {
  630. EducationMissionClassIDList = educationMissionClassIDs.SplitIDString();
  631. }
  632. else
  633. {
  634. EducationMissionClassIDList = null;
  635. }
  636. var dt = educationMissionClassServices.GetEducationMissionClassViewList(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, null, null, null, EducationMissionClassIDList)
  637. .Select(x => new
  638. {
  639. x.OrderNo,
  640. x.Name,
  641. // x.SchoolyearCode,
  642. x.CourseCode,
  643. x.CourseName,
  644. x.DepartmentName,
  645. // x.CollegeName,
  646. x.ClassroomTypeName,
  647. x.ClassroomName,
  648. x.StartStopWeeklyNum,
  649. x.Totalhours,
  650. x.CourseProcessTimes,
  651. // x.SchedulingClassNum,
  652. x.ClassNum,
  653. x.TeacherName,
  654. x.ApprovalStatusName
  655. }).ToTable();
  656. string[] liststring = { "排课序号", "任务班名称","课程代码", "课程名称", "教研室", "教室类型", "教室名称",
  657. "执行周次", "总学时", "执行学时", "班级人数","授课老师", "状态" };
  658. neh.Export(dt, liststring, "教学任务班基础信息");
  659. return Json(new ReturnMessage()
  660. {
  661. IsSuccess = true,
  662. Message = "导出成功!"
  663. });
  664. }
  665. [HttpPost]
  666. public ActionResult GetCourseProcessViewList(Guid educationMissionClassID)
  667. {
  668. var courseProcessList = this.educationMissionClassServices.GetCourseProcessView(educationMissionClassID);
  669. return Json(new GridResultSet<CourseProcessView> { rows = courseProcessList, total = courseProcessList.Count });
  670. }
  671. [HttpPost]
  672. public ActionResult CourseProcess(EducationMissionClassView educationMissionClassView)
  673. {
  674. try
  675. {
  676. var courseProcessList = DataGrid.GetTableData<CourseProcessView>("dgCourseProcessList");
  677. educationMissionClassServices.SaveCourseProcessView(educationMissionClassView, courseProcessList);
  678. return Json(new ReturnMessage()
  679. {
  680. IsSuccess = true,
  681. Message = "保存成功。"
  682. });
  683. }
  684. catch (Exception ex)
  685. {
  686. return Json(new ReturnMessage()
  687. {
  688. IsSuccess = false,
  689. Message = "保存失败:" + ex.Message
  690. });
  691. }
  692. }
  693. [HttpPost]
  694. public ActionResult GetStudentCount(Guid educationMissionClassID)
  695. {
  696. return Json(educationMissionClassServices.GetStudentCount(educationMissionClassID));
  697. }
  698. /// <summary>
  699. /// 列出课程进度中的可选教室
  700. /// </summary>
  701. /// <param name="pararms"></param>
  702. /// <returns></returns>
  703. [HttpPost]
  704. public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms)
  705. {
  706. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  707. int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo<int>();
  708. int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo<int>();
  709. var collegeID = pararms.getExtraGuid("CollegeDropdown") ?? Guid.Empty;
  710. var buildingsID = pararms.getExtraInt("BuildingsDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraGuid("BuildingsDropdown");
  711. return base.Json(educationMissionClassServices.GetAvailableClassroom(configuretView, collegeID, buildingsID, classroomType, minSeatCount, (int)pararms.page, (int)pararms.rows));
  712. }
  713. public ActionResult StudentExport(Guid educationMissionClassID)
  714. {
  715. NpoiExcelHelper neh = new NpoiExcelHelper();
  716. var dt = educationMissionClassServices.GetEducationMissionClassSchedulingStudentViewList(educationMissionClassID)
  717. .Select(x => new
  718. {
  719. x.LoginID,
  720. x.Name,
  721. x.ClassName,
  722. x.StudentStatusName
  723. }).ToTable();
  724. string[] liststring = { "学号", "姓名","班级", "学籍状态" };
  725. neh.Export(dt, liststring, "教学任务班学生信息");
  726. return Json(new ReturnMessage()
  727. {
  728. IsSuccess = true,
  729. Message = "导出成功!"
  730. });
  731. }
  732. public ActionResult ClassRoomEdit(Guid educationMissionClassID)
  733. {
  734. EducationMissionClassView educationMissionClassView = new EducationMissionClassView();
  735. if (educationMissionClassID != null && educationMissionClassID != Guid.Empty)
  736. {
  737. educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID);
  738. }
  739. return View(educationMissionClassView);
  740. }
  741. [HttpPost]
  742. public ActionResult ClassRoomEdit(EducationMissionClassView educationMissionClassView)
  743. {
  744. try
  745. {
  746. educationMissionClassServices.EducationMissionClassUpdateClassRoom(educationMissionClassView);
  747. return Json(new ReturnMessage()
  748. {
  749. IsSuccess = true,
  750. Message = "保存成功!"
  751. });
  752. }
  753. catch (Exception ex)
  754. {
  755. return Json(new ReturnMessage()
  756. {
  757. IsSuccess = false,
  758. Message = "保存失败,原因:" + ex.Message + "!"
  759. });
  760. }
  761. }
  762. /// <summary>
  763. /// 操作前验证
  764. /// </summary>
  765. /// <param name="universityID"></param>
  766. /// <param name="code"></param>
  767. /// <returns></returns>
  768. [HttpPost]
  769. [Obsolete]
  770. public ActionResult Verification(string collegeIDs, string SchoolyearIDs)
  771. {
  772. List<Guid?> collegeIDlist = collegeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  773. .Select(x => (Guid?)new Guid(x)).ToList();
  774. List<Guid?> schoolyearIDlist = SchoolyearIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  775. .Select(x => (Guid?)new Guid(x)).ToList();
  776. var isOK = true;
  777. if (collegeIDlist.Count > 0 && schoolyearIDlist.Count>0)
  778. {
  779. isOK = educationMissionClassServices.Verification(collegeIDlist, schoolyearIDlist);
  780. }
  781. if (isOK)
  782. {
  783. return Json("成功");
  784. }
  785. else
  786. {
  787. return Json("教学任务的提交有时间限制,当前时间不在提交时间范围内,不能进行提交。");
  788. }
  789. }
  790. /// <summary>
  791. /// 操作前验证
  792. /// </summary>
  793. /// <param name="universityID"></param>
  794. /// <param name="code"></param>
  795. /// <returns></returns>
  796. [HttpPost]
  797. public ActionResult CheckEducationMissionClassOpenControl(string educationMissionClassIDs)
  798. {
  799. List<Guid> educationMissionClassIDList = educationMissionClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  800. .Select(x => new Guid(x)).ToList();
  801. if (educationMissionClassIDList.Count > 0)
  802. {
  803. try
  804. {
  805. return Json(new ReturnMessage
  806. {
  807. IsSuccess = educationMissionClassServices.CheckEducationMissionClassOpenControl(educationMissionClassIDList)
  808. });
  809. }
  810. catch (Exception ex)
  811. {
  812. return Json(new ReturnMessage
  813. {
  814. IsSuccess = false,
  815. Message = ex.Message
  816. });
  817. }
  818. }
  819. return Json(new ReturnMessage { IsSuccess = true });
  820. }
  821. [HttpPost]
  822. public ActionResult GZMSStudentListReport(List<Guid?> educationMissionClassIDList)
  823. {
  824. //ExcelForPDF.Worksheet
  825. AsposeExcelHelper excel = new AsposeExcelHelper();
  826. var pageList = new List<PageItem>();
  827. List<CellItem> cellItems = new List<CellItem>();
  828. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  829. List<EducationMissionClassView> educationMissionClassViewList = educationMissionClassServices.GetEducationMissionClassViewList(configuretView, null, null, null, null, null, null, null, null, null, null, null, null, educationMissionClassIDList);
  830. var educationMissionClass = educationMissionClassViewList.FirstOrDefault();
  831. List<EducationMissionClassStudentView> studentList = educationMissionClassServices.GetEducationMissionClassSchedulingStudentViewList(educationMissionClassIDList.FirstOrDefault());
  832. CellItem cell = new CellItem();
  833. cell.Row = 2;
  834. cell.Col = 2;
  835. cell.Value = educationMissionClass.Name;
  836. cellItems.Add(cell);
  837. CellItem cell1 = new CellItem();
  838. cell1.Row = 3;
  839. cell1.Col = 2;
  840. cell1.Value = educationMissionClass.SpecialtyName;
  841. cellItems.Add(cell1);
  842. string [][] vs = studentList.Select((data, i) => new string[]{
  843. (i+1).ToString(),
  844. data.Name
  845. }).ToArray();
  846. var count = vs.Length;
  847. var vslist = vs.ToList();
  848. if (count % 48 != 0) {
  849. do
  850. {
  851. var number = count + 1;
  852. vslist.Add(new string[]{
  853. number.ToString(),
  854. ""
  855. });
  856. count++;
  857. } while (count < 48 || (count > 48 && (count-48) % 55 != 0 ));
  858. }
  859. pageList.Add(new PageItem
  860. {
  861. CellItemList = cellItems,
  862. ListItemList = new List<ListItem>{
  863. new ListItem { StartRow = 5, StartColumn = 0, EndColumn = 2, Values = vslist.ToArray() }
  864. },
  865. });
  866. var newExcelName = Guid.NewGuid().ToString() + DateTime.Now.Ticks.ToString() + ".xlsx";
  867. FileInfo file = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + "studentListReport.xlsx"));
  868. file.CopyTo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName));
  869. FileInfo newfile = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName));
  870. var stream = new FileStream(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName), FileMode.Open);
  871. var excelNewStream = excel.ExportToTemplate(stream, pageList);
  872. var fileName = ExcelToPDF.ExportToFile(excelNewStream, Const.LOCAL_SETTING_UPLOAD_FILEPATH);
  873. var url = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + ":" + HttpContext.Request.Url.Port + Url.Content("~/").TrimEnd('/');
  874. //var host = HttpContext.Request.Url;
  875. var fileUrl = url + fileName.Substring(1, fileName.Length - 1);
  876. stream.Close();
  877. newfile.Delete();
  878. return Json(new ReturnMessage()
  879. {
  880. IsSuccess = true,
  881. Message = fileUrl,
  882. });
  883. //File(Server.MapPath(fileName), "application/x-pdf", "测试" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
  884. }
  885. }
  886. }