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 etw_c_m_addcountry : System.Web.UI.Page
{
    public int lid = 0;
    public int zid = 0;
    public string action = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        action = Request.QueryString["action"];
        if (Request.QueryString["lid"] != null)
        {
            lid = Convert.ToInt32(Request.QueryString["lid"].ToString());
        }
        else lid = 0;
        if (!IsPostBack)
        {
            etw.etw_Address weblead = new etw.etw_Address();
            DataSet dsc = weblead.GetList(0);
            DropDownList1.DataSource = dsc.Tables[0].DefaultView;
            DropDownList1.DataTextField = "name";
            DropDownList1.DataValueField = "id";
            DropDownList1.DataBind();

            if (action == "edit")
            {
                etw.etw_country lead = new etw.etw_country();
                lead.id = lid;
                lead.GetModel();
                country_entxt.Text = lead.country_en;
                country_cntxt.Text = lead.country_cn;
                shortnametxt.Text = lead.shortname;
                zid = lead.zid;
                etw.etw_Address add = new etw.etw_Address();
                DataSet ds1 = add.GetList(zid);
                if (ds1.Tables[0].Rows.Count>0)
                {
                DropDownList1.Items[0].Text = ds1.Tables[0].Rows[0]["name"].ToString();
                DropDownList1.Items[0].Value = ds1.Tables[0].Rows[0]["id"].ToString();
                }
            }

        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        etw.etw_country lead = new etw.etw_country();
        lead.zid = Convert.ToInt32(DropDownList1.SelectedItem.Value);
        lead.country_en = country_entxt.Text.Trim();
        lead.country_cn = country_cntxt.Text.Trim();
        lead.shortname = shortnametxt.Text.Trim();
        if (action == "edit") { lead.id = lid; lead.Update(); Fun.JsAlerT("编辑成功!", "country_list.aspx"); }
        else
        {
            lead.Add();
            Fun.JsAlerT("上传成功！", "addcountry.aspx");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {

    }
}
