/// <summary> /// 填充數据 /// </summary> protected void BindData(string id) { lgk.Model.tb_systemBank bank = bankBLL.GetModel(int.Parse(id)); if (bank.BankType == 1) { textBankName.Value = bank.BankName; textBankAccount.Value = bank.BankAccount; textBankAccountUser.Value = bank.BankAccountUser; tr1.Visible = true; tr2.Visible = false; tr3.Visible = false; } else if (bank.BankType == 2) { textRichesNum.Value = bank.BankAccount; textRichesName.Value = bank.BankAccountUser; tr1.Visible = false; tr2.Visible = true; tr3.Visible = false; } else if (bank.BankType == 3) { textPayNum.Value = bank.BankAccount; textPayName.Value = bank.BankAccountUser; tr1.Visible = false; tr2.Visible = false; tr3.Visible = true; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(lgk.Model.tb_systemBank model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_systemBank set IsMor=0 ; insert into tb_systemBank("); strSql.Append("BankName,BankAddress,BankAccount,BankAccountUser,BankType,IsMor)"); strSql.Append(" values ("); strSql.Append("@BankName,@BankAddress,@BankAccount,@BankAccountUser,@BankType,@IsMor)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@BankName", SqlDbType.VarChar, 50), new SqlParameter("@BankAddress", SqlDbType.VarChar, 50), new SqlParameter("@BankAccount", SqlDbType.VarChar, 50), new SqlParameter("@BankAccountUser", SqlDbType.VarChar, 50), new SqlParameter("@BankType", SqlDbType.Int, 4), new SqlParameter("@IsMor", SqlDbType.Int, 4) }; parameters[0].Value = model.BankName; parameters[1].Value = model.BankAddress; parameters[2].Value = model.BankAccount; parameters[3].Value = model.BankAccountUser; parameters[4].Value = model.BankType; parameters[5].Value = model.IsMor; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 支付宝 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkbtnPay_Click(object sender, EventArgs e) { if (textPayNum.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('支付宝號不能为空!');", true); return; } if (textPayName.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('支付宝名稱不能为空!');", true); return; } lgk.Model.tb_systemBank bank = bankBLL.GetModel(getIntRequest("id")); bank.BankAccount = textPayNum.Value.Trim(); bank.BankAccountUser = textPayName.Value.Trim(); if (bankBLL.Update(bank)) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('编辑成功!');window.location.href='AccountSet.aspx'", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('設置失败!');", true); return; } }
/// <summary> /// 操作 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void rpBank_ItemCommand(object source, RepeaterCommandEventArgs e) { int ID = int.Parse(e.CommandArgument.ToString()); lgk.Model.tb_systemBank bank = bankBLL.GetModel(ID); if (bank == null) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('该记录已删除!');", true); return; } if (bank.Flag == 1) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('该记录已删除!');", true); return; } if (e.CommandName == "modify") { Response.Redirect("BankEdit.aspx?ID=" + ID); } if (e.CommandName == "del") { if (bankBLL.Cancel(Convert.ToInt32(ID))) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除成功!');", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除失败!');", true); } } BindData(); }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_systemBank GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,BankName,BankAddress,BankAccount,BankAccountUser,BankType,Flag from tb_systemBank "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; lgk.Model.tb_systemBank model = new lgk.Model.tb_systemBank(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["BankName"] != null && ds.Tables[0].Rows[0]["BankName"].ToString() != "") { model.BankName = ds.Tables[0].Rows[0]["BankName"].ToString(); } if (ds.Tables[0].Rows[0]["BankAddress"] != null && ds.Tables[0].Rows[0]["BankAddress"].ToString() != "") { model.BankAddress = ds.Tables[0].Rows[0]["BankAddress"].ToString(); } if (ds.Tables[0].Rows[0]["BankAccount"] != null && ds.Tables[0].Rows[0]["BankAccount"].ToString() != "") { model.BankAccount = ds.Tables[0].Rows[0]["BankAccount"].ToString(); } if (ds.Tables[0].Rows[0]["BankAccountUser"] != null && ds.Tables[0].Rows[0]["BankAccountUser"].ToString() != "") { model.BankAccountUser = ds.Tables[0].Rows[0]["BankAccountUser"].ToString(); } if (ds.Tables[0].Rows[0]["BankType"] != null && ds.Tables[0].Rows[0]["BankType"].ToString() != "") { model.BankType = int.Parse(ds.Tables[0].Rows[0]["BankType"].ToString()); } if (ds.Tables[0].Rows[0]["Flag"] != null && ds.Tables[0].Rows[0]["Flag"].ToString() != "") { model.Flag = int.Parse(ds.Tables[0].Rows[0]["Flag"].ToString()); } return(model); } else { return(null); } }
private void bind() { lgk.Model.tb_systemBank bank = bankBLL.GetModel(getIntRequest("ID")); if (bank != null) { textBankName.Value = bank.BankName; textBankAccount.Value = bank.BankAccount; textBankAccountUser.Value = bank.BankAccountUser; tr1.Visible = true; tr2.Visible = false; tr3.Visible = false; } }
/// <summary> /// 銀行賬戶 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (textBankName.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('银行名称不能为空!');", true); return; } if (textBankAccount.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('银行账号不能为空!');", true); return; } if (textBankAccountUser.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('开户名不能为空!');", true); return; } lgk.Model.tb_systemBank bank = bankBLL.GetModel(getIntRequest("ID")); if (bank != null) { bank.BankAccount = textBankAccount.Value.Trim(); bank.BankName = textBankName.Value.Trim(); bank.BankAccountUser = textBankAccountUser.Value.Trim(); if (bankBLL.Update(bank)) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置成功!');window.location.href='AccountSet.aspx';", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置失败!');", true); return; } } else { bank = new lgk.Model.tb_systemBank(); bank.BankAccount = textBankAccount.Value.Trim(); bank.BankName = textBankName.Value.Trim(); bank.BankAccountUser = textBankAccountUser.Value.Trim(); if (bankBLL.Add(bank) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置成功!');window.location.href='AccountSet.aspx';", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置失败!');", true); return; } } }
/// <summary> /// 插入表1:銀行,2:微信,3:支付宝 /// </summary> /// <param name="type"></param> protected void BuidModel(int type) { string BankAccount = ""; string BankName = ""; string BankAccountUser = ""; string BankAddress = ""; //switch (type) //{ // case 1: // BankAccount = textBankAccount.Value; // BankName = textBankName.Value; // BankAccountUser = textBankAccountUser.Value; // break; //} BankAccount = textBankAccount.Value; BankName = textBankName.Value; BankAccountUser = textBankAccountUser.Value; BankAddress = textBankAddress.Value; lgk.Model.tb_systemBank bank = new lgk.Model.tb_systemBank(); bank.BankAccount = BankAccount; bank.BankName = BankName; bank.BankAccountUser = BankAccountUser; bank.BankType = type; bank.IsMor = 0; bank.BankAddress = BankAddress; //if (dryRedio.Checked == true) //{ // UpdateAccountDefault(); // bank.IsMor = Convert.ToInt32(dryRedio.Value); //} //if (nodryRedio.Checked == true) //{ // bank.IsMor = Convert.ToInt32(nodryRedio.Value); //} if (bankBLL.Add(bank) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置成功!');window.location.href='AccountSet.aspx';", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('设置失败!');", true); return; } }
protected void dropBank_SelectedIndexChanged(object sender, EventArgs e) { string strName = dropBank.SelectedValue; if (strName == "0") { lblBankAccount.Text = ""; lblBankAccountUser.Text = ""; } else { lgk.Model.tb_systemBank model = bankBLL.GetModel(strName.ToInt()); lblBankAccount.Text = model.BankAccount; lblBankAccountUser.Text = model.BankAccountUser; } }
/// <summary> /// 获得数据列表 /// </summary> public lgk.Model.tb_systemBank strGetModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,BankName,BankAddress,BankAccount,BankAccountUser,BankType "); strSql.Append(" FROM tb_systemBank "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } lgk.Model.tb_systemBank model = new lgk.Model.tb_systemBank(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["BankName"] != null && ds.Tables[0].Rows[0]["BankName"].ToString() != "") { model.BankName = ds.Tables[0].Rows[0]["BankName"].ToString(); } if (ds.Tables[0].Rows[0]["BankAddress"] != null && ds.Tables[0].Rows[0]["BankAddress"].ToString() != "") { model.BankAddress = ds.Tables[0].Rows[0]["BankAddress"].ToString(); } if (ds.Tables[0].Rows[0]["BankAccount"] != null && ds.Tables[0].Rows[0]["BankAccount"].ToString() != "") { model.BankAccount = ds.Tables[0].Rows[0]["BankAccount"].ToString(); } if (ds.Tables[0].Rows[0]["BankAccountUser"] != null && ds.Tables[0].Rows[0]["BankAccountUser"].ToString() != "") { model.BankAccountUser = ds.Tables[0].Rows[0]["BankAccountUser"].ToString(); } if (ds.Tables[0].Rows[0]["BankType"] != null && ds.Tables[0].Rows[0]["BankType"].ToString() != "") { model.BankType = int.Parse(ds.Tables[0].Rows[0]["BankType"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_systemBank GetModel() { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,BankName,BankAddress,BankAccount,BankAccountUser,BankType from tb_systemBank "); strSql.Append(" order by ID desc"); lgk.Model.tb_systemBank model = new lgk.Model.tb_systemBank(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["BankName"] != null && ds.Tables[0].Rows[0]["BankName"].ToString() != "") { model.BankName = ds.Tables[0].Rows[0]["BankName"].ToString(); } if (ds.Tables[0].Rows[0]["BankAddress"] != null && ds.Tables[0].Rows[0]["BankAddress"].ToString() != "") { model.BankAddress = ds.Tables[0].Rows[0]["BankAddress"].ToString(); } if (ds.Tables[0].Rows[0]["BankAccount"] != null && ds.Tables[0].Rows[0]["BankAccount"].ToString() != "") { model.BankAccount = ds.Tables[0].Rows[0]["BankAccount"].ToString(); } if (ds.Tables[0].Rows[0]["BankAccountUser"] != null && ds.Tables[0].Rows[0]["BankAccountUser"].ToString() != "") { model.BankAccountUser = ds.Tables[0].Rows[0]["BankAccountUser"].ToString(); } if (ds.Tables[0].Rows[0]["BankType"] != null && ds.Tables[0].Rows[0]["BankType"].ToString() != "") { model.BankType = int.Parse(ds.Tables[0].Rows[0]["BankType"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(lgk.Model.tb_systemBank model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_systemBank set "); strSql.Append("BankName=@BankName,"); strSql.Append("BankAddress=@BankAddress,"); strSql.Append("BankAccount=@BankAccount,"); strSql.Append("BankAccountUser=@BankAccountUser,"); strSql.Append("BankType=@BankType,"); strSql.Append("Flag=@Flag"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@BankName", SqlDbType.VarChar, 50), new SqlParameter("@BankAddress", SqlDbType.VarChar, 50), new SqlParameter("@BankAccount", SqlDbType.VarChar, 50), new SqlParameter("@BankAccountUser", SqlDbType.VarChar, 50), new SqlParameter("@BankType", SqlDbType.Int, 4), new SqlParameter("@Flag", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.BankName; parameters[1].Value = model.BankAddress; parameters[2].Value = model.BankAccount; parameters[3].Value = model.BankAccountUser; parameters[4].Value = model.BankType; parameters[5].Value = model.Flag; parameters[6].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }