pedrotugo123 Posted June 1, 2015 at 01:53 PM Report #584034 Posted June 1, 2015 at 01:53 PM (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 June 1, 2015 at 03:40 PM by apocsantos geshi
Solution He B TeMy Posted June 1, 2015 at 07:12 PM Solution Report #584050 Posted June 1, 2015 at 07:12 PM uh... estás a gravar onde? If CodCliente.Text = "registo" Then 'Resto do código Metes num 'loop' dependendo de onde tiveres a gravar.
pedrotugo123 Posted June 1, 2015 at 10:33 PM Author Report #584058 Posted June 1, 2015 at 10:33 PM Estou a utilizar ficheiros para guardar, e vou experimentar agora, já digo alguma coisa! Desde já um grande obrigado!
pedrotugo123 Posted June 2, 2015 at 12:09 AM Author Report #584064 Posted June 2, 2015 at 12:09 AM (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 June 2, 2015 at 09:20 AM by apocsantos geshi
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now