using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Account_BankInfo : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            BindPage();
        }
    }
    /// <summary>
    /// 绑定页面信息
    /// </summary>
    public void BindPage()
    {
        if (!string.IsNullOrEmpty(Request["bid"]))
        {
            DataSet ds = SqlHelper.GetDataSet("SELECT BankName FROM tabA_Account_Bank WHERE BankID=" + ConvertHelper.GetInteger(Request["bid"]) + " AND State=1", "constring");
            if (ds.Tables[0].Rows.Count > 0)
            {
                txtBankName.Text = Convert.ToString(ds.Tables[0].Rows[0]["BankName"]);//银行名称
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Request["bid"] != null)//修改银行
        {
            int flag = SqlHelper.Operation("UPDATE tabA_Account_Bank SET BankName='" + txtBankName.Text.Trim() + "' WHERE BankID=" + ConvertHelper.GetInteger(Request["bid"]) + "", "constring");
            if (flag > 0)
            {
                Response.Redirect("BankList.aspx");
            }
            else
            {
                ScriptHelper.AlertMessage(this.Page, "修改失败，请联系管理员！");
            }
        }
        else//添加银行
        {
            int flag = SqlHelper.Operation("INSERT INTO tabA_Account_Bank(BankName,CreateTime) VALUES('" + txtBankName.Text.Trim() + "','" + System.DateTime.Now + "')", "constring");
            if (flag > 0)
            {
                Response.Redirect("BankList.aspx");
            }
            else
            {
                ScriptHelper.AlertMessage(this.Page, "添加失败，请联系管理员！");
            }
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)//取消事件
    {
        Response.Redirect("BankList.aspx");
    }
}
