informatika komputer Latihan Listview Perhitungan Penjualan Barang | Informatika komputer

Sabtu, 07 Desember 2013

Latihan Listview Perhitungan Penjualan Barang

Public Class Form1
    Sub buattabel()
        Lv.Columns.Add("kodepembelian", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("kodebarang", 180, HorizontalAlignment.Left)
        Lv.Columns.Add("namabarang", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("merk", 180, HorizontalAlignment.Left)
        Lv.Columns.Add("harga", 180, HorizontalAlignment.Left)
        Lv.Columns.Add("jumlahbeli", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("totalharga", 80, HorizontalAlignment.Center)

        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
    End Sub
    Sub isitabel()
        Dim lst As New ListViewItem
        lst.Text = nopembelian.Text
        lst.Text = kodebarang.Text
        lst.Text = namabarang.Text
        lst.Text = merk.Text
        lst.Text = jumlahbeli.Text
        lst.Text = harga.Text
        lst.Text = Totalharga.Text
        lst.SubItems.Add(nopembelian.Text)
        lst.SubItems.Add(kodebarang.Text)
        lst.SubItems.Add(namabarang.Text)
        lst.SubItems.Add(merk.Text)
        lst.SubItems.Add(harga.Text)
        lst.SubItems.Add(jumlahbeli.Text)
        lst.SubItems.Add(Totalharga.Text)
        Lv.Items.Add(lst)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
        If x = "TS" Then
            merk.Text = " Toshiba"
            harga.Text = "200000"

        ElseIf x = "VG" Then
            merk.Text = "V-Gen"
            harga.Text = "400000"
        End If
        x = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
        If x = "001" Then
            namabarang.Text = "flashdisc 4G"
        ElseIf x = "002" Then
            namabarang.Text = "flashdisc 2G"




        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        buattabel()
        kodebarang.Items.Add("TS001")
        kodebarang.Items.Add("TS002")
        kodebarang.Items.Add("VG001")
        kodebarang.Items.Add("VG002")
    End Sub

    Private Sub jumlahbeli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlahbeli.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Totalharga.Text = Val(jumlahbeli.Text) + harga.Text

        End If
    End Sub

    Private Sub jumlahbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlahbeli.TextChanged

    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        isitabel()
        nopembelian.Text = ""
        kodebarang.Text = ""
        namabarang.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlahbeli.Text = ""
        Totalharga.Text = ""




    End Sub

    Private Sub Btnsemuadata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsemuadata.Click
        Lv.Items.Remove(Lv.SelectedItems(0))

    End Sub

    Private Sub btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusdata.Click
        Lv.Items.Clear()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        nopembelian.Text = ""
        kodebarang.Text = ""
        namabarang.Text = ""
        merk.Text = ""
        jumlahbeli.Text = ""
        harga.Text = ""
        Totalharga.Text = ""



    End Sub
End Class


0 komentar:

Posting Komentar