using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class etwuser_updateaddress : System.Web.UI.Page
{
    public string onlines_id = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            onlines_id = Request.QueryString["id"].ToString();
        }
        if (!IsPostBack)
        {
            Data();
        }
    }
    public void Data()
    {
        this.DropDownList1.Items.Clear();
        DataSet ds = DbHelperSQL.Query("select * from etw_Address");
        if (ds.Tables[0].Rows.Count > 0)
        {
            DropDownList1.DataSource = ds.Tables[0].DefaultView;
            DropDownList1.DataTextField = "name";
            DropDownList1.DataValueField = "id";
            DropDownList1.DataBind();
            dataset(DropDownList1.SelectedValue);
        }
    }
    public void dataset(string str)
    {
        this.DropDownList2.Items.Clear();
        DataSet dss = DbHelperSQL.Query("select * from etw_country where zid=" + str + "");
        if (dss.Tables[0].Rows.Count > 0)
        {
            DropDownList2.DataSource = dss.Tables[0].DefaultView;
            DropDownList2.DataTextField = "country_cn";
            DropDownList2.DataValueField = "shortname";
            DropDownList2.DataBind();
        }
    }
    protected void DropDownList1_TextChanged(object sender, EventArgs e)
    {
        dataset(DropDownList1.SelectedValue);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (onlines_id != "")
        {
            etw.etw_onlines lead = new etw.etw_onlines();
            lead.id = Convert.ToInt32(onlines_id);
            lead.address = DropDownList2.SelectedValue + "," + DropDownList2.SelectedItem.Text;
            lead.Upaddress();
            Response.Write("<script type=text/javascript>alert('修改成功');self.opener.location.reload(); top.close(); </script>");
        }
    }
}
