using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
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.Common;

namespace JuSNS.Web.user.friend
{
    public partial class invitemsn : JuSNS.UI.Page.UserPage
    {
        public string result = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                FindData();
                DataBind();
            }
        }

        protected void ShowErr(string MSG)
        {
            Response.Redirect("find.aspx?r=" + JuSNS.Common.Input.URLEncode(MSG) + "");
        }

        /// <summary>
        /// 查找数据
        /// </summary>
        protected void FindData()
        {
            string msnName = Request.Form["login"];
            string msnPwd = Request.Form["password"];
            if (string.IsNullOrEmpty(msnName))
                ShowErr("MSN帐号不能为空!");

            MSNConnection Msn = new MSNConnection();
            int n = Msn.Connect(msnName, msnPwd);
            switch (n)
            {
                case 1:
                    ShowErr("MSN帐号或密码错误！请重新再试");
                    break;
                case 401:
                    ShowErr("未知错误!请重新再试");
                    break;
                case 0:
                    Dictionary<string, string> Linkmans = Msn.Linkmans;
                    foreach (KeyValuePair<string, string> kvp in Linkmans)
                    {
                        result += "<div class=\"content\">";
                        result += "<input type=\"checkbox\" name=\"TxtEmails\" value=\"" + kvp.Key + "\" checked=\"checked\" />" + kvp.Value;
                        result += " <span class=\"tshow\">(" + kvp.Key + ")</span></div>";
                    }
                    Cnt.Text = Linkmans.Count.ToString();
                    break;
            }
        }
    }
}
