private void btnTim_Click(object sender, EventArgs e) { if (txtMaCBGV.Text == txtMaCBGV.Text) { CanBoGiaoVienBUL cb = new CanBoGiaoVienBUL(); string MaCanBoGiaoVien = txtMaCBGV.Text; DataTable dt = cb.TimKiem(MaCanBoGiaoVien); dgvHT.DataSource = dt; } else { dgvHT.DataSource = CanBoGiaoVienBUL.LayDsCanBo(); } }
private void btnSua_Click(object sender, EventArgs e) { try { CanBoGiaoVienBUL myCB = new CanBoGiaoVienBUL(); string MaCanBoGiaoVien = txtMCBGV.Text; string HoTen = txtHoTen.Text; string DiaChi = txtDiaChi.Text; string SoDienThoai = txtSDT.Text; string TaiKhoan = txtTaiKhoan.Text; string MatKhau = txtMatKhau.Text; string LoaiTaiKhoan = (string)cboLoaiTK.SelectedValue; myCB.Sua(MaCanBoGiaoVien, HoTen, DiaChi, SoDienThoai, TaiKhoan, MatKhau, LoaiTaiKhoan); dgvCBGV.DataSource = myCB.LayDsCanBo(); } catch (Exception) { MessageBox.Show("Sửa thông tin không hợp lệ!!!"); } }
private void btnXoa_Click(object sender, EventArgs e) { try { CanBoGiaoVienBUL myCB = new CanBoGiaoVienBUL(); string MaCanBoGiaoVien = txtMCBGV.Text; myCB.Xoa(MaCanBoGiaoVien); } catch (Exception) { MessageBox.Show("Xóa thông tin không hợp lệ!!!"); } DialogResult dlr = MessageBox.Show("Thông báo xác nhận xóa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlr == DialogResult.No) { } if (dlr == DialogResult.Yes) { dgvCBGV.DataSource = myCB.LayDsCanBo(); ClearCanBoGiaoVien(); } }
private void btnLuu_Click(object sender, EventArgs e) { if (btnThem.Enabled == false) { try { CanBoGiaoVienBUL myCB = new CanBoGiaoVienBUL(); string MaCanBoGiaoVien = txtMCBGV.Text; string HoTen = txtHoTen.Text; string DiaChi = txtDiaChi.Text; string SoDienThoai = txtSDT.Text; string TaiKhoan = txtTaiKhoan.Text; string MatKhau = txtMatKhau.Text; string LoaiTaiKhoan = (string)cboLoaiTK.SelectedValue; myCB.Them(MaCanBoGiaoVien, HoTen, DiaChi, SoDienThoai, TaiKhoan, MatKhau, LoaiTaiKhoan); dgvCBGV.DataSource = myCB.LayDsCanBo(); btnThem.Enabled = true; } catch (Exception) { MessageBox.Show("Thêm mới không hợp lệ!!!"); } } if (btnSua.Enabled == false) { try { CanBoGiaoVienBUL myCB = new CanBoGiaoVienBUL(); string MaCanBoGiaoVien = txtMCBGV.Text; string HoTen = txtHoTen.Text; string DiaChi = txtDiaChi.Text; string SoDienThoai = txtSDT.Text; string TaiKhoan = txtTaiKhoan.Text; string MatKhau = txtMatKhau.Text; string LoaiTaiKhoan = (string)cboLoaiTK.SelectedValue; myCB.Sua(MaCanBoGiaoVien, HoTen, DiaChi, SoDienThoai, TaiKhoan, MatKhau, LoaiTaiKhoan); dgvCBGV.DataSource = myCB.LayDsCanBo(); btnSua.Enabled = true; } catch (Exception) { MessageBox.Show("Sửa thông tin không hợp lệ!!!"); } } if (btnXoa.Enabled == false) { try { CanBoGiaoVienBUL myCB = new CanBoGiaoVienBUL(); string MaCanBoGiaoVien = txtMCBGV.Text; myCB.Xoa(MaCanBoGiaoVien); } catch (Exception) { MessageBox.Show("Xóa thông tin không hợp lệ!!!"); } DialogResult dlr = MessageBox.Show("Thông báo xác nhận xóa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlr == DialogResult.No) { } if (dlr == DialogResult.Yes) { dgvCBGV.DataSource = myCB.LayDsCanBo(); ClearCanBoGiaoVien(); btnXoa.Enabled = true; } } }