Felipe75 Posted June 21, 2016 at 10:46 PM Report #597355 Posted June 21, 2016 at 10:46 PM Private Sub btn_concluir_Click(sender As Object, e As EventArgs) Handles btn_concluir.Click mensagem = "Deseja concluir esta fatura?" titulo = "Gestão de Restaurante - Paulo Pereira - Conclusão de Fatura" botoes = MessageBoxButtons.YesNo icone = MessageBoxIcon.Question resposta = MessageBox.Show(mensagem, titulo, botoes, icone) If DialogResult.Yes = True Then Dim instrucdadosfatura As String If CheckBox1.Checked = True Then If txtNIF.Text = Nothing Or txtNome.Text = Nothing Or txtMorada.Text = Nothing Then MsgBox("O preenchimento dos dados pessoais é obrigatório.", MsgBoxStyle.Information, "Gestão de Restaurante - Paulo Pereira") Else If mtd_pagamento.Text = Nothing Or txtentrega.Text = Nothing Or lbl_troco.Text = "Entrega Insuficiente" Then MsgBox("O preenchimento dos campos Método de Pagamento e Entrega é obrigatório e o valor da Entrega deve ser maior que o valor a pagar.", MsgBoxStyle.Information, "Gestão de Restaurante - Paulo Pereira") Else lblentrega.Text = txtentrega.Text lblentrega.Text = Replace(lblentrega.Text, ".", ",") instrucdadosfatura = "UPDATE DadosFatura SET NIF='" & txtNIF.Text & "', Nome='" & txtNome.Text & "', Morada='" & txtMorada.Text & "', MtdPagamento='" & mtd_pagamento.Text & "', Entrega='" & lblentrega.Text & " €" & "', Troco='" & lbl_troco.Text & "', Estado='" & "Concluída" & "' WHERE Cod='" & lbl_nrfatura.Text & "'" Me.DadosFaturaTableAdapter.Adapter.SelectCommand.CommandText = instrucdadosfatura Me.DadosFaturaTableAdapter.Update(Me._OFICINA_MDFDataSet.DadosFatura) Me.DadosFaturaTableAdapter.Fill(Me._OFICINA_MDFDataSet.DadosFatura) MsgBox("O Recibo foi finalizado com sucesso.", MsgBoxStyle.Information, "Gestão de Restaurante - Paulo Pereira") Me.Close() Peças.Show() End If End If Else If mtd_pagamento.Text = Nothing Or txtentrega.Text = Nothing Or lbl_troco.Text = "Entrega Insuficiente" Then MsgBox("O preenchimento dos campos Método de Pagamento e Entrega é obrigatório e o valor da Entrega deve ser maior que o valor a pagar.", MsgBoxStyle.Information, "Gestão de Restaurante - Paulo Pereira") Else lblentrega.Text = txtentrega.Text lblentrega.Text = Replace(lblentrega.Text, ".", ",") instrucdadosfatura = "UPDATE DadosFatura SET MtdPagamento='" & mtd_pagamento.Text & "', Entrega='" & lblentrega.Text & " €" & "', Troco='" & lbl_troco.Text & "', Estado='" & "Concluída" & "' WHERE Cod='" & lbl_nrfatura.Text & "'" Me.DadosFaturaTableAdapter.Adapter.SelectCommand.CommandText = instrucdadosfatura Me.DadosFaturaTableAdapter.Update(Me._OFICINA_MDFDataSet.DadosFatura) Me.DadosFaturaTableAdapter.Fill(Me._OFICINA_MDFDataSet.DadosFatura) MsgBox("O Recibo foi finalizado com sucesso.", MsgBoxStyle.Information, "Gestão de Restaurante - Paulo Pereira") Me.Close() Peças.Show() End If End If End If End Sub Alguem me consegue dizer onde esta o erro sff?
ribeiro55 Posted June 21, 2016 at 11:06 PM Report #597356 Posted June 21, 2016 at 11:06 PM Podes dizer qual é o erro sff? Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips"
Felipe75 Posted June 21, 2016 at 11:14 PM Author Report #597357 Posted June 21, 2016 at 11:14 PM ao clicar no botão concluir nao aparece o outro form Peças
Cerzedelo Posted June 22, 2016 at 08:46 AM Report #597362 Posted June 22, 2016 at 08:46 AM O seu código está uma confusão. Existe algum motivo para repetir o update 2 vezes? I.e. , se o ckeckbox for checkado finaliza o recibo, se não for também finaliza o recibo, não faz muito sentido? Aprenda a utilizar a função exit sub() para sair da comparação if then quando ela não é verdadeira, e não necessita de prosseguir. Por exemplo, se os dados não foram preenchidos, despolta a mensagem, e em seguida aplica um exit sub(), para sair do procedimento, dado que o que o resto do processo não interessa. Tem a certeza que o outro form se chama peças, uma regra que eu utilizo e nunca usar nos nomes dos form caracteres especiais , tais como cedilhas, acentos, etc..
Felipe75 Posted June 25, 2016 at 10:15 PM Author Report #597391 Posted June 25, 2016 at 10:15 PM muito obrigado. Sim o outro form chama-se peças
FreiNando Posted June 26, 2016 at 07:25 AM Report #597394 Posted June 26, 2016 at 07:25 AM Onde você tem If DialogResult.Yes = True Then não devia ser If resposta = DialogResult.Yes Then ? Verifica que DialogResult.Yes não é boolean, mas inteiro com o valor 6, e True ao ser convertido para inteiro dá -1, logo a condição é falsa! O caminho mais curto para conseguir fazer muitas coisas é fazer uma de cada vez. Samuel Smiles
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