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

public partial class _changeInfo : System.Web.UI.Page
{
    MembershipUser u;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Response.Cache.SetExpires(DateTime.Now);
            if (User.Identity.Name != "")
            {
                u = Membership.GetUser(User.Identity.Name);
                (LoginView1.FindControl("Email") as TextBox).Text = u.Email;
                (LoginView1.FindControl("homepage") as TextBox).Text = Profile.homepage;
                (LoginView1.FindControl("msn") as TextBox).Text = Profile.msn;
                (LoginView1.FindControl("qq") as TextBox).Text = Profile.qq;
                (LoginView1.FindControl("city") as TextBox).Text = Profile.city;
                (LoginView1.FindControl("country") as TextBox).Text = Profile.country;
            }
        }
    }

    protected void ChangeButton_Click(object sender, EventArgs e)
    {
        u = Membership.GetUser(User.Identity.Name);
        if (u.Email != (LoginView1.FindControl("Email") as TextBox).Text)        
        {
            u.Email = (LoginView1.FindControl("Email") as TextBox).Text;
            Membership.UpdateUser(u);
        }
        Profile.homepage = (LoginView1.FindControl("homepage") as TextBox).Text;
        Profile.msn = (LoginView1.FindControl("msn") as TextBox).Text;
        Profile.qq = (LoginView1.FindControl("qq") as TextBox).Text;
        Profile.city = (LoginView1.FindControl("city") as TextBox).Text;
        Profile.country =(LoginView1.FindControl("country") as TextBox).Text;
        Profile.Save();
        Anthem.Manager.AddScriptForClientSideEval("alert('您的资料已经成功修改!')");
    }
}
