public void hienthidanhsachtheloai(ComboBox cbo) { BAL_theloai xulytheloai = new BAL_theloai(); cbo.DataSource = xulytheloai.getAllExist(); cbo.DisplayMember = "the_loai"; cbo.ValueMember = "ma_the_loai"; }
private void Formtheloai_Load(object sender, EventArgs e) { AutoCompleteStringCollection acsc = new AutoCompleteStringCollection(); txtMaTheLoai.Enabled = false; txtTim.MaxLength = 20; txtMaTheLoai.MaxLength = 20; txtTenTheLoai.MaxLength = 20; //thây getAll() = getAllExit() //getAllExit() = khong lấy đọc giả đã xóa BAL_theloai xulytheloai = new BAL_theloai(); DataTable data = null; dgvTheLoai.AllowUserToAddRows = false; if (FormDangNhap.Nhanvien.Quan_ly) { data = xulytheloai.getAll(); dgvTheLoai.DataSource = data; rowtotheloai(0); btnKhoiPhuc.Visible = theloai.Da_xoa; } else { data = xulytheloai.getAllExist(); dgvTheLoai.DataSource = data; rowtotheloai(0); dgvTheLoai.Columns[2].Visible = false; } btnXatNhan.Visible = btnLamMoi.Visible = btnQuayLai.Visible = false; foreach (DataRow row in data.Rows) { acsc.Add(row["ma_the_loai"].ToString()); acsc.Add(row["the_loai"].ToString()); } txtTim.AutoCompleteCustomSource = acsc; }
private void btnTim_Click(object sender, EventArgs e) { BAL_theloai xulytheloai = new BAL_theloai(); if (IsNumber(txtTim.Text) == true) { DataTable Table = null; if (FormDangNhap.Nhanvien.Quan_ly) { Table = xulytheloai.searcher_mtheloai_quanly(txtTim.Text); } else { Table = xulytheloai.searcher_mtheloai(txtTim.Text); } if (Table != null && Table.Rows.Count > 0) { dgvTheLoai.DataSource = xulytheloai.searcher_mtheloai(txtTim.Text); dgvTheLoai.AllowUserToAddRows = false; } else if (string.IsNullOrEmpty(txtTim.Text)) { if (FormDangNhap.Nhanvien.Quan_ly) { dgvTheLoai.DataSource = xulytheloai.getAll(); //xóa dòng cuối dgvTheLoai.AllowUserToAddRows = false; } else { dgvTheLoai.DataSource = xulytheloai.getAllExist(); //xóa dòng cuối dgvTheLoai.AllowUserToAddRows = false; } } else { MessageBox.Show("Mã này " + txtTim.Text + " chưa tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { DataTable Table = null; if (FormDangNhap.Nhanvien.Quan_ly) { Table = xulytheloai.searcher_theloai_quanly(txtTim.Text); } else { Table = xulytheloai.searcher_theloai(txtTim.Text); } if (Table != null && Table.Rows.Count > 0) { dgvTheLoai.DataSource = xulytheloai.searcher_theloai(txtTim.Text); dgvTheLoai.AllowUserToAddRows = false; } else if (string.IsNullOrEmpty(txtTim.Text)) { if (FormDangNhap.Nhanvien.Quan_ly) { dgvTheLoai.DataSource = xulytheloai.getAll(); //xóa dòng cuối dgvTheLoai.AllowUserToAddRows = false; } else { dgvTheLoai.DataSource = xulytheloai.getAllExist(); //xóa dòng cuối dgvTheLoai.AllowUserToAddRows = false; } } else { MessageBox.Show("Thể loại này " + txtTim.Text + " chưa tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }