Minggu, 29 Januari 2012

quiz2

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
        kodbrg.Items.Add("TS001")
        kodbrg.Items.Add("TS002")
        kodbrg.Items.Add("VG001")
        kodbrg.Items.Add("VG002")
    End Sub
    Sub BuatTabel()
        With LV
            .Columns.Add("No Pembelian", 80, HorizontalAlignment.Center)
            .Columns.Add("Kode Barang", 120, HorizontalAlignment.Left)
            .Columns.Add("Nama Barang", 100, HorizontalAlignment.Left)
            .Columns.Add("Merk", 100, HorizontalAlignment.Left)
            .Columns.Add("Harga", 100, HorizontalAlignment.Left)
            .Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Left)
            .Columns.Add("Total Harga", 80, HorizontalAlignment.Left)
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details
        End With
    End Sub
    Sub IsiTabel()
        Dim Lst As New ListViewItem
        With Lst
            .Text = pembelian.Text()
            .SubItems.Add(kodbrg.Text)
            .SubItems.Add(nmbrg.Text)
            .SubItems.Add(merk.Text)
            .SubItems.Add(harga.Text)
            .SubItems.Add(jlhbeli.Text)
            .SubItems.Add(ttlhrg.Text)
            LV.Items.Add(Lst)
        End With
    End Sub

    Private Sub kodbrg_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodbrg.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kodbrg.Text, 2)
        Select Case x
            Case "TS" : merk.Text = "Toshiba"
            Case "VG" : merk.Text = "V-Gen"
        End Select
        x = Microsoft.VisualBasic.Right(kodbrg.Text, 3)
        Select Case x
            Case "001" : nmbrg.Text = "Flashdisk 4GB"
            Case "002" : nmbrg.Text = "Flashdisk 2GB"
        End Select
        If kodbrg.Text = "TS001" Then
            harga.Text = 105000
        ElseIf kodbrg.Text = "TS002" Then
            harga.Text = 75000
        End If
        If kodbrg.Text = "VG001" Then
            harga.Text = 90000
        ElseIf kodbrg.Text = "VG002" Then
            harga.Text = 60000
        End If

    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        IsiTabel()
    End Sub

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        LV.Items.Clear()
    End Sub

    Private Sub btndata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndata.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub

    Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
        pembelian.Text = ""
        kodbrg.Text = ""
        nmbrg.Text = ""
        merk.Text = ""
        harga.Text = ""
        jlhbeli.Text = ""
        ttlhrg.Text = ""

    End Sub

    Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        End
    End Sub


    Private Sub jlhbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jlhbeli.TextChanged
        ttlhrg.Text = Val(jlhbeli.Text) * Val(harga.Text)
    End Sub
End Class



Tidak ada komentar:

Posting Komentar