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

public partial class webXabara_money_bankEdit : System.Web.UI.Page
{
    admin a = new admin();
    javasrcipt js = new javasrcipt();
    sqlServer sql = new sqlServer();

    protected void Page_Load(object sender, EventArgs e)
    {
        a.check("|bank|");

        if (!IsPostBack)
        {
            DataTable dt = sql.getDataTable("select * from payBank where id=" + xabara.isNum(Request["id"]).ToString());
            if (dt.Rows.Count > 0)
            {
                bankName.Text = dt.Rows[0]["bankName"].ToString().Trim();
                bankAdd.Text = dt.Rows[0]["bankAdd"].ToString().Trim();
                bankOpen.Text = dt.Rows[0]["bankUserName"].ToString().Trim();
                bankAccount.Text = dt.Rows[0]["bankAccount"].ToString().Trim();
            }
            else
            {
                js.div(false, "", "text", "您的操作有误！", 350, 150, "bankList.aspx", "goto");
            }

            dt.Dispose();
        }
    }

    protected void sysSet_Click(object sender, EventArgs e)
    {
        DataTable dt = sql.getDataTable("select * from payBank where bankAccount='" + bankAccount.Text.Trim() + "' and bankName='" + bankName.Text.Trim() + "' and id<>" + xabara.isNum(Request["id"]).ToString());
        if (dt.Rows.Count > 0)
        {
            js.div(false, "", "text", "您已添加过此银行帐号！", 350, 150, "bankList.aspx", "goto");
        }
        else
        {
            string strDim = "@bankName,@bankAdd,@bankUserName,@bankAccount,@adminID,@postDate,@postIP";
            string[] strValue = new string[7];
            strValue[0] = bankName.Text.Trim();
            strValue[1] = bankAdd.Text.Trim();
            strValue[2] = bankOpen.Text.Trim();
            strValue[3] = bankAccount.Text.Trim();
            strValue[4] = a.uid;
            strValue[5] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            strValue[6] = new ipAddress().address();

            sql.log(a.uid, "admin", "修改银行帐号");

            string returnStr = sql.update("payBank", strDim, strValue, "id=" + xabara.isNum(Request["id"]).ToString());
            js.div(false, "", "text", returnStr, 350, 150, "bankList.aspx", "goto");
        }
        dt.Dispose();
    }
}