Public Class latihan2
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles No.TextChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Kode.Items.Add("TS001")
Kode.Items.Add("TS002")
Kode.Items.Add("VG001")
Kode.Items.Add("VG002")
Call buat_tabel()
End Sub
Sub buat_tabel()
LV.GridLines = True
LV.View = View.Details
LV.FullRowSelect = True
LV.Columns.Add("No")
LV.Columns.Add("Kd_Barang")
LV.Columns.Add("NaBar")
LV.Columns.Add("Merk")
LV.Columns.Add("Harga")
LV.Columns.Add("Jumlah")
LV.Columns.Add("Tot_Harga")
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
Dim xkb As String
Dim yb As String
xkb = Microsoft.VisualBasic.Left(Kode.Text, 2)
Select Case xkb
Case "TS"
Merk.Text = "TOSHIBA"
Case "VG"
Merk.Text = "VGEN"
End Select
yb = Microsoft.VisualBasic.Right(Kode.Text, 3)
Select Case yb
Case "001"
Nama.Text = "Flashdisk 4GB"
Case "002"
Nama.Text = "Flashdisk 2GB"
End Select
If xkb = "TS" And yb = "001" Then
Harga.Text = "105000"
ElseIf xkb = "VG" And yb = "001" Then
Harga.Text = "90000"
ElseIf xkb = "TS" And yb = "002" Then
Harga.Text = "75000"
ElseIf xkb = "VG" And yb = "002" Then
Harga.Text = "60000"
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_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan.Click
Dim lst As New ListViewItem
lst.Text = No.Text
lst.SubItems.Add(Kode.Text)
lst.SubItems.Add(Nama.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 Bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bersih.Click
No.Text = ""
Kode.Text = ""
Nama.Text = ""
Merk.Text = ""
Harga.Text = ""
Jumlah.Text = ""
Total.Text = ""
End Sub
Private Sub Hapus_Pilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus_Pilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub Hapus_semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus_semua.Click
LV.Items.Clear()
End Sub
Private Sub Total_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Total.TextChanged
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
Total.Text = Harga.Text * Jumlah.Text
End If
End Sub
Private Sub Jumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jumlah.TextChanged
End Sub
End Class
Tidak ada komentar:
Posting Komentar