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_personedit : System.Web.UI.Page
{
    public string userid = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie GetCookie = Request.Cookies["cook_admin"];
        if (Request.Cookies["cook_admin"] == null)
        {
            Response.Redirect("index.aspx");
        }
        if (Request.QueryString["userid"] != null)
        {
            userid = Request.QueryString["userid"].ToString();
            if (!IsPostBack)
            {
                BindDrpClass();
                etw.etw_admin lead = new etw.etw_admin();
                lead.id = Convert.ToInt32(userid);
                lead.GetModel();
                role.SelectedValue = lead.roleid.ToString();
                langlist.SelectedValue = lead.transid.ToString();
                realname.Text = Fun.Fancode(lead.realname);
                etwadminname.Text = Fun.Fancode(lead.etwadminname);
                etwadminpwd.Text = lead.etwadminpwd;
            }
        }
    }
    private void BindDrpClass()
    {
        DataSet ds = DbHelperSQL.Query("select * from etw_role order by id");
        if (ds.Tables[0].Rows.Count > 0)
        {
            role.DataSource = ds.Tables[0].DefaultView;
            role.DataTextField = "rolename";
            role.DataValueField = "id";
            role.DataBind();
        }
        DataSet ds1 = DbHelperSQL.Query("select * from etw_language order by id");
        if (ds1.Tables[0].Rows.Count > 0)
        {
            langlist.DataSource = ds1.Tables[0].DefaultView;
            langlist.DataTextField = "language";
            langlist.DataValueField = "id";
            langlist.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        etw.etw_admin lead = new etw.etw_admin();
        lead.id = Convert.ToInt32(userid);
        lead.roleid = Convert.ToInt32(role.SelectedValue);
        if (role.SelectedValue.ToString() == "3")
        {
            lead.transid = Convert.ToInt32(langlist.SelectedValue);
        }
        lead.realname = Fun.Encode(realname.Text.Trim());
        lead.etwadminname = Fun.Encode(etwadminname.Text.Trim());
        lead.etwadminpwd = etwadminpwd.Text.Trim();
        lead.Update();
        Fun.JsAlerT("修改成功", "person.aspx");
    }
}
