using System;
using System.Data;
using System.Data.SqlClient;
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;


public partial class displayphoto : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@photoid", Request.QueryString["photoid"]);
            int albumid=(int)SqlHelper.ExecuteScalar("select albumid from photos where photoid=@photoid",p);

            SqlParameter[] p1 = new SqlParameter[1];
            p1[0] = new SqlParameter("@albumid", albumid);
            bool ispublic = bool.Parse(SqlHelper.ExecuteScalar("select ispublic from albums where albumid=@albumid", p1).ToString());
            if (!ispublic)
            {
                if (!User.Identity.IsAuthenticated)
                {
                    Response.Redirect("~/login.aspx");
                }
            }

            HyperLink1.NavigateUrl = "~/displayalbum.aspx?albumid=" + albumid.ToString();
        }
    }
    protected void FormView1_ItemCreated(object sender, EventArgs e)
    {
        Image img = (Image)FormView1.FindControl("Image1");
        if (img != null)
            img.ImageUrl = "~/getphoto.aspx?imgtype=full&photoid=" + FormView1.DataKey[0];

    }
    protected void FormView1_DataBound(object sender, EventArgs e)
    {
    }
}
