- Back to Home »
- Latihan Listview Perhitungan Penjualan Barang
Posted by : SIMATUPANG
Kamis, 06 Juni 2013
Public Class Form1
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 btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
IsiTabel()
pembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlah.Text = ""
total.Text = ""
End Sub
Sub BuatTabel()
LV.Columns.Add("No.Pembelian", 100, HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Merk", 100, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
LV.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = pembelian.Text
Lst.SubItems.Add(kodebarang.Text)
Lst.SubItems.Add(namabarang.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jumlah.Text)
Lst.SubItems.Add(total.Text)
LV.Items.Add(Lst)
End Sub
Private Sub kodebarang_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"
ElseIf x = "VG" Then
merk.Text = "V-Gen"
End If
x = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
If x = "001" Then
namabarang.Text = "Flashdisk 4GB"
ElseIf x = "002" Then
namabarang.Text = "Flashdisk 2GB"
End If
If kodebarang.Text = "TS001" Then
harga.Text = "105000"
ElseIf kodebarang.Text = "TS002" Then
harga.Text = "75000"
ElseIf kodebarang.Text = "VG001" Then
harga.Text = "90000"
ElseIf kodebarang.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub
Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
Dim tombol As Integer
If tombol = 13(e.KeyChar) Then
jumlah.Focus()
End If
total.Text = harga.Text * jumlah.Text
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
End
End Sub
End Class
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 btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
IsiTabel()
pembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlah.Text = ""
total.Text = ""
End Sub
Sub BuatTabel()
LV.Columns.Add("No.Pembelian", 100, HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Merk", 100, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
LV.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = pembelian.Text
Lst.SubItems.Add(kodebarang.Text)
Lst.SubItems.Add(namabarang.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jumlah.Text)
Lst.SubItems.Add(total.Text)
LV.Items.Add(Lst)
End Sub
Private Sub kodebarang_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"
ElseIf x = "VG" Then
merk.Text = "V-Gen"
End If
x = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
If x = "001" Then
namabarang.Text = "Flashdisk 4GB"
ElseIf x = "002" Then
namabarang.Text = "Flashdisk 2GB"
End If
If kodebarang.Text = "TS001" Then
harga.Text = "105000"
ElseIf kodebarang.Text = "TS002" Then
harga.Text = "75000"
ElseIf kodebarang.Text = "VG001" Then
harga.Text = "90000"
ElseIf kodebarang.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub
Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
Dim tombol As Integer
If tombol = 13(e.KeyChar) Then
jumlah.Focus()
End If
total.Text = harga.Text * jumlah.Text
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
End
End Sub
End Class