private void txtCPF_Leave(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtCPF.Text)) { var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(); if (repP.Existe(a => a.CPF.Equals(txtCPF.Text))) { txtNome.Text = repP.Buscar(txtCPF.Text).Nome; } else { MessageBox.Show("CPF: " + txtCPF.Text + " não encontrado", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Text = ""; txtCPF.Focus(); return; } } }