CourseTimeHoursController.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.SchedulingManage.SchedulingSettings;
  9. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  10. using Bowin.Common.Exceptions;
  11. namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
  12. {
  13. [Authorization]
  14. public class CourseTimeHoursController : Controller
  15. {
  16. public ICourseTimeHoursServices ICourseTimeHoursServices { get; set; }
  17. /// <summary>
  18. /// 学时转换页面
  19. /// </summary>
  20. /// <returns></returns>
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. /// <summary>
  26. /// 列表查询
  27. /// </summary>
  28. /// <param name="pararms"></param>
  29. /// <returns></returns>
  30. [HttpPost]
  31. public ActionResult List(QueryParamsModel pararms)
  32. {
  33. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  34. var year = pararms.getExtraInt("SchoolyearDictionaryDropDown");
  35. var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid");
  36. return base.Json(ICourseTimeHoursServices.GetCoursesTimeViewGrid(configuretView, year, CoursesTimeID, (int)pararms.page, (int)pararms.rows));
  37. }
  38. public ActionResult Edit(Guid? CoursesTimeID)
  39. {
  40. CourseTimeHoursView CourseTimeHoursView = new CourseTimeHoursView();
  41. if (CoursesTimeID.HasValue)
  42. {
  43. CourseTimeHoursView = ICourseTimeHoursServices.GetCourseTimeHoursView(CoursesTimeID);
  44. }
  45. return View(CourseTimeHoursView);
  46. }
  47. [HttpPost]
  48. public ActionResult Edit(CourseTimeHoursView CourseTimeHoursView)
  49. {
  50. try
  51. {
  52. ICourseTimeHoursServices.save(CourseTimeHoursView);
  53. return Json(new ReturnMessage()
  54. {
  55. IsSuccess = true,
  56. Message = "保存成功!"
  57. });
  58. }
  59. catch (Exception ex)
  60. {
  61. return Json(new ReturnMessage()
  62. {
  63. IsSuccess = false,
  64. Message = "保存失败:" + ex.Message
  65. });
  66. }
  67. }
  68. [HttpPost]
  69. public ActionResult Delete(string ids)
  70. {
  71. try
  72. {
  73. var list = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Guid.Parse(s)).ToList();
  74. ICourseTimeHoursServices.Delete(list);
  75. return base.Json("删除成功");
  76. }
  77. catch (Exception ex)
  78. {
  79. string mge = ex.Message;
  80. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  81. if (num != null)
  82. {
  83. if (num.Number == 547)
  84. mge = "请先删除所有关联的数据!";
  85. }
  86. return base.Json("删除失败,原因:" + mge);
  87. }
  88. }
  89. }
  90. }