PersonalScoreController.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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.Students;
  7. using System.Dynamic;
  8. using EMIS.ViewModel.ScoreManage;
  9. using Bowin.Common.Utility;
  10. using EMIS.ViewModel;
  11. using EMIS.Utility;
  12. using EMIS.Entities;
  13. using EMIS.CommonLogic.ScoreManage;
  14. using EMIS.Web.Controls;
  15. using EMIS.ViewModel.CacheManage;
  16. using EMIS.CommonLogic.CalendarManage;
  17. using EMIS.CommonLogic.SystemServices;
  18. namespace EMIS.Web.Controllers.ScoreManage
  19. {
  20. [Authorization]
  21. public class PersonalScoreController : Controller
  22. {
  23. public IStudentScoreServices StudentScoreServices { get; set; }
  24. public ICourseGradeServices CourseGradeServices { get; set; }
  25. public IStudentsServices StudentfileServices { get; set; }
  26. public ISchoolYearServices SchoolYearServices { get; set; }
  27. public IParameterServices ParameterServices { get; set; }
  28. /// <summary>
  29. /// 通用个人成绩页面
  30. /// </summary>
  31. /// <returns></returns>
  32. public ActionResult List()
  33. {
  34. List<PersonalCoursematerialScoreView> listPersonalCoursematerialScoreView = new List<PersonalCoursematerialScoreView>();
  35. ViewBag.ListPersonalCoursematerialScoreView = listPersonalCoursematerialScoreView;
  36. //默认加载学生成绩
  37. //var student = StudentfileServices.Value.GetStudentView();
  38. //ViewBag.StudentNo = student.UserID;
  39. return View();
  40. }
  41. /// <summary>
  42. /// 广体个人成绩页面
  43. /// </summary>
  44. /// <returns></returns>
  45. public ActionResult NewList()
  46. {
  47. List<PersonalCoursematerialScoreView> listPersonalCoursematerialScoreView = new List<PersonalCoursematerialScoreView>();
  48. ViewBag.ListPersonalCoursematerialScoreView = listPersonalCoursematerialScoreView;
  49. var userID = Request.Params["UserID"];
  50. if (userID != null)
  51. {
  52. ViewBag.StudentNo = userID;
  53. }
  54. //默认加载学生成绩
  55. //var student = StudentfileServices.Value.GetStudentView();
  56. //ViewBag.StudentNo = student.UserID;
  57. return View();
  58. }
  59. //[HttpPost]
  60. //public ActionResult List(Guid? Id)
  61. //{
  62. // var userID = Request.Form["StudentsComboGrid"].ParseStrTo<Guid>();
  63. // List<PersonalCoursematerialScoreView> listPersonalCoursematerialScoreView = new List<PersonalCoursematerialScoreView>();
  64. // //课程成绩
  65. // var listCoursematerialScore = courseGradeServices.Value.GetStudentCourseGrade((Guid)userID);
  66. // if (listCoursematerialScore.Count > 0)
  67. // {
  68. // var Student = courseGradeServices.Value.GetStudentPersonalScore((Guid)userID);
  69. // PersonalCoursematerialScoreView personalCoursematerialScoreView = new PersonalCoursematerialScoreView();
  70. // if (Student != null)
  71. // {
  72. // personalCoursematerialScoreView.UserID = Student.UserID;
  73. // personalCoursematerialScoreView.LoginID = Student.LoginID;
  74. // personalCoursematerialScoreView.UserName = Student.UserName;
  75. // personalCoursematerialScoreView.CollegeName = Student.FacultyName;
  76. // personalCoursematerialScoreView.ClassName = Student.ClassName;
  77. // personalCoursematerialScoreView.CoursematerialCount = Student.Menshu;
  78. // personalCoursematerialScoreView.AVGScore = Student.AverageGrade;
  79. // personalCoursematerialScoreView.TotalCredit = Student.TotalScore;
  80. // personalCoursematerialScoreView.PlanningGraduateDate = Student.PlanningGraduateDate;
  81. // }
  82. // personalCoursematerialScoreView.ListStarttermID = listCoursematerialScore.Select(x => (int)x.StarttermID).Distinct().ToList();
  83. // personalCoursematerialScoreView.ListCourseGradeView = listCoursematerialScore.ToList();
  84. // listPersonalCoursematerialScoreView.Add(personalCoursematerialScoreView);
  85. // }
  86. // ViewBag.ListPersonalCoursematerialScoreView = listPersonalCoursematerialScoreView;
  87. // return View();
  88. //}
  89. [HttpPost]
  90. public ActionResult CoursematerialList(Guid? userID)
  91. {
  92. userID = userID ?? Guid.Empty;
  93. List<PersonalCoursematerialScoreView> listPersonalCoursematerialScoreView = new List<PersonalCoursematerialScoreView>();
  94. //课程成绩
  95. var listCoursematerialScore = CourseGradeServices.GetStudentCourseGrade((Guid)userID);
  96. if (listCoursematerialScore.Count > 0)
  97. {
  98. var Student = CourseGradeServices.GetStudentPersonalScore((Guid)userID);
  99. PersonalCoursematerialScoreView personalCoursematerialScoreView = new PersonalCoursematerialScoreView();
  100. if (Student != null)
  101. {
  102. personalCoursematerialScoreView.UserID = Student.UserID;
  103. personalCoursematerialScoreView.LoginID = Student.LoginID;
  104. personalCoursematerialScoreView.UserName = Student.UserName;
  105. personalCoursematerialScoreView.CollegeName = Student.FacultyName;
  106. personalCoursematerialScoreView.ClassName = Student.ClassName;
  107. personalCoursematerialScoreView.CoursematerialCount = Student.Menshu;
  108. personalCoursematerialScoreView.AVGScore = Student.AverageGrade ?? 0;
  109. personalCoursematerialScoreView.TotalCredit = Student.TotalScore ?? 0;
  110. personalCoursematerialScoreView.PlanningGraduateDate = Student.PlanningGraduateDate;
  111. }
  112. try
  113. {
  114. personalCoursematerialScoreView.ListStarttermID = listCoursematerialScore.Select(x => (int)x.StarttermID).Distinct().ToList();
  115. }
  116. catch (Exception ex)
  117. {
  118. throw ex;
  119. }
  120. personalCoursematerialScoreView.ListCourseGradeView = listCoursematerialScore.ToList();
  121. listPersonalCoursematerialScoreView.Add(personalCoursematerialScoreView);
  122. }
  123. return Json(listPersonalCoursematerialScoreView);
  124. }
  125. /// <summary>
  126. /// 个人成绩(开课学期分组)
  127. /// </summary>
  128. /// <param name="userID"></param>
  129. /// <returns></returns>
  130. [HttpPost]
  131. public ActionResult NewCoursematerialList(Guid? userID)
  132. {
  133. userID = userID ?? Guid.Empty;
  134. List<PersonalCoursematerialScoreView> listPersonalCoursematerialScoreView = new List<PersonalCoursematerialScoreView>();
  135. //课程成绩
  136. var listCoursematerialScore = CourseGradeServices.GetStudentCourseGrade((Guid)userID);
  137. if (listCoursematerialScore.Count > 0)
  138. {
  139. var Student = CourseGradeServices.GetStudentPersonalScoreGT((Guid)userID);
  140. PersonalCoursematerialScoreView personalCoursematerialScoreView = new PersonalCoursematerialScoreView();
  141. if (Student != null)
  142. {
  143. personalCoursematerialScoreView.UserID = Student.UserID;
  144. personalCoursematerialScoreView.LoginID = Student.LoginID;
  145. personalCoursematerialScoreView.UserName = Student.UserName;
  146. personalCoursematerialScoreView.CollegeName = Student.FacultyName;
  147. personalCoursematerialScoreView.ClassName = Student.ClassName;
  148. personalCoursematerialScoreView.CoursematerialCount = Student.Menshu;
  149. personalCoursematerialScoreView.AVGScore = Student.AverageGrade ?? 0;
  150. //personalCoursematerialScoreView.TotalCredit = (Student.Required ?? 0) + (Student.CapLimit ?? 0) + (Student.Optional ?? 0) + (Student.Direction ?? 0) + (Student.Commonality ?? 0) + (Student.PractiseNotCredit ?? 0);//Student.TotalScore ?? 0;
  151. personalCoursematerialScoreView.PlanningGraduateDate = Student.PlanningGraduateDate;
  152. personalCoursematerialScoreView.RequiredCredit = ((Student.Required ?? 0) - (Student.PractiseCredit ?? 0));//必修 - 实践环节
  153. personalCoursematerialScoreView.OptionalCourseCredit = ((Student.OptionalCourseCredit ?? 0) - (Student.SchoolbasedCredit ?? 0) - (Student.ElectiveCredit ?? 0));//限选 - 校本课程 - 方向性选修
  154. personalCoursematerialScoreView.FreeSelectionCourseCredit = (Student.FreeSelectionCourseCredit ?? 0) - (Student.ElectivePublicCredit ?? 0);//任选 - 公共选修
  155. personalCoursematerialScoreView.ElectiveCredit = Student.ElectiveCredit ?? 0;
  156. personalCoursematerialScoreView.ElectivePublicCredit = Student.ElectivePublicCredit ?? 0;
  157. personalCoursematerialScoreView.PractiseNotCredit = Student.PractiseNotCredit ?? 0;//实践环节不包含俱乐部
  158. personalCoursematerialScoreView.ClubWithSchoolbasedCredit = ((Student.PractiseWithClub ?? 0) > 4 ? 4 : (Student.PractiseWithClub ?? 0)) + ((Student.SchoolbasedWithClub ?? 0) > 4 ? 4 : (Student.SchoolbasedWithClub ?? 0)) + (Student.SchoolbasedNotClub ?? 0);
  159. personalCoursematerialScoreView.TotalCredit = (Student.Required ?? 0) + (Student.OptionalCourseCredit ?? 0) + (Student.FreeSelectionCourseCredit ?? 0) - (Student.PractiseCredit ?? 0) - (Student.SchoolbasedCredit ?? 0)
  160. + (Student.PractiseNotCredit ?? 0) + ((Student.PractiseWithClub ?? 0) > 4 ? 4 : (Student.PractiseWithClub ?? 0)) + (Student.SchoolbasedNotClub ?? 0) + ((Student.SchoolbasedWithClub ?? 0) > 4 ? 4 : (Student.SchoolbasedWithClub ?? 0));
  161. }
  162. try
  163. {
  164. personalCoursematerialScoreView.ListStarttermID = listCoursematerialScore.Select(x => (int)x.StarttermID).Distinct().ToList();
  165. }
  166. catch (Exception ex)
  167. {
  168. throw ex;
  169. }
  170. personalCoursematerialScoreView.ListCourseGradeView = listCoursematerialScore.ToList();
  171. listPersonalCoursematerialScoreView.Add(personalCoursematerialScoreView);
  172. }
  173. return Json(listPersonalCoursematerialScoreView);
  174. }
  175. /// <summary>
  176. /// 学生个人成绩报表
  177. /// </summary>
  178. /// <returns></returns>
  179. public ActionResult StudentScoreReport()
  180. {
  181. return View();
  182. }
  183. /// <summary>
  184. /// 列表查询
  185. /// </summary>
  186. /// <param name="pararms"></param>
  187. /// <returns></returns>
  188. [HttpPost]
  189. public ActionResult GetSubmitedScoreList(Guid? CoursematerialID, int? StartTermID, Guid? UserID)
  190. {
  191. return base.Json(CourseGradeServices.GetSubmitedScoreList(CoursematerialID.Value, StartTermID, UserID.Value));
  192. }
  193. public ActionResult Add(Guid? submitedScoreID)
  194. {
  195. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; //获取当前登录用户
  196. Guid curUserID = curUser.UserID;
  197. ViewBag.curUserName = curUser.Name;
  198. ViewBag.curLoginID = curUser.LoginID;
  199. List<Dictionary<string, string>> listDictionary = new List<Dictionary<string, string>>();
  200. var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  201. SubmitedScoreDetailView submitedScoreDetailView = new SubmitedScoreDetailView();
  202. if (submitedScoreID.HasValue)
  203. {
  204. submitedScoreDetailView = CourseGradeServices.GetSubmitedScoreDetailView(submitedScoreID);
  205. ER_SubmitedScore submitedScore = CourseGradeServices.GetSubmitedScore(submitedScoreID);
  206. var listSubmitedScoreDetail = submitedScore.ER_SubmitedScoreDetail.ToList();
  207. foreach (var scoreDynamicType in scoreDynamicTypes)
  208. {
  209. ER_SubmitedScoreDetail submitedScoreDetail = listSubmitedScoreDetail.Where(x => x.ScoreTypeID == scoreDynamicType.Value).FirstOrDefault();
  210. listDictionary.Add(new Dictionary<string, string> { { "Formula_" + submitedScoreDetail.ScoreTypeID, submitedScoreDetail.Score.ToString() } });
  211. }
  212. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  213. }
  214. else
  215. {
  216. submitedScoreDetailView.StarttermID = Convert.ToInt32(Request["StarttermID"]);
  217. submitedScoreDetailView.SchoolyearID = new Guid(Request["SchoolyearID"]);
  218. submitedScoreDetailView.CoursematerialID = new Guid(Request["CoursematerialID"]);
  219. submitedScoreDetailView.UserID = new Guid(Request["UserID"]);
  220. foreach (var scoreDynamicType in scoreDynamicTypes)
  221. {
  222. listDictionary.Add(new Dictionary<string, string> { { "Formula_" + scoreDynamicType.Value, "0" } });
  223. }
  224. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", "0" } });
  225. }
  226. submitedScoreDetailView.CreatorUserID = curUserID;
  227. ViewBag.ListDictionary = listDictionary;
  228. ViewBag.ScoreDynamicTypes = scoreDynamicTypes;
  229. return View(submitedScoreDetailView);
  230. }
  231. /// <summary>
  232. /// 新增
  233. /// </summary>
  234. /// <param name="submitedScoreDetailView"></param>
  235. /// <returns></returns>
  236. [HttpPost]
  237. public ActionResult Add(SubmitedScoreDetailView submitedScoreDetailView)
  238. {
  239. try
  240. {
  241. int atype = Convert.ToInt32(Request.Form["hid_atype"]);
  242. List<ExpandoObject> listExpandoObject = new List<ExpandoObject>();
  243. var differentDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  244. foreach (var differentDynamicType in differentDynamicTypes)
  245. {
  246. dynamic dyic = new ExpandoObject();
  247. dyic.ScoreTypeID = differentDynamicType.Value;
  248. dyic.Score = Convert.ToDecimal(Request.Form["Formula_" + differentDynamicType.Value]);
  249. listExpandoObject.Add(dyic);
  250. }
  251. submitedScoreDetailView.TotalScore = Convert.ToDecimal(Request.Form["TotalScore"]);
  252. submitedScoreDetailView.ScoreCredit = Convert.ToDecimal(Request.Form["ScoreCredit"]);
  253. submitedScoreDetailView.GradePoint = Convert.ToDecimal(Request.Form["GradePoint"]);
  254. submitedScoreDetailView.Remarks = Request.Params["hid_SaveType"];//识别是否是复制性新增操作~~
  255. submitedScoreDetailView.StudentScoreRemark = Request.Form["Remark"];
  256. //Request.Params["changedUserID"] = submitedScoreDetailView.UserID.ToString();
  257. StudentScoreServices.StudentScoreAdd(submitedScoreDetailView, listExpandoObject);
  258. return Json(new ReturnMessage<Guid?>
  259. {
  260. IsSuccess = true,
  261. Message = "保存成功!",
  262. Data = submitedScoreDetailView.UserID
  263. });
  264. }
  265. catch (Exception ex)
  266. {
  267. return Json(new ReturnMessage()
  268. {
  269. IsSuccess = false,
  270. Message = "保存失败:" + ex.Message
  271. });
  272. }
  273. }
  274. public ActionResult Edit(Guid? submitedScoreID)
  275. {
  276. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; //获取当前登录用户
  277. Guid curUserID = curUser.UserID;
  278. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);//获取当前学年学期
  279. Guid schoolYearID = schoolYear.SchoolyearID;
  280. Guid? departmentID = StudentScoreServices.GetDepartmentByUserID(curUserID);
  281. List<Dictionary<string, string>> listDictionary = new List<Dictionary<string, string>>();
  282. var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  283. int examsState = (int)CF_ExamsState.NormalExams;
  284. List<int?> examsStateList = StudentScoreServices.GetNormalExamsState();
  285. SubmitedScoreDetailView submitedScoreDetailView = new SubmitedScoreDetailView();
  286. var scoreDigitCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.ScoreDigitCount) ?? 1;
  287. if (submitedScoreID.HasValue)
  288. {
  289. submitedScoreDetailView = CourseGradeServices.GetSubmitedScoreDetailView(submitedScoreID);
  290. ER_SubmitedScore submitedScore = CourseGradeServices.GetSubmitedScore(submitedScoreID);
  291. var listSubmitedScoreDetail = submitedScore.ER_SubmitedScoreDetail.ToList();
  292. foreach (var scoreDynamicType in scoreDynamicTypes)
  293. {
  294. ER_SubmitedScoreDetail submitedScoreDetail = listSubmitedScoreDetail.Where(x => x.ScoreTypeID == scoreDynamicType.Value).FirstOrDefault();
  295. listDictionary.Add(new Dictionary<string, string> { { "Formula_" + submitedScoreDetail.ScoreTypeID, submitedScoreDetail.Score == null ? "" : submitedScoreDetail.Score.ToString() } });//平时、实验、考试成绩为空时显示为0
  296. }
  297. if (examsStateList.Any(x => x.Value == submitedScoreDetailView.ExamsStateID))
  298. {
  299. if (submitedScoreDetailView.ResultTypeID == (int)CF_ResultType.Percentage)
  300. {
  301. if (scoreDigitCount > 0)
  302. {
  303. if (scoreDigitCount > 1)
  304. {
  305. submitedScoreDetailView.TotalScore = Math.Round((decimal)submitedScoreDetailView.TotalScore, scoreDigitCount);
  306. //listDictionary.RemoveAll(x => x.Keys.Contains("TotalScore"));
  307. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  308. }
  309. else
  310. {
  311. submitedScoreDetailView.TotalScore = Math.Round((decimal)submitedScoreDetailView.TotalScore, scoreDigitCount);
  312. //listDictionary.RemoveAll(x => x.Keys.Contains("TotalScore"));
  313. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  314. }
  315. }
  316. else
  317. {
  318. submitedScoreDetailView.TotalScore = Math.Round((decimal)submitedScoreDetailView.TotalScore, scoreDigitCount);
  319. //listDictionary.RemoveAll(x => x.Keys.Contains("TotalScore"));
  320. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  321. }
  322. //listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  323. }
  324. else {
  325. string totalStr = StudentScoreServices.GetResultTypeDetailByIDandScore((int)submitedScoreDetailView.ResultTypeID, (decimal)submitedScoreDetailView.TotalScore).Name;
  326. submitedScoreDetailView.ResultTypeDetailID = StudentScoreServices.GetResultTypeDetailByIDandScore((int)submitedScoreDetailView.ResultTypeID, (decimal)submitedScoreDetailView.TotalScore).ResultTypeDetailID;
  327. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  328. }
  329. }
  330. else
  331. {
  332. string totalStr = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExamsState.ToString()).Where(x => x.Value == submitedScoreDetailView.ExamsStateID).Select(x => x.Name).FirstOrDefault();
  333. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", totalStr } });
  334. }
  335. }
  336. else
  337. {
  338. if (Request["UserID"].ToString() != null && Request["UserID"].ToString() != "")
  339. submitedScoreDetailView.UserID = new Guid(Request["UserID"]);
  340. if (submitedScoreDetailView.UserID != null) {
  341. submitedScoreDetailView.ClassName = StudentScoreServices.GetClassByUserID(submitedScoreDetailView.UserID.Value);
  342. }
  343. submitedScoreDetailView.ResultTypeID = (int)CF_ResultType.TwoGrade;
  344. foreach (var scoreDynamicType in scoreDynamicTypes)
  345. {
  346. listDictionary.Add(new Dictionary<string, string> { { "Formula_" + scoreDynamicType.Value, "" } });
  347. }
  348. listDictionary.Add(new Dictionary<string, string> { { "TotalScore", "" } });
  349. submitedScoreDetailView.SchoolyearID = schoolYearID;
  350. submitedScoreDetailView.ExamsCategoryID = (int)CF_ExamsCategory.FinalExam;
  351. submitedScoreDetailView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  352. submitedScoreDetailView.ExamsStateID = (int)CF_ExamsState.NormalExams;
  353. submitedScoreDetailView.CreatorUserID = curUserID;
  354. submitedScoreDetailView.DepartmentID = departmentID;
  355. }
  356. //var scoreDigitCount = ParameterServices.GetParameterValue<int>(CF_ParameterType.ScoreDigitCount) ?? 1;
  357. if (scoreDigitCount > 0)
  358. {
  359. if (scoreDigitCount > 1)
  360. {
  361. submitedScoreDetailView.TotalScorePattern = @"^\d+(\.\d{1," + scoreDigitCount.ToString() + "})?$";
  362. submitedScoreDetailView.TotalScorePatternError = "请输入整数或1-" + scoreDigitCount.ToString() + "位小数。";
  363. //submitedScoreDetailView.TotalScore = Math.Round((decimal)submitedScoreDetailView.TotalScore, scoreDigitCount);
  364. //listDictionary.RemoveAll(x => x.Keys.Contains("TotalScore"));
  365. //listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  366. }
  367. else
  368. {
  369. submitedScoreDetailView.TotalScorePattern = @"^\d+(\.\d{1}(0{0,1}))?$";
  370. submitedScoreDetailView.TotalScorePatternError = "请输入整数或1位小数。";
  371. //submitedScoreDetailView.TotalScore = Math.Round((decimal)submitedScoreDetailView.TotalScore, scoreDigitCount);
  372. //listDictionary.RemoveAll(x => x.Keys.Contains("TotalScore"));
  373. //listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  374. }
  375. }
  376. else
  377. {
  378. submitedScoreDetailView.TotalScorePattern = @"^\d+(\.0{1,2})?$";
  379. submitedScoreDetailView.TotalScorePatternError = "请输入整数。";
  380. //submitedScoreDetailView.TotalScore = Math.Round((decimal)submitedScoreDetailView.TotalScore, scoreDigitCount);
  381. //listDictionary.RemoveAll(x => x.Keys.Contains("TotalScore"));
  382. //listDictionary.Add(new Dictionary<string, string> { { "TotalScore", submitedScoreDetailView.TotalScore.ToString() } });
  383. }
  384. ViewBag.ListDictionary = listDictionary;
  385. ViewBag.ScoreDynamicTypes = scoreDynamicTypes;
  386. ViewBag.ResultTypeDetailID = submitedScoreDetailView.ResultTypeDetailID;
  387. return View(submitedScoreDetailView);
  388. }
  389. /// <summary>
  390. /// 编辑
  391. /// </summary>
  392. /// <param name="submitedScoreDetailView"></param>
  393. /// <returns></returns>
  394. [HttpPost]
  395. public ActionResult Edit(SubmitedScoreDetailView submitedScoreDetailView)
  396. {
  397. try
  398. {
  399. int atype = Convert.ToInt32(Request.Form["hid_atype"]);
  400. List<ExpandoObject> listExpandoObject = new List<ExpandoObject>();
  401. var differentDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  402. decimal? Score = 0;
  403. foreach (var differentDynamicType in differentDynamicTypes)
  404. {
  405. dynamic dyic = new ExpandoObject();
  406. dyic.ScoreTypeID = differentDynamicType.Value;
  407. dyic.Score = Request.Form["Formula_" + differentDynamicType.Value];
  408. listExpandoObject.Add(dyic);
  409. }
  410. string totalScore = Request.Form["TotalScore"];
  411. if (submitedScoreDetailView.ResultTypeID == (int)CF_ResultType.Percentage || submitedScoreDetailView.ResultTypeID == -1)
  412. {
  413. submitedScoreDetailView.TotalScore = Convert.ToDecimal(Request.Form["TotalScore"]);
  414. }
  415. else if (submitedScoreDetailView.ResultTypeDetailID != null)
  416. {
  417. Score = StudentScoreServices.GetResultTypeDetailByDetaliID((Guid)submitedScoreDetailView.ResultTypeDetailID).Score;
  418. submitedScoreDetailView.TotalScore = Score;
  419. }
  420. submitedScoreDetailView.ScoreCredit = Convert.ToDecimal(Request.Form["ScoreCredit"]);
  421. submitedScoreDetailView.GradePoint = Convert.ToDecimal(Request.Form["GradePoint"]);
  422. submitedScoreDetailView.Remarks = Request.Params["hid_SaveType"];//识别是否是复制性新增操作~~
  423. submitedScoreDetailView.StudentScoreRemark = Request.Form["Remark"];
  424. //Request.Params["changedUserID"] = submitedScoreDetailView.UserID.ToString();
  425. StudentScoreServices.StudentScoreAdd(submitedScoreDetailView, listExpandoObject);
  426. return Json(new ReturnMessage<Guid?>
  427. {
  428. IsSuccess = true,
  429. Message = "保存成功!",
  430. Data = submitedScoreDetailView.UserID
  431. });
  432. }
  433. catch (Exception ex)
  434. {
  435. return Json(new ReturnMessage()
  436. {
  437. IsSuccess = false,
  438. Message = "保存失败:" + ex.Message
  439. });
  440. }
  441. }
  442. /// <summary>
  443. /// 删除
  444. /// </summary>
  445. /// <param name="submitedScoreID"></param>
  446. /// <returns></returns>
  447. [HttpPost]
  448. public ActionResult Delete(string submitedScoreIDs, Guid? schoolyearID, Guid? coursematerialID, int? starttermID, Guid? userID)
  449. {
  450. try
  451. {
  452. List<Guid> list = new List<Guid>();
  453. for (int i = 0; i < submitedScoreIDs.Split(',').Length; i++)
  454. {
  455. if (!string.IsNullOrEmpty(submitedScoreIDs.Split(',')[i]))
  456. {
  457. Guid submitedScoreID = new Guid(submitedScoreIDs.Split(',')[i]);
  458. list.Add(submitedScoreID);
  459. }
  460. }
  461. CourseGradeServices.SubmitedScoreDelete(list, schoolyearID, coursematerialID, starttermID, userID);
  462. return Json("删除成功");
  463. }
  464. catch (Exception ex)
  465. {
  466. return Json("删除失败,原因:" + ex.Message);
  467. }
  468. }
  469. [HttpPost]
  470. public ActionResult GetClassNameByUserID(Guid userID)
  471. {
  472. string className = StudentScoreServices.GetClassByUserID(userID);
  473. //return Json(StudentScoreServices.GetClassByUserID(userID));
  474. return Json(new ReturnMessage { IsSuccess = true, Message = className });
  475. }
  476. [HttpPost]
  477. public ActionResult GetTypeNameByID(int typeID)
  478. {
  479. //ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  480. return Json(StudentScoreServices.GetResultTypeDetail(typeID));
  481. }
  482. }
  483. }