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;
            string endDate    = this.txtEndTime.Text;

            Model.wx_userweixin model = bll.GetModel(_id);

            model.wxName     = wxName;
            model.wxId       = wxId;
            model.weixinCode = weixinCode;
            model.headerpic  = headerpic;
            model.apiurl     = apiurl;
            model.wxToken    = wxToken;
            model.AppId      = AppId;
            model.AppSecret  = AppSecret;
            model.endDate    = DateTime.Parse(endDate);
            bool ret = bll.Update(model);

            if (ret)
            {
                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "【管理】修改微信号,主键为:" + model.id + ",微信号为:" + model.weixinCode); //记录日志
                return(true);
            }
            return(false);
        }
        private bool DoEdit(int _id)
        {
            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          = MyCommFun.getWebSite() + "/api/weixin/api.aspx?apiid=" + _id;
            string wxToken         = this.txtwxToken.Text;
            string AppId           = this.txtAppId.Text;
            string AppSecret       = this.txtAppSecret.Text;
            bool   noChangeAppProp = true;

            Model.wx_userweixin model = bll.GetModel(_id);

            model.wxName     = wxName;
            model.wxId       = wxId;
            model.weixinCode = weixinCode;
            model.headerpic  = headerpic;
            model.apiurl     = apiurl;
            model.wxToken    = wxToken;

            if (model.AppId != AppId || model.AppSecret != AppSecret)
            {
                //改变了
                noChangeAppProp = false;
            }
            model.AppId     = AppId;
            model.AppSecret = AppSecret;

            bool ret = bll.Update(model);

            if (ret)
            {
                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改微信号,主键为:" + model.id + ",微信号为:" + model.weixinCode); //记录日志
                if (!noChangeAppProp)
                {                                                                                                       //更新access_token值
                    UpdateAccess_Token(_id, AppId, AppSecret);
                }
                return(true);
            }
            return(false);
        }
Exemple #3
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;

            Model.wx_userweixin model = bll.GetModel(_id);

            model.wxName     = wxName;
            model.wxId       = wxId;
            model.weixinCode = weixinCode;
            model.headerpic  = headerpic;
            model.apiurl     = apiurl;
            model.wxToken    = wxToken;
            model.AppId      = AppId;
            model.AppSecret  = AppSecret;
            model.wStatus    = MyCommFun.Str2Int(rblwStatus.SelectedItem.Value);

            int addYear = MyCommFun.Str2Int(ddlMaxNum.SelectedItem.Value);

            if (addYear > 0)
            {
                if (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)
                        {
                            BLL.wx_manager_bill   bBll = new BLL.wx_manager_bill();
                            Model.wx_manager_bill bill = new Model.wx_manager_bill();
                            bill.billMoney    = xfjine;
                            bill.managerId    = agent.managerId;
                            bill.operPersonId = agent.managerId;
                            bill.operDate     = DateTime.Now;
                            bill.billUsed     = "微帐号" + model.wxName + "增加时间" + addYear + "年";
                            bill.moneyType    = "扣减";
                            int addBillId = bBll.Add(bill);
                        }
                        else
                        {
                            JscriptMsg("数据执行错误,请重新操作!", "", "Error");
                            return(false);
                        }
                    }
                }
            }

            bool ret = bll.Update(model);

            if (ret)
            {
                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "【管理】修改微信号,主键为:" + model.id + ",微信号为:" + model.weixinCode); //记录日志
                return(true);
            }
            return(false);
        }