You are on page 1of 7

Public Class parqueestacionamento

Dim vhoraentrada, vminutoentrada, vhorasaida, vminutosaida, ventrada, vsaida,


vtempo, vhora, vminuto As Integer
Dim vvalor, vsoma, vnum, vtroco As Single

Private Sub btnentrada_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnentrada.Click
lblduracao.Text = ""
lbllegendaduracao.Text = ""
lbllegendavalorapagar.Text = ""
lbltroco.Text = ""
lblvalor.Text = ""
lbllegendahoraentrada.Text = ""
lbllegendahorasaida.Text = ""
lblhorasaida.Text = ""
lblhoraentrada.Text = ""
euro10.Visible = False
eurodez.Visible = False
euro1.Visible = False
euro2.Visible = False
euro20actns.Visible = False
euro20ctns.Visible = False
euro2a.Visible = False
euro50ctns.Visible = False
euro5.Visible = False
Do
vhoraentrada = Val(InputBox("Insira a Hora de Entrada", "Hora"))
If vhoraentrada < 7 Then

vhoraentrada = 0
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Horário incorrecto, Volte a inserir dados")
ElseIf vhoraentrada > 24 Then

vhoraentrada = 0
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Horário incorrecto, Volte a inserir dados")
End If
Loop Until vhoraentrada >= 7 And vhoraentrada < 24

