Berikut jawaban program :
form design :
Public Class
Form1
Sub buattable()
LV.Columns.Add("No. Pembeli", 100,
HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 100,
HorizontalAlignment.Center)
LV.Columns.Add("Nama Barang", 100,
HorizontalAlignment.Center)
LV.Columns.Add("Merk", 80, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 80, 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 isitable()
Dim Lst As New ListViewItem
Lst.Text =
no_pembeli.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
buattable()
kode_barang.Items.Add("TS001")
kode_barang.Items.Add("TS002")
kode_barang.Items.Add("VG001")
kode_barang.Items.Add("VG002")
End Sub
Private Sub
TextBox3_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
merk.TextChanged
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"
: merk.Text = "Toshiba"
Case "VG"
: merk.Text = "VGen"
End Select
Dim y As Integer
y =
Microsoft.VisualBasic.Right(kode_barang.Text, 1)
Select Case y
Case Is = "001" : nama_barang.Text = "Flashdisk 4 Giga"
Case Is = "002" : nama_barang.Text = "Flashdisk 2 Giga"
End Select
If kode_barang.Text = "TS001"
Then
harga.Text = "75000"
ElseIf kode_barang.Text = "TS002"
Then
harga.Text = "60000"
ElseIf kode_barang.Text = "VG001"
Then
harga.Text = "80000"
ElseIf kode_barang.Text = "VG002"
Then
harga.Text = "65000"
End If
End Sub
Private Sub
keluar_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
keluar.Click
End
End Sub
Private Sub
simpan_listview_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
simpan_listview.Click
isitable()
no_pembeli.Text = ""
kode_barang.Text =
""
nama_barang.Text =
""
merk.Text = ""
harga.Text = ""
jumlah_beli.Text =
""
total_harga.Text =
""
End Sub
Private Sub
hapus_semua_data_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
hapus_semua_data.Click
LV.Items.Clear()
End Sub
Private Sub
hapus_data_yangdipilih_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
hapus_data_yangdipilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Tidak ada komentar:
Posting Komentar