Beispiel #1
0
 public static bool Them(tblLikePost lp)
 {
     try
     {
         string sTruyVan = string.Format("insert into tblLikePost(IDPost,IDUserFB,Status) values(N'{0}',N'{1}',N'{2}')", lp.IDPost, lp.IDUserFB, lp.Status);
         con = DataProvider.KetNoi();
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #2
0
 public static bool Sua(tblLikePost lp)
 {
     try
     {
         con = DataProvider.KetNoi();
         string sTruyVan = string.Format("update tblLikePost set Status='{0}' where IDPost=N'{1}'", lp.Status, lp.IDUserFB);
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #3
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!");
        }