Design awal
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kodebarang.Items.Add("TS001")
kodebarang.Items.Add("TS002")
kodebarang.Items.Add("VG001")
kodebarang.Items.Add("VG002")
buattabel()
End Sub
Private Sub kodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
If x = "TS" Then
merk.Text = "Toshiba"
ElseIf x = "VG" Then
merk.Text = "V-Gen"
End If
x = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
If x = "001" Then
namabarang.Text = "Flashdisk 4GB"
ElseIf x = "002" Then
namabarang.Text = "Flashdisk 2GB"
End If
If kodebarang.Text = "TS001" Then
harga.Text = "105000"
ElseIf kodebarang.Text = "TS002" Then
harga.Text = "75000"
ElseIf kodebarang.Text = "VG001" Then
harga.Text = "90000"
ElseIf kodebarang.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub
Private Sub jumlahbeli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlahbeli.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
btnproses_Click(sender, e)
End If
End Sub
Private Sub btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnproses.Click
totalharga.Text = Val(jumlahbeli.Text) * Val(harga.Text)
End Sub
Sub buattabel()
With LV
.Columns.Add("Nomor Pembelian", 100, HorizontalAlignment.Center)
.Columns.Add("Kode Barang", 100, HorizontalAlignment.Left)
.Columns.Add("Nama Barang", 100, HorizontalAlignment.Left)
.Columns.Add("Merk", 110, HorizontalAlignment.Left)
.Columns.Add("Harga", 110, HorizontalAlignment.Left)
.Columns.Add("Jumlah Beli", 110, HorizontalAlignment.Left)
.Columns.Add("Total Harga", 120, HorizontalAlignment.Center)
.View = View.Details
.GridLines = True
.FullRowSelect = True
End With
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = nopembelian.Text
lst.SubItems.Add(kodebarang.Text)
lst.SubItems.Add(namabarang.Text)
lst.SubItems.Add(merk.Text)
lst.SubItems.Add(harga.Text)
lst.SubItems.Add(jumlahbeli.Text)
lst.SubItems.Add(totalharga.Text)
LV.Items.Add(lst)
End Sub
Sub clean()
nopembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlahbeli.Text = ""
totalharga.Text = ""
End Sub
Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
Call clean()
End Sub
Private Sub btnhapusdatayangdipilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusdatayangdipilih.Click
If LV.SelectedItems.Count <> 0 Then
LV.Items.Remove(LV.SelectedItems(0))
Else
MsgBox("PILIH DATA YANG INGIN DIHAPUS !")
End If
End Sub
Private Sub btnsimpankelistview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpankelistview.Click
Call isitabel()
Call buattabel()
Call clean()
End Sub
Private Sub btnhapussemuadata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapussemuadata.Click
LV.Items.Clear()
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
Close()
End Sub
End Class
Hasil tampilan
Tidak ada komentar:
Posting Komentar