Jump to content

Recommended Posts

Posted
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?

Posted

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..

Posted

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

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.