You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

125 lines
3.9 KiB

  1. using Learun.Application.OA.Schedule;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创建人:陈彬彬
  15. /// 日 期:2017.7.11
  16. /// 描 述:日程管理
  17. /// </summary>
  18. public class ScheduleController : MvcControllerBase
  19. {
  20. private ScheduleIBLL scheduleIBLL = new ScheduleBLL();
  21. #region 视图功能
  22. /// <summary>
  23. /// 管理页面
  24. /// </summary>
  25. /// <returns></returns>
  26. [HttpGet]
  27. public ActionResult Index()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 表单页面
  33. /// </summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. public ActionResult Form()
  37. {
  38. return View();
  39. }
  40. #endregion
  41. #region 获取数据
  42. /// <summary>
  43. /// 获取日程数据
  44. /// </summary>
  45. /// <returns></returns>
  46. [HttpGet]
  47. public ActionResult GetList()
  48. {
  49. var userInfo = LoginUserInfo.Get();
  50. List<Hashtable> data = new List<Hashtable>();
  51. foreach (ScheduleEntity entity in scheduleIBLL.GetList().Where(x => x.F_CreateUserId == userInfo.userId).ToList())
  52. {
  53. Hashtable ht = new Hashtable();
  54. ht["id"] = entity.F_ScheduleId;
  55. ht["title"] = entity.F_ScheduleContent;
  56. ht["end"] = (entity.F_EndDate.ToDate().ToString("yyyy-MM-dd") + " " + entity.F_EndTime.Substring(0, 2) + ":" + entity.F_EndTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm:ss");
  57. ht["start"] = (entity.F_StartDate.ToDate().ToString("yyyy-MM-dd") + " " + entity.F_StartTime.Substring(0, 2) + ":" + entity.F_StartTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm:ss");
  58. ht["allDay"] = false;
  59. data.Add(ht);
  60. }
  61. return ToJsonResult(data);
  62. }
  63. /// <summary>
  64. /// 获取实体
  65. /// </summary>
  66. /// <param name="keyValue">主键值</param>
  67. /// <returns>返回对象Json</returns>
  68. [HttpGet]
  69. public ActionResult GetFormJson(string keyValue)
  70. {
  71. var data = scheduleIBLL.GetEntity(keyValue);
  72. var jsonData = new
  73. {
  74. LR_OA_Schedule = data,
  75. };
  76. return Success(jsonData);
  77. }
  78. #endregion
  79. #region 提交数据
  80. /// <summary>
  81. /// 删除数据
  82. /// </summary>
  83. /// <param name="keyValue">主键值</param>
  84. /// <returns></returns>
  85. [HttpPost]
  86. [AjaxOnly]
  87. public ActionResult RemoveForm(string keyValue)
  88. {
  89. scheduleIBLL.RemoveForm(keyValue);
  90. return Success("删除成功。");
  91. }
  92. /// <summary>
  93. /// 保存表单(新增、修改)
  94. /// </summary>
  95. /// <param name="keyValue">主键值</param>
  96. /// <param name="entity">实体对象</param>
  97. /// <returns></returns>
  98. [HttpPost]
  99. [ValidateAntiForgeryToken]
  100. [AjaxOnly]
  101. public ActionResult SaveForm(string keyValue, ScheduleEntity entity)
  102. {
  103. var startTime = entity.F_StartDate.ToDate();
  104. var endTime = entity.F_EndDate.ToDate();
  105. if (startTime < DateTime.Now.Date)
  106. {
  107. return Fail("开始时间不能早于今天");
  108. }
  109. if (endTime < startTime)
  110. {
  111. return Fail("结束时间不能早与开始时间");
  112. }
  113. scheduleIBLL.SaveForm(keyValue, entity);
  114. return Success("操作成功。");
  115. }
  116. #endregion
  117. }
  118. }