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); } }
protected void Page_Load(object sender, EventArgs e) { string _action = MXRequest.GetQueryString("action"); if (!string.IsNullOrEmpty(_action) && _action == MXEnums.ActionEnum.Edit.ToString()) { this.action = MXEnums.ActionEnum.Edit.ToString();//修改类型 if (!int.TryParse(Request.QueryString["id"] as string, out this.id)) { JscriptMsg("传输参数不正确!", "back", "Error"); return; } if (!new ManagerInfoService().Exists(this.id)) { JscriptMsg("记录不存在或已被删除!", "back", "Error"); return; } } if (!Page.IsPostBack) { BindDdlProvince(ddlProvince); BindDdlCity(ddlCity); ChkAdminLevel("manager_list", MXEnums.ActionEnum.View.ToString()); //检查权限 var model = GetAdminInfo(); //取得管理员信息 var agent = aBll.GetAgentModel(model.Id); //代理商信息 if (agent != null) { lblremainMony.Text = agent.RemainMony.Value.ToString(); lblagentPrice.Text = agent.AgentPrice.Value.ToString(); lblMoney.Text = agent.AgentPrice.Value.ToString(); isAgent = true; } RoleBind(ddlRoleId, model.Id); if (action == MXEnums.ActionEnum.Edit.ToString()) //修改 { ShowInfo(this.id); } } }
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); }
//批量删除 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"); }