private void txtLuu_Click(object sender, EventArgs e) { if (txtTenNv.Text.Length == 0) { errTenNV.SetError(txtTenNv, "Không được để trống"); } else { errTenNV.SetError(txtTenNv, ""); } if (errTenNV.GetError(txtTenNv).Length == 0) { nv.TenNV = txtTenNv.Text; nv.MoTaKhac = txtMoTa.Text ?? ""; nv.DienThoaiLH = txtDT.Text ?? ""; if (NhanVienBus.UpdateNhanVien(nv)) { MessageBox.Show("Cập nhật thánh công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _frmNV.data = NhanVienBus.GetListNhanVien(); _frmNV.dgvNhanVien.DataSource = _frmNV.data; this.Close(); } else { MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnDelete_Click(object sender, EventArgs e) { var nv = dgvNhanVien.CurrentRow.DataBoundItem as NhanVien; DialogResult result = MessageBox.Show("Bạn có chắc chắn xóa", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { if (NhanVienBus.DeleteNhanVien(nv.MaNV)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); data = NhanVienBus.GetListNhanVien(); dgvNhanVien.DataSource = data; } else { MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public FrmNhanVien() { InitializeComponent(); data = NhanVienBus.GetListNhanVien(); dataFilter = data; }