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;

namespace JuSNS.Web.home.friend
{
    public partial class group : JuSNS.UI.Page.UserPage
    {
        JuSNS.Home.Friend frd = new JuSNS.Home.Friend();
        protected void Page_Load(object sender, EventArgs e)
        {
            string a = Request.QueryString["a"];
            if (a != string.Empty && a != null)
            {
                string id = Request.QueryString["id"];
                switch (a)
                {
                    case "del":
                        frd.DelFriendClass(Convert.ToInt32(id), UserID);
                        this.Panel1.Visible = true;
                        break;
                    case "add":
                        this.Panel2.Visible = true;
                        break;
                    case "addserr":
                        this.Panel3.Visible = true;
                        break;
                    case "addsucc":
                        this.Panel4.Visible = true;
                        break;
                }
            }
            string list = string.Empty;
            IDataReader dr = frd.GetFriendClass(UserID);
            while (dr.Read())
            {
                list += "<div class=\"content nl\"><label class=\"labelnone w200\">&bull; " + dr["CName"].ToString() + "[" + dr["FCount"].ToString() + "]</label>¡¾<a href=\"javascript:;\" onclick=\"delf('" + dr["ID"].ToString() + "'," + dr["FCount"].ToString() + ")\">É¾³ý</a>¡¿</div>";
            }
            dr.Close();
            this.Friendgroup.InnerHtml = list;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string CName = this.CName.Text;
            if (CName.Length<2)
            {
                Response.Redirect("group.aspx?a=addserr");
            }
            frd.AddFriendClass(CName, UserID);
            Response.Redirect("group.aspx?a=addsucc");
        }
    }
}
