Senin, 24 November 2014

Membuat Billing Tiket Bioskop Sederhana

Membuat billing tiket bioskop sederhana dan sangat mudah sekali . Program ini tidak perlu menggunakan database karena masih sangat sederhana.
Disamping kesederhanaannya program ini sangat tepat untuk belajar dasar vb.net karena sudah terdapat
contoh fungsi aritmatika, condition if, elseif, for while Case dan Class.
Langsung saja berikut sedikit screen shoot aplikasi beserta codingannya.




Script Form1.vb

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i As Integer = 1 To 6
            cboStudio.Items.Add("Studio " & i)
        Next

        With cboHari
            .Items.Add("Senin")
            .Items.Add("Selasa")
            .Items.Add("Rabu")
            .Items.Add("Kamis")
            .Items.Add("Jumat")
            .Items.Add("Sabtu")
            .Items.Add("Minggu")
        End With

        Dim a As Integer = 11
        Do While a < 24
            cboJam.Items.Add(a & ":00")
            a = a + 1
        Loop

        txtBayar.Enabled = False
        txtKembali.Enabled = False
        txtFilm.Enabled = False
        txtHarga.Enabled = False
    End Sub

    Private Sub cboStudio_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboStudio.SelectedIndexChanged
        Select Case cboStudio.Text
            Case Is = "Studio 1"
                txtFilm.Text = "The Hunger Games : Mokingjay"
            Case Is = "Studio 2"
                txtFilm.Text = "Big Hero 6"
            Case Is = "Studio 3"
                txtFilm.Text = "Interstellar"
            Case Is = "Studio 4"
                txtFilm.Text = "Salah Body"
            Case Is = "Studio 5"
                txtFilm.Text = "Automata"
            Case Is = "Studio 6"
                txtFilm.Text = "Penguin Of Madagascar"
        End Select
    End Sub
    Private Sub cboHari_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboHari.SelectedIndexChanged
        If cboHari.Text = "Senin" Or cboHari.Text = "Selasa" Or cboHari.Text = "Rabu" Or cboHari.Text = "Kamis" Then
            txtHarga.Text = "35000"
        ElseIf cboHari.Text = "Jumat" Then
            txtHarga.Text = "40000"
        Else
            txtHarga.Text = "50000"
        End If
    End Sub
    Private Sub txtJumlah_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtJumlah.KeyUp
        Dim hitung As hitung
        hitung = New hitung
        txtBayar.Text = hitung.totalHarga(Val(txtHarga.Text), Val(txtJumlah.Text))
    End Sub
    Private Sub cmdProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdProses.Click
        Dim hitung As hitung
        hitung = New hitung
        txtKembali.Text = hitung.kembalian(Val(txtBayar.Text), Val(txtDibayar.Text))
    End Sub
    Private Sub cmdBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBatal.Click
        cboStudio.Text = ""
        txtFilm.Text = ""
        cboHari.Text = ""
        txtHarga.Text = ""
        txtJumlah.Text = ""
        txtBayar.Text = ""
        txtDibayar.Text = ""
        txtKembali.Text = ""
    End Sub
    Private Sub cmdKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKeluar.Click
        End
    End Sub
End Class


Script hitung.class

Public Class hitung
    Public Function totalHarga(ByVal harga As Double, ByVal jumlah As Double) As Double
        Dim hasil As Double
        hasil = harga * jumlah
        totalHarga = hasil
    End Function

    Public Function kembalian(ByVal total As Double, ByVal bayar As Double) As Double
        Dim hasil As Double
        hasil = bayar - total
        kembalian = hasil
    End Function
End Class