public void Load() { DataTable dt = new ThietBiDao().DSPhong(); cbMaPhong.DataSource = dt; cbMaPhong.DisplayMember = "MaPhong"; cbMaPhong.SelectedIndex = -1; }
private void btnThem_Click(object sender, EventArgs e) { int c = new ThietBiDao().addTB(new THIETBI { idPhong = Int32.Parse(cbMaPhong.Text), TenThietBi = txtTenTB.Text, SoLuong = Int32.Parse(txtSoLuong.Text) }); if (c > 0) { MessageBox.Show("Thêm thiết bị thành công!"); dgvDS.DataSource = new ThietBiDao().DsTBTheoPhong(cbMaPhong.Text); } else { MessageBox.Show("Thêm thất bại !"); } }
private void btnXoa_Click(object sender, EventArgs e) { bool c = new ThietBiDao().xoaTB(new THIETBI { idPhong = Int32.Parse(cbMaPhong.Text), TenThietBi = txtTenTB.Text, SoLuong = Int32.Parse(txtSoLuong.Text) }); if (c) { MessageBox.Show("Xóa thiết bị thành công!"); dgvDS.DataSource = new ThietBiDao().DsTBTheoPhong(cbMaPhong.Text); txtTenTB.Text = ""; txtSoLuong.Text = ""; } else { MessageBox.Show("Xóa thất bại !"); } }