CustomerList.aspx.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace LYFZ.WeixinServers.WeiXinAPP
  9. {
  10. public partial class CustomerList : System.Web.UI.Page
  11. {
  12. LYFZ.WeixinServiceDate.DAL.DAL_CustomerInterfaces cusDal = new WeixinServiceDate.DAL.DAL_CustomerInterfaces();
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. CommonHandler.CheckLoginJump(this);
  16. if (!IsPostBack) {
  17. if (Request.QueryString["page"] != null)
  18. {
  19. try
  20. {
  21. pageIndex = Convert.ToInt32(Request.QueryString["page"].ToString());
  22. if (pageIndex <= 0) {
  23. pageIndex = 1;
  24. }
  25. }
  26. catch { }
  27. }
  28. if (Request.QueryString["Keyword"] != null)
  29. {
  30. Keyword = Request.QueryString["Keyword"].ToString().Trim();
  31. }
  32. if (Request.QueryString["del"] != null && Request.QueryString["del"].ToString().Length > 0)
  33. {
  34. try
  35. {
  36. if (CommonHandler.CheckAdmin(this))
  37. {
  38. string[] tempQuerys = Request.QueryString["del"].ToString().Split('@');
  39. int delID = Convert.ToInt32(tempQuerys[0]);
  40. if (cusDal.Delete(delID))
  41. {
  42. if (tempQuerys.Length == 2)
  43. {
  44. Global.DeleteCustInfo(tempQuerys[1]);
  45. }
  46. showMsegesBox("已删除成功");
  47. }
  48. }
  49. }
  50. catch (Exception ex)
  51. {
  52. showMsegesBox("删除失败,请重试.错误原因:" + ex.Message);
  53. }
  54. }
  55. else if (Request.QueryString["delwx"] != null && Request.QueryString["delwx"].ToString()=="1")
  56. {
  57. LYFZ.Helper.SQLHelper.ExecuteSql("delete [tb_CustomerInterfaces] where [JMGDomainName] like '%????%' or [JMGDomainName] not in (SELECT [JMGDomainName] FROM [tb_authorization_info])");
  58. showMsegesBox("已清除无效数据");
  59. }
  60. else if (Request.QueryString["eid"] != null)
  61. {
  62. if (CommonHandler.CheckAdmin(this))
  63. {
  64. int eid = Convert.ToInt32(Request.QueryString["eid"].ToString());
  65. SetISEnabled(eid);
  66. }
  67. }
  68. else
  69. {
  70. bindCustomerList();
  71. }
  72. }
  73. }
  74. void SetISEnabled(int eID)
  75. {
  76. try
  77. {
  78. LYFZ.WeixinServiceDate.Model.Model_CustomerInterfaces cusModel = cusDal.GetModel(eID);
  79. if (cusModel.ID > 0)
  80. {
  81. string msg = "";
  82. if (cusModel.ISEnabled == 1)
  83. {
  84. cusModel.ISEnabled = 0;
  85. msg = "禁用";
  86. }
  87. else
  88. {
  89. cusModel.ISEnabled = 1;
  90. msg = "启用";
  91. }
  92. if (cusDal.Update(cusModel))
  93. {
  94. Global.UpdateCustInfo(cusModel.JMGDomainName, cusModel);
  95. showMsegesBox(msg + "成功");
  96. }
  97. else
  98. {
  99. showMsegesBox(msg + "失败");
  100. }
  101. }
  102. else {
  103. showMsegesBox("要设置的记录不存在,请刷新后重试");
  104. }
  105. }
  106. catch(Exception ex) {
  107. showMsegesBox("操作失败,原因:"+ex.Message);
  108. }
  109. }
  110. void showMsegesBox(string msg)
  111. {
  112. Response.Write("<script>alert('" + msg + "');document.location='CustomerList.aspx';</script>"); return;
  113. }
  114. string Keyword = "";
  115. public string PagingInfoHtml = "";
  116. int pageIndex = 1;
  117. int pageSize = Global.PageSize;
  118. public System.Text.StringBuilder CustomerListHtmlTb = new System.Text.StringBuilder();
  119. void bindCustomerList()
  120. {
  121. string whereStr = "";
  122. if (Keyword.Length > 0) {
  123. whereStr = " [JMGDomainName] like '%" + Keyword + "%' or [ShellDomainName] like '%" + Keyword + "%' or [IPAddress] like '%" + Keyword + "%' or [CompanyName] like '%" + Keyword + "%' ";
  124. }
  125. int pageCount = 0;
  126. int sumCount = cusDal.GetRecordCount(whereStr); ;
  127. DataSet ds = cusDal.GetListByPage(whereStr, "id desc", pageIndex, pageSize, ref pageCount);
  128. if (pageIndex > pageCount) {pageIndex= pageCount; }
  129. string countInfo = "当前" + pageIndex.ToString() + "/" + pageCount.ToString() + "页|" + pageSize.ToString() + "条/页|共" + sumCount.ToString() + "条记录";
  130. PagingInfoHtml = LYFZ.WXLibrary.PageTabList.GetPagingInfo_Web(pageCount, pageIndex, countInfo);
  131. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  132. {
  133. DataRow row = ds.Tables[0].Rows[i];
  134. string ISEnabled = "禁用";
  135. string iconName = "lock";
  136. if (row["ISEnabled"].ToString() == "1")
  137. {
  138. ISEnabled = "启用";
  139. iconName = "ok";
  140. }
  141. string thisUrl = row["ShellDomainName"].ToString();
  142. CustomerListHtmlTb.Append("<tr>"
  143. + " <td>" + (i + 1).ToString() + "</td>"
  144. + " <td>" + row["CompanyName"].ToString() + "</td>"
  145. + " <td>" + row["JMGDomainName"].ToString() + "</td>"
  146. + " <td>" + row["ShellDomainName"].ToString() + "</td>"
  147. + " <td>" + row["AppSecret"].ToString() + "</td>"
  148. + " <td>" + row["CallFrequency"].ToString() + "</td>"
  149. + "<td>" + Convert.ToDateTime(row["RefreshTime"]).ToString("yyyy-MM-dd HH:mm") + "</td>"
  150. + "<td>" + Convert.ToDateTime(row["CreateTime"]).ToString("yyyy-MM-dd HH:mm") + "</td>"
  151. + " <td>" + ISEnabled + "</td>"
  152. + " <td>"
  153. + "<a target=\"_blank\" href=\"" + thisUrl + "\" style=\"margin-right:10px;\"><i class=\"icon-home\"></i></a>"
  154. + "<a href=\"CustomerList.aspx?eid=" + row["id"].ToString() + "\" style=\"margin-right:10px;\"><i class=\"icon-" + iconName + "\"></i></a>"
  155. + "<a href=\"#myModal\" role=\"button\" onclick=\"setModalValue('" + row["id"].ToString() + "@" + row["JMGDomainName"].ToString() + "')\" data-toggle=\"modal\"><i class=\"icon-remove\"></i></a>"
  156. + "</td>"
  157. + " </tr>");
  158. }
  159. }
  160. }
  161. }