CustomerController.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using LeaRun.Application.Entity.CustomerManage;
  2. using LeaRun.Application.Busines.CustomerManage;
  3. using LeaRun.Util;
  4. using LeaRun.Util.WebControl;
  5. using System.Web.Mvc;
  6. using LeaRun.Application.Code;
  7. namespace LeaRun.Application.Web.Areas.CustomerManage.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 6.1
  11. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  12. /// 创 建:佘赐雄
  13. /// 日 期:2016-03-14 09:47
  14. /// 描 述:客户信息
  15. /// </summary>
  16. public class CustomerController : MvcControllerBase
  17. {
  18. private CustomerBLL customerbll = new CustomerBLL();
  19. private CustomerContactBLL customercontactbll = new CustomerContactBLL();
  20. #region 视图功能
  21. /// <summary>
  22. /// 客户列表页面
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. [HandlerAuthorize(PermissionMode.Enforce)]
  27. public ActionResult Index()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 客户表单页面
  33. /// </summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. [HandlerAuthorize(PermissionMode.Enforce)]
  37. public ActionResult Form()
  38. {
  39. return View();
  40. }
  41. /// <summary>
  42. /// 客户明细页面
  43. /// </summary>
  44. /// <returns></returns>
  45. [HttpGet]
  46. [HandlerAuthorize(PermissionMode.Enforce)]
  47. public ActionResult Detail()
  48. {
  49. return View();
  50. }
  51. /// <summary>
  52. /// 联系人列表
  53. /// </summary>
  54. /// <returns></returns>
  55. [HttpGet]
  56. [HandlerAuthorize(PermissionMode.Enforce)]
  57. public ActionResult ContactIndex()
  58. {
  59. return View();
  60. }
  61. /// <summary>
  62. /// 联系人表单
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult ContactForm()
  67. {
  68. return View();
  69. }
  70. #endregion
  71. #region 获取数据
  72. /// <summary>
  73. /// 获取客户列表
  74. /// </summary>
  75. /// <returns>返回列表Json</returns>
  76. [HttpGet]
  77. public ActionResult GetListJson()
  78. {
  79. var data = customerbll.GetList();
  80. return ToJsonResult(data);
  81. }
  82. /// <summary>
  83. /// 获取客户列表
  84. /// </summary>
  85. /// <param name="pagination">分页参数</param>
  86. /// <param name="queryJson">查询参数</param>
  87. /// <returns>返回分页列表Json</returns>
  88. [HttpGet]
  89. public ActionResult GetPageListJson(Pagination pagination, string queryJson)
  90. {
  91. var watch = CommonHelper.TimerStart();
  92. var data = customerbll.GetPageList(pagination, queryJson);
  93. var jsonData = new
  94. {
  95. rows = data,
  96. total = pagination.total,
  97. page = pagination.page,
  98. records = pagination.records,
  99. costtime = CommonHelper.TimerEnd(watch)
  100. };
  101. return ToJsonResult(jsonData);
  102. }
  103. /// <summary>
  104. /// 获取客户实体
  105. /// </summary>
  106. /// <param name="keyValue">主键值</param>
  107. /// <returns>返回对象Json</returns>
  108. [HttpGet]
  109. public ActionResult GetFormJson(string keyValue)
  110. {
  111. var data = customerbll.GetEntity(keyValue);
  112. return ToJsonResult(data);
  113. }
  114. /// <summary>
  115. /// 获取联系人列表
  116. /// </summary>
  117. /// <param name="queryJson">查询参数</param>
  118. /// <returns>返回列表Json</returns>
  119. [HttpGet]
  120. public ActionResult GetContactListJson(string queryJson)
  121. {
  122. var data = customercontactbll.GetList(queryJson);
  123. return ToJsonResult(data);
  124. }
  125. /// <summary>
  126. /// 获取联系人实体
  127. /// </summary>
  128. /// <param name="keyValue">主键值</param>
  129. /// <returns>返回对象Json</returns>
  130. [HttpGet]
  131. public ActionResult GetContactFormJson(string keyValue)
  132. {
  133. var data = customercontactbll.GetEntity(keyValue);
  134. return ToJsonResult(data);
  135. }
  136. #endregion
  137. #region 验证数据
  138. /// <summary>
  139. /// 客户名称不能重复
  140. /// </summary>
  141. /// <param name="FullName">名称</param>
  142. /// <param name="keyValue">主键</param>
  143. /// <returns></returns>
  144. [HttpGet]
  145. public ActionResult ExistFullName(string FullName, string keyValue)
  146. {
  147. bool IsOk = customerbll.ExistFullName(FullName, keyValue);
  148. return Content(IsOk.ToString());
  149. }
  150. #endregion
  151. #region 提交数据
  152. /// <summary>
  153. /// 删除客户数据
  154. /// </summary>
  155. /// <param name="keyValue">主键值</param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. [ValidateAntiForgeryToken]
  159. [AjaxOnly]
  160. [HandlerAuthorize(PermissionMode.Enforce)]
  161. public ActionResult RemoveForm(string keyValue)
  162. {
  163. customerbll.RemoveForm(keyValue);
  164. return Success("删除成功。");
  165. }
  166. /// <summary>
  167. /// 保存客户表单(新增、修改)
  168. /// </summary>
  169. /// <param name="keyValue">主键值</param>
  170. /// <param name="entity">实体对象</param>
  171. /// <returns></returns>
  172. [HttpPost]
  173. [ValidateAntiForgeryToken]
  174. [AjaxOnly]
  175. public ActionResult SaveForm(string keyValue, CustomerEntity entity)
  176. {
  177. customerbll.SaveForm(keyValue, entity);
  178. return Success("操作成功。");
  179. }
  180. /// <summary>
  181. /// 删除联系人数据
  182. /// </summary>
  183. /// <param name="keyValue">主键值</param>
  184. /// <returns></returns>
  185. [HttpPost]
  186. [ValidateAntiForgeryToken]
  187. [AjaxOnly]
  188. public ActionResult RemoveContactForm(string keyValue)
  189. {
  190. customercontactbll.RemoveForm(keyValue);
  191. return Success("删除成功。");
  192. }
  193. /// <summary>
  194. /// 保存联系人表单(新增、修改)
  195. /// </summary>
  196. /// <param name="keyValue">主键值</param>
  197. /// <param name="entity">实体对象</param>
  198. /// <returns></returns>
  199. [HttpPost]
  200. [ValidateAntiForgeryToken]
  201. [AjaxOnly]
  202. public ActionResult SaveContactForm(string keyValue, CustomerContactEntity entity)
  203. {
  204. customercontactbll.SaveForm(keyValue, entity);
  205. return Success("操作成功。");
  206. }
  207. #endregion
  208. }
  209. }