Esempio n. 1
0
        private void btnTieuCuc_Click(object sender, EventArgs e)
        {
            //lưu thông tin tài khoản
            tblUserFB newu = new tblUserFB();

            newu.IDUser = lsIDUserBinhLuan[LsNguoiDungBL.FocusedItem.Index].ToString();
            newu.Name   = LsNguoiDungBL.FocusedItem.Text;
            UserFB.Them(newu);
            //lưu thông tin tài khoản
            //lưu dữ liệu bình luận
            tblCommentPost newcp = new tblCommentPost();

            newcp.IDComment   = lsIDBinhLuan[LsNguoiDungBL.FocusedItem.Index].ToString();
            newcp.IDPost      = idpost;
            newcp.IDUser      = lsIDUserBinhLuan[LsNguoiDungBL.FocusedItem.Index].ToString();
            newcp.Status      = -5;
            newcp.Description = lsNoiDungBL[LsNguoiDungBL.FocusedItem.Index].ToString();
            newcp.TimeComment = lsTimeBinhLuan[LsNguoiDungBL.FocusedItem.Index];
            CommentPost.Them(newcp);
            //kết thúc lưu dữ liệu bình luận
            // loai bỏ item trong danh sách
            lsIDBinhLuan.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            lsNoiDungBL.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            lsIDUserBinhLuan.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            LsNguoiDungBL.Items.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            //kết thúc loại bỏ item trong danh sách
            txtNoiDungBinhLuan.Text = null;
        }
Esempio n. 2
0
 public static bool Sua(tblCommentPost cp)
 {
     try
     {
         con = DataProvider.KetNoi();
         string sTruyVan = string.Format("update tblCommentPost set Status='{0}' where IDComment=N'{1}'", cp.Status, cp.IDComment);
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 3
0
 public static bool Them(tblCommentPost cp)
 {
     try
     {
         string sTruyVan = string.Format("insert into tblCommentPost(IDComment,IDPost,IDUser,TimeComment,Description,Status) values(N'{0}',N'{1}',N'{2}',N'{3}',N'{4}',N'{5}')", cp.IDComment, cp.IDPost, cp.IDUser, cp.TimeComment, cp.Description, cp.Status);
         con = DataProvider.KetNoi();
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            // cập nhật thông tin bài viết
            tblPost p = new tblPost();

            p.IDPost       = idpost;
            p.TimePost     = DateTime.Parse(timepost);
            p.CountComment = tongsocomment;
            p.CountLike    = int.Parse(tongsoluonglike);
            if (danhgia == "Tích cực")
            {
                p.Status = "Tích cực";
            }
            else
            {
                p.Status = "Tiêu cực";
            }
            Post.Sua(p);
            // kết thúc cập nhật thông tin bài viết

            //thêm tài khoản người dùng
            for (int i = 0; i < lsIDTichCuc.Count; i++)
            {
                tblUserFB   newu  = new tblUserFB();
                tblLikePost newlp = new tblLikePost();
                newu.IDUser = lsIDTichCuc[i].ToString();
                newu.Name   = lsNameTichCuc[i].ToString();
                UserFB.Them(newu);
                newlp.IDPost   = idpost;
                newlp.IDUserFB = lsIDTichCuc[i].ToString();
                newlp.Status   = 1;
                LikePost.Them(newlp);
            }
            for (int i = 0; i < lsIDTieuCuc.Count; i++)
            {
                tblUserFB   newu  = new tblUserFB();
                tblLikePost newlp = new tblLikePost();
                newu.IDUser = lsIDTieuCuc[i].ToString();
                newu.Name   = lsNameTieuCuc[i].ToString();
                UserFB.Them(newu);
                newlp.IDPost   = idpost;
                newlp.IDUserFB = lsIDTieuCuc[i].ToString();
                newlp.Status   = -1;
                LikePost.Them(newlp);
            }
            //thêm từ những người bình luận
            for (int i = 0; i < LsNguoiDungBL.Items.Count; i++)
            {
                tblUserFB newu = new tblUserFB();
                newu.IDUser = lsIDUserBinhLuan[i];
                newu.Name   = LsNguoiDungBL.Items[i].Text;
                UserFB.Them(newu);

                //lưu người dùng bình luận vào sql
                tblCommentPost newcommentpost = new tblCommentPost();
                newcommentpost.IDPost      = idpost;
                newcommentpost.IDComment   = lsIDBinhLuan[i].ToString();
                newcommentpost.IDUser      = lsIDUserBinhLuan[i];
                newcommentpost.Description = lsNoiDungBL[i];
                newcommentpost.Status      = 0;

                CommentPost.Them(newcommentpost);
                //kết thúc lưu người dùng bình luận
            }
            //kết thúc thêm tài khoản
            MessageBox.Show("Đã lưu tất cả thông tin!");
        }