コード例 #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int    index              = e.ColumnIndex;
            string userIdStr          = dataGridView1.Rows[e.RowIndex].Cells["UserId"].Value.ToString();
            int    commentOwnerUserId = Convert.ToInt32(userIdStr);

            string commentIdStr = dataGridView1.Rows[e.RowIndex].Cells["CommentId"].Value.ToString();
            int    commentId    = Convert.ToInt32(commentIdStr);

            if (index == 3)//删除
            {
                //本人或管理员
                if (Form_main.UserNow.UserId == commentOwnerUserId ||
                    Form_main.UserNow.Authority == true)
                {
                    ManagePostsServices.DeleteComment(commentId);
                    comments = ManagePostsServices.QueryCommentsByPostId(post.PostId);
                    dataGridView1.DataSource = comments;
                }
            }
            else if (index == 4)//举报
            {
            }
        }