CampusController.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.Exceptions;
  8. using Bowin.Common.Utility;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
  14. using EMIS.CommonLogic.UniversityManage.AdministrativeOrgan;
  15. namespace EMIS.Web.Controllers.UniversityManage.AdministrativeOrgan
  16. {
  17. [Authorization]
  18. public class CampusController : Controller
  19. {
  20. public ICampusServices CampusServices { get; set; }
  21. /// <summary>
  22. /// 校区信息页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 校区信息列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. return base.Json(CampusServices.GetCampusViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
  39. }
  40. /// <summary>
  41. /// 校区信息下拉查询
  42. /// </summary>
  43. /// <param name="bindType"></param>
  44. /// <returns></returns>
  45. [HttpPost]
  46. public ActionResult CampusDropdownListBanid(DropdownListBindType? bindType)
  47. {
  48. List<DropdownListItem> list = CampusServices.GetCampusList().Select(x => new DropdownListItem
  49. {
  50. Text = x.Name,
  51. Value = x.CampusID.ToString()
  52. }).ToList();
  53. DropdownList.FormatDropdownItemList(bindType.Value, list);
  54. return base.Json(list);
  55. }
  56. /// <summary>
  57. /// 复制新增
  58. /// </summary>
  59. /// <param name="campusID"></param>
  60. /// <returns></returns>
  61. public ActionResult CopyAdd(Guid campusID)
  62. {
  63. CampusView campusView = new CampusView();
  64. campusView = CampusServices.GetCampusView(campusID);
  65. return View("Edit", campusView);
  66. }
  67. /// <summary>
  68. /// 复制新增
  69. /// </summary>
  70. /// <param name="campusView"></param>
  71. /// <returns></returns>
  72. [HttpPost]
  73. public ActionResult CopyAdd(CampusView campusView)
  74. {
  75. campusView.CampusID = Guid.Empty;
  76. return this.Edit(campusView);
  77. }
  78. /// <summary>
  79. /// 编辑(新增、修改,业务主键:校区代码或校区名称)
  80. /// </summary>
  81. /// <param name="campusID"></param>
  82. /// <returns></returns>
  83. [HttpGet]
  84. public ActionResult Edit(Guid? campusID)
  85. {
  86. //ViewBag.Type = Request.Params["Type"];//临时性加参数控制、屏蔽列表进入无保存按钮权限
  87. CampusView campusView = new CampusView();
  88. if (campusID.HasValue && campusID != Guid.Empty)
  89. {
  90. campusView = CampusServices.GetCampusView(campusID);
  91. }
  92. return View(campusView);
  93. }
  94. /// <summary>
  95. /// 编辑(新增、修改,业务主键:校区代码或校区名称)
  96. /// </summary>
  97. /// <param name="campusView"></param>
  98. /// <returns></returns>
  99. [HttpPost]
  100. public ActionResult Edit(CampusView campusView)
  101. {
  102. try
  103. {
  104. CampusServices.CampusEdit(campusView);
  105. return Json(new ReturnMessage()
  106. {
  107. IsSuccess = true,
  108. Message = "保存成功。"
  109. });
  110. }
  111. catch (Exception ex)
  112. {
  113. return Json(new ReturnMessage()
  114. {
  115. IsSuccess = false,
  116. Message = "保存失败,原因:" + ex.Message
  117. });
  118. }
  119. }
  120. /// <summary>
  121. /// 删除
  122. /// </summary>
  123. /// <param name="campusIDs"></param>
  124. /// <returns></returns>
  125. [HttpPost]
  126. public JsonResult Delete(string campusIDs)
  127. {
  128. try
  129. {
  130. List<Guid?> list = campusIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  131. CampusServices.CampusDelete(list);
  132. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  133. }
  134. catch (Exception ex)
  135. {
  136. string mge = ex.Message;
  137. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  138. if (num != null)
  139. {
  140. if (num.Number == 547)
  141. {
  142. mge = "请先删除与其有关联的数据,如:" + RSL.Get("College") + "等。";
  143. }
  144. }
  145. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  146. }
  147. }
  148. /// <summary>
  149. /// 校区对应的院系所信息
  150. /// </summary>
  151. /// <returns></returns>
  152. public ActionResult CollegeList()
  153. {
  154. return View();
  155. }
  156. /// <summary>
  157. /// 校区对应的院系所信息
  158. /// </summary>
  159. /// <param name="pararms"></param>
  160. /// <returns></returns>
  161. [HttpPost]
  162. public ActionResult CollegeList(QueryParamsModel pararms)
  163. {
  164. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  165. var campusID = Request["campusID"].ParseStrTo<Guid>();
  166. var unitCategoryID = pararms.getExtraInt("DictionaryUnitCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryUnitCategory");
  167. return Json(CampusServices.GetCollegeListViewGrid(configuretView, campusID, unitCategoryID, (int)pararms.page, (int)pararms.rows));
  168. }
  169. /// <summary>
  170. /// 校区对应的院系所信息Excel导出
  171. /// </summary>
  172. /// <returns></returns>
  173. [HttpPost]
  174. public ActionResult CollegeListExcel()
  175. {
  176. return null;
  177. }
  178. /// <summary>
  179. /// Excel导出
  180. /// </summary>
  181. /// <returns></returns>
  182. [HttpPost]
  183. public ActionResult Excel()
  184. {
  185. NpoiExcelHelper neh = new NpoiExcelHelper();
  186. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  187. var dt = CampusServices.GetCampusViewList(configuretView)
  188. .Select(x => new
  189. {
  190. x.No,
  191. x.Name,
  192. x.SimpleName,
  193. x.EnglishName,
  194. x.UniversityCode,
  195. x.UniversityName,
  196. x.GeneralsuperName,
  197. x.RecruitstudentsName,
  198. x.PlacesuperName,
  199. x.TeachingsuperName,
  200. x.StudentchargeName,
  201. x.ZIPCode,
  202. x.Officephone,
  203. x.FAX,
  204. x.Email,
  205. x.Evolution,
  206. x.CollegeCount,
  207. x.Remark
  208. }).ToTable();
  209. string[] liststring = {
  210. RSL.Get("CampusCode"), RSL.Get("CampusName"), RSL.Get("CampusSimpleName"),
  211. "英文名称", "学校代码", "学校名称", "总负责人", "招生负责人", "学籍负责人",
  212. "教学负责人", "学生负责人", "邮政编码", "办公电话",
  213. "传真", "电子邮箱", "历史沿革", RSL.Get("CollegeCount"), "备注"
  214. };
  215. neh.Export(dt, liststring, RSL.Get("CampusName") + "信息" + DateTime.Now.ToString("yyyyMMdd"));
  216. return Json(new ReturnMessage()
  217. {
  218. IsSuccess = true,
  219. Message = "导出成功。"
  220. });
  221. }
  222. }
  223. }