Do
vminutoentrada = Val(InputBox("Complete e insira a informação dos
Minutos", "Hora"))
If vminutoentrada > 59 Then

vminutoentrada = -1

Dim Player As New System.Media.SoundPlayer


Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try

MessageBox.Show("Horário incorrecto, Volte a inserir dados")

End If
Loop Until vminutoentrada >= 0 And vminutoentrada < 60
ventrada = (vhoraentrada * 60) + vminutoentrada
If ventrada > 1350 Then
MessageBox.Show("Atenção o ESSES Park encerra à Meia Noite", "Aviso!!!")
End If
End Sub

Private Sub btnsaida_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnsaida.Click

If ventrada <= 0 Then

lblduracao.Text = ""
lbllegendaduracao.Text = ""
lblvalor.Text = ""
lbllegendavalorapagar.Text = ""
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Não efectuou o registo de entrada, Termine este
processo, Pagamento não válido!!! Clique no botão Reíniciar ou dirija-se à caixa
central")
End If
Do
vhorasaida = Val(InputBox("Insira a Hora de Saída", "Hora"))
If vhorasaida < 7 Or vhorasaida > 23 Then

vhorasaida = 0
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception
End Try
MessageBox.Show("Horário incorrecto, insira valor entre 7 e 23")
End If
Loop Until vhorasaida >= 7 And vhorasaida < 24

Do
vminutosaida = Val(InputBox("Complete e insira a informação dos
Minutos", "Hora"))
If vminutosaida > 59 Then

Dim Player As New System.Media.SoundPlayer


Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Horário incorrecto, Volte a inserir dados")
vminutosaida = -1
End If
Loop Until vminutosaida >= 0 And vminutosaida < 60

vsaida = (vhorasaida * 60) + vminutosaida


vtempo = vsaida - ventrada
vhora = vtempo \ 60
vminuto = vtempo Mod 60
lblduracao.Text = vhora & "H" & Format(vminuto, "0#") & "M"
lbllegendaduracao.Text = "Tempo de Utilização"
vvalor = (vtempo \ 15) * 0.2
lblvalor.Text = Format(vvalor, "0.00€")
lbllegendavalorapagar.Text = "Valor a Pagar"
lbllegendahoraentrada.Text = "Hora de Entrada"
lbllegendahorasaida.Text = "Hora de Saída"
lblhorasaida.Text = vhorasaida & "H" & Format(vminutosaida, "0#") & "M"
lblhoraentrada.Text = vhoraentrada & "H" & Format(vminutosaida, "0#") & "M"
If vsaida < ventrada Then

lblduracao.Text = ""
lbllegendaduracao.Text = ""
lbllegendavalorapagar.Text = ""
lbltroco.Text = ""
lblvalor.Text = ""
lbllegendahoraentrada.Text = ""
lbllegendahorasaida.Text = ""
lblhorasaida.Text = ""
lblhoraentrada.Text = ""
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Algo está errado, a sua hora de saída é inferior á sua
hora de entrada. Reínicie o processo de registo")
End If
If vvalor > 0 Then
MessageBox.Show("Muito Obrigado. Efetue Pagamento", "Efetuar Pagamento")

End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnpagamento.Click
Dim vcinco, vdois, vum, vcinquenta, vvinte, vdez, vnotamoeda As Integer
If ventrada <= 0 Or vsaida <= 0 Then

lblduracao.Text = ""
lbllegendaduracao.Text = ""
lblvalor.Text = ""
lbllegendavalorapagar.Text = ""
vtroco = 0
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Faça os registos de entrada ou saida. Insira valor
zero, carregue no botão Reíniciar ou dirija-se à caixa central")
End If

vsoma = 0

Do
vnum = Val(InputBox("Insira o valor", "Pagamento"))

Select Case vnum


Case 10
eurodez.Visible = True
Case 5
euro5.Visible = True
Case 2
euro2.Visible = True
Case 1
euro1.Visible = True
Case 0.5
euro50ctns.Visible = True
Case 0.2
euro20ctns.Visible = True
Case 0.1
euro10.Visible = True
Case Else

Dim Player As New System.Media.SoundPlayer


Try
Player.SoundLocation = "erro.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
MessageBox.Show("Insira o valor de moeda correcto", "Valor")
vnum = 0
End Select

vsoma = vsoma + vnum

MessageBox.Show("O valor acumulado do seu pagamento é " & vsoma, "Valor


Pago")
eurodez.Visible = False
euro5.Visible = False
euro2.Visible = False
euro1.Visible = False
euro50ctns.Visible = False
euro20ctns.Visible = False
euro10.Visible = False

Loop Until vsoma >= vvalor


vtroco = vsoma - vvalor

If vtroco = 0 Then
MessageBox.Show("Pagamento efetuado. Muito obrigado", "Obrigado")
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "impressora.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
Else
MessageBox.Show("Pagamento efectuado. Muito obrigado, recolha o seu
troco no valor de " & Format(vtroco, "0.00€"), "Obrigado")
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "impressora.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
End If

vnotamoeda = vtroco * 100


vcinco = vnotamoeda \ 500

If vcinco = 0 Then
euro5.Visible = False
Else
euro5.Visible = True
End If

vdois = (vnotamoeda Mod 500) \ 200


If vdois = 0 Then
euro2.Visible = False
euro2a.Visible = False
ElseIf vdois = 1 Then
euro2.Visible = True
euro2a.Visible = False
ElseIf vdois = 2 Then
euro2.Visible = True
euro2a.Visible = True
End If

vum = ((vnotamoeda Mod 500) Mod 200) \ 100


If vum = 0 Then
euro1.Visible = False
Else
euro1.Visible = True
End If

vcinquenta = (((vnotamoeda Mod 500) Mod 200) Mod 100) \ 50


If vcinquenta = 0 Then
euro50ctns.Visible = False
Else
euro50ctns.Visible = True
End If

vvinte = ((((vnotamoeda Mod 500) Mod 200) Mod 100) Mod 50) \ 20
If vvinte = 0 Then
euro20ctns.Visible = False
euro20actns.Visible = False
ElseIf vvinte = 1 Then
euro20ctns.Visible = True
euro20actns.Visible = False
ElseIf vvinte = 2 Then
euro20ctns.Visible = True
euro20actns.Visible = True
End If

vdez = (((((vnotamoeda Mod 500) Mod 200) Mod 100) Mod 50) Mod 20) \ 10
If vdez = 0 Then
euro10.Visible = False
Else
euro10.Visible = True
End If

If vtroco > 0 Then


lbltroco.Text = "O seu troco tem um valor de " & Format(vtroco, "0.00€")
End If

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As


System.EventArgs)

End Sub

Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnlimpar.Click
Dim Player As New System.Media.SoundPlayer
Try
Player.SoundLocation = "reiniciar.wav"
Player.LoadAsync()
If Player.IsLoadCompleted Then Player.Play()
Catch ex As Exception

End Try
lblduracao.Text = ""
lbllegendaduracao.Text = ""
lbllegendavalorapagar.Text = ""
lbltroco.Text = ""
lblvalor.Text = ""
lbllegendahoraentrada.Text = ""
lbllegendahorasaida.Text = ""
lblhorasaida.Text = ""
lblhoraentrada.Text = ""
euro10.Visible = False
eurodez.Visible = False
euro1.Visible = False
euro2.Visible = False
euro20actns.Visible = False
euro20ctns.Visible = False
euro2a.Visible = False
euro50ctns.Visible = False
euro5.Visible = False
ventrada = 0
End Sub

Private Sub parqueestacionamento_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub
End Class

You might also like