Latihan Listview Perhitungan Penjualan Barang



Public Class databarang

 

    Private Sub databarang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        rancangtabel()
        bersih()
        Call addkodebarang()

       
    End Sub

    Sub addkodebarang()
        kodebarang.Items.Add("c001")
        kodebarang.Items.Add("c002")
        kodebarang.Items.Add("c003")
    End Sub


    Sub bersih()
        kodebarang.Text = ""
        namabarang.Text = ""
        satuan.Text = ""
        harga.Text = ""
        jumlah.Text = ""


    End Sub


    Sub rancangtabel()
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
        lv.Columns.Add("kodebarang", 100)
        lv.Columns.Add("namabarang", 140)
        lv.Columns.Add("satua", 100)
        lv.Columns.Add("harga", 100)
        lv.Columns.Add("jumlah", 80)


    End Sub


    Sub isitabel()
        Dim lst As New ListViewItem
        lst.Text = kodebarang.Text
        lst.SubItems.Add(namabarang.Text)
        lst.SubItems.Add(satuan.Text)
        lst.SubItems.Add(harga.Text)
        lst.SubItems.Add(jumlah.Text)
        lv.Items.Add(lst)

    End Sub




    Private Sub kodebarang_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        rancangtabel()
    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        isitabel()
        bersih()
        kodebarang.Focus()

    End Sub

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

    End Sub

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

    End Sub

    Private Sub kodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged

        If kodebarang.Text = "c001" Then
            namabarang.Text = "acer"
            satuan.Text = "unit"
            harga.Text = "4200000"
            jumlah.Text = "1"

        ElseIf kodebarang.Text = "c002" Then
            namabarang.Text = "tosiba"
            satuan.Text = "unit"
            harga.Text = "4000000"
            jumlah.Text = "1"

        ElseIf kodebarang.Text = "c003" Then
            namabarang.Text = "HP"
            satuan.Text = "unit"
            harga.Text = "11200000"
            jumlah.Text = "12"

        End If

    End Sub
End Class




hasilnya :




Subscribe to receive free email updates:

0 Response to "Latihan Listview Perhitungan Penjualan Barang"

Post a Comment