Jump to content

Estrutura de repetição


Go to solution Solved by He B TeMy,

Recommended Posts

Posted (edited)

Boa Tarde,

queria utilizar uma estrutura de repetir, sempre que o CodCliente fosse repetido e aparece-se uma mensagem de erro, a indicar-me que o código já está a ser utilizado. Será que me podem ajudar, sff?

Este é o código que tenho no botão "Adicionar":

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BotaoAdicionar.Click
 If TextBoxCodCliente.Text <> Nothing And TextBoxNome.Text <> Nothing And ComboBoxSexo.Text <> Nothing And dtpdatadenascimento.Text <> Nothing And TextBoxMorada.Text <> Nothing And
	 TextBoxLocalidade.Text <> Nothing And TextBoxTelemovel.Text <> Nothing And TextBoxEmail.Text <> Nothing Then
	 Guardar_registo_cliente()
	 ler_registo_clientes()
	 Limpar_campos()
 Else
	 mensagem = "Registo incompleto" & vbNewLine & "Todos os campos são de preenchimento obrigatório."
	 titulo = "Registo de Clientes"
	 botoes = MessageBoxButtons.OK
	 icone = MessageBoxIcon.Error
	 MessageBox.Show(mensagem, titulo, botoes, icone)
 End If
End Sub

Obrigado!

Edited by apocsantos
geshi
Posted (edited)

Boas Noites,

testei agora e deu certo, muitíssimo obrigado, amigo!

Deixo aqui o código para quem precisar também:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BotaoAdicionar.Click
 If TextBoxCodCliente.Text = rc.codcliente Then
	 mensagem = "Erro no Registo" & vbNewLine & "Já está a ser utilizado o código em outro cliente"
	 titulo = "Registo de Clientes"
	 botoes = MessageBoxButtons.OK
	 icone = MessageBoxIcon.Error
	 MessageBox.Show(mensagem, titulo, botoes, icone)
 Else
	 If TextBoxCodCliente.Text <> Nothing And TextBoxNome.Text <> Nothing And ComboBoxSexo.Text <> Nothing And dtpdatadenascimento.Text <> Nothing And TextBoxMorada.Text <> Nothing And
		 TextBoxLocalidade.Text <> Nothing And TextBoxTelemovel.Text <> Nothing And TextBoxEmail.Text <> Nothing Then
		 Guardar_registo_cliente()
		 ler_registo_clientes()
		 Limpar_campos()
	 Else
		 mensagem = "Registo incompleto" & vbNewLine & "Todos os campos são de preenchimento obrigatório."
		 titulo = "Registo de Clientes"
		 botoes = MessageBoxButtons.OK
		 icone = MessageBoxIcon.Error
		 MessageBox.Show(mensagem, titulo, botoes, icone)
	 End If
 End If
End Sub
Edited by apocsantos
geshi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.