ChargeProjectController.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.ViewModel.ChargeManage.ChargeSituation;
  8. using EMIS.CommonLogic.ChargeManage.ChargeSituation;
  9. using EMIS.Web.Controls;
  10. using Bowin.Common.Exceptions;
  11. using Bowin.Common.Utility;
  12. using Bowin.Web.Controls.Mvc;
  13. using Bowin.Common.Data;
  14. using EMIS.Utility;
  15. namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
  16. {
  17. [Authorization]
  18. public class ChargeProjectController : Controller
  19. {
  20. public IChargeProjectServices ChargeProjectService { get; set; }
  21. /// <summary>
  22. ///收费项目页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 收费项目列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. return base.Json(ChargeProjectService.GetChargeProjectViewGrid(configuretView,(int)pararms.page, (int)pararms.rows));
  39. }
  40. /// <summary>
  41. /// 编辑
  42. /// </summary>
  43. /// <param name="chargeProjectID"></param>
  44. /// <returns></returns>
  45. [HttpGet]
  46. public ActionResult Edit(Guid? chargeProjectID)
  47. {
  48. ChargeProjectView chargeProjectView = new ChargeProjectView();
  49. if (chargeProjectID.HasValue && chargeProjectID != Guid.Empty)
  50. {
  51. chargeProjectView = ChargeProjectService.GetChargeProjectView(chargeProjectID);
  52. }
  53. return View(chargeProjectView);
  54. }
  55. /// <summary>
  56. /// 编辑
  57. /// </summary>
  58. /// <param name="chargeProjectView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult Edit(ChargeProjectView chargeProjectView)
  62. {
  63. try
  64. {
  65. ChargeProjectService.ChargeProjectAdd(chargeProjectView);
  66. return Json(new ReturnMessage()
  67. {
  68. IsSuccess = true,
  69. Message = "保存成功。"
  70. });
  71. }
  72. catch (Exception ex)
  73. {
  74. return Json(new ReturnMessage()
  75. {
  76. IsSuccess = false,
  77. Message = "保存失败,原因:" + ex.Message + "。"
  78. });
  79. }
  80. }
  81. /// <summary>
  82. /// 详情页面
  83. /// </summary>
  84. /// <param name="chargeProjectID"></param>
  85. /// <returns></returns>
  86. [HttpGet]
  87. public ActionResult Details(Guid? chargeProjectID)
  88. {
  89. ChargeProjectView chargeProjectView = new ChargeProjectView();
  90. if (chargeProjectID.HasValue && chargeProjectID != Guid.Empty)
  91. {
  92. chargeProjectView = ChargeProjectService.GetChargeProjectDetailsView(chargeProjectID);
  93. }
  94. return View(chargeProjectView);
  95. }
  96. /// <summary>
  97. /// 删除
  98. /// </summary>
  99. /// <param name="ChargeProjectIDs"></param>
  100. /// <returns></returns>
  101. [HttpPost]
  102. public ActionResult Delete(string ChargeProjectIDs)
  103. {
  104. try
  105. {
  106. List<Guid> list = new List<Guid>();
  107. for (int i = 0; i < ChargeProjectIDs.Split(',').Length; i++)
  108. {
  109. string id = ChargeProjectIDs.Split(',')[i];
  110. if (!string.IsNullOrEmpty(id))
  111. {
  112. Guid chargeProjectID = new Guid(id);
  113. list.Add(chargeProjectID);
  114. }
  115. }
  116. ChargeProjectService.ChargeProjectDelete(list);
  117. return base.Json("删除成功。");
  118. }
  119. catch (Exception ex)
  120. {
  121. string mge = ex.Message;
  122. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  123. if (num != null)
  124. {
  125. if (num.Number == 547)
  126. mge = "请先删除与其关联的数据,如:收费标准等";
  127. }
  128. return base.Json("删除失败,原因:" + mge + "。");
  129. }
  130. }
  131. /// <summary>
  132. /// 验证
  133. /// </summary>
  134. /// <param name="chargeProjectID"></param>
  135. /// <param name="chrageProjectName"></param>
  136. /// <returns></returns>
  137. [HttpPost]
  138. public ActionResult Verification(Guid? chargeProjectID, string chrageProjectName)
  139. {
  140. return Json(ChargeProjectService.GetVerification(chargeProjectID, chrageProjectName));
  141. }
  142. /// <summary>
  143. /// Excel导出
  144. /// </summary>
  145. /// <param name="pararms"></param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. public ActionResult Excel(ChargeProjectView pararms)
  149. {
  150. NpoiExcelHelper neh = new NpoiExcelHelper();
  151. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  152. var dt = ChargeProjectService.GetChargeProjectViewList(configuretView).Select(x => new
  153. {
  154. x.ChrageProjectName,
  155. x.Remark
  156. }).ToTable();
  157. string[] liststring = { "收费项目", "备注" };
  158. neh.Export(dt, liststring, "收费项目信息" + DateTime.Now.ToString("yyyyMMdd"));
  159. return Json(new ReturnMessage()
  160. {
  161. IsSuccess = true,
  162. Message = "导出成功。"
  163. });
  164. }
  165. }
  166. }