Exemplo n.º 1
0
        private bool DoAdd()
        {
         
            var adminEntity = GetAdminInfo(); //取得管理员信息
            var agent = new AgentInfo();
            bool isAgent = false;
            if (adminEntity.AgentLevel < 0)
            {
                return false;
            }
            if (adminEntity.AgentLevel > 0)
            {
                agent = aBll.GetAgentModel(adminEntity.Id);
                isAgent = true;
                if (agent.RemainMony < agent.AgentPrice)
                {
                    JscriptMsg("余额不足,请联系管理员充值!", "", "Error");
                    return false;
                }
            }
            else
            { 
                
            }
            //int oldMaxNum = MyCommFun.Str2Int(hidOldMaxNum.Value);
            int newMaxNum = MyCommFun.Str2Int(ddlMaxNum.SelectedItem.Value);
            
            //地区
            string prov = ddlProvince.SelectedItem.Value;
            string city = ddlCity.SelectedItem.Value;
            string dist = txtArea.Text.Trim();

            var model = new ManagerInfo();
            var bll = new ManagerInfoService();
            model.RoleId = int.Parse(ddlRoleId.SelectedValue);
            model.RoleType = new ManagerRoleService().GetModel(model.RoleId).RoleType;
            if (cbIsLock.Checked == true)
            {
                model.IsLock = 0;
            }
            else
            {
                model.IsLock = 1;
            }
            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return false;
            }
            model.UserName = txtUserName.Text.Trim();
            //获得6位的salt加密字符串
            model.Salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.Password = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.Salt);
            model.RealName = txtRealName.Text.Trim();
            model.Telephone = txtTelephone.Text.Trim();
            model.Email = txtEmail.Text.Trim();
            model.AddTime = DateTime.Now;
            model.WxNum = newMaxNum;
            model.AgentId = GetAdminInfo().Id;
            model.QQ = txtqq.Text;
            model.Email = txtEmail.Text;
            model.RegIp = MXRequest.GetIP();
            model.Province = prov;
            model.City = city;
            model.County = dist;
            model.SortId=MyCommFun.Obj2Int(txtSortid.Text);
            model.AgentLevel = -1;
            model.Remark = txtRemark.Text;
            model.AgentId = adminEntity.Id;
            int addId = bll.Add(model);
         
            if (addId>0 && isAgent)
            {
                int xfjine = newMaxNum * agent.AgentPrice.Value;//消费金额

                //是代理商 :缴费,扣除金额,增加消费记录
                agent.RemainMony -= xfjine;
                agent.UserNum += 1;
                agent.WcodeNum += newMaxNum;
                bool updateRet= aBll.Update(agent);

                if (updateRet)
                {
                    var bBll = new WXManagerBillService(new ManagerBillRepository());
                    var bill = new ManagerBillInfo
                    {
                        BillMoney = xfjine,
                        ManagerId = agent.ManagerId,
                        OperPersonId = agent.ManagerId,
                        OperDate = DateTime.Now,
                        BillUsed = "开通1个用户" + model.UserName + "的" + newMaxNum + "个微帐号",
                        MoneyType = "扣减"
                    };
                    int addBillId= bBll.Add(bill);
                   
                }
                else
                {
                    bll.Delete(addId);
                    addId = 0;
                }
            }
             
            if (addId> 0)
            {

                AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加用户:" + model.UserName); //记录日志
                return true;
            }
            return false;
        }
Exemplo n.º 2
0
        private bool DoEdit(int _id)
        {
            int oldMaxNum = MyCommFun.Str2Int(hidOldMaxNum.Value);
            int newMaxNum = MyCommFun.Str2Int(ddlMaxNum.SelectedItem.Value);
            int addNewNum = newMaxNum - oldMaxNum; //新增的帐号
         

            var adminEntity = GetAdminInfo(); //取得管理员信息
            var agent = new AgentInfo();
            bool isAgent = false;
            if (adminEntity.AgentLevel < 0)
            {
                return false;
            }
            if (adminEntity.AgentLevel > 0)
            {
                agent = aBll.GetAgentModel(adminEntity.Id);
                isAgent = true;
                if (agent.RemainMony < agent.AgentPrice * addNewNum)
                {
                    JscriptMsg("余额不足,请联系管理员充值!", "", "Error");
                    return false;
                }
            }
            

            //地区
            string prov = ddlProvince.SelectedItem.Value;
            string city = ddlCity.SelectedItem.Value;
            string dist = txtArea.Text.Trim();


            bool result = false;
            var bll = new ManagerInfoService();
            var model = bll.GetModel(_id);

            model.RoleId = int.Parse(ddlRoleId.SelectedValue);
            model.RoleType = new ManagerRoleService().GetModel(model.RoleId).RoleType;
            if (cbIsLock.Checked == true)
            {
                model.IsLock = 0;
            }
            else
            {
                model.IsLock = 1;
            }
            //判断密码是否更改
            if (txtPassword.Text.Trim() != "")
            {
                //获取用户已生成的salt作为密钥加密
                model.Password = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.Salt);
            }
            model.RealName = txtRealName.Text.Trim();
            model.Telephone = txtTelephone.Text.Trim();
            model.Email = txtEmail.Text.Trim();
            model.WxNum = int.Parse(ddlMaxNum.SelectedItem.Value);

            model.QQ = txtqq.Text;
            model.Email = txtEmail.Text;
          
            model.Province = prov;
            model.City = city;
            model.County = dist;
            model.SortId = MyCommFun.Str2Int(txtSortid.Text);
            model.Remark = txtRemark.Text;
          
            bool updateRet = bll.Update(model);

            if (updateRet && isAgent && addNewNum > 0)
            {
                int xfjine = addNewNum * agent.AgentPrice.Value;//消费金额

                agent.RemainMony -= xfjine;
                agent.WcodeNum += newMaxNum;

                bool updateRet2 = aBll.Update(agent);
                if (updateRet2)
                {
                    var bBll = new WXManagerBillService(new ManagerBillRepository());
                    var bill = new ManagerBillInfo
                    {
                        BillMoney = xfjine,
                        ManagerId = agent.ManagerId,
                        OperPersonId = agent.ManagerId,
                        OperDate = DateTime.Now,
                        BillUsed = "原用户" + model.UserName + "新增了" + addNewNum + "个微帐号",
                        MoneyType = "扣减"
                    };
                    int addBillId = bBll.Add(bill);

                }
                else
                {
                    bll.Delete(_id);
                    updateRet=false;
                }
 
            }

            if (updateRet)
            {
                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改用户:" + model.UserName); //记录日志
                result = true;
            }

            return result;
        }
Exemplo n.º 3
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");
        }