SOCDetailGroupController.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.Web.Controls;
  8. using EMIS.CommonLogic.DQPSystem;
  9. using Bowin.Common.Utility;
  10. using EMIS.ViewModel.DQPSystem;
  11. using EMIS.ViewModel.Students;
  12. using Bowin.Web.Controls.Mvc;
  13. using EMIS.ViewModel.SystemView;
  14. using Bowin.Common.Data;
  15. namespace EMIS.Web.Controllers.DQPSystem
  16. {
  17. [Authorization]
  18. public class SOCDetailGroupController : Controller
  19. {
  20. //
  21. // GET: /SOCDetailGroup/
  22. public ISOCDetailGroupServices SOCDetailGroupServices { get; set; }
  23. public ISOCDetailScoreServices SOCDetialScoreServices { get; set; }
  24. public ActionResult List()
  25. {
  26. return View();
  27. }
  28. [HttpPost]
  29. public ActionResult List(QueryParamsModel pararms)
  30. {
  31. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  32. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  33. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  34. var result = SOCDetailGroupServices.GetSOCDetailViewGrid(configuretView, schoolyearID, null, null, null, coursematerialID, (int)pararms.page, (int)pararms.rows);
  35. return Json(result);
  36. }
  37. [HttpGet]
  38. public ActionResult Detail(Guid? SOCDetailID)
  39. {
  40. ViewBag.SOCDetailID = SOCDetailID;
  41. return View();
  42. }
  43. [HttpPost]
  44. public ActionResult Detail()
  45. {
  46. var SOCID = Request["SOCID"].ParseStrTo<Guid>();
  47. return Json("");
  48. }
  49. [HttpGet]
  50. public ActionResult Group(Guid? SOCDetailID)
  51. {
  52. ViewBag.SOCDetailID = SOCDetailID;
  53. return View();
  54. }
  55. [HttpPost]
  56. public ActionResult Group(QueryParamsModel pararms)
  57. {
  58. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  59. var SOCDetailID = Request["SOCDetailID"].ParseStrTo<Guid>();
  60. var result = SOCDetailGroupServices.GetSOCDetailGroupViewGrid(configuretView, SOCDetailID, (int)pararms.page, (int)pararms.rows);
  61. return Json(result);
  62. }
  63. [HttpGet]
  64. public ActionResult AddGroup(Guid? SOCDetailID)
  65. {
  66. var groupSOCDetail = SOCDetailGroupServices.GetGroupSOCDetailViewGrid(SOCDetailID);
  67. return View(groupSOCDetail);
  68. }
  69. [HttpPost]
  70. public ActionResult AddGroup(GroupSOCDetailView groupSOCDetailView)
  71. {
  72. try
  73. {
  74. SOCDetailGroupServices.GroupSOCDetailSave(groupSOCDetailView);
  75. return base.Json(
  76. new ReturnMessage {
  77. IsSuccess = true,
  78. Message = "添加成功"
  79. });
  80. }
  81. catch (Exception ex)
  82. {
  83. return base.Json(
  84. new ReturnMessage {
  85. IsSuccess = false,
  86. Message = "添加失败,原因:" + ex.Message + "!"
  87. });
  88. }
  89. }
  90. /// <summary>
  91. /// 修改学生
  92. /// </summary>
  93. /// <param name="finalExaminationID"></param>
  94. /// <returns></returns>
  95. public ActionResult StudentEdit(Guid? SOCDetailGroupID)
  96. {
  97. SOCDetailGroupView SOCDetailGroupView = new SOCDetailGroupView();
  98. if (SOCDetailGroupID.HasValue)
  99. {
  100. SOCDetailGroupView = SOCDetailGroupServices.GetSOCDetailGroupView(SOCDetailGroupID);
  101. }
  102. else
  103. {
  104. SOCDetailGroupView.SOCDetailGroupID = Guid.NewGuid();
  105. }
  106. return View(SOCDetailGroupView);
  107. }
  108. /// <summary>
  109. /// 修改学生
  110. /// </summary>
  111. /// <param name="finalExaminationView"></param>
  112. /// <returns></returns>
  113. [HttpPost]
  114. public ActionResult StudentEdit(SOCDetailGroupView SOCDetailGroupView)
  115. {
  116. try
  117. {
  118. var studentList = DataGrid.GetTableData<BaseStudentView>("dgStudentList");
  119. SOCDetailGroupServices.SOCDetailGroupStudentAdd(SOCDetailGroupView.SOCDetailGroupID, studentList);
  120. return Json(new ReturnMessage()
  121. {
  122. IsSuccess = true,
  123. Message = "保存成功。"
  124. });
  125. }
  126. catch (Exception ex)
  127. {
  128. return Json(new ReturnMessage()
  129. {
  130. IsSuccess = false,
  131. Message = "保存失败:" + ex.Message
  132. });
  133. }
  134. }
  135. /// <summary>
  136. /// 添加学生
  137. /// </summary>
  138. /// <param name="finalExaminationID"></param>
  139. /// <returns></returns>
  140. public ActionResult StudentAdd(Guid? SOCDetailGroupID)
  141. {
  142. ViewBag.SOCDetailGroupID = SOCDetailGroupID;
  143. return View();
  144. }
  145. ///// <summary>
  146. ///// 添加学生
  147. ///// </summary>
  148. ///// <param name="finalExaminationID"></param>
  149. ///// <returns></returns>
  150. //[HttpPost]
  151. //public ActionResult StudentAdd(FinalExaminationView finalExaminationView)
  152. //{
  153. // try
  154. // {
  155. // finalExaminationServices.Value.StudentAdd(finalExaminationView);
  156. // return Json(new ReturnMessage()
  157. // {
  158. // IsSuccess = true,
  159. // Message = "保存成功。"
  160. // });
  161. // }
  162. // catch (Exception ex)
  163. // {
  164. // return Json(new ReturnMessage()
  165. // {
  166. // IsSuccess = false,
  167. // Message = "保存失败:" + ex.Message
  168. // });
  169. // }
  170. //}
  171. /// <summary>
  172. /// 学生名单
  173. /// </summary>
  174. /// <param name="pararms"></param>
  175. /// <returns></returns>
  176. [HttpPost]
  177. public ActionResult SOCDetailGroupStudentList()
  178. {
  179. var SOCDetailGroupID = Request["SOCDetailGroupID"].ParseStrTo<Guid>();
  180. return Json(SOCDetailGroupServices.GetSOCDetailGroupStudent(SOCDetailGroupID));
  181. }
  182. [HttpPost]
  183. public ActionResult SOCDetailGroupStudentNotGroupList(QueryParamsModel pararms)
  184. {
  185. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  186. var SOCDetailGroupID = Request["SOCDetailGroupID"].ParseStrTo<Guid>();
  187. return Json(SOCDetailGroupServices.GetNotGroupStudent(configuretView, SOCDetailGroupID));
  188. }
  189. public ActionResult SOCDetailGroupDelete(string SOCDetailGroupIDs)
  190. {
  191. try
  192. {
  193. List<Guid?> list = new List<Guid?>();
  194. for (int i = 0; i < SOCDetailGroupIDs.Split(',').Length; i++)
  195. {
  196. if (!string.IsNullOrEmpty(SOCDetailGroupIDs.Split(',')[i]))
  197. {
  198. Guid SOCDetailGroupID = new Guid(SOCDetailGroupIDs.Split(',')[i]);
  199. list.Add(SOCDetailGroupID);
  200. }
  201. }
  202. SOCDetailGroupServices.SOCDetailGroupDelete(list);
  203. return this.Json("删除成功!");
  204. }
  205. catch (Exception ex)
  206. {
  207. return this.Json("删除失败,原因:" + ex.Message);
  208. }
  209. }
  210. [HttpGet]
  211. public ActionResult SendMessage(string socDetailGroupIDs)
  212. {
  213. var groupIDList = socDetailGroupIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  214. var userIDList = SOCDetailGroupServices.GetUserIDByGroupID(groupIDList);
  215. var studentUserIDLists = "";
  216. foreach (var userID in userIDList)
  217. {
  218. studentUserIDLists = studentUserIDLists + "," + userID.ToString();
  219. }
  220. studentUserIDLists = studentUserIDLists.Substring(1);
  221. ViewBag.UserIDLists = studentUserIDLists;
  222. return View();
  223. }
  224. public ActionResult SendMessage(AnnouncementView announcementView)
  225. {
  226. announcementView.Content = HttpContext.Server.HtmlDecode(announcementView.Content);
  227. var userIDs = Request.Form["idList"];
  228. //var message = Request.Form["Message"];
  229. var userIDList = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  230. try
  231. {
  232. SOCDetialScoreServices.SendMessage(userIDList, announcementView);
  233. return Json(new ReturnMessage()
  234. {
  235. IsSuccess = true,
  236. Message = "发送成功。"
  237. });
  238. }
  239. catch (Exception ex)
  240. {
  241. return Json(new ReturnMessage()
  242. {
  243. IsSuccess = false,
  244. Message = "发送失败:" + ex.Message
  245. });
  246. }
  247. //return View();
  248. }
  249. public ActionResult GroupExcel()
  250. {
  251. NpoiExcelHelper neh = new NpoiExcelHelper();
  252. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  253. var SOCDetailID = Request["SOCDetailID"].ParseStrTo<Guid>();
  254. var dt = SOCDetailGroupServices.GetSOCDetailGroupViewList(configuretView, SOCDetailID)
  255. .Select(x => new
  256. {
  257. x.CourseName,
  258. x.Name,
  259. x.No,
  260. x.StudentName,
  261. }).ToTable();
  262. string[] liststring = {
  263. "课程名称", "成果名称", "组别", "学生"
  264. };
  265. neh.Export(dt, liststring, "学生分组信息");
  266. return Json(new ReturnMessage()
  267. {
  268. IsSuccess = true,
  269. Message = "导出成功。"
  270. });
  271. }
  272. }
  273. }