Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
kdbarang.Items.Add("TS001")
kdbarang.Items.Add("TS002")
kdbarang.Items.Add("VG001")
kdbarang.Items.Add("VG002")
End Sub
Sub buattabel()
With lv
.Columns.Add("No Pembelian", 80, HorizontalAlignment.Center)
.Columns.Add("Kode Barang", 120, HorizontalAlignment.Left)
.Columns.Add("Nama Barang", 100, HorizontalAlignment.Left)
.Columns.Add("Merk", 100, HorizontalAlignment.Left)
.Columns.Add("Harga", 100, HorizontalAlignment.Left)
.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Left)
.Columns.Add("Total Harga", 80, HorizontalAlignment.Left)
.GridLines = True
.FullRowSelect = True
.View = View.Details
End With
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
masuktabel()
End Sub
Sub masuktabel()
Dim lst As New ListViewItem
With lst
.Text = nomor.Text
.SubItems.Add(kdbarang.Text)
.SubItems.Add(nama.Text)
.SubItems.Add(merk.Text)
.SubItems.Add(harga.Text)
.SubItems.Add(jumlah.Text)
.SubItems.Add(totharga.Text)
lv.Items.Add(lst)
End With
End Sub
Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
nomor.Text = ""
kdbarang.Text = ""
nama.Text = ""
merk.Text = ""
harga.Text = ""
jumlah.Text = ""
totharga.Text = ""
End Sub
Private Sub hapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusdata.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 keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
MsgBox("terima kasih")
End
End Sub
Private Sub kdbarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kdbarang.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kdbarang.Text, 2)
Select Case x
Case "TS" : merk.Text = "Toshiba"
Case "VG" : merk.Text = "V-GEN"
End Select
x = Microsoft.VisualBasic.Right(kdbarang.Text, 3)
Select Case x
Case "001" : nama.Text = "flashdisk 4GB"
Case "002" : nama.Text = "flashdisk 2 GB"
End Select
If kdbarang.Text = "TS001" Then
harga.Text = 105000
ElseIf kdbarang.Text = "TS002" Then
harga.Text = 75000
ElseIf kdbarang.Text = "VG001" Then
harga.Text = 90000
ElseIf kdbarang.Text = "VG002" Then
harga.Text = 60000
End If
End Sub
Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
kdbarang_SelectedIndexChanged(sender, e)
End If
totharga.Text = Val(harga.Text) * Val(jumlah.Text)
End Sub
End Class
Hasil formnya :
Tidak ada komentar:
Posting Komentar