DifferentDynamicApplyController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.ViewModel.DifferentDynamic;
  8. using EMIS.Web.Controls;
  9. using EMIS.CommonLogic.Students;
  10. using Bowin.Common.Exceptions;
  11. using Bowin.Common.Linq.Entity;
  12. using Bowin.Web.Controls.Mvc;
  13. using Bowin.Common.Utility;
  14. using Bowin.Common.Linq;
  15. using Bowin.Common.Mvc;
  16. using EMIS.CommonLogic.CalendarManage;
  17. namespace EMIS.Web.Controllers.DifferentDynamic
  18. {
  19. /// <summary>
  20. /// 异动申请
  21. /// </summary>
  22. [Authorization]
  23. public class DifferentDynamicApplyController : DifferentDynamicController
  24. {
  25. public ISchoolYearServices SchoolYearServices { get; set; }
  26. //[StaticFileWriteFilter]
  27. public ActionResult List()
  28. {
  29. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  30. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  31. return View();
  32. }
  33. [HttpPost]
  34. public ActionResult ApplyStatusDropDown(DropdownListBindType? bindType)
  35. {
  36. var statusList = this.DifferentDynamicServices.GetStatusViewList()
  37. .Where(x => x.ID != DifferentDynamicServices.GetCorrectEndStatus())
  38. .OrderBy(x => x.ID)
  39. .Select(x => new DropdownListItem()
  40. {
  41. Text = x.Name,
  42. Value = x.ID.HasValue ? x.ID.Value.ToString() : ""
  43. }).ToList();
  44. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  45. DropdownList.FormatDropdownItemList(dbt, statusList);
  46. return base.Json(statusList);
  47. }
  48. /// <summary>
  49. /// 列表查询
  50. /// </summary>
  51. /// <param name="pararms"></param>
  52. /// <returns></returns>
  53. [HttpPost]
  54. public ActionResult List(QueryParamsModel pararms)
  55. {
  56. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  57. var campusID = pararms.getExtraGuid("CampusDropdown"); //校区
  58. var collegeID = pararms.getExtraGuid("CollegeDropdown"); //院系所
  59. var year = CheckIsSelectAll(pararms.getExtraInt("SchoolyearDictionaryDropDown")); //年级
  60. var standard = CheckIsSelectAll(pararms.getExtraInt("StandardDictionaryDropDown")); //专业名称
  61. var education = CheckIsSelectAll(pararms.getExtraInt("DictionaryEducation")); //培养层次
  62. var learningform = CheckIsSelectAll(pararms.getExtraInt("DictionaryLearningform")); //学习形式
  63. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); //班级名称
  64. var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown"); //异动学期
  65. var differentDynamicType = CheckIsSelectAll(pararms.getExtraInt("DictionaryDifferentDynamicType")); //异动类型
  66. var differentDynamicStatus = CheckIsSelectAll(pararms.getExtraInt("DictionaryDifferentDynamicStatus")); //审批状态
  67. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  68. var result = DifferentDynamicServices.GetDifferentDynamicViewGrid(configuretView, campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus,LearnSystem, (int)pararms.page, (int)pararms.rows, 1);
  69. return Json(result);
  70. }
  71. public ActionResult Edit(Guid? id)
  72. {
  73. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  74. var vm = new DifferentDynamicView();
  75. vm.SchoolyearID = schoolYear.SchoolyearID;
  76. vm.ApplyTypeID = (int)CF_ChangeApplyType.Normal;
  77. if (id != null && id != Guid.Empty)
  78. {
  79. vm = DifferentDynamicServices.GetDifferentDynamicView(id);
  80. }
  81. var isView = (vm.EntityApprovalStatus.HasValue && vm.EntityApprovalStatus != DifferentDynamicServices.GetStartStatus()) ? true : false;
  82. ViewBag.IsView = isView;
  83. ViewBag.StartStatusID = DifferentDynamicServices.GetStartStatus();
  84. return View(vm);
  85. }
  86. /// <summary>
  87. /// 新增或更新
  88. /// </summary>
  89. /// <param name="vm"></param>
  90. /// <returns></returns>
  91. [HttpPost]
  92. public ActionResult Edit(DifferentDynamicView vm)
  93. {
  94. try
  95. {
  96. vm.Action = Request.Params["type"];
  97. DifferentDynamicServices.AddOrUpdateDifferentDynamic(vm);
  98. return Json(new ReturnMessage()
  99. {
  100. IsSuccess = true,
  101. Message = "保存成功!"
  102. });
  103. }
  104. catch (Exception ex)
  105. {
  106. return Json(new ReturnMessage()
  107. {
  108. IsSuccess = false,
  109. Message = "保存失败,原因:" + ex.Message
  110. });
  111. }
  112. }
  113. /// <summary>
  114. /// 删除
  115. /// </summary>
  116. /// <param name="ids"></param>
  117. /// <returns></returns>
  118. [HttpPost]
  119. public ActionResult Delete(string ids)
  120. {
  121. try
  122. {
  123. var list = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Guid.Parse(s)).ToList();
  124. DifferentDynamicServices.DeleteDifferentDynamic(list);
  125. return base.Json("删除成功");
  126. }
  127. catch (Exception ex)
  128. {
  129. string mge = ex.Message;
  130. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  131. if (num != null)
  132. {
  133. if (num.Number == 547)
  134. //mge = "请先删除所有关联的数据,如:专业计划、选修计划等!";
  135. mge = "请先删除所有关联的数据!";
  136. }
  137. return base.Json("删除失败,原因:" + mge);
  138. }
  139. }
  140. /// <summary>
  141. /// 提交
  142. /// </summary>
  143. /// <param name="planApplicationIDs"></param>
  144. /// <returns></returns>
  145. [HttpPost]
  146. public ActionResult Submit(string ids)
  147. {
  148. try
  149. {
  150. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  151. var list = ids.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(s => Guid.Parse(s)).ToList();
  152. DifferentDynamicServices.Submit(list, user.UserID);
  153. return Json("提交成功");
  154. }
  155. catch (Exception ex)
  156. {
  157. string mge = ex.Message;
  158. return Json("提交失败,原因:" + mge);
  159. }
  160. }
  161. [HttpPost]
  162. public ActionResult Excel()
  163. {
  164. NpoiExcelHelper neh = new NpoiExcelHelper();
  165. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  166. //避开全选值
  167. //var roleID = Request.Form["Role"].ParseStrTo<Guid>();
  168. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>(); //校区
  169. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>(); //院系所
  170. var year = CheckIsSelectAll(Request.Form["DictionarySchoolyear"].ParseStrTo<int>()); //年级
  171. var standard = CheckIsSelectAll(Request.Form["DictionaryStandard"].ParseStrTo<int>()); //专业名称
  172. var education = CheckIsSelectAll(Request.Form["DictionaryEducation"].ParseStrTo<int>()); //培养层次
  173. var learningform = CheckIsSelectAll(Request.Form["DictionaryLearningform"].ParseStrTo<int>()); //学习形式
  174. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>(); //班级名称
  175. var schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>(); //异动学期
  176. var differentDynamicType = CheckIsSelectAll(Request.Form["DictionaryDifferentDynamicType"].ParseStrTo<int>()); //异动类型
  177. var differentDynamicStatus = CheckIsSelectAll(Request.Form["DictionaryDifferentDynamicStatus"].ParseStrTo<int>()); //审批状态
  178. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  179. var result = DifferentDynamicServices.GetDifferentDynamicViewList(configuretView, campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus, LearnSystem,1);
  180. var dt = result.Select(s => new
  181. {
  182. s.SchoolyearCode,
  183. s.LoginID,
  184. s.Name,
  185. s.DifferentDynamicTypeName,
  186. s.ReasonName,
  187. s.InSchoolStatusName,
  188. s.StudentStatusName,
  189. s.StandardName,
  190. s.ClassmajorName,
  191. s.AfterStandardName,
  192. s.AfterClassmajorName,
  193. s.AfterInSchoolStatusName,
  194. s.AfterStudentStatusName,
  195. s.ReturnSchoolyearCode,
  196. s.ApprovalStatusName,
  197. s.ReportStatusName,
  198. }).ToTable();
  199. string[] liststring = { "异动学期", "学号", "姓名", "异动类型", "异动原因", "在校状态", "学籍状态",
  200. "异动前专业", "异动前班级", "异动后专业", "异动后班级", "异动后在校状态", "异动后学籍状态",
  201. "异动日期", "审批状态", "注册状态" };
  202. neh.Export(dt, liststring, "异动申请");
  203. return RedirectToAction("MsgShow", "Common", new
  204. {
  205. msg = "导出成功!",
  206. url = Url.Action("List").AddMenuParameter()
  207. });
  208. }
  209. /// <summary>
  210. /// 添加更新前验证
  211. /// </summary>
  212. /// <param name="activitiesID"></param>
  213. /// <param name="Name"></param>
  214. /// <returns></returns>
  215. [HttpPost]
  216. public ActionResult Verification(Guid? ID)
  217. {
  218. return base.Json("成功");
  219. }
  220. /// <summary>
  221. ///
  222. /// </summary>
  223. /// <param name="LoginID"></param>
  224. /// <returns></returns>
  225. public ActionResult DifferentDynamicApplyReport(string LoginID)
  226. {
  227. return View();
  228. }
  229. /// <summary>
  230. /// 列表查询(已弃用)
  231. /// </summary>
  232. /// <param name="pararms"></param>
  233. /// <returns></returns>
  234. //[HttpPost]
  235. //public ActionResult GetSelectReport(QueryParamsModel pararms)
  236. //{
  237. // ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  238. // var result = DifferentDynamicServices.GetDifferentDynamicViewGrid(configuretView);
  239. // return Json(result);
  240. //}
  241. }
  242. }