using System;
using System.Text;
using System.Data;
using System.Collections.Generic;
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.Common;
using JuSNS.UI.Control;
using JuSNS.Model;

namespace JuSNS.Web.home.album
{
    public partial class photos : JuSNS.UI.Page.UserPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Photoslist();
        }

        protected void Photoslist()
        {
            //需要判断隐私 
            int ReCount, PgCount;
            int PageIndex = 1;
            DataTable dt = null;
            string r = Request.QueryString["r"];
            if (JuSNS.Common.Input.IsInteger(r))
            {
                dt = JuSNS.Home.UtilPage.GetPage("photos_ID_aspx", PageIndex, 30, out ReCount, out PgCount, new SqlConditionInfo("@UserID", Convert.ToInt32(r), TypeCode.Int32));
            }
            else
            {
                dt = JuSNS.Home.UtilPage.GetPage("photos_aspx", PageIndex, 30, out ReCount, out PgCount, new SqlConditionInfo("@UserID", this.UserID, TypeCode.Int32));
            }
            DataTable data = new DataTable();
            data.Columns.Add("d", typeof(string));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                StringBuilder sb = new StringBuilder();
                DataRow dr = data.NewRow();
                sb.Append("<li>");
                sb.Append("<div><a href=\"../../user/" + JuSNS.Common.Public.URLWrite("", "r", dt.Rows[i]["UploadUser"].ToString()) + "\">" + dt.Rows[i]["UserName"].ToString() + "</a><br /><span class=\"time\">上传于 " + JuSNS.Common.Public.getTimeEXPINSpan(Convert.ToDateTime(dt.Rows[i]["PostTime"].ToString())) + "</span></div>");
                sb.Append("<div><a href=\"photoview.aspx?r[0]=" + dt.Rows[i]["PhotoID"].ToString() + "\"><img src=\"" + this.GetSmallPic(dt.Rows[i]["FilePath"].ToString(),0) + "\" /></a></div>");
                sb.Append("</li>");
                dr["d"] = sb.ToString();
                data.Rows.Add(dr);
            }
            this.PhotosList.Visible = true;
            this.PhotosList.DataSource = data;
            this.PhotosList.DataBind();
        }
    }
}
