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;
using System.Data.SqlClient;

public partial class WTOSYSadmin_vipmag_vipedit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["WtoRightName"] == null)
        {
            Response.Redirect("~/SYSADMIN/main/error.aspx?err=非法登陆!或系统超时，请刷新后重新登录");
        }
        if (!IsPostBack)
        {
            SqlConnection conn = CDatabase.wtoconn();
            conn.Open();
            SqlCommand smd = new SqlCommand("select * from UserAdmin where id=" + Request.QueryString["id"], conn);
            SqlDataReader sdr = smd.ExecuteReader();
            sdr.Read();
            if (sdr["IsOpen"].ToString().Trim() == "open")
            {
                this.open.Checked = true;
            }
            else
            {
                this.close.Checked = true;
            }
            this.linkpeaplo.Text = sdr["linkpeaplo"].ToString();
            this.UserName.Text = sdr["UserName"].ToString();
            this.UserPwd.Text = sdr["UserPwd"].ToString();
            this.Email.Text = sdr["Email"].ToString();
            this.id.Text = sdr["id"].ToString();
            sdr.Close();
            conn.Close();
        }
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        string isopen = "";

        if (this.id.Text != "10000001")
        {
            if (this.open.Checked)
            {
                isopen = "open";
            }
            else
            {
                isopen = "close";
            }
        }
        else
        {
            isopen = "open";
        }
        string sql = "update  UserAdmin set linkpeaplo='" + this.linkpeaplo.Text + "',UserName='" + this.UserName.Text + "',UserPwd='" + this.UserPwd.Text + "',Email='" + this.Email.Text + "',addtime='" + DateTime.Now.ToString() + "',isopen='"+isopen+"' where id=" + this.id.Text;
        if (Doadmin.Exec(sql))
        {
            Response.Write("<script>alert('修改成功!');location.href='SysMag.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('此次操作失败!')</script>");
        }
    }
}
