WorktimeAdjustmentController.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.PaymentManage;
  7. using EMIS.ViewModel.PaymentManage;
  8. using EMIS.ViewModel;
  9. using EMIS.Web.Controls;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. namespace EMIS.Web.Controllers.PaymentManage
  14. {
  15. [Authorization]
  16. public class WorktimeAdjustmentController : Controller
  17. {
  18. public IWorktimeAdjustmentServices WorktimeAdjustmentServices { get; set; }
  19. public ActionResult List()
  20. {
  21. return View();
  22. }
  23. public ActionResult Edit(Guid? WorktimeAdjustmentID)
  24. {
  25. WorktimeAdjustmentView worktimeAdjustmentView = new WorktimeAdjustmentView();
  26. if (WorktimeAdjustmentID.HasValue)
  27. {
  28. worktimeAdjustmentView = WorktimeAdjustmentServices.GetWorktimeAdjustmentView(WorktimeAdjustmentID);
  29. }
  30. else
  31. {
  32. worktimeAdjustmentView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  33. }
  34. return View(worktimeAdjustmentView);
  35. }
  36. public ActionResult GenerateChargeAgainst()
  37. {
  38. return View();
  39. }
  40. [HttpPost]
  41. public ActionResult List(QueryParamsModel pararms)
  42. {
  43. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  44. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  45. var coursematerialID = pararms.getExtraGuid("cgbCourse");
  46. var teacherUserID = pararms.getExtraGuid("cgbUser");
  47. var worktimeAdjustmentTypeID = pararms.getExtraInt("ddlWorktimeAdjustmentType") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("ddlWorktimeAdjustmentType");
  48. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  49. return base.Json(WorktimeAdjustmentServices.GetWorktimeAdjustmentViewList(configuretView, schoolyearID, coursematerialID, teacherUserID, worktimeAdjustmentTypeID, (int)pararms.page, (int)pararms.rows));
  50. }
  51. [HttpPost]
  52. public ActionResult Edit(WorktimeAdjustmentView worktimeAdjustmentView)
  53. {
  54. try
  55. {
  56. WorktimeAdjustmentServices.Save(worktimeAdjustmentView);
  57. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  58. }
  59. catch (Exception ex)
  60. {
  61. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  62. }
  63. }
  64. [HttpPost]
  65. public ActionResult Delete(string worktimeAdjustmentIDs)
  66. {
  67. try
  68. {
  69. List<Guid?> list = worktimeAdjustmentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  70. WorktimeAdjustmentServices.Delete(list);
  71. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
  72. }
  73. catch (Exception ex)
  74. {
  75. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  76. }
  77. }
  78. [HttpPost]
  79. public ActionResult GetEducationMissionClass(QueryParamsModel pararms)
  80. {
  81. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  82. var schoolyearID = pararms.getExtraGuid("SchoolyearID");
  83. var userID = pararms.getExtraGuid("UserID");
  84. var adjustDate = pararms.getExtraDateTime("AdjustDate");
  85. var collegeID = pararms.getExtraGuid("CollegeID");
  86. var gradeYearID = pararms.getExtraInt("GradeYearID") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("GradeYearID");
  87. var standardID = pararms.getExtraInt("StandardID") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("StandardID");
  88. var coursematerialID = pararms.getExtraGuid("CoursematerialID");
  89. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  90. return base.Json(WorktimeAdjustmentServices.GetEducationMissionClassList(configuretView, schoolyearID, userID,
  91. adjustDate, collegeID, gradeYearID, standardID, coursematerialID, (int)pararms.page, (int)pararms.rows));
  92. }
  93. [HttpPost]
  94. public ActionResult GenerateChargeAgainst(Guid schoolyearID)
  95. {
  96. try
  97. {
  98. WorktimeAdjustmentServices.GenerateChargeAgainst(schoolyearID);
  99. return base.Json(new ReturnMessage { IsSuccess = true, Message = "生成成功" });
  100. }
  101. catch (Exception ex)
  102. {
  103. return base.Json(new ReturnMessage { IsSuccess = false, Message = "生成失败:" + ex.Message });
  104. }
  105. }
  106. /// <summary>
  107. /// 导出Excel
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost]
  111. public ActionResult Excel()
  112. {
  113. NpoiExcelHelper neh = new NpoiExcelHelper();
  114. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  115. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  116. var coursematerialID = Request.Form["cgbCourse"].ParseStrTo<Guid>();
  117. var teacherUserID = Request.Form["cgbUser"].ParseStrTo<Guid>();
  118. var worktimeAdjustmentTypeID = Request.Form["ddlWorktimeAdjustmentType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWorktimeAdjustmentType"].ParseStrTo<int>();
  119. var dt = WorktimeAdjustmentServices.GetWorktimeAdjustmentViewList(configuretView, schoolyearID, coursematerialID, teacherUserID, worktimeAdjustmentTypeID).Select(x => new
  120. {
  121. x.AdjustDate,
  122. x.SchoolyearCode,
  123. x.EducationMissionClassName,
  124. x.TeacherName,
  125. x.CourseCode,
  126. x.CourseName,
  127. x.WorktimeAdjustmentTypeDesc,
  128. x.Worktime,
  129. }).ToTable();
  130. string[] liststring = { "记录时间", "学年学期", "任务班级", "教师", "课程编码", "课程名称", "登记类型", "课时数" };
  131. neh.Export(dt, liststring, "工作量调整");
  132. return RedirectToAction("MsgShow", "Common", new
  133. {
  134. msg = "导出成功!",
  135. url = Url.Action("List").AddMenuParameter()
  136. });
  137. }
  138. }
  139. }