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.gift
{
    public partial class index : JuSNS.UI.Page.UserPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string t = Request.QueryString["t"];
            string r = Request.QueryString["r"];
            string uName = Request.QueryString["uName"];
            if (JuSNS.Common.Input.IsInteger(r))
            {
                JuSNS.Home.Space sp = new JuSNS.Home.Space();
                if (sp.GetIsFriend(UserID, Convert.ToInt32(r)))
                {
                    this.giftUserID.Value = uName;
                    this.Hid_UserID.Value = r;
                }
            }
            this.giftClass.InnerHtml = GetGiftClass();
            if (t == "image")
            {   
                string uID = Request.QueryString["UserID"];
                if (JuSNS.Common.Input.IsInteger(uID))
                {
                    Response.Write("<a href=\"../../user/" + JuSNS.Common.Public.URLWrite("", "r", uID) + "\"><img style=\"width:48px;height:48px;\" src=\"" + GetHeadImage(Convert.ToInt32(uID), 1) + "\" /></a>");
                    Response.End();
                }
            }
        }

        protected string GetGiftClass()
        {
            string listSTR = string.Empty;
            JuSNS.Home.Gift gt = new JuSNS.Home.Gift();
            IDataReader dr = gt.GetGiftClass();
            string unCount="0";
            while (dr.Read())
            {
                listSTR += "<a href=\"javascript:void(0);\" onclick=\"ShowGiftList('1','" + dr["ID"].ToString() + "','n')\">" + dr["CName"].ToString() + "(" + dr["Count"] + ")</a> &nbsp; ";
                unCount=dr["Count1"].ToString();
            }
            dr.Close();
            return listSTR + "<a href=\"javascript:void(0);\" onclick=\"ShowGiftList('1','0')\",'n'>未分类(" + unCount + ")</a> &nbsp; <a href=\"javascript:void(0);\" onclick=\"ShowGiftList('1','','use')\">最受欢迎</a> &nbsp; <a href=\"javascript:void(0);\" onclick=\"ShowGiftList('1','','ph')\">价格高到低</a> &nbsp; <a href=\"javascript:void(0);\" onclick=\"ShowGiftList('1','','pl')\">价格低到高</a>";
        }
    }
}
