Esempio n. 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 == 5) //查看详情
            {
                Form_postDetail form = new Form_postDetail(postNow);
                form.Show();
            }
            else if (index == 6)//收藏
            {
                //已经收藏
                if (ManagePostsServices.GetCollectByUserIdAndPostId(UserNow.UserId, postNow.PostId) != 0)
                {
                    MessageBox.Show("已收藏过该帖子!");
                    return;
                }
                //未收藏
                Collect c = new Collect(postNow.PostId, UserNow.UserId, DateTime.Now);
                ManagePostsServices.Collect(c);
                MessageBox.Show("收藏成功!");
            }
        }
Esempio n. 2
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)//修改
            {
            }
        }
Esempio n. 3
0
        public Form_main()
        {
            InitializeComponent();
            //推荐
            postsNow = ManagePostsServices.Recommend(UserNow.UserId);
            //postsNow = PostServices.GetAllPosts();

            dataGridView1.DataSource = postsNow;
        }
Esempio n. 4
0
        private void button_comment_Click(object sender, EventArgs e)
        {
            Comment c = new Comment(richTextBox_comment.Text, post.PostId,
                                    Form_main.UserNow.UserId, Form_main.UserNow.UserName);

            ManagePostsServices.IssueComment(c);
            richTextBox_comment.Text = "";

            comments = ManagePostsServices.QueryCommentsByPostId(post.PostId);
            dataGridView1.DataSource = comments;
        }
Esempio n. 5
0
        public Form_postDetail(Post post)
        {
            InitializeComponent();
            this.post = post;
            //帖子信息
            textBox_title.Text           = post.Title;
            textBox_time.Text            = post.Time.ToString();
            textBox_type.Text            = post.Type.ToString();
            textBox_postType.Text        = post.PostType.ToString();
            richTextBox_description.Text = post.BriefDescription;
            pictureBox.Image             = post.Image;

            //评论
            comments = ManagePostsServices.QueryCommentsByPostId(post.PostId);
            dataGridView1.DataSource = comments;
        }
Esempio n. 6
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)//举报
            {
            }
        }