DZKJ_DistributorAccount.aspx.cs 9.1 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_DistributorAccount : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. CommonHandler.CheckLoginJump(this);
  16. if (!IsPostBack)
  17. {
  18. string Action = Request.QueryString["a"];
  19. if (Action != null)
  20. {
  21. switch (Action) {
  22. case "recharge":
  23. recharge();
  24. break;
  25. default:
  26. showMsegesBox("参数错误");
  27. break;
  28. }
  29. return;
  30. }
  31. if (Request.QueryString["page"] != null)
  32. {
  33. try
  34. {
  35. pageIndex = Convert.ToInt32(Request.QueryString["page"].ToString());
  36. if (pageIndex <= 0)
  37. {
  38. pageIndex = 1;
  39. }
  40. }
  41. catch { }
  42. }
  43. if (Request.QueryString["Keyword"] != null)
  44. {
  45. Keyword = Request.QueryString["Keyword"].ToString().Trim();
  46. }
  47. if (Request.QueryString["IsEnabled"] != null)
  48. {
  49. IsEnabled = Request.QueryString["IsEnabled"].ToString().Trim();
  50. }
  51. if (Request.QueryString["PeriodOfValidity"] != null)
  52. {
  53. PeriodOfValidity = Request.QueryString["PeriodOfValidity"].ToString().Trim();
  54. }
  55. if (Request.QueryString["del"] != null && Request.QueryString["del"].ToString().Length > 0)
  56. {
  57. try
  58. {
  59. if (CommonHandler.CheckAdmin(this))
  60. {
  61. long delID = Convert.ToInt64(Request.QueryString["del"].ToString());
  62. deleteDZKJ_Customer(delID);
  63. }
  64. }
  65. catch (Exception ex)
  66. {
  67. showMsegesBox("删除失败,请重试.错误原因:" + ex.Message);
  68. }
  69. }
  70. }
  71. bindUserList();
  72. }
  73. private void recharge()
  74. {
  75. long Id = long.Parse(Request.Form["distributorId"].Trim('\''));
  76. int Amount = int.Parse(Request.Form["amount"]);
  77. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_DistributorAccount DDzkjDistAccount = new WeixinServiceDate.DAL.DAL_DZKJ_DistributorAccount();
  78. DDzkjDistAccount.Recharge(Id, CommonHandler.GetAdminUser(this).Account, 0, Amount, "续费充值");
  79. }
  80. void deleteDZKJ_Customer(long id)
  81. {
  82. LYFZ.WeixinServiceDate.Model.Model_DZKJ_DistributorAccount MDistAccount = DZKJ_Dal.GetModel(id);
  83. if (DZKJ_Dal.Delete(id))
  84. {
  85. LYFZ.WeixinServiceDate.DAL.DAL_AdminUser DAdminUser = new WeixinServiceDate.DAL.DAL_AdminUser();
  86. DAdminUser.Delete(MDistAccount.AccountID);
  87. this.Response.Redirect("DZKJ_DistributorAccount.aspx");
  88. }
  89. else
  90. {
  91. showMsegesBox("删除失败,请重试.");
  92. }
  93. }
  94. void showMsegesBox(string msg)
  95. {
  96. Response.Write("<script>alert('" + msg + "');document.location='DZKJ_DistributorAccount.aspx';</script>"); return;
  97. }
  98. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_DistributorAccount DZKJ_Dal = new WeixinServiceDate.DAL.DAL_DZKJ_DistributorAccount();
  99. public System.Text.StringBuilder CustomerAccountListHtmlTb = new System.Text.StringBuilder();
  100. string Keyword = "";
  101. string IsEnabled = "";
  102. string PeriodOfValidity = "";
  103. int pageIndex = 1;
  104. int pageSize = Global.PageSize;
  105. public string PagingInfoHtml = "";
  106. void bindUserList()
  107. {
  108. string whereStr = String.Empty;
  109. if (String.IsNullOrWhiteSpace(Keyword))
  110. {
  111. whereStr = " [AccountId] like '%" + Keyword + "%' or [CompanyName] like '%" + Keyword + "%' or [Contacts] like '%" + Keyword + "%' or [Telephone] like '%" + Keyword + "%' ";
  112. }
  113. else if (!String.IsNullOrEmpty(IsEnabled.Trim()))
  114. {
  115. whereStr = "IsEnabled=" + IsEnabled;
  116. }
  117. int pageCount = 0;
  118. int sumCount = DZKJ_Dal.GetRecordCount(whereStr); ;
  119. DataSet ds = DZKJ_Dal.GetListByPage(whereStr, "RegistrationTime desc", pageIndex, pageSize, ref pageCount);
  120. if (pageIndex > pageCount)
  121. {
  122. pageIndex = pageCount;
  123. }
  124. string countInfo = "当前" + pageIndex.ToString() + "/" + pageCount.ToString() + "页|" + pageSize.ToString() + "条/页|共" + sumCount.ToString() + "条记录";
  125. PagingInfoHtml = LYFZ.WXLibrary.PageTabList.GetPagingInfo_Web(pageCount, pageIndex, countInfo);
  126. foreach (DataRow row in ds.Tables[0].Rows)
  127. {
  128. int DistAccountId = (int)row["AccountID"];
  129. LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DCustomerAccount = new LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount();
  130. /* 注意:DistributorID 存的是分销商的登录帐号Id 不是分销商Id*/
  131. int used = DCustomerAccount.GetUsed(DistAccountId);
  132. string distUsername = (new LYFZ.WeixinServiceDate.DAL.DAL_AdminUser()).GetModel(DistAccountId).Account;
  133. CustomerAccountListHtmlTb.AppendFormat(@"
  134. <tr>
  135. <td>{0}</td><td><a href=""/DZKJ/DZKJ_CustomerAccount.aspx?DistId={12}"">{1}</a></td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td><td>{9}</td><td>{10}</td>
  136. <td>
  137. <a href=""#ChargeModal"" class=""btn-charge"" data-distributor-id=""'{11}'"" data-toggle=""modal""><i class=""fa fa-money""></i></a>
  138. <a href=""DZKJ_AddDistributor.aspx?eid={11}""><i class=""fa fa-pencil""></i></a>
  139. <a href=""#myModal"" role=""button"" onclick=""setModalValue('{11}')"" data-toggle=""modal""><i class=""fa fa-remove""></i></a>
  140. </td>
  141. </tr>",
  142. GetIsEnabled(Convert.ToInt32(row["IsEnabled"].ToString())),
  143. row["CompanyName"],
  144. distUsername,
  145. row["Contacts"],
  146. GetSex(Convert.ToInt32(row["Sex"].ToString())),
  147. row["Telephone"],
  148. row["StartSimulatorCount"],
  149. (int)row["StartSimulatorCount"] - used,
  150. Convert.ToDateTime(row["RegistrationTime"]).ToString("yyyy-MM-dd HH:mm:ss"),
  151. row["ip"],
  152. GetLatestLoginTime(row["LatestLoginTime"]),
  153. row["id"],
  154. row["AccountId"]);
  155. }
  156. }
  157. string GetLatestLoginTime(object LatestLoginTime)
  158. {
  159. try
  160. {
  161. DateTime tempt;
  162. if (LatestLoginTime != null)
  163. {
  164. if (DateTime.TryParse(LatestLoginTime.ToString(), out tempt))
  165. {
  166. return tempt.ToString("yyyy-MM-dd HH:mm:ss");
  167. }
  168. else
  169. {
  170. return "";
  171. }
  172. }
  173. }
  174. catch { }
  175. return "";
  176. }
  177. string GetIsEnabled(int IsEnabled)
  178. {
  179. if (IsEnabled == 1)
  180. {
  181. return "正常";
  182. }
  183. else
  184. {
  185. return "已禁用";
  186. }
  187. }
  188. string GetSex(int sex)
  189. {
  190. if (sex == 1)
  191. {
  192. return "男";
  193. }
  194. else
  195. {
  196. return "女";
  197. }
  198. }
  199. /**
  200. <th>状态</th>
  201. <th>企业名</th>
  202. <th>帐号</th>
  203. <th>联系人</th>
  204. <th>性别</th>
  205. <th>联系电话</th>
  206. <th>有效期</th>
  207. <th>模拟器个数</th>
  208. <th>注册时间</th>
  209. <th>最新登录IP</th>
  210. <th>最新登录时间</th>
  211. *
  212. [ID]
  213. ,[Account]
  214. ,[Password]
  215. ,[Contacts]
  216. ,[Telephone]
  217. ,[Sex]
  218. ,[CompanyName]
  219. ,[CompanyAddress]
  220. ,[PeriodOfValidity]
  221. ,[StartSimulatorCount]
  222. ,[HardwareCode]
  223. ,[IP]
  224. ,[RegistrationTime]
  225. ,[LatestLoginTime]
  226. ,[IsEnabled]
  227. **/
  228. }
  229. }