//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("manager_list", MXEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.wx_userweixin wBll = new BLL.wx_userweixin(); int sucCount = 0; int errorCount = 0; BLL.manager bll = new BLL.manager(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { int hasNum = wBll.GetUserWxNumCount(id); if (hasNum > 0) { JscriptMsg("该用户已经添加微信号,无法删除!", "back", "Error"); return; } } } for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { int hasNum = wBll.GetUserWxNumCount(id); if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除用户" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("manager_list.aspx", "keywords={0}", this.keywords), "Success"); }
/// <summary> /// 判断已经有的微信个数,若超过,则不能添加 /// </summary> /// <returns>超过为true,未超过为false</returns> private bool IsChaoGuoWxNum() { Model.manager manager = GetAdminInfo(); int hasNum = bll.GetUserWxNumCount(manager.id); if (hasNum >= manager.wxNum) { JscriptMsg("你只能添加" + manager.wxNum + "个微信公众帐号,若想添加多个,请联系管理员!", "myweixinlist.aspx", "Error"); return(true); } else { return(false); } }
/// <summary> /// 判断已经有的微信个数,若超过,则不能添加 /// </summary> /// <returns>超过为true,未超过为false</returns> private bool IsChaoGuoWxNum() { BLL.manager mBll = new BLL.manager(); Model.manager manager = mBll.GetModel(this.uid); int hasNum = bll.GetUserWxNumCount(this.uid); if (hasNum >= manager.wxNum) { JscriptMsg("该用户只能添加" + manager.wxNum + "个微信公众帐号,若想添加多个,请联系管理员!", "weixin_list.aspx?id=" + uid, "Error"); return(true); } else { return(false); } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("manager_list", MXEnums.ActionEnum.Delete.ToString()); //检查权限 bool isAgent = false; BLL.wx_agent_info aBll = new BLL.wx_agent_info(); Model.manager adminEntity = GetAdminInfo(); //取得管理员信息 Model.wx_agent_info agent = new Model.wx_agent_info(); if (adminEntity.agentLevel > 0) { isAgent = true; agent = aBll.GetAgentModel(adminEntity.id); } BLL.wx_userweixin wBll = new BLL.wx_userweixin(); int sucCount = 0; int errorCount = 0; BLL.manager bll = new BLL.manager(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { int hasNum = wBll.GetUserWxNumCount(id); if (hasNum > 0) { JscriptMsg("该用户已经添加微信号,无法删除!", "back", "Error"); return; } } } for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { int hasNum = wBll.GetUserWxNumCount(id); if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } if (isAgent && agent != null) { //如果为代理商,则将起用户数量减掉 agent.userNum -= sucCount; aBll.Update(agent); } AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除用户" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("manager_list.aspx", "keywords={0}", this.keywords), "Success"); }