private void txtSearch_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string key = txtSearch.Text; string tenNhom = (string)dgvNhom.CurrentCell.Value; //Nhom nhom = Nhom.getNhomByName(tenNhom); Nhom nhom = Nhom.getNhomFromDBByName(tenNhom); //List<DanhBa> list = DanhBa.getDanhBaTheoNhom(nhom.maNhom); List <DanhBa> list = DanhBa.getDanhBaFromDBTheoNhom(nhom.maNhom); List <DanhBa> rs = new List <DanhBa>(); for (int i = 0; i < list.Count; i++) { if (list.ElementAt(i).tenGoi.Equals(key) || list.ElementAt(i).email.Equals(key) || list.ElementAt(i).sdt.Equals(key)) { rs.Add(list.ElementAt(i)); } } bdsDanhBa.DataSource = rs; dgvDanhBa.DataSource = bdsDanhBa; } if (txtSearch.Text.Equals("")) { string tenNhom = (string)dgvNhom.CurrentCell.Value; //Nhom nhom = Nhom.getNhomByName(tenNhom); Nhom nhom = Nhom.getNhomFromDBByName(tenNhom); //List<DanhBa> list = DanhBa.getDanhBaTheoNhom(nhom.maNhom); List <DanhBa> list = DanhBa.getDanhBaFromDBTheoNhom(nhom.maNhom); bdsDanhBa.DataSource = list; dgvDanhBa.DataSource = bdsDanhBa; } }
private void dgvNhom_CellClick(object sender, DataGridViewCellEventArgs e) { string tenNhom = (string)dgvNhom.CurrentCell.Value; if (tenNhom != null) { //Nhom nhom = Nhom.getNhomByName(tenNhom); Nhom nhom = Nhom.getNhomFromDBByName(tenNhom); //List<DanhBa> list = DanhBa.getDanhBaTheoNhom(nhom.maNhom); List <DanhBa> list = DanhBa.getDanhBaFromDBTheoNhom(nhom.maNhom); bdsDanhBa.DataSource = list; dgvDanhBa.DataSource = bdsDanhBa; } }
public void refreshList() { //List<Nhom> listNhom = Nhom.getNhom(); List <Nhom> listNhom = Nhom.getNhomFromDB(); bdsNhom.DataSource = listNhom; dgvNhom.DataSource = bdsNhom; if (listNhom.Count > 0) { string tenNhom = (string)dgvNhom.CurrentCell.Value; //Nhom nhom = Nhom.getNhomByName(tenNhom); Nhom nhom = Nhom.getNhomFromDBByName(tenNhom); //List<DanhBa> list = DanhBa.getDanhBaTheoNhom(nhom.maNhom); List <DanhBa> list = DanhBa.getDanhBaFromDBTheoNhom(nhom.maNhom); bdsDanhBa.DataSource = list; dgvDanhBa.DataSource = bdsDanhBa; } }