地铁二期项目正式开始

DutyNumberController.cs 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using YTSoft.BaseCallCenter.Model;
  10. using YTSoft.BaseCallCenter.MVCWeb.Models;
  11. /// <summary>
  12. /// 话务-值班号码
  13. /// </summary>
  14. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  15. {
  16. public class DutyNumberController : BaseController
  17. {
  18. BLL.T_HW_DutyNumber busdutyNumber = new BLL.T_HW_DutyNumber();
  19. /// <summary>
  20. /// 值班电话列表
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult GetList()
  24. {
  25. return View();
  26. }
  27. /// <summary>
  28. /// 添加 视图
  29. /// </summary>
  30. /// <returns></returns>
  31. public ActionResult Add()
  32. {
  33. return View();
  34. }
  35. /// <summary>
  36. /// 修改 视图
  37. /// </summary>
  38. /// <returns></returns>
  39. public ActionResult Edit()
  40. {
  41. return View();
  42. }
  43. [ActionName("GetListData")]
  44. public string GetListData(string phone="",string name="",int page=0,int limit = 20)
  45. {
  46. string strWhere = " 1=1 ";
  47. if (!string.IsNullOrEmpty(phone))
  48. {
  49. strWhere += string.Format(" and F_DutyNumber='{0}'", phone);
  50. }
  51. if (!string.IsNullOrEmpty(name))
  52. {
  53. strWhere += string.Format(" and F_Remark like '%{0}%'", name);
  54. }
  55. DataTable dt = busdutyNumber.GetListByPage(strWhere,"", (page - 1)* limit + 1, page * limit).Tables[0];
  56. int count = busdutyNumber.GetRecordCount(strWhere);
  57. return Success("成功", dt, count);
  58. }
  59. [ActionName("GetData")]
  60. public string GettData(int id = 0)
  61. {
  62. if(id==0)
  63. return Error("请输入ID");
  64. Model.T_HW_DutyNumber model = busdutyNumber.GetModel(id);
  65. return Success("成功", model, 1);
  66. }
  67. [ActionName("adddata")]
  68. public string AddData(string phone = "", string name = "")
  69. {
  70. string strWhere = " 1=1 ";
  71. if (string.IsNullOrEmpty(phone))
  72. {
  73. return Error("请输入值班电话");
  74. }
  75. else {
  76. strWhere += string.Format(" and F_DutyNumber='{0}'", phone);
  77. }
  78. int count = busdutyNumber.GetRecordCount(strWhere);
  79. if (count > 0)
  80. {
  81. return Error("值班电话已存在");
  82. }
  83. Model.T_HW_DutyNumber model = new T_HW_DutyNumber();
  84. model.F_AddTime = DateTime.Now;
  85. model.F_AddUser = F_UserCode;
  86. model.F_DutyNumber = phone;
  87. model.F_Remark = name;
  88. model.F_State = 0;
  89. model.F_Group = "";
  90. model.F_Groupid = 0;
  91. int n = busdutyNumber.Add(model);
  92. if(n>0)
  93. return Success("成功", model, n);
  94. else
  95. return Error("失败");
  96. }
  97. [ActionName("editdata")]
  98. public string EditData(string phone = "", string name = "",int id=0)
  99. {
  100. string strWhere = " 1=1 ";
  101. if (string.IsNullOrEmpty(phone))
  102. {
  103. return Error("请输入值班电话");
  104. }
  105. else
  106. {
  107. strWhere += string.Format(" and F_ID!={1} and F_DutyNumber='{0}'", phone, id);
  108. }
  109. if (id==0)
  110. {
  111. return Error("请输入id");
  112. }
  113. int count = busdutyNumber.GetRecordCount(strWhere);
  114. if (count > 0)
  115. {
  116. return Error("值班电话已存在");
  117. }
  118. Model.T_HW_DutyNumber model = busdutyNumber.GetModel(id);
  119. model.F_AddTime = DateTime.Now;
  120. model.F_AddUser = F_UserCode;
  121. model.F_DutyNumber = phone;
  122. model.F_Remark = name;
  123. model.F_State = 0;
  124. model.F_Group = "";
  125. model.F_Groupid = 0;
  126. if (busdutyNumber.Update(model))
  127. return Success("成功");
  128. else
  129. return Error("失败");
  130. }
  131. [ActionName("deletedata")]
  132. public string DeleteData( int id = 0)
  133. {
  134. if (busdutyNumber.Delete(id))
  135. return Success("删除成功");
  136. else
  137. return Error("失败");
  138. }
  139. }
  140. }