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.Collections.Generic;
using JuSNS.Common;

namespace JuSNS.Web.user.friend
{
    public partial class invitegtalk : 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 GtalkName = Request.Form["login"];
            string GtalkPwd = Request.Form["password"];
            if (GtalkName == null || GtalkName.ToString() == "")
                ShowErr("Gtalk帐号不能为空！");

            Gtalk gtalk = new Gtalk();
            int n = gtalk.Connect(GtalkName + "@gmail.com", GtalkPwd);

            if (n == 1)
                ShowErr("Gtalk帐号或密码错误，请重新再试！");

            List<string> Linkmans = gtalk.Linkmans;
            foreach (string email in Linkmans)
            {
                result += "<div class=\"content\">";
                result += "<input type=\"checkbox\" name=\"TxtEmails\" value=\"" + email + "\" checked=\"checked\" />";
                result += " <span class=\"tshow\">(" + email + ")</span></div>";
            }
            Cnt.Text = Linkmans.Count.ToString();
        }
    }
}
