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

public partial class member_UserInfo_MyAccount : nspBase.MemberBasePge
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckCookies())
        {
            if (!IsPostBack)
            {
                UserBind();
            }
        }
        else
        {
            Response.Redirect("~/login/login.aspx", true);
        }
    }
    ///**************************************************
    /// <summary>
    /// depiction：实现对用户的绑定
    /// </summary>
    /// <param name="<参数名称>">
    /// UserID 通过Session得到
    /// <参数说明></param>
    /// <returns>
    ///<对方法返回值的说明，该说明必须明确说明返回的值代表什么含义>
    /// </returns>
    ///Writer：作者中文名
    ///Create Date：<方法创建日期，格式：YYYY-MM-DD>
    ///**************************************************

    public void UserBind()
    {
        int UserID = Convert.ToInt32(GetCookie("UserID"));
        IUserInfo RUser = new RUserInfo();
        TUserInfo TUser = RUser.GateItem(UserID);       
        txtlinkName.Text = TUser.LinkName;
        radlSex.SelectedValue = TUser.Sex;
        txtDepartment.Text = TUser.Department;
        txtPosition.Text = TUser.Position;
        txtTel_International.Text = TUser.Tel_International;
        txtTel_DistrictNumber.Text = TUser.Tel_DistrictNumber;
        txtTel_Telephone.Text = TUser.Tel_Telephone;
        txtTel_Ext.Text = TUser.Tel_Ext; 
        txtFax_International.Text=TUser.Fax_International;
        txtFax_DistrictNumber.Text = TUser.Fax_DistrictNumber;
        txtFax_Telephone.Text = TUser.Fax_Telephone;
        txtFax_Ext.Text = TUser.Fax_Ext;
        txtMobilePhone.Text = TUser.MobilePhone;
        txtEmail.Text = TUser.Email;
        txtQQ.Text = TUser.QQ;
        txtMSN.Text = TUser.MSN;
        
    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
       try
        {
            string userName = GetCookie("LoginName");
            int UserID = Convert.ToInt32(GetCookie("UserID"));
            TUserInfo TUser = new TUserInfo();
            TUser.UserID = UserID;
            TUser.LinkName = this.txtlinkName.Text;
            TUser.Sex = this.radlSex.SelectedValue.ToString();
            TUser.Department = this.txtDepartment.Text;
            TUser.Position = this.txtPosition.Text;
            TUser.Tel_International = this.txtTel_International.Text;
            TUser.Tel_DistrictNumber = this.txtTel_DistrictNumber.Text;
            TUser.Tel_Telephone = this.txtTel_Telephone.Text;
            TUser.Tel_Ext=this.txtTel_Ext.Text;
            TUser.Fax_International = this.txtFax_International.Text;
            TUser.Fax_DistrictNumber = this.txtFax_DistrictNumber.Text;
            TUser.Fax_Telephone = this.txtFax_Telephone.Text;
            TUser.Fax_Ext = this.txtFax_Ext.Text;
            TUser.MobilePhone = this.txtMobilePhone.Text;
            TUser.Email = this.txtEmail.Text;
            TUser.QQ = this.txtQQ.Text;
            TUser.MSN = this.txtMSN.Text;

            IUserInfo RUser = new RUserInfo();
            RUser.UpdateLinkMan(TUser);
            ShowMessage("您的注册信息已修改成功！","UserInfo/LinkManInfo.aspx");
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message);
        }
    }
   
}
