private void capNhat() { if (flag == true) { LopDAO adapterDAO = new LopDAO(); Lop[] Danh_Sach_Lop = adapterDAO.getAllClass(); int chi_soHK = combHocKi.SelectedIndex; int chi_soMH = combMonHoc.SelectedIndex; if (chi_soHK >= 0 && chi_soMH >= 0) { HocKi[] HK = (HocKi[])combHocKi.Tag; HocKi KQHK = HK[chi_soHK]; MonHoc[] MonHoc = (MonHoc[])combMonHoc.Tag; MonHoc KQMH = MonHoc[chi_soMH]; monHoc = KQMH.TenMonHoc; hocKi = KQHK.TenHocKi; DataTable dt = new DataTable(); dt.Columns.Add("Stt"); dt.Columns.Add("tenLop"); dt.Columns.Add("siSo"); dt.Columns.Add("soLuongDat"); dt.Columns.Add("tiLe"); int stt = 0; int i = 0; noiDungBaoCao = new BaoCaoTongKetMon[Danh_Sach_Lop.Length]; foreach (Lop lop in Danh_Sach_Lop) { BaoCaoTongKetMon temp = new BaoCaoTongKetMon(); DataRow dr = dt.NewRow(); dt.Rows.Add(dr); temp.Stt = stt; dr["Stt"] = stt++; dr["tenLop"] = lop.TenLop; dr["siSo"] = lop.SiSo; int soLuongDat = adapterDAO.soLuongDat(KQMH.MaMonHoc, KQHK.MaHocKi, lop.MaLop); dr["soLuongDat"] = soLuongDat; dr["tiLe"] = (float)soLuongDat / lop.SiSo * 100 + "%"; temp.TenLop = lop.TenLop; temp.SiSo = lop.SiSo; temp.SoLuongDat = soLuongDat; temp.TiLe = (float)soLuongDat / lop.SiSo * 100 + "%"; noiDungBaoCao[i] = temp; i++; } dgvBaoCao.DataSource = dt; } } }
private void frmThayDoiBangDiem_Load(object sender, EventArgs e) { LopDAO adaterLop = new LopDAO(); HocKiDAO adapterHK = new HocKiDAO(); MonHocDAO adapterMH = new MonHocDAO(); if (flag == false) { combMonHoc.DataSource = adapterMH.getAllMH(); combMonHoc.DisplayMember = "tenMonHoc"; combMonHoc.Tag = adapterMH.getAllMH(); combHK.DataSource = adapterHK.getAllHK(); combHK.DisplayMember = "tenHocKi"; combHK.Tag = adapterHK.getAllHK(); combLop.DataSource = adaterLop.getAllClass(); combLop.DisplayMember = "tenLop"; combLop.Tag = adaterLop.getAllClass(); flag = true; } XL_Chon(); }