SpecialtyApplyController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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.Utility;
  7. using Bowin.Common.Data;
  8. using Bowin.Common.JSON;
  9. using Bowin.Common.Exceptions;
  10. using Bowin.Web.Controls.Mvc;
  11. using EMIS.Web.Controls;
  12. using EMIS.Utility;
  13. using EMIS.ViewModel;
  14. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  15. using EMIS.CommonLogic.EnrollManage.SpecialtyManage;
  16. namespace EMIS.Web.Controllers.EnrollManage.SpecialtyManage
  17. {
  18. [Authorization]
  19. public class SpecialtyApplyController : Controller
  20. {
  21. public ISpecialtyApplyServices specialtyApplyServices { get; set; }
  22. /// <summary>
  23. /// 专业申请页面
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult List()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 专业申请页面列表查询
  32. /// </summary>
  33. /// <param name="pararms"></param>
  34. /// <returns></returns>
  35. [HttpPost]
  36. public ActionResult List(QueryParamsModel pararms)
  37. {
  38. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  39. var campusID = pararms.getExtraGuid("CampusDropdown");
  40. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  42. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  43. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  44. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  45. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  46. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  47. return base.Json(specialtyApplyServices.GetSpecialtyApplyViewGrid(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, approvalStatus, (int)pararms.page, (int)pararms.rows));
  48. }
  49. /// <summary>
  50. /// 编辑(提交)
  51. /// </summary>
  52. /// <param name="specialtyApplyID"></param>
  53. /// <returns></returns>
  54. [HttpGet]
  55. public ActionResult Edit(Guid? specialtyApplyID)
  56. {
  57. SpecialtyApplyView specialtyApplyView = new SpecialtyApplyView();
  58. if (specialtyApplyID.HasValue && specialtyApplyID != Guid.Empty)
  59. {
  60. specialtyApplyView = specialtyApplyServices.GetSpecialtyApplyView(specialtyApplyID);
  61. }
  62. return View(specialtyApplyView);
  63. }
  64. /// <summary>
  65. /// 编辑(提交)
  66. /// </summary>
  67. /// <param name="specialtyApplyView"></param>
  68. /// <returns></returns>
  69. [HttpPost]
  70. public ActionResult Edit(SpecialtyApplyView specialtyApplyView)
  71. {
  72. try
  73. {
  74. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  75. List<Guid> list = new List<Guid>();
  76. list.Add(specialtyApplyView.SpecialtyApplyID);
  77. specialtyApplyServices.SpecialtyApplySubmit(list, user.UserID, specialtyApplyView.Comment);
  78. return Json(new ReturnMessage()
  79. {
  80. IsSuccess = true,
  81. Message = "提交成功。"
  82. });
  83. }
  84. catch (Exception ex)
  85. {
  86. return Json(new ReturnMessage()
  87. {
  88. IsSuccess = false,
  89. Message = "提交失败,原因:" + ex.Message
  90. });
  91. }
  92. }
  93. /// <summary>
  94. /// 专业信息申请批量新增
  95. /// </summary>
  96. /// <returns></returns>
  97. [HttpGet]
  98. public ActionResult SpecialtyApplyBatchAdd()
  99. {
  100. SpecialtyApplyView specialtyApplyView = new SpecialtyApplyView();
  101. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  102. specialtyApplyView.CollegeID = user.CollegeID;
  103. return View(specialtyApplyView);
  104. }
  105. /// <summary>
  106. /// 专业信息申请批量新增
  107. /// </summary>
  108. /// <param name="specialtyApplyView"></param>
  109. /// <returns></returns>
  110. public ActionResult SpecialtyApplyBatchAdd(SpecialtyApplyView specialtyApplyView)
  111. {
  112. try
  113. {
  114. var specialtyIDList = Request["specialtyIDs"].JsonToObject<List<Guid?>>();
  115. string result = specialtyApplyServices.SpecialtyApplyBatchAdd(specialtyIDList, specialtyApplyView);
  116. return Json(new ReturnMessage()
  117. {
  118. IsSuccess = true,
  119. Message = "申请成功" + result + "。"
  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. /// 查询专业申请中的未申请专业信息SpecialtyView
  133. /// </summary>
  134. /// <param name="pararms"></param>
  135. /// <returns></returns>
  136. [HttpPost]
  137. public ActionResult SpecialtyNoApplyList(QueryParamsModel pararms)
  138. {
  139. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  140. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  141. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  142. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  143. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  144. var scienceclassID = pararms.getExtraInt("DictionaryScienceclass") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryScienceclass");
  145. var collegeID = pararms.getExtraGuid("CollegeID");
  146. var gradeID = pararms.getExtraInt("GradeID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GradeID");
  147. var semesterID = pararms.getExtraInt("SemesterID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SemesterID");
  148. return base.Json(specialtyApplyServices.GetSpecialtyViewNoApply(configuretView, collegeID, gradeID, semesterID, standardID, educationID,
  149. learningformID, learnSystem, scienceclassID, (int)pararms.page, (int)pararms.rows));
  150. }
  151. /// <summary>
  152. /// 删除
  153. /// </summary>
  154. /// <param name="specialtyApplyIDs"></param>
  155. /// <returns></returns>
  156. [HttpPost]
  157. public ActionResult Delete(string specialtyApplyIDs)
  158. {
  159. try
  160. {
  161. List<Guid?> list = specialtyApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  162. specialtyApplyServices.SpecialtyApplyDelete(list);
  163. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  164. }
  165. catch (Exception ex)
  166. {
  167. string mge = ex.Message;
  168. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  169. if (num != null)
  170. {
  171. if (num.Number == 547)
  172. {
  173. mge = "请先删除与其关联的数据,如:招生专业等。";
  174. }
  175. }
  176. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  177. }
  178. }
  179. /// <summary>
  180. /// 提交
  181. /// </summary>
  182. /// <param name="specialtyApplyIDs"></param>
  183. /// <returns></returns>
  184. [HttpPost]
  185. public ActionResult Submit(string specialtyApplyIDs)
  186. {
  187. try
  188. {
  189. List<Guid> list = specialtyApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  190. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  191. string result = specialtyApplyServices.SpecialtyApplySubmit(list, user.UserID, "");
  192. return Json(new ReturnMessage()
  193. {
  194. IsSuccess = true,
  195. Message = "提交成功" + result + "。"
  196. });
  197. }
  198. catch (Exception ex)
  199. {
  200. return Json(new ReturnMessage()
  201. {
  202. IsSuccess = false,
  203. Message = "提交失败,原因:" + ex.Message
  204. });
  205. }
  206. }
  207. /// <summary>
  208. /// Excel导出
  209. /// </summary>
  210. /// <param name="pararms"></param>
  211. /// <returns></returns>
  212. [HttpPost]
  213. public ActionResult Excel()
  214. {
  215. NpoiExcelHelper neh = new NpoiExcelHelper();
  216. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  217. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  218. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  219. var gradeID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  220. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  221. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  222. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  223. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  224. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  225. var dt = specialtyApplyServices.GetSpecialtyApplyViewList(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, approvalStatus)
  226. .Select(x => new
  227. {
  228. x.Code,
  229. x.StandardID,
  230. x.StandardName,
  231. x.GradeID,
  232. x.SemesterName,
  233. x.EducationName,
  234. x.LearningformName,
  235. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  236. x.ScienceclassName,
  237. x.PropertyName,
  238. x.StandardTitleName,
  239. x.StandardLevelName,
  240. x.CreateTime,
  241. x.CreateUserName,
  242. x.ApprovalStatusName,
  243. x.CollegeCode,
  244. x.CollegeName,
  245. x.CampusCode,
  246. x.CampusName
  247. }).ToTable();
  248. string[] liststring = {
  249. "专业代码", "专业ID(Value)", "专业名称", "年级", "学期", RSL.Get("EducationID"), "学习形式", "学制", "专业科类",
  250. "专业属性", "专业称号", "称号级别", "申请时间", "申请人", "状态", RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
  251. RSL.Get("CampusCode"), RSL.Get("CampusName")
  252. };
  253. neh.Export(dt, liststring, "专业申请信息" + DateTime.Now.ToString("yyyyMMdd"));
  254. return Json(new ReturnMessage()
  255. {
  256. IsSuccess = true,
  257. Message = "导出成功。"
  258. });
  259. }
  260. }
  261. }