assalamualaikum wr.wb selamat datang di blog aini

Kamis, 06 Juni 2013

Yuk! Belajar Konsep Pemrograman Di Mesran.Blogspot.Com

 QUIS LISVIEW PENJUALAN BARANG

Kemudian ketik listing programnya seperti berikut:


Public Class Listview
    Sub BuatTabel()
        LV.Columns.Add("nmrpmb", 50, HorizontalAlignment.Left)
        LV.Columns.Add("kode", 50, HorizontalAlignment.Left)
        LV.Columns.Add("nama", 100, HorizontalAlignment.Left)
        LV.Columns.Add("merk", 80, HorizontalAlignment.Left)
        LV.Columns.Add("harga", 60, HorizontalAlignment.Left)
        LV.Columns.Add("jumlah", 50, HorizontalAlignment.Left)
        LV.Columns.Add("tothrga", 70, HorizontalAlignment.Left)
        LV.View = View.Details
        LV.GridLines = True
        LV.FullRowSelect = True
    End Sub
    Sub IsiTabel()
        Dim Lst As New ListViewItem
        Lst.Text = nmrpmb.Text
        Lst.SubItems.Add(kode.Text)
        Lst.SubItems.Add(nama.Text)
        Lst.SubItems.Add(merk.Text)
        Lst.SubItems.Add(harga.Text)
        Lst.SubItems.Add(jumlah.Text)
        Lst.SubItems.Add(tothrga.Text)
        LV.Items.Add(Lst)
    End Sub
    Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kode.Text, 2)
        Select Case x
            Case "TS" : merk.Text = "Toshiba"
            Case "VG" : merk.Text = "V-Gen"
        End Select
        Dim x2 As String
        x2 = Microsoft.VisualBasic.Right(kode.Text, 3)
        Select Case x2
            Case "001" : nama.Text = "flashdisk 4GB"
            Case "002" : nama.Text = "flashdisk 2GB"
        End Select
        If x = "TS" And x2 = "001" Then
            harga.Text = "105000"
        ElseIf x = "TS" And x2 = "002" Then
            harga.Text = "75000"
        ElseIf x = "VG" And x2 = "001" Then
            harga.Text = "90000"
        ElseIf x = "VG" And x2 = "002" Then
            harga.Text = "60000"
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
        kode.Items.Add("TS001")
        kode.Items.Add("TS002")
        kode.Items.Add("VG001")
        kode.Items.Add("VG002")
    End Sub
    Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
        tothrga.Text = harga.Text * jumlah.Text
    End Sub
    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        nmrpmb.Text = ""
        kode.Text = ""
        nama.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlah.Text = ""
        tothrga.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 btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        IsiTabel()
        nmrpmb.Text = ""
        kode.Text = ""
        nama.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlah.Text = ""
        tothrga.Text = ""
    End Sub
    Private Sub btnhapuspilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapuspilih.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub
    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
        LV.Items.Clear()
    End Sub
End Class
Kemudian clik debug atau tekan  tombol F5
Setelah itu,input textbox yang kosong setelah anda memilih kode barang nya..Maka tampilannya akan seperti di bawah ini






Lalu klik simpan ke listview,maka tampilannya akan seperti ini

Tidak ada komentar: