郑许地铁

MobileDataController.cs 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 ZXDT.CallCenter.Model;
  10. using ZXDT.CallCenter.MVCWeb.Models;
  11. /// <summary>
  12. /// 话务-值班号码
  13. /// </summary>
  14. namespace ZXDT.CallCenter.MVCWeb.Controllers
  15. {
  16. public class MobileDataController : BaseController
  17. {
  18. BLL.T_Sys_MobileData busdutyNumber = new BLL.T_Sys_MobileData();
  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. [ActionName("GetListData")]
  36. public string GetListData(string phone="")
  37. {
  38. DataTable dt = null;
  39. int count = 0;
  40. //if (string.IsNullOrEmpty(phone))
  41. //{
  42. // return Success("成功", dt, count);
  43. //}
  44. AddAction("T_Sys_MobileData", "page", "查询列表", string.Format(" 获取前50条 phone={0}", phone));
  45. string strWhere = " 1=1 ";
  46. if (!string.IsNullOrEmpty(phone))
  47. {
  48. strWhere += string.Format(" and F_MobileNum like '%{0}%'", phone);
  49. }
  50. dt = busdutyNumber.GetList(50,strWhere, " F_MobileNum ASC").Tables[0];
  51. if (dt != null && dt.Rows.Count > 0)
  52. {
  53. count = dt.Rows.Count;
  54. }
  55. return Success("成功", dt, count);
  56. }
  57. [ActionName("GetData")]
  58. public string GettData(string id = "")
  59. {
  60. if(id.Length!=7)
  61. return Error("请输入ID");
  62. Model.T_Sys_MobileData model = busdutyNumber.GetModel(id);
  63. return Success("成功", model, 1);
  64. }
  65. [ActionName("adddata")]
  66. public string AddData(string phone = "", string ZipCode = "",string CityDes="未知",string CardDes="未知")
  67. {
  68. string strWhere = " 1=1 ";
  69. if (string.IsNullOrEmpty(phone))
  70. {
  71. return Error("请输入号码前七位");
  72. }
  73. else if (string.IsNullOrEmpty(ZipCode))
  74. {
  75. return Error("请输入城市固话区号");
  76. }
  77. else if (phone.Length != 7)
  78. {
  79. return Error("请输入号码前七位");
  80. }
  81. else
  82. {
  83. strWhere += string.Format(" and F_MobileNum='{0}'", phone);
  84. }
  85. int count = busdutyNumber.GetRecordCount(strWhere);
  86. if (count > 0)
  87. {
  88. return Error("号码已存在");
  89. }
  90. Model.T_Sys_MobileData model = new T_Sys_MobileData();
  91. model.F_MobileNum = phone;
  92. model.F_ZipCode = ZipCode;
  93. model.F_CityDes = CityDes;
  94. model.F_CardDes = CardDes;
  95. if (busdutyNumber.Add(model))
  96. {
  97. AddAction("T_Sys_MobileData", phone, "新增电话库", phone);
  98. return Success("成功", model);
  99. }
  100. else
  101. return Error("失败");
  102. }
  103. [ActionName("deletedata")]
  104. public string DeleteData( string phone)
  105. {
  106. if (string.IsNullOrEmpty(phone))
  107. {
  108. return Error("请输入ID");
  109. }
  110. Model.T_Sys_MobileData model = busdutyNumber.GetModel(phone);
  111. if (busdutyNumber.Delete(phone))
  112. {
  113. AddAction("T_Sys_MobileData", phone.ToMyString(), "删除电话库",JsonConvert.SerializeObject(model),"敏感信息");
  114. AddAction("T_Sys_MobileData", phone.ToMyString(), "删除电话库");
  115. return Success("删除成功");
  116. }
  117. else
  118. return Error("失败");
  119. }
  120. }
  121. }