SOCDetailController.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.DQPSystem;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using EMIS.ViewModel.DQPSystem;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using Bowin.Common.Exceptions;
  13. namespace EMIS.Web.Controllers.DQPSystem
  14. {
  15. [Authorization]
  16. public class SOCDetailController : Controller
  17. {
  18. //
  19. // GET: /SOCDetail/
  20. public ISOCDetailServices SOCDetailServices { get; set; }
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. [HttpPost]
  26. public ActionResult List(QueryParamsModel pararms)
  27. {
  28. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  29. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  30. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  31. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  32. var staffID = pararms.getExtraGuid("StaffDropdown");
  33. var result = SOCDetailServices.GetSOCDetailViewGrid(configuretView, schoolyearID, coursematerialID, collegeID, staffID, (int)pararms.page, (int)pararms.rows);
  34. return Json(result);
  35. }
  36. [HttpPost]
  37. public ActionResult Excel()
  38. {
  39. NpoiExcelHelper neh = new NpoiExcelHelper();
  40. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  41. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  42. var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
  43. var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  44. var staffID = Request.Form["StaffDropdown"].ParseStrTo<Guid>();
  45. var socDetailIDString = Request.Form["SelectedID"];
  46. var socDetailIDList = socDetailIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  47. var dt = SOCDetailServices.GetSOCDetailViewList(configuretView, schoolyearID, coursematerialID, collegeID, staffID, socDetailIDList)
  48. .Select(x => new
  49. {
  50. x.SchoolyearCode,
  51. x.CourseCode,
  52. x.CourseName,
  53. x.StudentCount,
  54. x.Name,
  55. x.Credit,
  56. x.Weight,
  57. x.IsGroupStr,
  58. x.StartTimeStr,
  59. x.EndTimeStr
  60. }).ToTable();
  61. string[] liststring = { "学年学期", "课程代码", "课程名称", "学生人数", "成果名称", "成果学分", "成果权重", "是否分组", "开始上传时间", "截止上传时间" };
  62. neh.Export(dt, liststring, "课程SOC明细" + DateTime.Now.ToString("yyyyMMdd"));
  63. return Json(new ReturnMessage()
  64. {
  65. IsSuccess = true,
  66. Message = "导出成功。"
  67. });
  68. }
  69. /// <summary>
  70. /// 编辑
  71. /// </summary>
  72. /// <param name="minorConditionID"></param>
  73. /// <returns></returns>
  74. [HttpGet]
  75. public ActionResult Edit(Guid? SOCDetailID)
  76. {
  77. SOCDetailView SOCDetailView = new SOCDetailView();
  78. if (SOCDetailID.HasValue && SOCDetailID != Guid.Empty)
  79. {
  80. SOCDetailView = SOCDetailServices.GetSOCDetailView(SOCDetailID);
  81. }
  82. return View(SOCDetailView);
  83. }
  84. /// <summary>
  85. /// 编辑
  86. /// </summary>
  87. /// <param name="graduationConditionView"></param>
  88. /// <returns></returns>
  89. [HttpPost]
  90. public ActionResult Edit(SOCDetailView SOCDetailView)
  91. {
  92. try
  93. {
  94. var count = Session.Count;
  95. List<FileUploadView> filelist = new List<FileUploadView>();
  96. for (int i = 0; i < count; i++)
  97. {
  98. var file = Session[i];
  99. if (file.GetType() == typeof(List<FileUploadView>))
  100. {
  101. filelist = (List<FileUploadView>)file;
  102. }
  103. }
  104. SOCDetailServices.SOCDetailEdit(SOCDetailView, filelist);
  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. public ActionResult Delete(string SOCDetailIDs)
  121. {
  122. try
  123. {
  124. List<Guid?> list = new List<Guid?>();
  125. for (int i = 0; i < SOCDetailIDs.Split(',').Length; i++)
  126. {
  127. if (!string.IsNullOrEmpty(SOCDetailIDs.Split(',')[i]))
  128. {
  129. Guid SOCDetailID = new Guid(SOCDetailIDs.Split(',')[i]);
  130. list.Add(SOCDetailID);
  131. }
  132. }
  133. SOCDetailServices.SOCDetailDelete(list);
  134. return this.Json("删除成功!");
  135. }
  136. catch (Exception ex)
  137. {
  138. string mge = ex.Message;
  139. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  140. if (num != null)
  141. {
  142. if (num.Number == 547)
  143. mge = "请先删除所有关联的数据(SOC分组、SOC学生成果、SOC学生成绩等)。";
  144. }
  145. return base.Json("删除失败,原因:" + mge);
  146. }
  147. }
  148. [HttpGet]
  149. public ActionResult Upload(Guid? detailID)
  150. {
  151. SOCDetailView SOCDetailView = new SOCDetailView();
  152. SOCDetailView.SOCDetailID = detailID.Value;
  153. return View(SOCDetailView);
  154. }
  155. [HttpPost]
  156. public ActionResult Upload(SOCDetailView SOCDetailView)
  157. {
  158. return Json("上传成功");
  159. //try
  160. //{
  161. // var count = Session.Count;
  162. // List<FileUploadView> filelist = new List<FileUploadView>();
  163. // for (int i = 0; i < count; i++)
  164. // {
  165. // var file = Session[i];
  166. // filelist = (List<FileUploadView>)file;
  167. // }
  168. // SOCDetailServices.SOCDetailAttachmentSave(SOCDetailView.SOCDetailID, filelist);
  169. // return this.Json("上传成功!");
  170. //}
  171. //catch (Exception ex)
  172. //{
  173. // return this.Json("上传成功,原因:" + ex.Message);
  174. //}
  175. }
  176. [HttpPost]
  177. public ActionResult GetAttachmentList(QueryParamsModel pararms)
  178. {
  179. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  180. var socDetailID = pararms.getExtraGuid("hidSOCDetailID");
  181. return base.Json(SOCDetailServices.GetSOCDetailAttachmentViewList(configuretView, socDetailID, (int)pararms.page, (int)pararms.rows));
  182. }
  183. }
  184. }