private void btnExcluirClientes_Click(object sender, EventArgs e) { if (txtCPF.Text == "") { MessageBox.Show("Preencha o campo CPF corretamente para realizar esta opereção!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { string[] strings = new string[] { ".", "/", "-", ",", "(", ")", " " }; string cpf = txtCPF.Text; string Telefone = txtTelefone.Text; foreach (string str in strings) //limpando as strings { cpf = cpf.Replace(str, ""); Telefone = Telefone.Replace(str, ""); } try { if (MessageBox.Show("Deseja realmente excluir?", "Inativar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (_clienteController.Deletar(cpf)) { MessageBox.Show("Exclusão realizada com Sucesso!"); txtNome.Text = ""; txtCPF.Text = ""; txtEndereço.Text = ""; txtemail.Text = ""; txtRG.Text = ""; txtTelefone.Text = ""; dtDataNascimento.Text = ""; btnCadastrarClientes.Visible = true; lblCancelar.Visible = false; btnAlterarClientes.Enabled = false; btnExcluirClientes.Enabled = false; } } } catch (NaoEncontradoException ex) { MessageBox.Show(ex.Message); } catch (ConcorrenciaBancoException ex) { MessageBox.Show(ex.Message); } } }