private void BindData() { //获取当前绑定卡总数 ISysUserBankService userbankService = IoC.Resolve <ISysUserBankService>(); var bindCount = userbankService.Where(c => c.UserId == CookUserInfo.Id).Count(); if (bindCount >= 5) { Response.Write("<script>alert('error');</script>"); Response.End(); return; } meBindNum.Text = bindCount.ToString(); ISysBankType bankType = IoC.Resolve <ISysBankType>(); var banks = bankType.SelectAllBankType();//获取银行信息 foreach (var item in banks) { if (item.BankDesc == "zfb" || item.BankDesc == "cft") { continue; } drpBanks.Items.Add(new ListItem(item.BankName, item.Id + "_" + item.IsShowZhiHang)); } if (!string.IsNullOrEmpty(Request.Params["drpBanks"])) { drpBanks.SelectedValue = Request.Params["drpBanks"]; } //获取省 var provinces = bankType.SelectAllProvinces(); this.drpPro.DataTextField = "ProvinceName"; this.drpPro.DataValueField = "ProvinceID"; this.drpPro.DataSource = provinces; this.drpPro.DataBind(); bool ispro = !string.IsNullOrEmpty(Request.Params["drpPro"]); if (ispro) { this.drpPro.SelectedValue = Request.Params["drpPro"]; } if (provinces.Count > 0 || ispro) { int proid = ispro ? Convert.ToInt32(Request.Params["drpPro"]) : provinces.FirstOrDefault().ProvinceID; BindCitys(bankType, proid); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtZjPwd.Text.Trim())) { Response.End(); return; } //验证资金密码 ISysUserBalanceService userBalanceService = IoC.Resolve <ISysUserBalanceService>(); if (!userBalanceService.VdUserBalancePwd(CookUserInfo.Id, this.txtZjPwd.Text.Trim())) { //验证失败 Alert("资金密码验证失败!"); return; } var bank = new SysUserBank { BankNo = opsNo.Text, BankId = Convert.ToInt32(ViewState["drpBanks"].ToString().Split('_')[0]), BankOwner = opsname.Text, Branch = opszhihang.Text, CityId = Convert.ToInt32(ViewState["drpCity"]), IsDelete = false, OccDate = DateTime.Now, ProvinceId = Convert.ToInt32(ViewState["drpPro"]), UserId = this.CookUserInfo.Id }; ISysUserBankService userBanks = IoC.Resolve <ISysUserBankService>(); //验证是否存在同样的银行卡号 if (userBanks.Where(c => c.BankNo == bank.BankNo).FirstOrDefault() != null) { Alert("银行卡号已经被绑定,请确认是否输入正确!", "", 3); return; } //验证开户姓名是否一致 var userBindBanks = userBanks.GetUserBanks(this.CookUserInfo.Id); var firstBindCard = userBindBanks.FirstOrDefault(); bool isCompled = false; if (firstBindCard == null) { isCompled = true; } else { //验证是否存在同一银行,的卡 if (firstBindCard.BankOwner != bank.BankOwner) { BackParam += "&at=nb"; Response.Redirect("/Mobile/user/ConfirmBindCardNum.aspx?" + BackParam); //Alert("一个账户只能绑定同一个开户人姓名的银行卡!"); //ClientScript.RegisterStartupScript(this.GetType(),"_down_key","<script>$('#bankback').click();</script>",true); return; } if (userBindBanks.Where(x => x.BankId == bank.BankId).FirstOrDefault() != null) { BackParam += "&at=cb"; Response.Redirect("/Mobile/user/ConfirmBindCardNum.aspx?" + BackParam); //Alert("同一个银行只允许绑定一张卡!"); //ClientScript.RegisterStartupScript(this.GetType(), "_down_key", "<script>$('#bankback').click();</script>", true); return; } } if (userBanks.CreateBank(bank)) { Response.Write("<script>parent.window.location.href = '/Mobile/user/BindBankCard.aspx?dt=dt';</script>"); } else { Alert("绑定银行卡失败,请稍后重试!"); } }