コード例 #1
0
        protected void gvReportedPosts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int idx = int.Parse(e.CommandArgument.ToString());

            switch (e.CommandName)
            {
            case "ViewPost":
                System.Diagnostics.Debug.WriteLine("gvReportedPosts_RowCommand, ViewPost:" + e.CommandArgument);
                UserReportedPost userReportedPost = GetReports(true)[idx];
                Post             post             = Post.GetPostById(userReportedPost.postId);
                User             postCreator      = BLL.User.GetUserById(post.UserId);

                System.Diagnostics.Debug.WriteLine("gv SelectedIndexChanged," + post.Id);
                Session[keySessionRowIdx] = idx;

                lblModalPostCreatorName.Text = postCreator.Username;
                lblModalCircleId.Text        = post.CircleId;

                imgModalPost.ImageUrl = post.Image;
                imgModalPost.Visible  = post.Image != null;

                lblModalContent.Text = post.Content;

                lblModalTimeLocation.Text = post.DateTime.Value.ToString("d\\/MM\\/yyyy") + ", " + post.DateTime.Value.ToString("h:mm tt") + ", " + postCreator.City;

                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openViewPostModal();", true);
                break;

            case "DeletePost":
                System.Diagnostics.Debug.WriteLine("gvReportedPosts_RowCommand, DeletePost:" + e.CommandArgument);
                deleteOp(idx);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Javascript", "javascript:drawChart();", true);
                break;
            }
        }
コード例 #2
0
        protected void gvReportedPosts_DataBound(object sender, EventArgs e)
        {
            int topRowIdx  = -1;
            int currPostId = -1;
            int rowSpan    = 0;

            for (int idx = 0; idx < GetReports(true).Count; idx++)
            {
                UserReportedPost report = GetReports(true)[idx];
                GridViewRow      row    = gvReportedPosts.Rows[idx];

                if (report.postId != currPostId) // new post for current report, not the same post as previous report
                {
                    // need to set row span when going to next post
                    if (currPostId > -1)
                    {
                        GridViewRow topRow = gvReportedPosts.Rows[topRowIdx];
                        topRow.Cells[3].RowSpan = rowSpan;
                        topRow.Cells[4].RowSpan = rowSpan;
                    }

                    rowSpan    = 1;   // resets row span to 1, because new row
                    topRowIdx  = idx; // saves this top row
                    currPostId = report.postId;
                }
                else // current report's postId matches previous report's postId, so increase rowSpan
                {
                    // to hide the cell, cause no need to display anymore
                    row.Cells[3].Visible = false;
                    row.Cells[4].Visible = false;

                    // increase rowSpawn cause this row's post is the same as before
                    rowSpan += 1;
                }

                if (idx == (GetReports(true).Count - 1)) // when reaches the end of the row, we must assign the topRow thingy and stuffs
                {
                    GridViewRow topRow = gvReportedPosts.Rows[topRowIdx];
                    topRow.Cells[3].RowSpan = rowSpan;
                    topRow.Cells[4].RowSpan = rowSpan;
                }
            }

            //GridViewRow row = gvReportedPosts.Rows[0];
            //row.Cells[3].RowSpan = 2;
            //GridViewRow row1 = gvReportedPosts.Rows[1];
            //row1.Cells[3].Visible = false;
        }
コード例 #3
0
        public void deleteOp(int index)
        {
            // TODO deleting from modal, index is out of range
            System.Diagnostics.Debug.WriteLine("deleteOp, index:" + index);
            UserReportedPost userReportedPost = GetReports(true)[index];
            Post             post             = Post.GetPostById(userReportedPost.postId);

            System.Diagnostics.Debug.WriteLine("deleteOp, postId:" + post.Id);

            // Set reportedpost data's postId to null, to indicate post got deleted
            ReportedPost rp = ReportedPost.GetReportedPostById(userReportedPost.id);

            System.Diagnostics.Debug.WriteLine("deleteOp, reportedPost:" + rp.reason);
            ReportedPost.DeleteReportedPostByPostId(userReportedPost.postId);

            // delete post data
            Post.DeletePost(post.Id);

            // TODO - Investigate why cannot use remove, but removeRange can work for inside the DAO

            refreshGridView();
        }