/// <summary> /// Load thong tin chung cua hoc sinh bao gom ca diem len listview DSHS /// </summary> void LoadDSHS_DSHS() { DShocsinhBLL hocSinhbll = new DShocsinhBLL(); List <ThongTinChungHS_DiemTB> listThongTinChungHocSinh; if (cbTieuChiTimKiem.SelectedIndex == 0) { listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoTen(tbTuKhoaTimKiem.Text); } else { listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoLop(tbTuKhoaTimKiem.Text); } lvdshs.Items.Clear(); int soThuTu = 1; HocKyBLL hockybll = new HocKyBLL(); List <HocKy> listhocky = hockybll.GetListHocKy(); foreach (ThongTinChungHS_DiemTB hocsinh in listThongTinChungHocSinh) { int indexHocKy = 0; for (int i = 0; i < listhocky.Count; i++) { if (listhocky[i].MaHocKy == hocsinh.maHocKy) { indexHocKy = i + 4; } } bool kiemTraTonTai = false; if (lvdshs.Items.Count > 0) { foreach (ListViewItem lvitem in lvdshs.Items) { if (lvitem.SubItems[1].Text == hocsinh.maHocSinh) { kiemTraTonTai = true; lvitem.SubItems[indexHocKy].Text = hocsinh.diemTB; break; } } } if (!kiemTraTonTai) { ListViewItem lvi = new ListViewItem(soThuTu + ""); lvi.SubItems.Add(hocsinh.maHocSinh); lvi.SubItems.Add(hocsinh.TenHocSinh); lvi.SubItems.Add(hocsinh.Lop); lvi.SubItems.Add("NULL"); // diem tb hoc ki 1 lvi.SubItems.Add("NULL"); // dim trung binh hk 2 lvi.SubItems.Add("NULL"); // dim trung binh hk 3 lvi.SubItems.Add("NULL"); // dim trung binh hk 4 lvi.SubItems[indexHocKy].Text = hocsinh.diemTB; lvdshs.Items.Add(lvi); soThuTu++; } } }
/// <summary> /// Load thong tin chung cua hoc sinh bao gom ca diem len listview DSHS /// </summary> void LoadDSHS_DSHS() { DShocsinhBLL hocSinhbll = new DShocsinhBLL(); List <ThongTinChungHS_DiemTB> listThongTinChungHocSinh; if (cbTieuChiTimKiem.SelectedIndex == 0) { listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoTen(tbTuKhoaTimKiem.Text); } else if (cbTieuChiTimKiem.SelectedIndex == 2) { try { string[] listdiem = tbTuKhoaTimKiem.Text.Split(' '); float canTren = float.Parse(listdiem[1]); float canDuoi = float.Parse(listdiem[0]); listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoDiemTB(canDuoi, canTren); } catch { MessageBox.Show("Không đúng định dạng tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else // if (cbTieuChiTimKiem.SelectedIndex == 1) { listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoLop(tbTuKhoaTimKiem.Text); } lvdshs.Items.Clear(); int soThuTu = 1; HocKyBLL hockybll = new HocKyBLL(); List <HocKy> listhocky = hockybll.GetListHocKy(); foreach (ThongTinChungHS_DiemTB hocsinh in listThongTinChungHocSinh) { int indexHocKy = 0; for (int i = 0; i < listhocky.Count; i++) { if (listhocky[i].MaHocKy == hocsinh.maHocKy) { indexHocKy = i + 4; } } bool kiemTraTonTai = false; if (lvdshs.Items.Count > 0) { foreach (ListViewItem lvitem in lvdshs.Items) { if (lvitem.SubItems[1].Text == hocsinh.maHocSinh) { kiemTraTonTai = true; lvitem.SubItems[indexHocKy].Text = hocsinh.diemTB; break; } } } if (!kiemTraTonTai) { ListViewItem lvi = new ListViewItem(soThuTu + ""); lvi.SubItems.Add(hocsinh.maHocSinh); lvi.SubItems.Add(hocsinh.TenHocSinh); lvi.SubItems.Add(hocsinh.Lop); lvi.SubItems.Add("-"); // diem tb hoc ki 1 lvi.SubItems.Add("-"); // dim trung binh hk 2 lvi.SubItems.Add("-"); // dim trung binh hk 3 lvi.SubItems.Add("-"); // dim trung binh hk 4 lvi.SubItems[indexHocKy].Text = hocsinh.diemTB; lvdshs.Items.Add(lvi); soThuTu++; } } }