Buatlah program untuk menampilkan hasil ke listview untuk kasus Latihan Listview Perhitungan Penjualan Barang
FROM LISTVIEW
PERHITUNGAN PENJUALAN BARANG
.
CODDING PROGRAMNYA :
Public Class Form1
Sub
BuatTabel()
LV.Columns.Add("No
Pembelian", 120, HorizontalAlignment.Left)
LV.Columns.Add("Kode
Barang", 80, HorizontalAlignment.Left)
LV.Columns.Add("Nama
Barang", 120, HorizontalAlignment.Left)
LV.Columns.Add("Merk",
120, HorizontalAlignment.Left)
LV.Columns.Add("Harga",
120, HorizontalAlignment.Left)
LV.Columns.Add("Jumlah
Beli", 120, HorizontalAlignment.Left)
LV.Columns.Add("Total
Harga", 120, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub
IsiTabel()
Dim Lst
As New
ListViewItem
Lst.Text = No_pembelian.Text
Lst.SubItems.Add(kode_barang.Text)
Lst.SubItems.Add(nama_barang.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jumlah_beli.Text)
Lst.SubItems.Add(total_harga.Text)
LV.Items.Add(Lst)
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
BuatTabel()
kode_barang.Items.Add("TS001")
kode_barang.Items.Add("TS002")
kode_barang.Items.Add("VG001")
kode_barang.Items.Add("VG002")
Me.Text
= "julianto simbolon"
End Sub
Private Sub btn_proses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_proses.Click
total_harga.Text = harga.Text *
jumlah_beli.Text
End Sub
Private Sub btn_simpankelistview_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
btn_simpankelistview.Click
IsiTabel()
End Sub
Private Sub btn_hapusdatayangdipilih_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
btn_hapusdatayangdipilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub btn_hapussemuadata_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
btn_hapussemuadata.Click
LV.Items.Clear()
End Sub
Private Sub kode_barang_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
kode_barang.SelectedIndexChanged
Dim x As String
x =
Microsoft.VisualBasic.Left(kode_barang.Text, 2)
Select Case x
Case
"TS" : nama_barang.Text = "Flashdisk 4GB"
Case
"VG" : nama_barang.Text = "Flashdisk 2GB"
End Select
Dim y As String
y =
Microsoft.VisualBasic.Mid(kode_barang.Text, 3)
Select Case y
Case
"001" : merk.Text = "Toshiba"
Case
"002" : merk.Text = "V-Gen"
End Select
If
kode_barang.Text = "TS001" Then
harga.Text = "105000"
ElseIf
kode_barang.Text = "TS002" Then
harga.Text = "75000"
ElseIf
kode_barang.Text = "VG001" Then
harga.Text = "90000"
ElseIf
kode_barang.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub
Private Sub btn_baru_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_baru.Click
No_pembelian.Text = ""
kode_barang.Text = ""
nama_barang.Text = ""
merk.Text = ""
harga.Text = ""
jumlah_beli.Text = ""
total_harga.Text = ""
End Sub
Private Sub No_pembelian_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
No_pembelian.TextChanged
If
No_pembelian.Text = "1" Then
kode_barang.Text = "TS001"
ElseIf
No_pembelian.Text = "2" Then
kode_barang.Text = "TS002"
ElseIf
No_pembelian.Text = "3" Then
kode_barang.Text = "VG001"
ElseIf
No_pembelian.Text = "4" Then
End If
End Sub
Private Sub btn_keluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
End Class
HASIL PROGRAMNYA
:
Tidak ada komentar:
Posting Komentar