Ejemplo n.º 1
0
 private void tiếpTụcToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         TuDongBinhLuan r      = new TuDongBinhLuan(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "IDPost").ToString(), gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "KhoangTime").ToString(), gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TongComment").ToString(), taikhoan);
         Thread         tudong = new Thread(r.DoWork);
         tudong.SetApartmentState(ApartmentState.STA);
         tudong.Start();
         danhsach.Add(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "IDPost").ToString(), tudong);
         Work.updatetrangthai(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "IDPost").ToString(), "Đang bình luận", taikhoan);
         r.getreload = new TuDongBinhLuan.GetReload(LoadDuLieu);
     }
     catch { }
     LoadDuLieu();
 }
Ejemplo n.º 2
0
 private void BatDauTatCaToolStripMenuItem_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < gridView1.RowCount; i++)
     {
         DataTable dt = new DataTable();
         dt = HoatDongGanDay.LoadDuLieu(taikhoan);
         try
         {
             TuDongBinhLuan r      = new TuDongBinhLuan(dt.Rows[i]["IDPost"].ToString(), dt.Rows[i]["KhoangTime"].ToString(), dt.Rows[i]["TongComment"].ToString(), taikhoan);
             Thread         tudong = new Thread(r.DoWork);
             tudong.SetApartmentState(ApartmentState.STA);
             tudong.Start();
             danhsach.Add(dt.Rows[i]["IDPost"].ToString(), tudong);
             Work.updatetrangthai(dt.Rows[i]["IDPost"].ToString(), "Đang bình luận", taikhoan);
             r.getreload = new TuDongBinhLuan.GetReload(LoadDuLieu);
         }
         catch { }
         Thread.Sleep(20000);
     }
     LoadDuLieu();
 }
Ejemplo 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");
        }