OpenObjectController.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.Utility;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.JSON;
  10. using EMIS.Web.Controls;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.StudentManage.OnlineChecking;
  13. using EMIS.CommonLogic.StudentManage.OnlineChecking;
  14. namespace EMIS.Web.Controllers.StudentManage.OnlineChecking
  15. {
  16. [Authorization]
  17. public class OpenObjectController : Controller
  18. {
  19. public Lazy<IOpenObjectServices> OpenObjectServices { get; set; }
  20. /// <summary>
  21. /// 学生开放对象页面
  22. /// </summary>
  23. /// <returns></returns>
  24. public ActionResult List()
  25. {
  26. return View();
  27. }
  28. /// <summary>
  29. /// 学生开放对象页面列表查询
  30. /// </summary>
  31. /// <param name="pararms"></param>
  32. /// <returns></returns>
  33. [HttpPost]
  34. public ActionResult List(QueryParamsModel pararms)
  35. {
  36. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  37. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  38. var schoolyearNumID = pararms.getExtraInt("DictionarySchoolyearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyearNum");
  39. var dateRange = pararms.getExtraDateTime("txtDateRange");
  40. return base.Json(OpenObjectServices.Value.GetStudentEditObjectViewGrid(configuretView, educationID, schoolyearNumID, dateRange, (int)pararms.page, (int)pararms.rows));
  41. }
  42. /// <summary>
  43. /// 复制新增
  44. /// </summary>
  45. /// <param name="studentEditObjectID"></param>
  46. /// <returns></returns>
  47. public ActionResult CopyAdd(Guid studentEditObjectID)
  48. {
  49. OpenObjectView openObjectView = new OpenObjectView();
  50. openObjectView = OpenObjectServices.Value.GetStudentEditObjectView(studentEditObjectID);
  51. return View("Edit", openObjectView);
  52. }
  53. /// <summary>
  54. /// 复制新增
  55. /// </summary>
  56. /// <param name="openObjectView"></param>
  57. /// <returns></returns>
  58. [HttpPost]
  59. public ActionResult CopyAdd(OpenObjectView openObjectView)
  60. {
  61. openObjectView.StudentEditObjectsID = Guid.Empty;
  62. return this.Edit(openObjectView);
  63. }
  64. /// <summary>
  65. /// 编辑(新增、修改)
  66. /// </summary>
  67. /// <param name="studentEditObjectID"></param>
  68. /// <returns></returns>
  69. [HttpGet]
  70. public ActionResult Edit(Guid? studentEditObjectID)
  71. {
  72. OpenObjectView openObjectView = new OpenObjectView();
  73. if (studentEditObjectID.HasValue && studentEditObjectID != Guid.Empty)
  74. {
  75. openObjectView = OpenObjectServices.Value.GetStudentEditObjectView(studentEditObjectID);
  76. }
  77. else
  78. {
  79. openObjectView.Starttime = DateTime.Now;
  80. openObjectView.Endtime = DateTime.Now.AddMonths(1);
  81. }
  82. return View(openObjectView);
  83. }
  84. /// <summary>
  85. /// 编辑(新增、修改)
  86. /// </summary>
  87. /// <param name="openObjectView"></param>
  88. /// <returns></returns>
  89. [HttpPost]
  90. public ActionResult Edit(OpenObjectView openObjectView)
  91. {
  92. try
  93. {
  94. OpenObjectServices.Value.StudentEditObjectEdit(openObjectView);
  95. return Json(new ReturnMessage()
  96. {
  97. IsSuccess = true,
  98. Message = "保存成功。"
  99. });
  100. }
  101. catch (Exception ex)
  102. {
  103. return Json(new ReturnMessage()
  104. {
  105. IsSuccess = false,
  106. Message = "保存失败,原因:" + ex.Message
  107. });
  108. }
  109. }
  110. /// <summary>
  111. /// 开放对象信息批量新增
  112. /// </summary>
  113. /// <returns></returns>
  114. [HttpGet]
  115. public ActionResult OpenObjectBatchAdd()
  116. {
  117. OpenObjectView openObjectView = new OpenObjectView();
  118. openObjectView.Starttime = DateTime.Now;
  119. openObjectView.Endtime = DateTime.Now.AddMonths(1);
  120. return View(openObjectView);
  121. }
  122. /// <summary>
  123. /// 开放对象信息批量新增
  124. /// </summary>
  125. /// <param name="openObjectView"></param>
  126. /// <returns></returns>
  127. public ActionResult OpenObjectBatchAdd(OpenObjectView openObjectView)
  128. {
  129. try
  130. {
  131. var schoolyearNumIDList = Request["schoolyearNumIDList"].JsonToObject<List<int?>>();
  132. string result = OpenObjectServices.Value.StudentEditObjectBatchAdd(schoolyearNumIDList, openObjectView);
  133. return Json(new ReturnMessage()
  134. {
  135. IsSuccess = true,
  136. Message = "新增成功" + result + "。"
  137. });
  138. }
  139. catch (Exception ex)
  140. {
  141. return Json(new ReturnMessage()
  142. {
  143. IsSuccess = false,
  144. Message = "新增失败,原因:" + ex.Message
  145. });
  146. }
  147. }
  148. /// <summary>
  149. /// 查询对应的未新增开放学年信息DictionaryItemView
  150. /// </summary>
  151. /// <param name="pararms"></param>
  152. /// <returns></returns>
  153. [HttpPost]
  154. public ActionResult SchoolyearNumNoAddList(QueryParamsModel pararms)
  155. {
  156. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  157. var educationID = pararms.getExtraInt("EducationID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("EducationID");
  158. return base.Json(OpenObjectServices.Value.GetSchoolyearNumNoAddGrid(configuretView, educationID, (int)pararms.page, (int)pararms.rows));
  159. }
  160. /// <summary>
  161. /// 删除
  162. /// </summary>
  163. /// <param name="studentEditObjectIDs"></param>
  164. /// <returns></returns>
  165. [HttpPost]
  166. public ActionResult Delete(string studentEditObjectIDs)
  167. {
  168. try
  169. {
  170. List<Guid?> list = studentEditObjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  171. OpenObjectServices.Value.StudentEditObjectDelete(list);
  172. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  173. }
  174. catch (Exception ex)
  175. {
  176. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  177. }
  178. }
  179. /// <summary>
  180. /// Excel导出
  181. /// </summary>
  182. /// <returns></returns>
  183. [HttpPost]
  184. public ActionResult Excel()
  185. {
  186. NpoiExcelHelper neh = new NpoiExcelHelper();
  187. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  188. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  189. var schoolyearNumID = Request.Form["DictionarySchoolyearNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyearNum"].ParseStrTo<int>();
  190. var dateRange = Request.Form["txtDateRange"].ParseStrTo<DateTime>();
  191. var dt = OpenObjectServices.Value.GetStudentEditObjectViewList(configuretView, educationID, schoolyearNumID, dateRange)
  192. .Select(x => new
  193. {
  194. x.EducationName,
  195. x.SchoolyearNumName,
  196. Starttime = x.Starttime == null ? null : x.Starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
  197. Endtime = x.Endtime == null ? null : x.Endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
  198. x.Remark,
  199. x.CreateUserName,
  200. x.ModifyUserName,
  201. ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
  202. }).ToTable();
  203. string[] liststring = {
  204. "培养层次", "开放学年", "开始时间", "结束时间", "备注", "创建人", "修改人", "修改时间"
  205. };
  206. neh.Export(dt, liststring, "开放对象信息" + DateTime.Now.ToString("yyyyMMdd"));
  207. return Json(new ReturnMessage()
  208. {
  209. IsSuccess = true,
  210. Message = "导出成功。"
  211. });
  212. }
  213. }
  214. }