using LYFZ.WeixinServers.WeiXinAPP; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace LYFZ.WeixinServers.DZKJ { public partial class DZKJ_CustomerAccount : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { CommonHandler.CheckLoginJump(this); if (!IsPostBack) { if (Request.QueryString["page"] != null) { try { pageIndex = Convert.ToInt32(Request.QueryString["page"].ToString()); if (pageIndex <= 0) { pageIndex = 1; } } catch { } } if (Request.QueryString["Keyword"] != null) { Keyword = Request.QueryString["Keyword"].ToString().Trim(); } if (Request.QueryString["IsEnabled"] != null) { IsEnabled = Request.QueryString["IsEnabled"].ToString().Trim(); } if (!String.IsNullOrEmpty(Request.QueryString["DistId"])) { DistId = Request.QueryString["DistId"].ToString().Trim(); } if (Request.QueryString["PeriodOfValidity"] != null) { PeriodOfValidity = Request.QueryString["PeriodOfValidity"].ToString().Trim(); } if (Request.QueryString["del"] != null && Request.QueryString["del"].ToString().Length > 0) { try { if (CommonHandler.CheckAdmin(this)) { long delID = Convert.ToInt64(Request.QueryString["del"].ToString()); deleteDZKJ_Customer(delID); } } catch (Exception ex) { showMsegesBox("删除失败,请重试.错误原因:" + ex.Message); } } } bindUserList(); } void deleteDZKJ_Customer(long id) { LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics DDTes = new WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics(); LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DDCustAcount = new WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount(); string account = DDCustAcount.GetModel(id).Account; LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics DDTeakExecStatistics = new WeixinServiceDate.DAL.DAL_DZKJ_TaskExecutionStatistics(); if (DDTeakExecStatistics.Exists("Account", account) && !CommonHandler.isAdmin(this,false)) { showMsegesBox("删除失败,客户已经开始使用中"); } else { if (DZKJ_Dal.Delete(id)) { this.Response.Redirect("DZKJ_CustomerAccount.aspx"); } else { showMsegesBox("删除失败,请重试."); } } } void showMsegesBox(string msg) { Response.Write(""); return; } LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount DZKJ_Dal = new WeixinServiceDate.DAL.DAL_DZKJ_CustomerAccount(); public System.Text.StringBuilder CustomerAccountListHtmlTb = new System.Text.StringBuilder(); string Keyword = String.Empty; string IsEnabled = String.Empty; string PeriodOfValidity = String.Empty; string DistId = String.Empty; int pageIndex = 1; int pageSize = Global.PageSize; public string PagingInfoHtml = String.Empty; void bindUserList() { string whereStr = String.Empty; if (!String.IsNullOrEmpty(Keyword)) { whereStr = " ([Account] like '%" + Keyword + "%' or [CompanyName] like '%" + Keyword + "%' or [Contacts] like '%" + Keyword + "%' or [Telephone] like '%" + Keyword + "%' ) and "; } else if (!String.IsNullOrEmpty(IsEnabled)) { whereStr = "IsEnabled=" + IsEnabled + " and "; } else if (!String.IsNullOrEmpty(PeriodOfValidity)) { if (PeriodOfValidity.Trim() == "0") { whereStr = "PeriodOfValidity<'" + DateTime.Now.ToString("yyyy-MM-dd") + "' and "; } else if (PeriodOfValidity.Trim() == "1") { whereStr = "PeriodOfValidity>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and "; } } if (!String.IsNullOrEmpty(DistId)){ whereStr += "DistributorID=" + DistId; }else{ whereStr += CommonHandler.isAdmin(this, false) ? "1=1" : "DistributorID=" + CommonHandler.GetAdminUser(this).ID; } int pageCount = 0; int sumCount = DZKJ_Dal.GetRecordCount(whereStr); DataSet ds = DZKJ_Dal.GetListByPage(whereStr, "RegistrationTime desc", pageIndex, pageSize, ref pageCount); pageIndex = pageIndex > pageCount ? pageCount : pageIndex; string countInfo = "当前" + pageIndex.ToString() + "/" + pageCount.ToString() + "页|" + pageSize.ToString() + "条/页|共" + sumCount.ToString() + "条记录"; PagingInfoHtml = LYFZ.WXLibrary.PageTabList.GetPagingInfo_Web(pageCount, pageIndex, countInfo); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = ds.Tables[0].Rows[i]; CustomerAccountListHtmlTb.Append("" + "" + GetIsEnabled(Convert.ToInt32(row["IsEnabled"].ToString())) + "" + "" + row["CompanyName"].ToString() + "" + "" + row["Account"].ToString() + "" + "" + row["Contacts"].ToString() + "" + "" + GetSex(Convert.ToInt32(row["Sex"].ToString())) + "" + "" + row["Telephone"].ToString() + "" + "" + Convert.ToDateTime(row["PeriodOfValidity"]).ToString("yyyy-MM-dd") + "" + "" + row["StartSimulatorCount"].ToString() + "" + "" + Convert.ToDateTime(row["RegistrationTime"]).ToString("yyyy-MM-dd HH:mm:ss") + "" + "" + GetLatestLoginTime(row["LatestLoginTime"]) + "" + "" + "" + "" + "" + " "); } } string GetLatestLoginTime(object LatestLoginTime) { try { DateTime tempt; if (LatestLoginTime != null) { if (DateTime.TryParse(LatestLoginTime.ToString(), out tempt)) { return tempt.ToString("yyyy-MM-dd HH:mm:ss"); } else { return ""; } } } catch { } return ""; } string GetIsEnabled(int IsEnabled) { if (IsEnabled == 1) { return "正常"; } else { return "已禁用"; } } string GetSex(int sex) { if (sex == 1) { return "男"; } else { return "女"; } } /* * 状态 企业名 帐号 联系人 性别 联系电话 有效期 模拟器个数 注册时间 最新登录IP 最新登录时间 * [ID] ,[Account] ,[Password] ,[Contacts] ,[Telephone] ,[Sex] ,[CompanyName] ,[CompanyAddress] ,[PeriodOfValidity] ,[StartSimulatorCount] ,[HardwareCode] ,[IP] ,[RegistrationTime] ,[LatestLoginTime] ,[IsEnabled] */ } }