Public Class Form2
Sub
BuatTabel()
lv.Columns.Add("Pembeli",
80, HorizontalAlignment.Center)
lv.Columns.Add("Kode
Barang", 100, HorizontalAlignment.Left)
lv.Columns.Add("Nama
Barang", 100, HorizontalAlignment.Left)
lv.Columns.Add("Merk",
100, HorizontalAlignment.Left)
lv.Columns.Add("Jumlah
Beli", 100, HorizontalAlignment.Left)
lv.Columns.Add("Harga",
100, HorizontalAlignment.Left)
lv.View = View.Details
lv.GridLines = True
lv.FullRowSelect = True
End Sub
Sub
isitabel()
Dim lst
As New
ListViewItem
lst.Text = pembeli.Text
lst.SubItems.Add(kdbrg.Text)
lst.SubItems.Add(nmbrg.Text)
lst.SubItems.Add(merk.Text)
lst.SubItems.Add(jmlbeli.Text)
lst.SubItems.Add(harga.Text)
lv.Items.Add(lst)
End Sub
Private Sub kdbrg_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles kdbrg.SelectedIndexChanged
Dim X As String
Dim y As String
Dim z As String
X =
Microsoft.VisualBasic.Left(kdbrg.Text, 2)
y =
Microsoft.VisualBasic.Right(kdbrg.Text, 3)
z =
Microsoft.VisualBasic.Left(kdbrg.Text, 5)
Select Case X
Case
"TS" : merk.Text = "Toshiba"
Case
"VG" : merk.Text = "V-GEN"
End Select
Select Case y
Case
"001" : nmbrg.Text = "Flashdisk 4GB"
Case
"002" : nmbrg.Text = "Flashdisk 2GB"
End Select
Select Case z
Case
"TS001" : harga.Text = "105000"
Case
"TS002" : harga.Text = "90000"
Case
"VG001" : harga.Text = "75000"
Case
"VG002" : harga.Text = "60000"
End Select
End Sub
Private Sub Form2_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
BuatTabel()
kdbrg.Items.Add("TS001")
kdbrg.Items.Add("TS002")
kdbrg.Items.Add("VG001")
kdbrg.Items.Add("VG002")
End Sub
Private Sub btnbatal_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnbatal.Click
pembeli.Text = ""
kdbrg.Text = ""
nmbrg.Text = ""
merk.Text = ""
jmlbeli.Text = ""
harga.Text = ""
Total_Harga.Text = ""
End Sub
Private Sub hapussemua_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles hapussemua.Click
lv.Items.Clear()
End Sub
Private Sub hapusdipilih_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles hapusdipilih.Click
lv.Items.Remove(lv.SelectedItems(0))
End Sub
Private Sub simpan_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles simpan.Click
isitabel()
pembeli.Text = ""
kdbrg.Text = ""
nmbrg.Text = ""
merk.Text = ""
jmlbeli.Text = ""
harga.Text = ""
Total_Harga.Text = ""
End Sub
Private Sub jmlbeli_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
jmlbeli.KeyPress
If
e.KeyChar = Chr(13) Then
Total_Harga.Text = jmlbeli.Text *
harga.Text
End If
End Sub
End Class
No comments:
Post a Comment