SOCController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.DQPSystem;
  10. using Bowin.Common.Utility;
  11. using EMIS.ViewModel.DQPSystem;
  12. using EMIS.Utility;
  13. using EMIS.CommonLogic.SystemServices;
  14. namespace EMIS.Web.Controllers.DQPSystem
  15. {
  16. [Authorization]
  17. public partial class SOCController : Controller
  18. {
  19. //
  20. // GET: /SOC/
  21. public ISOCServices SOCServices { get; set; }
  22. public IRoleServices RoleServices { get; set; }
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. [HttpPost]
  28. public ActionResult List(QueryParamsModel pararms)
  29. {
  30. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  31. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  32. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  33. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  34. //var educationMissionID = pararms.getExtraGuid("EducationMissionGrid");
  35. var result = SOCServices.GetSOCViewGrid(configuretView, schoolyearID, coursematerialID, collegeID, (int)pararms.page, (int)pararms.rows);
  36. return Json(result);
  37. }
  38. [HttpGet]
  39. public ActionResult SOCDetail(Guid? SOCID)
  40. {
  41. ViewBag.SOCID = SOCID;
  42. return View();
  43. }
  44. [HttpPost]
  45. public ActionResult SOCDetail()
  46. {
  47. var SOCID = Request["SOCID"].ParseStrTo<Guid>();
  48. return Json(SOCServices.GetSOCDetailViewGridByID(SOCID));
  49. }
  50. public ActionResult Edit(string SOCIDList)
  51. {
  52. ViewBag.SOCIDList = SOCIDList;
  53. var socIDs = SOCIDList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  54. var socView = SOCServices.GetSOCViewByID(socIDs.FirstOrDefault());
  55. return View(socView);
  56. }
  57. [HttpPost]
  58. public ActionResult Edit(SOCView SOCView)
  59. {
  60. try
  61. {
  62. List<FileUploadView> filelist = new List<FileUploadView>();
  63. var socID = Request.Form["socIDList"] ?? "";
  64. var socIDs = socID.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  65. var TDList = DataGrid.GetTableData<SOCDetailView>("dgSOCDetailList");//获取底部列表项数据
  66. if (TDList.Count <= 0)
  67. {
  68. return Json(new ReturnMessage()
  69. {
  70. IsSuccess = false,
  71. Message = "保存失败,原因:SOC不能为空。"
  72. });
  73. }
  74. else
  75. {
  76. var detailIDList = TDList.Select(x => x.SOCDetailID).ToList();
  77. foreach (var id in detailIDList)
  78. {
  79. var sessionName = FileUploadHelper.GetFileUploadSessionName(id);
  80. var sessionfileList = (List<FileUploadView>)Session[sessionName];
  81. if (sessionfileList != null)
  82. {
  83. foreach (var file in sessionfileList)
  84. {
  85. filelist.Add(file);
  86. }
  87. }
  88. }
  89. SOCServices.SOCEdit(SOCView, TDList, filelist, socIDs);
  90. }
  91. return Json(new ReturnMessage()
  92. {
  93. IsSuccess = true,
  94. Message = "保存成功。"
  95. });
  96. }
  97. catch (Exception ex)
  98. {
  99. return Json(new ReturnMessage()
  100. {
  101. IsSuccess = false,
  102. Message = "保存失败,原因:" + ex.Message
  103. });
  104. }
  105. }
  106. [HttpGet]
  107. public ActionResult SOCDetailEdit(Guid? detailID)
  108. {
  109. //ViewBag.DetailID = detailID;
  110. //var detailView = Request["detailView"];
  111. //var SOCDetailView = SOCServices.GetSOCDetailViewByID(detailID);
  112. //if (SOCDetailView == null)
  113. //{
  114. // SOCDetailView = new SOCDetailView();
  115. // SOCDetailView.SOCDetailID = detailID.Value;
  116. //}
  117. SOCDetailView SOCDetailView = new SOCDetailView();
  118. SOCDetailView.SOCDetailID = detailID.Value;
  119. return View(SOCDetailView);
  120. }
  121. [HttpPost]
  122. public ActionResult SOCDetailEdit(SOCDetailView SOCDetailView)
  123. {
  124. var SOCID = Request["SOCID"].ParseStrTo<Guid>();
  125. ViewBag.SOCDetailView = SOCDetailView;
  126. return Json(new ReturnMessage()
  127. {
  128. IsSuccess = true,
  129. Message = "成功",
  130. });
  131. }
  132. [HttpPost]
  133. public ActionResult Generate(QueryParamsModel pararms)
  134. {
  135. try
  136. {
  137. //var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  138. //var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  139. //var facultymajorID = Request.Form["FacultymajorDropDown"].ParseStrTo<Guid>();
  140. //var coursematerialID = Request.Form["CoursematerialDropDown"].ParseStrTo<Guid>();
  141. SOCServices.GenerateSOC();
  142. return Json(new ReturnMessage()
  143. {
  144. IsSuccess = true,
  145. Message = "生成成功。"
  146. });
  147. }
  148. catch (Exception ex)
  149. {
  150. return Json(new ReturnMessage()
  151. {
  152. IsSuccess = false,
  153. Message = "生成失败:" + ex.Message
  154. });
  155. }
  156. }
  157. [HttpGet]
  158. public ActionResult Upload(Guid? detailID)
  159. {
  160. SOCDetailView SOCDetailView = new SOCDetailView();
  161. SOCDetailView.SOCDetailID = detailID.Value;
  162. return View(SOCDetailView);
  163. }
  164. [HttpPost]
  165. public ActionResult Upload()
  166. {
  167. return Json("上传成功");
  168. }
  169. [HttpPost]
  170. public ActionResult GetFileListByDetailID(string DetailID)
  171. {
  172. var detailID = DetailID.ParseStrTo<Guid>();
  173. var sessionName = FileUploadHelper.GetFileUploadSessionName(detailID ?? Guid.Empty);
  174. var fileList = (List<FileUploadView>)Session[sessionName];
  175. //var count = Session.Count;
  176. //List<FileUploadView> filelist = new List<FileUploadView>();
  177. //for (int i = 0; i < count; i++)
  178. //{
  179. // var file = Session[i];
  180. // if (file.GetType() == typeof(List<FileUploadView>))
  181. // {
  182. // filelist = (List<FileUploadView>)file;
  183. // }
  184. //}
  185. //ViewBag.FileList = filelist;
  186. //foreach (var file in filelist)
  187. //{
  188. //}
  189. return Json(fileList);
  190. }
  191. /// <summary>
  192. /// 学生名单
  193. /// </summary>
  194. /// <param name="pararms"></param>
  195. /// <returns></returns>
  196. [HttpGet]
  197. public ActionResult SOCStudentList()
  198. {
  199. return View();
  200. }
  201. /// <summary>
  202. /// 学生名单
  203. /// </summary>
  204. /// <param name="pararms"></param>
  205. /// <returns></returns>
  206. [HttpPost]
  207. public ActionResult SOCStudentList(QueryParamsModel pararms)
  208. {
  209. var SOCID = pararms.getExtraGuid("hidSOCID"); ;
  210. return Json(SOCServices.GetSOCStudent(SOCID, (int)pararms.page, (int)pararms.rows));
  211. }
  212. public ActionResult AttachmentList(Guid? detailID)
  213. {
  214. return View();
  215. }
  216. public ActionResult DeleteDetailCheck(string detailIDs)
  217. {
  218. var detailIDList = detailIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  219. var isOK = SOCServices.CheckDetailIsHaveMessage(detailIDList);
  220. if (isOK)
  221. {
  222. return Json(new ReturnMessage()
  223. {
  224. IsSuccess = false,
  225. Message = "选中的soc明细存在关联数据(SOC分组、SOC学生成果、SOC学生成绩等),不能删除!"
  226. });
  227. }
  228. else {
  229. return Json(new ReturnMessage()
  230. {
  231. IsSuccess = true,
  232. Message = "删除"
  233. });
  234. }
  235. }
  236. public ActionResult SOCCheck(string SOCIDs)
  237. {
  238. var socIDList = SOCIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  239. var isOK = SOCServices.CheckSOCIsHaveMessage(socIDList);
  240. if (isOK)
  241. {
  242. return Json(new ReturnMessage()
  243. {
  244. IsSuccess = false,
  245. Message = "选中的soc存在已经设置过明细的数据,是否重新设置?"
  246. });
  247. }
  248. else
  249. {
  250. return Json(new ReturnMessage()
  251. {
  252. IsSuccess = true,
  253. Message = "删除"
  254. });
  255. }
  256. }
  257. public ActionResult CheckCanSetting()
  258. {
  259. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  260. var role = RoleServices.GetEnabledTeacherRoleViewList();
  261. var teacherRole = role.Where(x => x.RoleName == "教师");
  262. if (curUser.RoleID != teacherRole.FirstOrDefault().RoleID)
  263. {
  264. return Json(new ReturnMessage()
  265. {
  266. IsSuccess = false,
  267. Message = "只有教师角色才能进行设置"
  268. });
  269. }
  270. else {
  271. return Json(new ReturnMessage()
  272. {
  273. IsSuccess = true,
  274. Message = ""
  275. });
  276. }
  277. }
  278. [HttpPost]
  279. public ActionResult EducationMissionList(QueryParamsModel pararms)
  280. {
  281. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  282. var result = SOCServices.GetEducationMissionViewGrid(configuretView, (int)pararms.page, (int)pararms.rows);
  283. return Json(result);
  284. }
  285. /// <summary>
  286. /// 根据登录教师获取对应院系所
  287. /// </summary>
  288. /// <param name="pararms"></param>
  289. /// <returns></returns>
  290. public ActionResult TeacherCollegeList(QueryParamsModel pararms)
  291. {
  292. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  293. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  294. var result = SOCServices.GetTeacherCollegeViewGrid(configuretView, schoolyearID, (int)pararms.page, (int)pararms.rows);
  295. return Json(result);
  296. }
  297. /// <summary>
  298. /// 根据登录教师获取对应班级
  299. /// </summary>
  300. /// <param name="pararms"></param>
  301. /// <returns></returns>
  302. public ActionResult TeacherClassmajorList(QueryParamsModel pararms)
  303. {
  304. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  305. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  306. var collegeID = pararms.getExtraGuid("cgbCollege");
  307. var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  308. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  309. var result = SOCServices.GetTeacherClassmajorViewGrid(configuretView, schoolyearID, collegeID, year, standardID, (int)pararms.page, (int)pararms.rows);
  310. return Json(result);
  311. }
  312. }
  313. }