Public Class TASK3

    Dim _dPrice As Double = 1.3
    Dim _95Price As Double = 1.5
    Dim _98Price As Double = 1.6

    Dim Result As Double
    Dim Payoff As Double
    ' Kolona 1
    Dim s1 As Integer = 0
    Dim m1 As Integer = 0
    ' Kolona 2
    Dim s2 As Integer = 0
    Dim m2 As Integer = 0
    ' Kolona 3
    Dim s3 As Integer = 0
    Dim m3 As Integer = 0
    ' Kolona 4
    Dim s4 As Integer = 0
    Dim m4 As Integer = 0

    'Timer 1
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        m1 = m1 + 1
        Label13.Text = "Fuel : " & s1 & "," & m1
        Result = Val(s1 & "." & m1) * Val(_dPrice)
        Label17.Text = "Payoff: " & s1 & "." & m1 & " * " & _dPrice & " = " & Result
        If m1 = 10 Then
            s1 = s1 + 1
            m1 = 0
        End If
    End Sub
    'Timer 2
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        m2 = m2 + 1
        Label14.Text = "Fuel : " & s2 & "," & m2
        Result = Val(s2 & "." & m2) * Val(_dPrice)
        Label18.Text = "Payoff: " & s2 & "." & m2 & " * " & _dPrice & " = " & Result
        If m2 = 10 Then
            s2 = s2 + 1
            m2 = 0
        End If
    End Sub
    'Timer 3
    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        m3 = m3 + 1
        Label15.Text = "Fuel : " & s3 & "," & m3
        Result = Val(s3 & "." & m3) * Val(_dPrice)
        Label19.Text = "Payoff: " & s3 & "." & m3 & " * " & _dPrice & " = " & Result
        If m3 = 10 Then
            s3 = s3 + 1
            m3 = 0
        End If
    End Sub
    'Timer 4
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        m4 = m4 + 1
        Label16.Text = "Fuel : " & s4 & "," & m4
        Result = Val(s4 & "." & m4) * Val(_dPrice)
        Label20.Text = "Payoff: " & s4 & "." & m4 & " * " & _dPrice & " = " & Result
        If m4 = 10 Then
            s4 = s4 + 1
            m4 = 0
        End If
    End Sub


    'STATION 1 COMBOBOX
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If (ComboBox1.Text = "DIESEL") Then
            Label9.Text = "Price for 1 L - " + _dPrice.ToString + " EURO"
        ElseIf (ComboBox1.Text = "95") Then
            Label9.Text = "Price for 1 L - " + _95Price.ToString + " EURO"
        ElseIf (ComboBox1.Text = "98") Then
            Label9.Text = "Price for 1 L - " + _98Price.ToString + " EURO"
        End If
    End Sub
    'STATION 2 COMBOBOX
    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        If (ComboBox2.Text = "DIESEL") Then
            Label10.Text = "Price for 1 L - " + _dPrice.ToString + " EURO"
        ElseIf (ComboBox2.Text = "95") Then
            Label10.Text = "Price for 1 L - " + _95Price.ToString + " EURO"
        ElseIf (ComboBox2.Text = "98") Then
            Label10.Text = "Price for 1 L - " + _98Price.ToString + " EURO"
        End If
    End Sub
    'STATION 3 COMBOBOX
    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        If (ComboBox3.Text = "DIESEL") Then
            Label11.Text = "Price for 1 L - " + _dPrice.ToString + " EURO"
        ElseIf (ComboBox3.Text = "95") Then
            Label11.Text = "Price for 1 L - " + _95Price.ToString + " EURO"
        ElseIf (ComboBox3.Text = "98") Then
            Label11.Text = "Price for 1 L - " + _98Price.ToString + " EURO"
        End If
    End Sub
    'STATION 4 COMBOBOX
    Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
        If (ComboBox4.Text = "DIESEL") Then
            Label12.Text = "Price for 1 L - " + _dPrice.ToString + " EURO"
        ElseIf (ComboBox4.Text = "95") Then
            Label12.Text = "Price for 1 L - " + _95Price.ToString + " EURO"
        ElseIf (ComboBox4.Text = "98") Then
            Label12.Text = "Price for 1 L - " + _98Price.ToString + " EURO"
        End If
    End Sub


    'STATION 1 BUTTON FILL IN
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If (ComboBox1.Text = "DIESEL") Then
            If Button1.Text = "STOP" Then
                Result = 0
                Timer1.Stop()
                Button1.Text = "FILL IN"
                Result = Val(s1 & "." & m1) * Val(_dPrice)
                Label17.Text = "Payoff: " & s1 & "." & m1 & " * " & _dPrice & " = " & Result
                Label31.Text = Result
                Button1.Enabled = False
                ComboBox1.Enabled = False
            Else
                Button1.Text = "STOP"
                Timer1.Start()
                Label13.Text = "Fuel : "
                Label17.Text = "Payoff : "
            End If

        ElseIf (ComboBox1.Text = "95") Then
            If Button1.Text = "STOP" Then
                Result = 0
                Timer1.Stop()
                Button1.Text = "FILL IN"
                Result = Val(s1 & "." & m1) * Val(_95Price)
                Label17.Text = "Payoff = " & s1 & "." & m1 & " * " & _95Price & " = " & Result
                Label31.Text = Result
                Button1.Enabled = False
                ComboBox1.Enabled = False
            Else
                Button1.Text = "STOP"
                Timer1.Start()
                Label13.Text = "Fuel : "
                Label17.Text = "Payoff : "
            End If

        ElseIf (ComboBox1.Text = "98") Then
            If Button1.Text = "STOP" Then
                Result = 0
                Timer1.Stop()
                Button1.Text = "FILL IN"
                Result = Val(s1 & "." & m1) * Val(_98Price)
                Label17.Text = "Payoff = " & s1 & "." & m1 & " * " & _98Price & " = " & Result
                Label31.Text = Result
                Button1.Enabled = False
                ComboBox1.Enabled = False
            Else
                Button1.Text = "STOP"
                Timer1.Start()
                Label13.Text = "Fuel : "
                Label17.Text = "Payoff : "
            End If
        Else : MessageBox.Show("Please select the fuel type")
        End If

    End Sub
    'STATION 2 BUTTON FILL IN
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If (ComboBox2.Text = "DIESEL") Then
            If Button2.Text = "STOP" Then
                Result = 0
                Timer2.Stop()
                Button2.Text = "FILL IN"
                Result = Val(s2 & "." & m2) * Val(_dPrice)
                Label18.Text = "Payoff: " & s2 & "." & m2 & " * " & _dPrice & " = " & Result
                Label32.Text = Result
                Button2.Enabled = False
                ComboBox2.Enabled = False
            Else
                Button2.Text = "STOP"
                Timer2.Start()
                Label14.Text = "Fuel : "
                Label18.Text = "Payoff : "

            End If

        ElseIf (ComboBox2.Text = "95") Then
            If Button2.Text = "STOP" Then
                Result = 0
                Timer2.Stop()
                Button2.Text = "FILL IN"
                Result = Val(s2 & "." & m2) * Val(_95Price)
                Label18.Text = "Payoff = " & s2 & "." & m2 & " * " & _95Price & " = " & Result
                Label32.Text = Result
                Button2.Enabled = False
                ComboBox2.Enabled = False
            Else
                Button2.Text = "STOP"
                Timer2.Start()
                Label14.Text = "Fuel : "
                Label18.Text = "Payoff : "
            End If

        ElseIf (ComboBox2.Text = "98") Then
            If Button2.Text = "STOP" Then
                Result = 0
                Timer2.Stop()
                Button2.Text = "FILL IN"
                Result = Val(s2 & "." & m2) * Val(_98Price)
                Label18.Text = "Payoff = " & s2 & "." & m2 & " * " & _98Price & " = " & Result
                Label32.Text = Result
                Button2.Enabled = False
                ComboBox2.Enabled = False
            Else
                Button2.Text = "STOP"
                Timer2.Start()
                Label14.Text = "Fuel : "
                Label18.Text = "Payoff : "
            End If
        Else : MessageBox.Show("Please select the fuel type")
        End If
    End Sub
    'STATION 3 BUTTON FILL IN
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If (ComboBox3.Text = "DIESEL") Then
            If Button3.Text = "STOP" Then
                Timer3.Stop()
                Button3.Text = "FILL IN"
                Result = Val(s3 & "." & m3) * Val(_dPrice)
                Label19.Text = "Payoff: " & s3 & "." & m3 & " * " & _dPrice & " = " & Result
                Label33.Text = Result
                Button3.Enabled = False
                ComboBox3.Enabled = False
            Else
                Button3.Text = "STOP"
                Timer3.Start()
                Label15.Text = "Fuel : "
                Label19.Text = "Payoff : "
            End If

        ElseIf (ComboBox3.Text = "95") Then
            If Button3.Text = "STOP" Then
                Timer3.Stop()
                Button3.Text = "FILL IN"
                Result = Val(s3 & "." & m3) * Val(_95Price)
                Label19.Text = "Payoff = " & s3 & "." & m3 & " * " & _95Price & " = " & Result
                Label33.Text = Result
                Button3.Enabled = False
                ComboBox3.Enabled = False
            Else
                Button3.Text = "STOP"
                Timer3.Start()
                Label15.Text = "Fuel : "
                Label19.Text = "Payoff : "
            End If

        ElseIf (ComboBox3.Text = "98") Then
            If Button3.Text = "STOP" Then
                Timer3.Stop()
                Button3.Text = "FILL IN"
                Result = Val(s3 & "." & m3) * Val(_98Price)
                Label19.Text = "Payoff = " & s3 & "." & m3 & " * " & _98Price & " = " & Result
                Label33.Text = Result
                Button3.Enabled = False
                ComboBox3.Enabled = False
            Else
                Button3.Text = "STOP"
                Timer3.Start()
                Label15.Text = "Fuel : "
                Label19.Text = "Payoff : "
            End If
        Else : MessageBox.Show("Please select the fuel type")
        End If
    End Sub
    'STATION 4 BUTTON FILL IN
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If (ComboBox4.Text = "DIESEL") Then
            If Button4.Text = "STOP" Then
                Timer4.Stop()
                Button4.Text = "FILL IN"
                Result = Val(s4 & "." & m4) * Val(_dPrice)
                Label20.Text = "Payoff: " & s4 & "." & m4 & " * " & _dPrice & " = " & Result
                Label34.Text = Result
                Button4.Enabled = False
                ComboBox4.Enabled = False
            Else
                Button4.Text = "STOP"
                Timer4.Start()
                Label16.Text = "Fuel : "
                Label20.Text = "Payoff : "
            End If

        ElseIf (ComboBox4.Text = "95") Then
            If Button4.Text = "STOP" Then
                Timer4.Stop()
                Button4.Text = "FILL IN"
                Result = Val(s4 & "." & m4) * Val(_95Price)
                Label20.Text = "Payoff = " & s4 & "." & m4 & " * " & _95Price & " = " & Result
                Label34.Text = Result
                Button4.Enabled = False
                ComboBox4.Enabled = False
            Else
                Button4.Text = "STOP"
                Timer4.Start()
                Label16.Text = "Fuel : "
                Label20.Text = "Payoff : "
            End If

        ElseIf (ComboBox4.Text = "98") Then
            If Button4.Text = "STOP" Then
                Timer4.Stop()
                Button4.Text = "FILL IN"
                Result = Val(s4 & "." & m4) * Val(_98Price)
                Label20.Text = "Payoff = " & s4 & "." & m4 & " * " & _98Price & " = " & Result
                Label34.Text = Result
                Button4.Enabled = False
                ComboBox4.Enabled = False
            Else
                Button4.Text = "STOP"
                Timer4.Start()
                Label16.Text = "Fuel : "
                Label20.Text = "Payoff : "
            End If
        Else : MessageBox.Show("Please select the fuel type")
        End If
    End Sub
    ' Результаты :
    Dim R As Double
    Dim Summa As Double = 0

    'Pay 1 Button
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        'If (Label31.Text = "0") Then
        '    MessageBox.Show("The fuel is paid")
        'End If
        If Label31.Text <> "0" Then
            R = Label31.Text
            Summa = Val(Summa) + Val(R)
            Label36.Text = Summa
        End If
        Label31.Text = "0"
        Label13.Text = "Fuel : "
        Label17.Text = "Payoff : "
        s1 = 0
        Button1.Enabled = True
        ComboBox1.Enabled = True
    End Sub
    'Pay 2 Button
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        'If (Label32.Text = "0") Then
        '    MessageBox.Show("The fuel is paid")
        'End If
        If Label32.Text <> "0" Then
            R = Label32.Text
            Summa = Val(Summa) + Val(R)
            Label36.Text = Summa
        End If
        Label32.Text = "0"
        Label14.Text = "Fuel : "
        Label18.Text = "Payoff : "
        s2 = 0
        Button2.Enabled = True
        ComboBox2.Enabled = True
    End Sub
    'Pay 3 Button
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        'If (Label33.Text = "0") Then
        '    MessageBox.Show("The fuel is paid")
        'End If
        If Label33.Text <> "0" Then
            R = Label33.Text
            Summa = Val(Summa) + Val(R)
            Label36.Text = Summa
        End If
        Label33.Text = "0"
        Label15.Text = "Fuel : "
        Label19.Text = "Payoff : "
        s3 = 0
        'Result = 0
        Button3.Enabled = True
        ComboBox3.Enabled = True
    End Sub
    'Pay 4 Button
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        'If (Label34.Text = "0") Then
        'MessageBox.Show("The fuel is paid")
        'End If
        If Label34.Text <> "0" Then
            R = Label34.Text
            Summa = Val(Summa) + Val(R)
            Label36.Text = Summa
        End If
        Label34.Text = "0"
        Label16.Text = "Fuel : "
        Label20.Text = "Payoff : "
        s4 = 0
        'Result = 0
        Button4.Enabled = True
        ComboBox4.Enabled = True
    End Sub

    'Change Diesel Fuel
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Try
            If (TextBox1.Text.Length = 0) Then
                MessageBox.Show("Please enter the value")
            Else : _dPrice = TextBox1.Text
            End If
        Catch
            MessageBox.Show("Invalid value format")
        End Try
    End Sub
    'Change 95 Fuel
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Try
            If (TextBox2.Text.Length = 0) Then
                MessageBox.Show("Please enter the value")
            Else : _95Price = TextBox2.Text
            End If
        Catch
            MessageBox.Show("Invalid value format")
        End Try
    End Sub
    'Change 98 Fuel
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try
            If (TextBox3.Text.Length = 0) Then
                MessageBox.Show("Please enter the value")
            Else : _98Price = TextBox3.Text
            End If
        Catch
            MessageBox.Show("Invalid value format")
        End Try
    End Sub


End Class