DZKJ_CustomerAccount.aspx.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using LYFZ.WeixinServers.WeiXinAPP;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. namespace LYFZ.WeixinServers.DZKJ
  10. {
  11. public partial class DZKJ_CustomerAccount : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. CommonHandler.CheckLoginJump(this);
  16. if (!IsPostBack)
  17. {
  18. if (Request.QueryString["page"] != null)
  19. {
  20. try
  21. {
  22. pageIndex = Convert.ToInt32(Request.QueryString["page"].ToString());
  23. if (pageIndex <= 0)
  24. {
  25. pageIndex = 1;
  26. }
  27. }
  28. catch { }
  29. }
  30. if (Request.QueryString["Keyword"] != null)
  31. {
  32. Keyword = Request.QueryString["Keyword"].ToString().Trim();
  33. }
  34. if (Request.QueryString["IsEnabled"] != null)
  35. {
  36. IsEnabled = Request.QueryString["IsEnabled"].ToString().Trim();
  37. }
  38. if (!String.IsNullOrEmpty(Request.QueryString["DistId"]))
  39. {
  40. DistId = Request.QueryString["DistId"].ToString().Trim();
  41. }
  42. if (Request.QueryString["PeriodOfValidity"] != null)
  43. {
  44. PeriodOfValidity = Request.QueryString["PeriodOfValidity"].ToString().Trim();
  45. }
  46. if (Request.QueryString["del"] != null && Request.QueryString["del"].ToString().Length > 0)
  47. {
  48. try
  49. {
  50. if (CommonHandler.CheckAdmin(this))
  51. {
  52. long delID = Convert.ToInt64(Request.QueryString["del"].ToString());
  53. deleteDZKJ_Customer(delID);
  54. }
  55. }
  56. catch (Exception ex)
  57. {
  58. showMsegesBox("删除失败,请重试.错误原因:" + ex.Message);
  59. }
  60. }
  61. }
  62. bindUserList();
  63. }
  64. void deleteDZKJ_Customer(long id)
  65. {
  66. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics DDTes = new WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics();
  67. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DDCustAcount = new WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount();
  68. string account = DDCustAcount.GetModel(id).Account;
  69. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics DDTeakExecStatistics = new WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics();
  70. if (DDTeakExecStatistics.Exists("Account", account) && !CommonHandler.isAdmin(this,false))
  71. {
  72. showMsegesBox("删除失败,客户已经开始使用中");
  73. }
  74. else {
  75. if (DZKJ_Dal.Delete(id))
  76. {
  77. this.Response.Redirect("DZKJ_CustomerAccount.aspx");
  78. }
  79. else
  80. {
  81. showMsegesBox("删除失败,请重试.");
  82. }
  83. }
  84. }
  85. void showMsegesBox(string msg)
  86. {
  87. Response.Write("<script>alert('" + msg + "');document.location='DZKJ_CustomerAccount.aspx';</script>"); return;
  88. }
  89. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DZKJ_Dal = new WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount();
  90. public System.Text.StringBuilder CustomerAccountListHtmlTb = new System.Text.StringBuilder();
  91. string Keyword = String.Empty;
  92. string IsEnabled = String.Empty;
  93. string PeriodOfValidity = String.Empty;
  94. string DistId = String.Empty;
  95. int pageIndex = 1;
  96. int pageSize = Global.PageSize;
  97. public string PagingInfoHtml = String.Empty;
  98. void bindUserList()
  99. {
  100. string whereStr = String.Empty;
  101. if (!String.IsNullOrEmpty(Keyword))
  102. {
  103. whereStr = " ([Account] like '%" + Keyword + "%' or [CompanyName] like '%" + Keyword + "%' or [Contacts] like '%" + Keyword + "%' or [Telephone] like '%" + Keyword + "%' ) and ";
  104. }
  105. else if (!String.IsNullOrEmpty(IsEnabled))
  106. {
  107. whereStr = "IsEnabled=" + IsEnabled + " and ";
  108. }
  109. else if (!String.IsNullOrEmpty(PeriodOfValidity))
  110. {
  111. if (PeriodOfValidity.Trim() == "0")
  112. {
  113. whereStr = "PeriodOfValidity<'" + DateTime.Now.ToString("yyyy-MM-dd") + "' and ";
  114. }
  115. else if (PeriodOfValidity.Trim() == "1")
  116. {
  117. whereStr = "PeriodOfValidity>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and ";
  118. }
  119. }
  120. if (!String.IsNullOrEmpty(DistId)){
  121. whereStr += "DistributorID=" + DistId;
  122. }else{
  123. whereStr += CommonHandler.isAdmin(this, false) ? "1=1" : "DistributorID=" + CommonHandler.GetAdminUser(this).ID;
  124. }
  125. int pageCount = 0;
  126. int sumCount = DZKJ_Dal.GetRecordCount(whereStr);
  127. DataSet ds = DZKJ_Dal.GetListByPage(whereStr, "RegistrationTime desc", pageIndex, pageSize, ref pageCount);
  128. pageIndex = pageIndex > pageCount ? pageCount : pageIndex;
  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. CustomerAccountListHtmlTb.Append("<tr>"
  135. + "<td>" + GetIsEnabled(Convert.ToInt32(row["IsEnabled"].ToString())) + "</td>"
  136. + "<td>" + row["CompanyName"].ToString() + "</td>"
  137. + "<td><a href=\"/DZKJ/DZKJTaskOneView.aspx?viewtype=1&ExecDate=" + DateTime.Now.ToString("yyyy-MM-dd") + "&Account=" + row["Account"].ToString() + "\">" + row["Account"].ToString() + "</a></td>"
  138. + "<td>" + row["Contacts"].ToString() + "</td>"
  139. + "<td>" + GetSex(Convert.ToInt32(row["Sex"].ToString())) + "</td>"
  140. + "<td>" + row["Telephone"].ToString() + "</td>"
  141. + "<td>" + Convert.ToDateTime(row["PeriodOfValidity"]).ToString("yyyy-MM-dd") + "</td>"
  142. + "<td>" + row["StartSimulatorCount"].ToString() + "</td>"
  143. + "<td>" + Convert.ToDateTime(row["RegistrationTime"]).ToString("yyyy-MM-dd HH:mm:ss") + "</td>"
  144. + "<td>" + GetLatestLoginTime(row["LatestLoginTime"]) + "</td>"
  145. + "<td>"
  146. + "<a href=\"DZKJ_AddCustomer.aspx?eid=" + row["id"].ToString() + "\" style=\"margin-right:10px;\"><i class=\"fa fa-pencil\"></i></a>"
  147. + "<a href=\"#myModal\" role=\"button\" onclick=\"setModalValue('" + row["id"].ToString() + "')\" data-toggle=\"modal\"><i class=\"fa fa-remove\"></i></a>"
  148. + "</td>"
  149. + " </tr>");
  150. }
  151. }
  152. string GetLatestLoginTime(object LatestLoginTime)
  153. {
  154. try
  155. {
  156. DateTime tempt;
  157. if (LatestLoginTime != null)
  158. {
  159. if (DateTime.TryParse(LatestLoginTime.ToString(), out tempt))
  160. {
  161. return tempt.ToString("yyyy-MM-dd HH:mm:ss");
  162. }
  163. else
  164. {
  165. return "";
  166. }
  167. }
  168. }
  169. catch { }
  170. return "";
  171. }
  172. string GetIsEnabled(int IsEnabled)
  173. {
  174. if (IsEnabled == 1)
  175. {
  176. return "正常";
  177. }
  178. else
  179. {
  180. return "已禁用";
  181. }
  182. }
  183. string GetSex(int sex)
  184. {
  185. if (sex == 1)
  186. {
  187. return "男";
  188. }
  189. else
  190. {
  191. return "女";
  192. }
  193. }
  194. /*
  195. * <th>状态</th>
  196. <th>企业名</th>
  197. <th>帐号</th>
  198. <th>联系人</th>
  199. <th>性别</th>
  200. <th>联系电话</th>
  201. <th>有效期</th>
  202. <th>模拟器个数</th>
  203. <th>注册时间</th>
  204. <th>最新登录IP</th>
  205. <th>最新登录时间</th>
  206. * [ID]
  207. ,[Account]
  208. ,[Password]
  209. ,[Contacts]
  210. ,[Telephone]
  211. ,[Sex]
  212. ,[CompanyName]
  213. ,[CompanyAddress]
  214. ,[PeriodOfValidity]
  215. ,[StartSimulatorCount]
  216. ,[HardwareCode]
  217. ,[IP]
  218. ,[RegistrationTime]
  219. ,[LatestLoginTime]
  220. ,[IsEnabled] */
  221. }
  222. }