private bool DoAdd() { var check = context.li_bank_accounts.FirstOrDefault(q => q.owner == userId && q.account == txtAccount.Text.Trim()); //检测账户是否重复 if (check != null) { JscriptMsg("银行账户重复!", "", "Error"); return(false); } var model = new li_bank_accounts { owner = userId, bank = txtBank.Text.Trim(), opening_bank = txtOpeningBank.Text.Trim(), account = txtAccount.Text.Trim(), last_access_time = DateTime.Now, type = (int)Agp2pEnums.BankAccountType.Unknown, }; context.li_bank_accounts.InsertOnSubmit(model); try { context.SubmitChanges(); AddAdminLog(DTEnums.ActionEnum.Add.ToString(), lblUser.Text + " 添加银行账户: " + model.account); //记录日志 return(true); } catch (Exception) { return(false); } }
public new static string AjaxAppendCard(string cardNumber, string bankName) { var userInfo = GetUserInfoByLinq(); HttpContext.Current.Response.TrySkipIisCustomErrors = true; if (userInfo == null) { HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.Unauthorized; return("请先登录"); } // 检查用户的输入 if (!new Regex(@"^\d{16,}$").IsMatch(cardNumber)) { HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.BadRequest; return("银行卡号格式不正确"); } if (!new Regex(@"^[\u4e00-\u9fa5]+$").IsMatch(bankName)) { HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.BadRequest; return("银行名称格式不正确"); } var context = new Agp2pDataContext(); var alreadyHave = userInfo.li_bank_accounts.Any(c => c.account == cardNumber); if (alreadyHave) { HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.Conflict; return("你已经添加了卡号为 " + cardNumber + " 的银行卡,不能重复添加"); } if (3 <= userInfo.li_bank_accounts.Count) { HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.BadRequest; return("最多只能添加 3 张银行卡"); } //查询该客户是否已经在丰付绑定了银行卡 var user = context.dt_users.Single(u => u.id == userInfo.id); var req = new SignBankCardQueryRequest(user.id); MessageBus.Main.Publish(req); var resp = BaseRespMsg.NewInstance <SignBankCardQueryRespone>(req.SynResult); if (resp.RechargeProtocolList != null) { if (resp.CheckRechargeProtocol(bankName, cardNumber)) { var card = new li_bank_accounts { dt_users = user, account = cardNumber, bank = bankName, last_access_time = DateTime.Now, opening_bank = "", location = "", type = (int)Common.Agp2pEnums.BankAccountType.QuickPay, }; context.li_bank_accounts.InsertOnSubmit(card); context.SubmitChanges(); var msg = new UserPointMsg(user.id, user.user_name, (int)Agp2pEnums.PointEnum.BindingBank); MessageBus.Main.Publish(msg); return("保存银行卡信息成功"); } else { return("添加银行卡失败,您输入的银行卡号与丰付平台绑定的银行卡号不一致!"); } } var cardUnknown = new li_bank_accounts { dt_users = user, account = cardNumber, bank = bankName, last_access_time = DateTime.Now, opening_bank = "", location = "", type = (int)Common.Agp2pEnums.BankAccountType.Unknown, }; context.li_bank_accounts.InsertOnSubmit(cardUnknown); context.SubmitChanges(); var msg2 = new UserPointMsg(user.id, user.user_name, (int)Agp2pEnums.PointEnum.BindingBank); MessageBus.Main.Publish(msg2); return("保存银行卡信息成功"); }