Program Pembelian Alat Tulis
Penjelasan Program:
Pertama-tama pilih barang dari combo box , otomatis harga barang tersebut akan muncul .
Kemudian tulis jumlah barang yang diinginkan, bila jumlah barang lebih dari lima akan mendapatkan diskon (Checkbox1.checked akan langsung true). 
Lalu Klik button Potongan untuk mengetahui berapa ptongan yang kita dapat, bila langsung klik button Hitung akan keluar message box. 
Setelah button Potongan di klik baru kita bisa klik button Hitung yang akan menghitung total dari semuanya yang akan muncul di textbox dan messagebox.
Klik Selesai untuk keluar dari program
Source Code:
clsDiskon
Public Class clsDiskon
    Private harga1_private, jumlah1_private As Integer
    Public Function Discount(ByVal harga As Integer, ByVal jumlah As Integer) As String
        Discount = harga * jumlah * 0.1
    End Function
    Public Property harga1() As Integer
        Get
            harga1 = harga1_private
        End Get
        Set(ByVal value As Integer)
            harga1_private = value
        End Set
    End Property
    Public Property jumlah1() As Integer
        Get
            jumlah1 = jumlah1_private
        End Get
        Set(ByVal value As Integer)
            jumlah1_private = value
        End Set
    End Property
End Class
clsHitung
Public Class clsHitung
    Private harga2_private, jumlah2_private, potongan_private As Integer
    Public Function Hitung(ByVal harga As Integer, ByVal jumlah As Integer, ByVal potongan As Integer) As String
        Hitung = harga * jumlah - potongan
    End Function
    Public Property harga2() As Integer
        Get
            harga2 = harga2_private
        End Get
        Set(ByVal value As Integer)
            harga2_private = value
        End Set
    End Property
    Public Property jumlah2() As Integer
        Get
            jumlah2 = jumlah2_private
        End Get
        Set(ByVal value As Integer)
            jumlah2_private = value
        End Set
    End Property
    Public Property potongan() As Integer
        Get
            potongan = potongan_private
        End Get
        Set(ByVal value As Integer)
            potongan_private = value
        End Set
    End Property
End Class
Form1
Public Class Form1
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.Text
            Case Is = "Pensil"
                TextBox1.Text = "1000"
            Case Is = "Pulpen"
                TextBox1.Text = "2000"
            Case Is = "Penghapus"
                TextBox1.Text = "2000"
            Case Is = "Buku Tulis"
                TextBox1.Text = "4000"
            Case Is = "Penggaris"
                TextBox1.Text = "1500"
            Case Is = "Stabilo"
                TextBox1.Text = "3000"
            Case Else
                TextBox1.Text = ""
        End Select
    End Sub
    Private Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        If TextBox2.Text >= 5 Then
            CheckBox1.Checked = True
        Else
            CheckBox1.Checked = False
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As String
        Dim objy As clsDiskon
        objy = New clsDiskon
        If CheckBox1.Checked = True Then
            x = objy.Discount(Val(TextBox1.Text), Val(TextBox2.Text))
            TextBox3.Text = x
        Else
            TextBox3.Text = "0"
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim x As String
        Dim objy As clsHitung
        objy = New clsHitung
        If TextBox3.Text = "" Then
            Dim y As Integer
            y = MsgBox("Cek Potongan Harga!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Peringatan")
        Else
            x = objy.Hitung(Val(TextBox1.Text), Val(TextBox2.Text), Val(TextBox3.Text))
            TextBox4.Text = x
        End If
        objy.harga2 = TextBox4.Text
        MsgBox(objy.harga2, MsgBoxStyle.OkOnly, "Total")
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim z As Integer
        z = MsgBox("Selesai?", MsgBoxStyle.Question + MsgBoxStyle.OkCancel, "Keluar")
        If z = vbOK Then
            End
        End If
    End Sub
End Class
 
Tidak ada komentar:
Posting Komentar