Berikut adalah hasilnya:
Berikut adalah listing programnya:
Public Class Form1
Dim x As Byte
Sub buattable()
lv.Columns.Add("No", 40, HorizontalAlignment.Left)
lv.Columns.Add("Kode", 80, HorizontalAlignment.Left)
lv.Columns.Add("Nama Barang", 80, HorizontalAlignment.Left)
lv.Columns.Add("Harga", 80, HorizontalAlignment.Left)
lv.Columns.Add("Jumlah", 80, HorizontalAlignment.Left)
lv.Columns.Add("Total Harga", 80, HorizontalAlignment.Left)
lv.Columns.Add("merk", 80, HorizontalAlignment.Left)
lv.View = View.Details
lv.GridLines = True
lv.FullRowSelect = True
End Sub
Sub isitable()
Dim lst As New ListViewItem
lst.Text = x
lst.SubItems.Add(Kode_barang.Text)
lst.SubItems.Add(nama_barang.Text)
lst.SubItems.Add(Harga.Text)
lst.SubItems.Add(Jumlah.Text)
lst.SubItems.Add(TotalHarga.Text)
lst.SubItems.Add(merk.Text)
lv.Items.Add(lst)
x = 1 + x
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattable()
x = 1
Kode_barang.Items.Add("TS001")
Kode_barang.Items.Add("TS002")
Kode_barang.Items.Add("VG001")
Kode_barang.Items.Add("VG002")
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode_barang.SelectedIndexChanged
Dim x, y As String
x = Strings.Left(Kode_barang.Text, 2)
y = Strings.Right(Kode_barang.Text, 3)
If x = "TS" Then
merk.Text = "Thosiba"
If y = "001" Then
nama_barang.Text = "Flasdisk 4GB"
Harga.Text = "105000"
Else
nama_barang.Text = "Flasdisk 2GB"
Harga.Text = "75000"
End If
ElseIf x = "VG" Then
merk.Text = "V-GEN"
If y = "001" Then
nama_barang.Text = "Flasdisk 4GB"
Harga.Text = "90000"
Else
nama_barang.Text = "Flasdisk 2GB"
Harga.Text = "60000"
End If
End If
End Sub
Private Sub Jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah.KeyPress
If e.KeyChar = Chr(13) Then
TotalHarga.Text = Harga.Text * Jumlah.Text
End If
End Sub
Private Sub ButtonSimpanke_lv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSimpanke_lv.Click
isitable()
End Sub
Private Sub ButtonBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBersih.Click
Kode_barang.Text = ""
nama_barang.Text = ""
Harga.Text = ""
Jumlah.Text = ""
merk.Text = ""
TotalHarga.Text = ""
End Sub
Private Sub btnhpsdatayg_dipilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhpsdatayg_dipilih.Click
lv.Items.Remove(lv.Items(0))
End Sub
Private Sub ButtonHpssemua_data_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHpssemua_data.Click
lv.Clear()
Kode_barang.Text = ""
nama_barang.Text = ""
Harga.Text = ""
Jumlah.Text = ""
merk.Text = ""
TotalHarga.Text = ""
End Sub
Private Sub ButtonKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonKeluar.Click
Me.Close()
End Sub
End Class
NB: No.pembelian menggunakan perulangan , jadi dia akan muncul secara otomatis.
Sekian Artikel tentang "Program Aplikasi Listview Penjualan Barang". Semoga artikel ini bermanfaat bagi anda. Good luck...
Post a Comment