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 JuSNS.Home;
using JuSNS.Model;
using JuSNS.Common;

namespace JuSNS.Web.home.ibase
{
	public partial class msn : JuSNS.UI.Page.UserPage
	{
        JuSNS.Home.MyInfo ac = new JuSNS.Home.MyInfo();
        JuSNS.Home.User us = new JuSNS.Home.User();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getInfo();
            }

            try
            {
                string type = Request.Form["Type"];
                int n = 0;

                if (type == "MSN")
                {
                    if (Request.Form["Value"] != "")
                    {
                        if (ac.getMSNGtalk(Request.Form["Value"], 0) > 0)//判断MSN是否重复
                        {
                            Response.Write("2");
                            Response.End();

                        }
                    }
                    n = ac.UpdateMSNGtalk(Request.Form["Value"], this.UserID, 0);
                }
                else if (type == "Gtalk")
                {
                    if (Request.Form["Value"] != "")
                    {
                        if (ac.getMSNGtalk(Request.Form["Value"], 1) > 0)//判断MSN是否重复
                        {
                            Response.Write("3");
                            Response.End();

                        }
                    }
                    n = ac.UpdateMSNGtalk(Request.Form["Value"], this.UserID, 1);
                }

                if (n == 1)
                {
                    Response.Write("1");
                    Response.End();
                }
            }
            catch
            {

            }
        }

        /// <summary>
        /// 初始化
        /// </summary>
        public void getInfo()
        {
            UserBasicInfo ub = us.GetUserBasic(this.UserID);
            this.txtMSN.Value = ub.MSN;
            this.txtGtalk.Value = ub.GTalk;
        }
	}
}
