protected void dropOutAccount_SelectedIndexChanged(object sender, EventArgs e) { string strName = dropOutAccount.SelectedValue; if (strName == "0") { lblOutAccount.Text = ""; imgOutQRCode.ImageUrl = ""; } else { lgk.Model.tb_UserBank model = userBankBLL.GetModel(strName.ToInt()); lblOutAccount.Text = model.BankAccount; imgOutQRCode.ImageUrl = model.Bank001; if (model.Bank003 == 1) { divOutAccount.Visible = true; divOutQrCode.Visible = false; } else if (model.Bank003 == 2) { divOutAccount.Visible = true; divOutQrCode.Visible = true; } else if (model.Bank003 == 3) { divOutAccount.Visible = true; divOutQrCode.Visible = true; } } }
//取消银行卡 public bool BankCard(long userid, long bankid, out string message) { lgk.Model.tb_UserBank userbankInfo = userBankBLL.GetModel(bankid); if (userbankInfo == null) { message = "该记录已删除,无法再进行此操作!"; return(false); } if (userbankInfo.Bank004 != 0) { message = "该记录已审核,无法再进行此操作!"; return(false); } bool isDefault = userbankInfo.MasterType == 1;//是否删除的市默认的记录 if (userBankBLL.UpdateBank(Convert.ToInt64(userid), Convert.ToInt64(bankid)) > 0) { if (isDefault) { userBankBLL.AutoSetDefault(userid); //自动设置默认 } message = GetLanguage("CancellationSuccess"); //取消成功 return(true); } else { message = GetLanguage("FailedToCancel");//取消失败 return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(lgk.Model.tb_UserBank model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_UserBank set "); strSql.Append("UserID=@UserID,"); strSql.Append("BankName=@BankName,"); strSql.Append("BankAccount=@BankAccount,"); strSql.Append("BankAccountUser=@BankAccountUser,"); strSql.Append("BankAddress=@BankAddress,"); strSql.Append("MasterType=@MasterType,"); strSql.Append("Bank001=@Bank001,"); strSql.Append("Bank002=@Bank002,"); strSql.Append("Bank003=@Bank003,"); strSql.Append("Bank004=@Bank004"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.BigInt, 8), new SqlParameter("@BankName", SqlDbType.VarChar, 50), new SqlParameter("@BankAccount", SqlDbType.VarChar, 50), new SqlParameter("@BankAccountUser", SqlDbType.VarChar, 50), new SqlParameter("@BankAddress", SqlDbType.VarChar, 100), new SqlParameter("@MasterType", SqlDbType.Int, 4), new SqlParameter("@Bank001", SqlDbType.VarChar, 50), new SqlParameter("@Bank002", SqlDbType.VarChar, 50), new SqlParameter("@Bank003", SqlDbType.Int, 4), new SqlParameter("@Bank004", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.BankName; parameters[2].Value = model.BankAccount; parameters[3].Value = model.BankAccountUser; parameters[4].Value = model.BankAddress; parameters[5].Value = model.MasterType; parameters[6].Value = model.Bank001; parameters[7].Value = model.Bank002; parameters[8].Value = model.Bank003; parameters[9].Value = model.Bank004; parameters[10].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_UserBank DataRowToModel(DataRow row) { lgk.Model.tb_UserBank model = new lgk.Model.tb_UserBank(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["UserID"] != null && row["UserID"].ToString() != "") { model.UserID = long.Parse(row["UserID"].ToString()); } if (row["BankName"] != null) { model.BankName = row["BankName"].ToString(); } if (row["BankAccount"] != null) { model.BankAccount = row["BankAccount"].ToString(); } if (row["BankAccountUser"] != null) { model.BankAccountUser = row["BankAccountUser"].ToString(); } if (row["BankAddress"] != null) { model.BankAddress = row["BankAddress"].ToString(); } if (row["MasterType"] != null && row["MasterType"].ToString() != "") { model.MasterType = int.Parse(row["MasterType"].ToString()); } if (row["Bank001"] != null) { model.Bank001 = row["Bank001"].ToString(); } if (row["Bank002"] != null) { model.Bank002 = row["Bank002"].ToString(); } if (row["Bank003"] != null && row["Bank003"].ToString() != "") { model.Bank003 = int.Parse(row["Bank003"].ToString()); } if (row["Bank004"] != null && row["Bank004"].ToString() != "") { model.Bank004 = int.Parse(row["Bank004"].ToString()); } } return(model); }
//添加银行 public bool Bank(long userid, string BankName, string BankAccount, string BankUser, string Defaults, string PayPwd, string FromWhere, out string message) { if (BankValidate(userid, BankName, BankAccount, BankUser, Defaults, out message)) { lgk.Model.tb_user userModel = userBLL.GetModel(userid); if (userModel == null) { message = "用户ID不存在"; return(false); } if (FromWhere == "pc") { if (userModel.SecondPassword != PayPwd.ToUpper()) { message = "交易密码错误"; return(false); } } if (Defaults == "1") { userBankBLL.UpdateDefaults(userid); } lgk.Model.tb_UserBank userbankInfo = new lgk.Model.tb_UserBank(); userbankInfo.UserID = Convert.ToInt32(userid); userbankInfo.BankName = BankName; userbankInfo.BankAccount = BankAccount; userbankInfo.BankAccountUser = BankUser; userbankInfo.MasterType = Convert.ToInt32(Defaults); userbankInfo.Bank003 = 1; userbankInfo.Bank004 = 0; if (userBankBLL.Add(userbankInfo) > 0) { message = "添加成功"; return(true); } else { message = "添加失败"; return(false); } } else { return(false); } }
//绑定微信,支付宝 public bool AlipayWeixin(long userid, string nickname, string accounts, string states, string defaults, string picpath, string paypwd, string fromwhere, out string message) { if (AlipayValidate(userid, nickname, accounts, states, out message)) { lgk.Model.tb_user userModel = userBLL.GetModel(userid); if (GetUserCode(userid) == "") { message = "用户ID不存在"; return(false); } if (fromwhere == "pc") { if (userModel.SecondPassword != paypwd.ToUpper()) { message = "交易密码错误"; return(false); } } if (defaults == "1") { userBankBLL.UpdateDefaults(userid); } lgk.Model.tb_UserBank userbankInfo = new lgk.Model.tb_UserBank(); userbankInfo.UserID = Convert.ToInt32(userid); userbankInfo.BankName = nickname; userbankInfo.BankAccount = accounts; userbankInfo.Bank003 = Convert.ToInt32(states); userbankInfo.MasterType = defaults == "1" ? 1 : 0; userbankInfo.Bank004 = 0; userbankInfo.Bank001 = picpath; if (userBankBLL.Add(userbankInfo) > 0) { message = "绑定成功"; return(true); } else { message = "绑定失败"; return(false); } } else { return(false); } }
//钱包地址 public bool BagAddress(long userid, string accountname, string accounts, string defaults, string paypwd, string fromwhere, out string message) { if (BagAddressValidate(userid, accountname, accounts, out message)) { lgk.Model.tb_user userModel = userBLL.GetModel(userid); if (GetUserCode(userid) == "") { message = "用户ID不存在"; return(false); } if (fromwhere == "pc") { if (!ValidPassword(userModel.SecondPassword, paypwd)) { message = "交易密码错误"; return(false); } } if (defaults == "1") { userBankBLL.UpdateDefaults(userid); } lgk.Model.tb_UserBank userbankInfo = new lgk.Model.tb_UserBank(); userbankInfo.UserID = Convert.ToInt32(userid); userbankInfo.BankName = accountname; //钱包名称 userbankInfo.BankAccount = accounts; userbankInfo.Bank003 = 4; userbankInfo.MasterType = defaults == "1" ? 1 : 0; userbankInfo.Bank004 = 0; userbankInfo.Bank001 = ""; if (userBankBLL.Add(userbankInfo) > 0) { message = "绑定成功"; return(true); } else { message = "绑定失败"; return(false); } } else { return(false); } }
protected void dorpReceiveAccount_SelectedIndexChanged(object sender, EventArgs e) { string strName = dorpReceiveAccount.SelectedValue; if (strName == "0") { ltBankAccount.Text = ""; imgOutQRCode.ImageUrl = ""; } else { lgk.Model.tb_UserBank model = userBankBLL.GetModel(strName.ToInt()); ltBankAccount.Text = model.BankAccount; imgOutQRCode.ImageUrl = model.Bank001; ltBankAccountUser.Text = model.BankAccountUser; divBankAccount.Visible = false; divBankAccountUser.Visible = false; divBagAddress.Visible = false; divOutQrCode.Visible = false; divBagAddress.Visible = false; divQRNiceName.Visible = false; if (model.Bank003 == 1) //银行卡 { divBankAccount.Visible = true; divBankAccountUser.Visible = true; } else if (model.Bank003 == 2)//微信 { divQRNiceName.Visible = true; divOutQrCode.Visible = true; ltQRNiceName.Text = model.BankAccount; } else if (model.Bank003 == 3) //支付宝 { divQRNiceName.Visible = true; divOutQrCode.Visible = true; ltQRNiceName.Text = model.BankAccount; } else if (model.Bank003 == 4) //数字货币钱包 { divBagAddress.Visible = true; ltBagAddress.Text = model.BankAccount; } } }
/// <summary> /// 输入验证 /// </summary> /// <returns></returns> private bool BankValidate(long userid, string BankName, string BankAccount, string BankUser, string Defaults, out string message) { lgk.Model.tb_UserBank userbankInfo = new lgk.Model.tb_UserBank(); if (BankName.Trim() == "") { message = "请输入银行卡名称"; } if (BankAccount.Trim() == "") { message = "请输入银行账号"; } if (BankUser.Trim() == "") { message = "请输入持卡人姓名"; } message = ""; return(true); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(lgk.Model.tb_UserBank model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_UserBank("); strSql.Append("UserID,BankName,BankAccount,BankAccountUser,BankAddress,MasterType,Bank001,Bank002,Bank003,Bank004)"); strSql.Append(" values ("); strSql.Append("@UserID,@BankName,@BankAccount,@BankAccountUser,@BankAddress,@MasterType,@Bank001,@Bank002,@Bank003,@Bank004)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.BigInt, 8), new SqlParameter("@BankName", SqlDbType.VarChar, 50), new SqlParameter("@BankAccount", SqlDbType.VarChar, 50), new SqlParameter("@BankAccountUser", SqlDbType.VarChar, 50), new SqlParameter("@BankAddress", SqlDbType.VarChar, 100), new SqlParameter("@MasterType", SqlDbType.Int, 4), new SqlParameter("@Bank001", SqlDbType.VarChar, 50), new SqlParameter("@Bank002", SqlDbType.VarChar, 50), new SqlParameter("@Bank003", SqlDbType.Int, 4), new SqlParameter("@Bank004", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.BankName; parameters[2].Value = model.BankAccount; parameters[3].Value = model.BankAccountUser; parameters[4].Value = model.BankAddress; parameters[5].Value = model.MasterType; parameters[6].Value = model.Bank001; parameters[7].Value = model.Bank002; parameters[8].Value = model.Bank003; parameters[9].Value = model.Bank004; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_UserBank GetModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,UserID,BankName,BankAccount,BankAccountUser,BankAddress,MasterType,Bank001,Bank002,Bank003,Bank004 from tb_UserBank"); strSql.Append(" where " + strWhere); strSql.Append(" order by ID asc "); lgk.Model.tb_UserBank model = new lgk.Model.tb_UserBank(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_UserBank GetModel(long ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,UserID,BankName,BankAccount,BankAccountUser,BankAddress,MasterType,Bank001,Bank002,Bank003,Bank004 from tb_UserBank "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; lgk.Model.tb_UserBank model = new lgk.Model.tb_UserBank(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }