示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Utilities util = new Utilities();
     if (!IsPostBack)
     {
         LoadData();
     }
 }
示例#2
0
 protected internal bool checkUsersPic(int pictureID, string eid)
 {
     Utilities util = new Utilities();
     int userID = util.getID(eid);
     int counter = 0;
     db dbc = new db();
     string query = "SELECT * FROM pictures WHERE id = @PictureID AND userID = @UserID";
     dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
     dbc.cmd.Parameters.Add(new SqlParameter("UserID", userID));
     dbc.cmd.CommandText = query;
     SqlDataReader reader;
     reader = dbc.cmd.ExecuteReader();
     if (reader.Read())
     {
         counter++;
     }
     if (counter >= 1)
         return true;
     return false;
 }
示例#3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Utilities util = new Utilities();
     if (Request.QueryString["id"] != null)
     {
         if (IsPostBack)
         {
             int rank = Convert.ToInt32(Request.Form["rank"]);
             int pictureID = Convert.ToInt32(Request.QueryString["id"]);
             int userID = util.getID(Session["eid"].ToString());
             string insquery = "INSERT INTO rank(userID,rank,pictureID) VALUES(@userId, @Rank, @PictureID)";
             dbc.cmd.Parameters.Add(new SqlParameter("UserID", userID));
             dbc.cmd.Parameters.Add(new SqlParameter("Rank", rank));
             dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
             dbc.cmd.CommandText = insquery;
             dbc.cmd.ExecuteNonQuery();
         }
         int id = Convert.ToInt32(Request.QueryString["id"]);
         dbc.cmd.Parameters.Add(new SqlParameter("id", id));
         dbc.cmd.CommandText = query;
         reader = dbc.cmd.ExecuteReader();
         if(reader.Read())
         {
             picture.ImageUrl = reader["path"].ToString();
             picture.AlternateText = reader["name"].ToString();
             header.Text = reader["name"].ToString();
             int userID = Convert.ToInt32(reader["userID"]);
             author.Text = this.getAuthor(userID);
             description.Text = reader["description"].ToString();
             if (Session["eid"] != null && (bool)Session["lgin"] == true)
             {
                 upView(id);
             }
             views.Text = this.getView(id).ToString();
         }
         reader.Close();
         dbc.dbCon.Close();
     }
 }
示例#4
0
 void LoadData()
 {
     Utilities util = new Utilities();
     string query;
     db dbc = new db();
     query = "SELECT * FROM pictures WHERE UserID = @id ORDER BY date DESC";
     if (Request.QueryString["sort"] == "oldest")
         query = "SELECT * FROM pictures WHERE UserID = @id ORDER BY date ASC";
     else if (Request.QueryString["sort"] == "byalphaup")
         query = query = "SELECT * FROM pictures WHERE UserID = @id pictures ORDER BY id DESC";
     else if (Request.QueryString["sort"] == "byalphadown")
         query = query = "SELECT * FROM pictures WHERE UserID = @id pictures ORDER BY id ASC";
     int id = util.getID(Convert.ToString(Session["eid"]));
     dbc.cmd.Parameters.Add(new SqlParameter("id", id));
     dbc.cmd.CommandText = query;
     SqlDataAdapter da = new SqlDataAdapter(dbc.cmd);
     DataTable dt = new DataTable();
     da.Fill(dt);
     PagedDataSource pgitems = new PagedDataSource();
     System.Data.DataView dv = new System.Data.DataView(dt);
     pgitems.DataSource = dv;
     pgitems.AllowPaging = true;
     pgitems.PageSize = 9;
     pgitems.CurrentPageIndex = PageNumber;
     if (pgitems.PageCount > 1)
     {
         rptPages.Visible = true;
         System.Collections.ArrayList pages = new System.Collections.ArrayList();
         for (int i = 0; i < pgitems.PageCount; i++)
             pages.Add((i + 1).ToString());
         rptPages.DataSource = pages;
         rptPages.DataBind();
     }
     else
         rptPages.Visible = false;
     rptContent.DataSource = pgitems;
     rptContent.DataBind();
 }