Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bll         = new AppInfoService();
            aBll        = new WXAgentService(new AgentRepository());
            adminEntity = GetAdminInfo(); //取得管理员信息
            agent       = aBll.GetAgentModel(adminEntity.Id);
            if (!Page.IsPostBack)
            {
                int id = 0;

                if (!int.TryParse(Request.QueryString["id"] as string, out id))
                {
                    JscriptMsg("传输参数不正确!", "back", "Error");
                    return;
                }
                if (!bll.Exists(id))
                {
                    JscriptMsg("记录不存在或已被删除!", "back", "Error");
                    return;
                }
                returnPage = "wxcodemgr.aspx";
                //如果是从微用户管理里来的,还得判断下
                if (MyCommFun.QueryString("fpage").Trim().Length > 0 && MyCommFun.RequestInt("uid") > 0)
                {
                    returnPage = "weixin_list.aspx?id=" + MyCommFun.RequestInt("uid");
                }
                ShowInfo(id);
            }
        }
Exemplo n.º 2
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("manager_list", MXEnums.ActionEnum.Delete.ToString()); //检查权限

            bool isAgent     = false;
            var  aBll        = new WXAgentService(new AgentRepository());
            var  adminEntity = GetAdminInfo(); //取得管理员信息
            var  agent       = new AgentInfo();

            if (adminEntity.AgentLevel > 0)
            {
                isAgent = true;
                agent   = aBll.GetAgentModel(adminEntity.Id);
            }

            var wBll       = new AppInfoService();
            int sucCount   = 0;
            int errorCount = 0;

            var bll = new ManagerInfoService();

            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");
        }