Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(AgentInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into wx_agent_info(");
            strSql.Append("managerId,companyName,companyInfo,agentPrice,agentPrice2,sqJine,czTotMoney,remainMony,userNum,wcodeNum,agentType,agentLevel,industry,agentArea,expiryDate,aRemark,createDate)");
            strSql.Append(" values (");
            strSql.Append("@managerId,@companyName,@companyInfo,@agentPrice,@agentPrice2,@sqJine,@czTotMoney,@remainMony,@userNum,@wcodeNum,@agentType,@agentLevel,@industry,@agentArea,@expiryDate,@aRemark,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@managerId", SqlDbType.Int,4),
                    new SqlParameter("@companyName", SqlDbType.VarChar,200),
                    new SqlParameter("@companyInfo", SqlDbType.VarChar,800),
                    new SqlParameter("@agentPrice", SqlDbType.Int,4),
                    new SqlParameter("@agentPrice2", SqlDbType.Int,4),
                    new SqlParameter("@sqJine", SqlDbType.Int,4),
                    new SqlParameter("@czTotMoney", SqlDbType.Int,4),
                    new SqlParameter("@remainMony", SqlDbType.Int,4),
                    new SqlParameter("@userNum", SqlDbType.Int,4),
                    new SqlParameter("@wcodeNum", SqlDbType.Int,4),
                    new SqlParameter("@agentType", SqlDbType.Int,4),
                    new SqlParameter("@agentLevel", SqlDbType.VarChar,50),
                    new SqlParameter("@industry", SqlDbType.VarChar,200),
                    new SqlParameter("@agentArea", SqlDbType.VarChar,300),
                    new SqlParameter("@expiryDate", SqlDbType.DateTime),
                    new SqlParameter("@aRemark", SqlDbType.VarChar,1500),
                    new SqlParameter("@createDate", SqlDbType.DateTime)};
            parameters[0].Value = model.ManagerId;
            parameters[1].Value = model.CompanyName;
            parameters[2].Value = model.CompanyInfo;
            parameters[3].Value = model.AgentPrice;
            parameters[4].Value = model.AgentPrice2;
            parameters[5].Value = model.SqJine;
            parameters[6].Value = model.CzTotalMoney;
            parameters[7].Value = model.RemainMony;
            parameters[8].Value = model.UserNum;
            parameters[9].Value = model.WcodeNum;
            parameters[10].Value = model.AgentType;
            parameters[11].Value = model.AgentLevel;
            parameters[12].Value = model.Industry;
            parameters[13].Value = model.AgentArea;
            parameters[14].Value = model.ExpiryDate;
            parameters[15].Value = model.ARemark;
            parameters[16].Value = model.CreateDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(AgentInfo model)
 {
     return this._repository.Update(model);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(AgentInfo model)
 {
     return this._repository.Add(model);
 }
Ejemplo n.º 7
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");
        }
Ejemplo n.º 8
0
        private bool DoEdit()
        {
            int _id = MyCommFun.Str2Int(lblId.Text);
            string strErr = "";
            if (this.txtwxName.Text.Trim().Length == 0)
            {
                strErr += "公众帐号名称不能为空!";
            }
            if (this.txtwxId.Text.Trim().Length == 0)
            {
                strErr += "公众号原始id不能为空!";
            }

            if (this.txtweixinCode.Text.Trim().Length == 0)
            {
                strErr += "微信号不能为空!";
            }
            if (this.txtwxToken.Text.Trim().Length == 0)
            {
                strErr += "TOKEN值不能为空!";
            }

            if (strErr != "")
            {
                JscriptMsg(strErr, "back", "Error");
                return false;
            }

            string wxName = this.txtwxName.Text;
            string wxId = this.txtwxId.Text;
            string weixinCode = this.txtweixinCode.Text;
            string headerpic = this.txtImgUrl.Text;
            string apiurl = this.txtapiurl.Text;
            string wxToken = this.txtwxToken.Text;
            string AppId = this.txtAppId.Text;
            string AppSecret = this.txtAppSecret.Text;

            var model = bll.GetAppInfo(_id);

            model.WxName = wxName;
            model.WxId = wxId;
            model.WxCode = weixinCode;
            model.Headerpic = headerpic;
            model.Apiurl = apiurl;
            model.WxToken = wxToken;
            model.AppId = AppId;
            model.AppSecret = AppSecret;

            //TODO:状态赋值不对
            //model.wStatus = MyCommFun.Str2Int( rblwStatus.SelectedItem.Value);

            int addYear = MyCommFun.Str2Int(ddlMaxNum.SelectedItem.Value);
            if (addYear > 0)
            {
                if (model.EndDate.HasValue && model.EndDate.Value >= DateTime.Now)
                {
                    //直接加
                    model.EndDate = model.EndDate.Value.AddYears(addYear);
                }
                else
                {
                    //已过期的,直接在当天开始加年份
                    model.EndDate = DateTime.Now.AddYears(addYear);
                }

                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 xfjine = addYear * agent.AgentPrice.Value;//消费金额

                        //是代理商 :缴费,扣除金额,增加消费记录
                        agent.RemainMony -= xfjine;
                        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 = "微帐号" + model.WxName + "增加时间" + addYear + "年",
                                MoneyType = "扣减"
                            };

                            bBll.Add(bill);

                        }
                        else
                        {
                            JscriptMsg("数据执行错误,请重新操作!", "", "Error");
                            return false;
                        }
                    }
                }
            }

            bool ret = bll.Update(model);

            if (ret)
            {
                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "【管理】修改微信号,主键为:" + model.Id + ",微信号为:" + model.WxCode); //记录日志
                return true;
            }
            return false;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AgentInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update wx_agent_info set ");
            strSql.Append("managerId=@managerId,");
            strSql.Append("companyName=@companyName,");
            strSql.Append("companyInfo=@companyInfo,");
            strSql.Append("agentPrice=@agentPrice,");
            strSql.Append("agentPrice2=@agentPrice2,");
            strSql.Append("sqJine=@sqJine,");
            strSql.Append("czTotMoney=@czTotMoney,");
            strSql.Append("remainMony=@remainMony,");
            strSql.Append("userNum=@userNum,");
            strSql.Append("wcodeNum=@wcodeNum,");
            strSql.Append("agentType=@agentType,");
            strSql.Append("agentLevel=@agentLevel,");
            strSql.Append("industry=@industry,");
            strSql.Append("agentArea=@agentArea,");
            strSql.Append("expiryDate=@expiryDate,");
            strSql.Append("aRemark=@aRemark,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@managerId", SqlDbType.Int,4),
                    new SqlParameter("@companyName", SqlDbType.VarChar,200),
                    new SqlParameter("@companyInfo", SqlDbType.VarChar,800),
                    new SqlParameter("@agentPrice", SqlDbType.Int,4),
                    new SqlParameter("@agentPrice2", SqlDbType.Int,4),
                    new SqlParameter("@sqJine", SqlDbType.Int,4),
                    new SqlParameter("@czTotMoney", SqlDbType.Int,4),
                    new SqlParameter("@remainMony", SqlDbType.Int,4),
                    new SqlParameter("@userNum", SqlDbType.Int,4),
                    new SqlParameter("@wcodeNum", SqlDbType.Int,4),
                    new SqlParameter("@agentType", SqlDbType.Int,4),
                    new SqlParameter("@agentLevel", SqlDbType.VarChar,50),
                    new SqlParameter("@industry", SqlDbType.VarChar,200),
                    new SqlParameter("@agentArea", SqlDbType.VarChar,300),
                    new SqlParameter("@expiryDate", SqlDbType.DateTime),
                    new SqlParameter("@aRemark", SqlDbType.VarChar,1500),
                    new SqlParameter("@createDate", SqlDbType.DateTime),
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = model.ManagerId;
            parameters[1].Value = model.CompanyName;
            parameters[2].Value = model.CompanyInfo;
            parameters[3].Value = model.AgentPrice;
            parameters[4].Value = model.AgentPrice2;
            parameters[5].Value = model.SqJine;
            parameters[6].Value = model.CzTotalMoney;
            parameters[7].Value = model.RemainMony;
            parameters[8].Value = model.UserNum;
            parameters[9].Value = model.WcodeNum;
            parameters[10].Value = model.AgentType;
            parameters[11].Value = model.AgentLevel;
            parameters[12].Value = model.Industry;
            parameters[13].Value = model.AgentArea;
            parameters[14].Value = model.ExpiryDate;
            parameters[15].Value = model.ARemark;
            parameters[16].Value = model.CreateDate;
            parameters[17].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AgentInfo GetAgentModel(int managerId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,managerId,companyName,companyInfo,agentPrice,agentPrice2,sqJine,czTotMoney,remainMony,userNum,wcodeNum,agentType,agentLevel,industry,agentArea,expiryDate,aRemark,createDate from wx_agent_info ");
            strSql.Append(" where managerId=@managerId");
            SqlParameter[] parameters = {
                    new SqlParameter("@managerId", SqlDbType.Int,4)
            };
            parameters[0].Value = managerId;

            var model = new AgentInfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
		/// 得到一个对象实体
		/// </summary>
		public AgentInfo DataRowToModel(DataRow row)
        {
            var model = new AgentInfo();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.Id = int.Parse(row["id"].ToString());
                }
                if (row["managerId"] != null && row["managerId"].ToString() != "")
                {
                    model.ManagerId = int.Parse(row["managerId"].ToString());
                }
                if (row["companyName"] != null)
                {
                    model.CompanyName = row["companyName"].ToString();
                }
                if (row["companyInfo"] != null)
                {
                    model.CompanyInfo = row["companyInfo"].ToString();
                }
                if (row["agentPrice"] != null && row["agentPrice"].ToString() != "")
                {
                    model.AgentPrice = int.Parse(row["agentPrice"].ToString());
                }
                if (row["agentPrice2"] != null && row["agentPrice2"].ToString() != "")
                {
                    model.AgentPrice2 = int.Parse(row["agentPrice2"].ToString());
                }
                if (row["sqJine"] != null && row["sqJine"].ToString() != "")
                {
                    model.SqJine = int.Parse(row["sqJine"].ToString());
                }
                if (row["czTotMoney"] != null && row["czTotMoney"].ToString() != "")
                {
                    model.CzTotalMoney = int.Parse(row["czTotMoney"].ToString());
                }
                if (row["remainMony"] != null && row["remainMony"].ToString() != "")
                {
                    model.RemainMony = int.Parse(row["remainMony"].ToString());
                }
                if (row["userNum"] != null && row["userNum"].ToString() != "")
                {
                    model.UserNum = int.Parse(row["userNum"].ToString());
                }
                if (row["wcodeNum"] != null && row["wcodeNum"].ToString() != "")
                {
                    model.WcodeNum = int.Parse(row["wcodeNum"].ToString());
                }
                if (row["agentType"] != null && row["agentType"].ToString() != "")
                {
                    model.AgentType = int.Parse(row["agentType"].ToString());
                }
                if (row["agentLevel"] != null)
                {
                    model.AgentLevel = row["agentLevel"].ToString();
                }
                if (row["industry"] != null)
                {
                    model.Industry = row["industry"].ToString();
                }
                if (row["agentArea"] != null)
                {
                    model.AgentArea = row["agentArea"].ToString();
                }
                if (row["expiryDate"] != null && row["expiryDate"].ToString() != "")
                {
                    model.ExpiryDate = DateTime.Parse(row["expiryDate"].ToString());
                }
                if (row["aRemark"] != null)
                {
                    model.ARemark = row["aRemark"].ToString();
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["createDate"].ToString());
                }
            }
            return model;
        }