TrainingClassController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Data;
  7. using Bowin.Common.Utility;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.EducationManage;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.EducationManage;
  12. using EMIS.Web.Controls;
  13. namespace EMIS.Web.Controllers.EducationManage
  14. {
  15. [Authorization]
  16. public class TrainingClassController : Controller
  17. {
  18. public ITrainingClassServices TrainingClassServices { get; set; }
  19. public ActionResult List()
  20. {
  21. return View();
  22. }
  23. public ActionResult StudentList(Guid trainingClassID)
  24. {
  25. return View();
  26. }
  27. public ActionResult Generate()
  28. {
  29. return View(new GenerateTrainingClassConditions());
  30. }
  31. public ActionResult Split(Guid trainingClassID)
  32. {
  33. TrainingClassSplitView trainingClassSplitView = new TrainingClassSplitView();
  34. trainingClassSplitView = TrainingClassServices.GetTrainingClassSplitView(trainingClassID);
  35. //trainingClassSplitView.IsByStudentCount = false;
  36. //trainingClassSplitView.IsBySplitCount = false;
  37. //trainingClassSplitView.IsByClassmajor = false;
  38. //trainingClassSplitView.ClassStudentCount = null;
  39. //trainingClassSplitView.ClassCount = null;
  40. //trainingClassSplitView.ClassMinStudentCount = null;
  41. //return View(trainingClassSplitView);
  42. return View(trainingClassSplitView);
  43. }
  44. public ActionResult Merge()
  45. {
  46. return View(new TrainingClassMergeView());
  47. }
  48. [HttpPost]
  49. public ActionResult List(QueryParamsModel pararms)
  50. {
  51. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  52. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  53. var examinationBatchID = pararms.getExtraGuid("ddlExaminationBatch");
  54. var examinationTypeID = pararms.getExtraGuid("ddlExaminationType");
  55. var examinationProjectID = pararms.getExtraGuid("ddlExaminationProject");
  56. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  57. return base.Json(TrainingClassServices.GetTrainingClassViewGrid(conditionView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, (int)pararms.page, (int)pararms.rows));
  58. }
  59. [HttpPost]
  60. public ActionResult StudentList(QueryParamsModel pararms, Guid trainingClassID)
  61. {
  62. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  63. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  64. var collegeID = pararms.getExtraGuid("ddlCollege");
  65. var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  66. var standardID = pararms.getExtraInt("cgbStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cgbStandard");
  67. var classmajorID = pararms.getExtraGuid("cgbClassmajor");
  68. var name = pararms.getExtraString("txtName");
  69. var idNumber = pararms.getExtraString("txtIDNumber");
  70. return base.Json(TrainingClassServices.GetTrainingClassStudentViewGrid(conditionView, trainingClassID, schoolAreaID,
  71. collegeID, year, standardID, classmajorID, name, idNumber, pararms.page, pararms.rows));
  72. }
  73. [HttpPost]
  74. public ActionResult Excel()
  75. {
  76. NpoiExcelHelper neh = new NpoiExcelHelper();
  77. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null);
  78. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  79. var examinationBatchID = Request.Form["dllExaminationBatch"].ParseStrTo<Guid>();
  80. var examinationTypeID = Request.Form["dllExaminationType"].ParseStrTo<Guid>();
  81. var examinationProjectID = Request.Form["dllExaminationProject"].ParseStrTo<Guid>();
  82. var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo<int>();
  83. var trainingClassIDList = Request.Form["selectedIDs"].Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  84. var dt = TrainingClassServices.GetTrainingClassExportViewList(conditionView, schoolyearID, examinationBatchID, examinationTypeID,
  85. examinationProjectID, schoolAreaID, trainingClassIDList)
  86. .Select(x => new
  87. {
  88. x.SchoolyearCode,
  89. x.ExaminationBatchName,
  90. x.ExaminationTypeName,
  91. x.ExaminationProjectName,
  92. x.Year,
  93. x.ClassmajorName,
  94. x.UserName,
  95. x.SexName,
  96. x.CertificatesTypeName,
  97. x.IDNumber,
  98. x.Mobile,
  99. x.Name
  100. }).ToTable();
  101. string[] liststring = { "学年学期", "考试批次", "考试类型", "项目名称", "年级", "班级", "姓名",
  102. "性别", "证件类型", "证件号码", "联系方式", "培训班名" };
  103. neh.Export(dt, liststring, "学生培训信息" + DateTime.Now.ToString("yyyyMMdd"));
  104. return Json(new ReturnMessage()
  105. {
  106. IsSuccess = true,
  107. Message = "导出成功。"
  108. });
  109. }
  110. [HttpPost]
  111. public ActionResult Generate(GenerateTrainingClassConditions conditions)
  112. {
  113. try
  114. {
  115. if (!conditions.ExaminationBatchID.HasValue)
  116. {
  117. return Json(new ReturnMessage()
  118. {
  119. IsSuccess = false,
  120. Message = "请输入考试批次。"
  121. });
  122. }
  123. if (conditions.SchoolAreaID == DropdownList.PLEASE_SELECT)
  124. {
  125. conditions.SchoolAreaID = null;
  126. }
  127. TrainingClassServices.GenerateTrainingClass(conditions.ExaminationBatchID.Value, conditions.ExaminationProjectID, conditions.SchoolAreaID);
  128. return Json(new ReturnMessage()
  129. {
  130. IsSuccess = true,
  131. Message = "生成成功。"
  132. });
  133. }
  134. catch (Exception ex)
  135. {
  136. return Json(new ReturnMessage()
  137. {
  138. IsSuccess = false,
  139. Message = "生成失败:" + ex.Message
  140. });
  141. }
  142. }
  143. [HttpPost]
  144. public ActionResult Split(Guid trainingClassID, string newName, string userIDs)
  145. {
  146. try
  147. {
  148. var userIDList = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  149. TrainingClassServices.Split(trainingClassID, newName, userIDList);
  150. return Json(new ReturnMessage()
  151. {
  152. IsSuccess = true,
  153. Message = "分班成功!"
  154. });
  155. }
  156. catch (Exception ex)
  157. {
  158. return Json(new ReturnMessage()
  159. {
  160. IsSuccess = false,
  161. Message = "分班失败:" + ex.Message
  162. });
  163. }
  164. }
  165. [HttpPost]
  166. public ActionResult GetMergeName(string trainingClassIDs)
  167. {
  168. List<Guid> trainingClassIDList = trainingClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  169. try
  170. {
  171. return Json(new ReturnMessage<string>()
  172. {
  173. IsSuccess = true,
  174. Message = "",
  175. Data = this.TrainingClassServices.GetMergeName(trainingClassIDList)
  176. });
  177. }
  178. catch (Exception ex)
  179. {
  180. return Json(new ReturnMessage()
  181. {
  182. IsSuccess = false,
  183. Message = "合班失败:" + ex.Message
  184. });
  185. }
  186. }
  187. [HttpPost]
  188. public ActionResult Merge(TrainingClassMergeView trainingClassMergeView)
  189. {
  190. try
  191. {
  192. TrainingClassServices.Merge(trainingClassMergeView);
  193. return Json(new ReturnMessage()
  194. {
  195. IsSuccess = true,
  196. Message = "合班成功。"
  197. });
  198. }
  199. catch (Exception ex)
  200. {
  201. return Json(new ReturnMessage()
  202. {
  203. IsSuccess = false,
  204. Message = "合班失败:" + ex.Message
  205. });
  206. }
  207. }
  208. [HttpPost]
  209. public ActionResult AddStudent(Guid trainingClassID, string studentIDs)
  210. {
  211. var userIDList = studentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  212. try
  213. {
  214. TrainingClassServices.AddStudent(trainingClassID, userIDList);
  215. return Json(new ReturnMessage()
  216. {
  217. IsSuccess = true,
  218. Message = "添加成功。"
  219. });
  220. }
  221. catch (Exception ex)
  222. {
  223. return Json(new ReturnMessage()
  224. {
  225. IsSuccess = false,
  226. Message = "添加失败:" + ex.Message
  227. });
  228. }
  229. }
  230. [HttpPost]
  231. public ActionResult DelStudent(Guid trainingClassID, string studentIDs)
  232. {
  233. var userIDList = studentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  234. try
  235. {
  236. TrainingClassServices.DelStudent(trainingClassID, userIDList);
  237. return Json(new ReturnMessage()
  238. {
  239. IsSuccess = true,
  240. Message = "删除成功。"
  241. });
  242. }
  243. catch (Exception ex)
  244. {
  245. return Json(new ReturnMessage()
  246. {
  247. IsSuccess = false,
  248. Message = "删除失败:" + ex.Message
  249. });
  250. }
  251. }
  252. [HttpPost]
  253. public ActionResult StudentUserIDList(string trainingClassIDs)
  254. {
  255. var trainingClassIDList = trainingClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  256. return base.Json(TrainingClassServices.GetTrainingClassStudentIDList(trainingClassIDList));
  257. }
  258. [HttpGet]
  259. public ActionResult Edit(Guid? trainingClassID)
  260. {
  261. TrainingClassView trainingClassView = new TrainingClassView();
  262. if (trainingClassID.HasValue && trainingClassID != Guid.Empty)
  263. {
  264. trainingClassView = TrainingClassServices.GetTrainingClassView(trainingClassID);
  265. }
  266. return View(trainingClassView);
  267. }
  268. [HttpPost]
  269. public ActionResult Edit(TrainingClassView trainingClassView)
  270. {
  271. try
  272. {
  273. TrainingClassServices.Edit(trainingClassView);
  274. return Json(new ReturnMessage()
  275. {
  276. IsSuccess = true,
  277. Message = "保存成功。"
  278. });
  279. }
  280. catch (Exception ex)
  281. {
  282. return Json(new ReturnMessage()
  283. {
  284. IsSuccess = false,
  285. Message = "保存失败,原因:" + ex.Message
  286. });
  287. }
  288. }
  289. }
  290. }