Example #1
0
    protected void BtnImageDeleteAction_Click(object sender, EventArgs e)
    {
        //Get Image ID
        string strImageId = ((Label)FVImageLikesAndInfo.FindControl("lblImageIdForUndef")).Text;
        //  string qstr = Request.QueryString["img"];

        string ConnectionString     = Checks.getConnectionString();
        string deleteImageActionSQL = "DELETE FROM Cus_Upload WHERE ImageId=@ImageId";

        using (SqlConnection myConnection = new SqlConnection(ConnectionString))
        {
            myConnection.Open();
            SqlCommand ImageAction = new SqlCommand(deleteImageActionSQL, myConnection);

            ImageAction.Parameters.AddWithValue("@ImageId", strImageId);

            //  myCommand.Parameters.AddWithValue("@ImageName", qstr);



            ImageAction.ExecuteNonQuery();
        }

        Response.Redirect("~/Account/you.aspx");
    }
Example #2
0
    //Button Comments Add
    protected void BtnUserComments_Click(object sender, EventArgs e)
    {
        //Validation on server side
        if (!Page.IsValid)
        {
            return;
        }

        MembershipUser currentUser   = Membership.GetUser();
        Guid           currentUserId = (Guid)currentUser.ProviderUserKey;

        //Get Image ID
        string strImageId = ((Label)FVImageLikesAndInfo.FindControl("lblImageIdForUndef")).Text;
        //QueryString
        string qstr = Request.QueryString["img"];

        string ConnectionString    = Checks.getConnectionString();
        string insertSqlBtnComment = "INSERT INTO Cus_Coments(UserId, UserName, ComentBody, ImageName, ImageId) VALUES(@UserId, @UserName, @ComentBody, @ImageName, @ImageId)";

        //notofication insert
        string insertSqlNotif = "INSERT INTO Cus_Notif(UserId, UserName, ProfileName, NotifBody, IsRead, ImageName) VALUES(@UserId, @UserName, @ProfileName, @NotifBody, @isRead, @ImageName)";


        using (SqlConnection myConnection = new SqlConnection(ConnectionString))
        {
            myConnection.Open();
            SqlCommand BtnComment = new SqlCommand(insertSqlBtnComment, myConnection);

            BtnComment.Parameters.AddWithValue("@UserId", currentUserId);
            BtnComment.Parameters.AddWithValue("@UserName", currentUser.ToString());
            BtnComment.Parameters.AddWithValue("@ComentBody", TxtUserComments.Text.Trim());
            BtnComment.Parameters.AddWithValue("@ImageName", qstr);

            BtnComment.Parameters.AddWithValue("@ImageId", strImageId);

            BtnComment.ExecuteNonQuery();


            if ((Session["forMotherRussia"].ToString()) != currentUser.ToString())
            {
                //notif
                SqlCommand Notif       = new SqlCommand(insertSqlNotif, myConnection);
                string     notifBody   = "commented on you photo";
                string     isRead      = "NEW";
                string     profileName = Session["forMotherRussia"].ToString();
                Notif.Parameters.AddWithValue("@UserId", currentUserId);
                Notif.Parameters.AddWithValue("@UserName", profileName);
                Notif.Parameters.AddWithValue("@ProfileName", currentUser.ToString());
                Notif.Parameters.AddWithValue("@NotifBody", notifBody);
                Notif.Parameters.AddWithValue("@isRead", isRead);
                Notif.Parameters.AddWithValue("@ImageName", qstr);
                Notif.ExecuteNonQuery();
            }
        }
        TxtUserComments.Text = null;
    }
Example #3
0
    //Button to like the IMAGE
    protected void BtnLike_Click(object sender, EventArgs e)
    {
        MembershipUser currentUser   = Membership.GetUser();
        Guid           currentUserId = (Guid)currentUser.ProviderUserKey;;


        //Get Image ID
        string strImageId = ((Label)FVImageLikesAndInfo.FindControl("lblImageIdForUndef")).Text;

        string qstr = Request.QueryString["img"];


        string ConnectionString  = Checks.getConnectionString();
        string insertSqlBtnLikes = "INSERT INTO Cus_ImageLikes(UserId, ImageId, ImageName) VALUES(@UserId, @ImageId, @ImageName)";
        string UpdateSqlBtnkLike = "UPDATE Cus_Upload SET NumOfLikes= NumOfLikes+1   WHERE ImageId=@ImageId";

        //notofication insert
        string insertSqlNotif = "INSERT INTO Cus_Notif(UserId, UserName, ProfileName, NotifBody, IsRead, ImageName) VALUES(@UserId, @UserName, @ProfileName, @NotifBody, @isRead, @ImageName)";

        using (SqlConnection myConnection = new SqlConnection(ConnectionString))
        {
            myConnection.Open();
            SqlCommand BtnLikes = new SqlCommand(insertSqlBtnLikes, myConnection);

            BtnLikes.Parameters.AddWithValue("@UserId", currentUserId);
            BtnLikes.Parameters.AddWithValue("@ImageId", strImageId);
            BtnLikes.Parameters.AddWithValue("@ImageName", qstr);
            BtnLikes.ExecuteNonQuery();
            SqlCommand BtnkLike = new SqlCommand(UpdateSqlBtnkLike, myConnection);
            BtnkLike.Parameters.AddWithValue("@ImageId", strImageId);
            BtnkLike.ExecuteNonQuery();


            //notif
            SqlCommand Notif       = new SqlCommand(insertSqlNotif, myConnection);
            string     notifBody   = "liked your photo";
            string     isRead      = "NEW";
            string     profileName = Session["forMotherRussia"].ToString();
            Notif.Parameters.AddWithValue("@UserId", currentUserId);
            Notif.Parameters.AddWithValue("@UserName", profileName);
            Notif.Parameters.AddWithValue("@ProfileName", currentUser.ToString());
            Notif.Parameters.AddWithValue("@NotifBody", notifBody);
            Notif.Parameters.AddWithValue("@isRead", isRead);
            Notif.Parameters.AddWithValue("@ImageName", qstr);
            Notif.ExecuteNonQuery();
        }

        //reload page
        Page.Response.Redirect(Page.Request.Url.ToString(), true);
    }