protected void imgPhoto_Click(object sender, ImageClickEventArgs e) { ImageButton b = sender as ImageButton; string Id = b.Attributes["imgid"]; PhotoInfo photo = SqlTask.GetPhotoInfo(Id); switch (photo.rate) { case "1": s1.ImageUrl = "/Images/cstar.png"; break; case "2": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; break; case "3": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; break; case "4": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; break; case "5": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/cstar.png"; break; default: break; } imgW.ImageUrl = photo.imgUrl; userImg.ImageUrl = photo.userImg; phtProjectName.Text = photo.projectname; phtNameSurname.Text = photo.userFName + " " + photo.userSName; lblLikeCount.Text = photo.tLike.ToString(); lblPhotoDesc.Text = photo.Disc; btnLike.Attributes.Add("imgId", photo.PID); btnExifPopUp.CommandName = photo.PID; if (Session["loginuser"] != null) { photo = SqlTask.GetLikedPhoto(photo, Session["loginuser"].ToString()); } btnLike.ImageUrl = photo.Liked; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); //uptImgModal.Update(); }
public static PhotoInfo UpdatePhotoInfo(string comment, string rate, string publish, string id) { PhotoInfo photo = new PhotoInfo(); conn = new SqlConnection(connString); try { conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE Photos SET Rate=@rate , Disc=@comment , Publish=@publish WHERE PID=@pid ", conn); cmd.Parameters.AddWithValue("@comment", comment); cmd.Parameters.AddWithValue("@rate", rate); cmd.Parameters.AddWithValue("@publish", publish); cmd.Parameters.AddWithValue("@pid", id); cmd.ExecuteNonQuery(); cmd = new SqlCommand("SELECT * FROM PHOTOS WHERE PID=@pid ", conn); cmd.Parameters.AddWithValue("@pid", id); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { photo = new PhotoInfo { PID = dr["PID"].ToString(), imgUrl = "http://" + dr["P_Path"].ToString(), UID = dr["U_ID"].ToString(), publish = dr["Publish"].ToString(), rate = dr["Rate"].ToString(), tLike = Convert.ToInt32(dr["T_Like"].ToString()), Disc = dr["Disc"].ToString() }; } return(photo); } catch (Exception ex) { throw ex; } finally { conn.Close(); } }
public static PhotoInfo GetLikedPhoto(PhotoInfo photo, string UID) { conn = new SqlConnection(connString); try { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT P_ID FROM Likes WHERE U_ID=@uid AND P_ID=@pid", conn); cmd.Parameters.AddWithValue("@uid", UID); cmd.Parameters.AddWithValue("@pid", photo.PID); if (cmd.ExecuteScalar() != null) { photo.Liked = "/Images/like.png"; } SqlTask.conn.Close(); } catch (Exception ex) { throw new ApplicationException("Something wrong happened :", ex); } return(photo); }
public static PhotoInfo GetPhotoInfo(string id) { PhotoInfo photo = new PhotoInfo(); conn = new SqlConnection(connString); try { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT U_ID,p_path,PID,publish,rate,t_like,fname,sname,imgpath,Name,Photos.Disc FROM PHOTOS,USERS,PROJECTS WHERE PHOTOS.PID=@id AND PHOTOS.U_ID=USERS.ID AND PHOTOS.Pr_ID=PROJECTS.Pro_ID", conn); cmd.Parameters.AddWithValue("@id", id); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { photo = new PhotoInfo() { UID = dr[0].ToString(), imgUrl = "https://" + dr[1].ToString(), PID = dr[2].ToString(), userFName = dr[6].ToString(), userSName = dr[7].ToString(), userImg = dr[8].ToString(), publish = dr[3].ToString(), rate = dr[4].ToString(), tLike = Convert.ToInt32(dr[5]), projectname = dr[9].ToString(), Disc = dr[10].ToString(), }; } return(photo); } catch (Exception ex) { throw ex; } finally { conn.Close(); } }
protected void imgPhoto_Click(object sender, ImageClickEventArgs e) { txt_comment_edit.Visible = true; ImageButton b = sender as ImageButton; if (b.Attributes != null) { photoID = b.Attributes["imgID"]; deneme.Text = photoID.ToString(); PhotoInfo photo = SqlTask.GetPhotoInfo(photoID); switch (photo.rate) { case "1": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/ucstar.png"; s3.ImageUrl = "/Images/ucstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "2": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/ucstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "3": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "4": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "5": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/cstar.png"; break; default: break; } deneme2.Text = photo.rate.ToString(); imgW.ImageUrl = photo.imgUrl; userImg.ImageUrl = photo.userImg; phtProjectName.Text = photo.projectname; phtNameSurname.Text = photo.userFName + " " + photo.userSName; lblRate.Text = photo.rate; lbl_comment.Text = photo.Disc; if (photo.publish == "1") { Chck_publish.Checked = true; } else { Chck_publish.Checked = false; } txt_comment_edit.Visible = true; txt_comment_edit.Text = photo.Disc; lbl_comment.Visible = false; if (Session["loginuser"] != null) { photo = SqlTask.GetLikedPhoto(photo, Session["loginuser"].ToString()); } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); uptImgModal.Update(); } }
protected void editok_Click(object sender, EventArgs e) { string Id = deneme.Text; string com = txt_comment_edit.Text; string pub; string rate; var ra = deneme2.Text; if (ra.Contains("1")) { rate = "1"; } else if (ra.Contains("2")) { rate = "2"; } else if (ra.Contains("3")) { rate = "3"; } else if (ra.Contains("4")) { rate = "4"; } else { rate = "5"; } if (Chck_publish.Checked) { pub = "1"; } else { pub = "0"; } PhotoInfo photo = SqlTask.UpdatePhotoInfo(com, rate, pub, Id); switch (rate) { case "1": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/ucstar.png"; s3.ImageUrl = "/Images/ucstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "2": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/ucstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "3": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "4": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "5": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/cstar.png"; break; default: break; } imgW.ImageUrl = photo.imgUrl; userImg.ImageUrl = photo.userImg; phtProjectName.Text = photo.projectname; phtNameSurname.Text = photo.userFName + " " + photo.userSName; lblRate.Text = photo.rate; lbl_comment.Text = photo.Disc; if (photo.publish == "1") { Chck_publish.Checked = true; } else { Chck_publish.Checked = false; } txt_comment_edit.Visible = true; txt_comment_edit.Text = photo.Disc; lbl_comment.Visible = false; Response.Redirect("/MyPage.aspx"); }
/* protected void AddFoto(object sender, EventArgs e) * { * var x = sender as Button; * var Pro_ID = x.CommandName; * } */ protected void imgPhotoEdit_Click(object sender, ImageClickEventArgs e) { ImageButton b = sender as ImageButton; var Id = b.Attributes["imgid"]; string com = txt_comment_edit.Text; string pub; string rate; var ra = b.ID; if (ra.Contains("1")) { rate = "1"; } else if (ra.Contains("2")) { rate = "2"; } else if (ra.Contains("3")) { rate = "3"; } else if (ra.Contains("4")) { rate = "4"; } else { rate = "5"; } if (Chck_publish.Checked) { pub = "1"; } else { pub = "0"; } Id = deneme.Text; PhotoInfo photo = SqlTask.UpdatePhotoInfo(com, rate, pub, Id); switch (rate) { case "1": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/ucstar.png"; s3.ImageUrl = "/Images/ucstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "2": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/ucstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "3": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/ucstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "4": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/ucstar.png"; break; case "5": s1.ImageUrl = "/Images/cstar.png"; s2.ImageUrl = "/Images/cstar.png"; s3.ImageUrl = "/Images/cstar.png"; s4.ImageUrl = "/Images/cstar.png"; s5.ImageUrl = "/Images/cstar.png"; break; default: break; } deneme2.Text = rate.ToString(); imgW.ImageUrl = photo.imgUrl; userImg.ImageUrl = photo.userImg; phtProjectName.Text = photo.projectname; phtNameSurname.Text = photo.userFName + " " + photo.userSName; lblRate.Text = photo.rate; lbl_comment.Text = photo.Disc; if (photo.publish == "1") { Chck_publish.Checked = true; } else { Chck_publish.Checked = false; } txt_comment_edit.Visible = true; txt_comment_edit.Text = photo.Disc; lbl_comment.Visible = false; if (Session["loginuser"] != null) { //photo = SqlTask.GetLikedPhoto(photo, Session["loginuser"].ToString()); } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); }