Пример #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.ColumnIndex;

            string str    = dataGridView1.Rows[e.RowIndex].Cells["PostId"].Value.ToString();
            int    postId = Convert.ToInt32(str);

            postNow = PostServices.GetPostByPostId(postId);

            if (index == 7) //查看详情
            {
                Form_postDetail form = new Form_postDetail(postNow);
                form.Show();
            }
            else if (index == 8)//删除
            {
                if (label_myPostsOrCollects.Text == "收藏")
                {
                    int collectId = ManagePostsServices.GetCollectByUserIdAndPostId(user.UserId, postId);
                    ManagePostsServices.DeleteCollect(collectId);
                    MessageBox.Show("取消收藏成功!");
                }
                else  //我的帖子
                {
                    PostServices.DeletePost(user.UserId, postId);
                    MessageBox.Show("删除成功!");
                }
            }
            else if (index == 9)//修改
            {
            }
        }