ScoreConvertByLevelController.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.ScoreManage;
  10. using EMIS.ViewModel.ScoreManage;
  11. using Bowin.Common.Exceptions;
  12. using Bowin.Common.Utility;
  13. using Bowin.Common.Data;
  14. namespace EMIS.Web.Controllers.ScoreManage
  15. {
  16. public partial class ScoreConvertController
  17. {
  18. public IScoreConvertByLevelServices ScoreConvertByLevelServices { get; set; }
  19. public ActionResult ByLevelList()
  20. {
  21. return View();
  22. }
  23. /// <summary>
  24. /// 列表查询
  25. /// </summary>
  26. [HttpPost]
  27. public ActionResult ByLevelList(QueryParamsModel pararms)
  28. {
  29. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  30. //避开全选值
  31. var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  32. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  33. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  34. var coursematerialID = pararms.getExtraGuid("CourseDropdown");
  35. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  36. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  37. return base.Json(ScoreConvertByLevelServices.GetUniteMaintainViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, coursematerialID, (int)pararms.page, (int)pararms.rows));
  38. }
  39. /// <summary>
  40. /// 编辑
  41. /// </summary>
  42. /// <param name="finalExaminationID"></param>
  43. /// <returns></returns>
  44. public ActionResult ByLevelEdit()
  45. {
  46. ScoreConvertByLevelView scoreConvertByLevelView = new ScoreConvertByLevelView();
  47. return View(scoreConvertByLevelView);
  48. }
  49. [HttpPost]
  50. public ActionResult ByLevelEdit(ScoreConvertByLevelView scoreConvertByLevelView)
  51. {
  52. try
  53. {
  54. var success= ScoreConvertByLevelServices.Save(scoreConvertByLevelView);
  55. return Json(new ReturnMessage()
  56. {
  57. IsSuccess = true,
  58. Message = success
  59. });
  60. }
  61. catch (Exception ex)
  62. {
  63. return Json(new ReturnMessage()
  64. {
  65. IsSuccess = false,
  66. Message = "保存失败:" + ex.Message
  67. });
  68. }
  69. }
  70. /// <summary>
  71. /// 删除
  72. /// </summary>
  73. /// <param name="finalExaminationIDs"></param>
  74. /// <returns></returns>
  75. [HttpPost]
  76. public ActionResult ByLevelDelete(string ScoreConvertByLevelScoreIDs)
  77. {
  78. try
  79. {
  80. List<Guid?> list = new List<Guid?>();
  81. for (int i = 0; i < ScoreConvertByLevelScoreIDs.Split(',').Length; i++)
  82. {
  83. if (!string.IsNullOrEmpty(ScoreConvertByLevelScoreIDs.Split(',')[i]))
  84. {
  85. Guid ScoreConvertByLevelScoreID = new Guid(ScoreConvertByLevelScoreIDs.Split(',')[i]);
  86. list.Add(ScoreConvertByLevelScoreID);
  87. }
  88. }
  89. ScoreConvertByLevelServices.Delete(list);
  90. return this.Json("删除成功!");
  91. }
  92. catch (Exception ex)
  93. {
  94. string mge = ex.Message;
  95. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  96. if (num != null)
  97. {
  98. if (num.Number == 547)
  99. mge = "请先删除所有关联的数据!";
  100. }
  101. return this.Json("删除失败,原因:" + mge);
  102. }
  103. }
  104. /// <summary>
  105. /// 导出Excel
  106. /// </summary>
  107. /// <returns></returns>
  108. [HttpPost]
  109. public ActionResult ByLevelExcel()
  110. {
  111. NpoiExcelHelper neh = new NpoiExcelHelper();
  112. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  113. var ScoreConvertByLevelScoreIDs = Request.Form["ScoreConvertByLevelScoreIDs"];
  114. var schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  115. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  116. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  117. var coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  118. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  119. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  120. List<Guid?> ScoreConvertByLevelScoreIDList = new List<Guid?>();
  121. if (ScoreConvertByLevelScoreIDs != "")
  122. {
  123. ScoreConvertByLevelScoreIDList = ScoreConvertByLevelScoreIDs.SplitIDString();
  124. }
  125. else
  126. {
  127. ScoreConvertByLevelScoreIDList = null;
  128. }
  129. var dt = ScoreConvertByLevelServices.GetScoreConvertByLevelView_Excel(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, coursematerialID, ScoreConvertByLevelScoreIDList).Select(x => new
  130. {
  131. x.SchoolyearCode,
  132. x.CollegeName,
  133. x.Year,
  134. x.StandardStr,
  135. x.ClassmajorName,
  136. x.LoginID,
  137. x.UserName,
  138. x.CourseCode,
  139. x.CourseName,
  140. x.ExaminationSubjectName,
  141. x.Score
  142. }).ToTable();
  143. string[] liststring = { "学年学期", EMIS.Utility.RSL.Get("College"),"年级", "专业", "班级名称", "学号","姓名","课程代码", "课程名称","科目名称", "成绩" };
  144. neh.Export(dt, liststring, "统一认定信息");
  145. return RedirectToAction("MsgShow", "Common", new
  146. {
  147. msg = "导出成功!",
  148. url = Url.Action("List").AddMenuParameter()
  149. });
  150. }
  151. }
  152. }