private void checkboxHoanTat_CheckedChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(cbSoBuoi.Text)) { cbSoBuoi.Focus(); this.errorProvider1.SetError(cbSoBuoi, "Bạn phải chọn số buổi!"); } else { this.errorProvider1.SetError(cbSoBuoi, null); using (var _context = new DBLapTrinhWin()) { var get = (from u in _context.TienDoes where u.IDDeAn == key select u).FirstOrDefault(); string noidung = get.BaoCao; string link = get.LinkTaiLieu; string check = get.HoanThanh; noidung = noidung + rtxtNoiDung.Text + "$"; link = link + txtLinkTaiLieu.Text + ","; check = check + "true" + ","; get.BaoCao = noidung; get.LinkTaiLieu = link; get.HoanThanh = check; _context.SaveChanges(); Khoitao(); TaoDTG(); tienDo = (double)(BaoCaoTienDoController.GetHoanThanh(check).Count() - 1) / int.Parse(txtSoBuoi.Text); tienDo = Math.Round(tienDo, 2); var get1 = (from u in _context.DeAns where u.IDDeAn == key select u).FirstOrDefault(); get1.TienDo = tienDo; _context.SaveChanges(); } } }
public void TaoDTG() { using (var _context = new DBLapTrinhWin()) { int sobuoi = 0; var x = from u in _context.TienDoes where u.IDDeAn == key select u; if (x.Count() != 0) { if (x.First().SoBuoi != null) { sobuoi = (int)x.First().SoBuoi; } } var sobuoihientai = from u in _context.TienDoes where u.HoanThanh == null && u.IDDeAn == key select u; if (sobuoihientai.Count() == 1) { List <TienDoBaoCao> dtg = new List <TienDoBaoCao>(); for (int j = 0; j < sobuoi; j++) { TienDoBaoCao k = new TienDoBaoCao(); string buoi = "Buổi " + (j + 1).ToString(); k.Buoi = buoi; dtg.Add(k); } dtgTienDo.DataSource = dtg; return; } string xnd = ""; string xlink = ""; string xcheck = ""; if ((x.First().BaoCao != null)) { xnd = x.First().BaoCao; } if ((x.First().LinkTaiLieu != null)) { xlink = x.First().LinkTaiLieu; } if ((x.First().HoanThanh != null)) { xcheck = x.First().HoanThanh; } List <string> noidung = BaoCaoTienDoController.GetDanhSachNoiDungBaoCao(xnd); List <string> link = BaoCaoTienDoController.GetDanhSachLinkTaiLieu(xlink); List <bool> check = BaoCaoTienDoController.GetHoanThanh(xcheck); List <TienDoBaoCao> dtgsource = new List <TienDoBaoCao>(); for (int i = 0; i < sobuoi; i++) { TienDoBaoCao k = new TienDoBaoCao(); string buoi = "Buổi " + (i + 1).ToString(); k.Buoi = buoi; if (i < noidung.Count()) { k.NoiDung = noidung[i]; } if (i < link.Count()) { k.Link = link[i]; } if (i < check.Count()) { k.HoanThanh = check[i]; } dtgsource.Add(k); } dtgTienDo.DataSource = dtgsource; } }