Esempio n. 1
0
 public static bool Them(tblWorkComment wc)
 {
     try
     {
         string sTruyVan = string.Format("Insert into tblWorkComment(IDPost,NoiDung,TaiKhoan) values(N'{0}',N'{1}',N'{2}')", wc.IDPost, wc.Noidung, wc.TaiKhoan);
         con = DataProvider.KetNoi();
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 2
0
 public static bool Sua(tblWorkComment wc)
 {
     try
     {
         con = DataProvider.KetNoi();
         string sTruyVan = string.Format("Update tblWorkAccount set IDComment='{0}' where IDPost = '{1}'", wc.IDComment, wc.IDPost);
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 3
0
        private void btnBatDauBinhLuan_Click(object sender, EventArgs e)
        {
            // lấy danh sách bình luận
            idTaiKhoanBinhLuan = new List <string>();
            //lấy ra list tài khoản sử dụng để bình luận
            foreach (var item in lsCheckTKTichCuc.CheckedIndices)
            {
                string i = item.ToString();
                if (i == "0")
                {
                    for (int t = 0; t < tichcuc.Rows.Count; t++)
                    {
                        idTaiKhoanBinhLuan.Add(tichcuc.Rows[t]["NumberIDAccount"].ToString());
                    }
                }
                else
                {
                    idTaiKhoanBinhLuan.Add(tichcuc.Rows[int.Parse(i) - 1]["NumberIDAccount"].ToString());
                }
            }
            foreach (var item in lsCheckTKTieuCuc.CheckedIndices)
            {
                string i = item.ToString();
                if (i == "0")
                {
                    for (int t = 0; t < tieucuc.Rows.Count; t++)
                    {
                        idTaiKhoanBinhLuan.Add(tieucuc.Rows[t]["NumberIDAccount"].ToString());
                    }
                }
                else
                {
                    idTaiKhoanBinhLuan.Add(tieucuc.Rows[int.Parse(i) - 1]["NumberIDAccount"].ToString());
                }
            }
            //kết thúc lấy danh sách bình luận

            //cập nhật lại thông tin bài viết
            tblPost p = new tblPost();

            p.IDPost   = idpost;
            p.TimePost = DateTime.Parse(timepost);
            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
            //kiểm tra xem bài viết đã được bình luận chưa
            if (Work.LoadDuLieuLamViecCu(taikhoan, idpost).Rows.Count != 0)
            {
                //xóa dữ liệu đã lưu cũ
                //xoá trong work
                Work.Xoa(idpost, taikhoan);
                WorkAccount.Xoa(idpost, taikhoan);
                WorkComment.Xoa(idpost, taikhoan);
            }
            //kết thúc kiểm tra bài viết đã được bình luận chưa
            //lưu các thông số bình luận lại
            //lưu tài khoản bình luận lại vào bảng workaccount
            tblWorkAccount wa = new tblWorkAccount();

            wa.IDPost   = idpost;
            wa.TaiKhoan = taikhoan;
            for (int i = 0; i < idTaiKhoanBinhLuan.Count; i++)
            {
                wa.IDAccountComment = idTaiKhoanBinhLuan[i];
                WorkAccount.Them(wa);
            }
            //lưu các nội dung sẽ bình luận
            tblWorkComment wc = new tblWorkComment();

            wc.IDPost   = idpost;
            wc.TaiKhoan = taikhoan;
            for (int i = 0; i < LsNoiDungBinhLuan.Items.Count; i++)
            {
                wc.Noidung = LsNoiDungBinhLuan.Items[i].Text;
                WorkComment.Them(wc);
            }
            // lưu thông tin công việc bình luận lại
            tblWork w = new tblWork();

            w.TaiKhoan    = taikhoan;
            w.IDPost      = idpost;
            w.KhoangTime  = (int)numKhoangTime.Value;
            w.TongComment = (int)numSoBL.Value;
            w.TienDo      = 0;
            w.TrangThai   = "Đang bình luận";
            Work.Them(w);
            //Thêm thành công thông tin
            TuDongBinhLuan r      = new TuDongBinhLuan(idpost, numKhoangTime.Value.ToString(), numSoBL.Value.ToString(), taikhoan);
            Thread         tudong = new Thread(r.DoWork);

            tudong.SetApartmentState(ApartmentState.STA);
            tudong.Start();
            // chỗ này chưa đc vì chưa thêm đc vào danh sách luồng đang chạy chung
            danhsach.Add(idpost, tudong);
            Work.updatetrangthai(idpost, "Đang bình luận", taikhoan);
            MessageBox.Show("Đã thêm công việc thành công");
        }