Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call Tabel() KodeBarang.Items.Add("TS001") KodeBarang.Items.Add("TS002") KodeBarang.Items.Add("VG001") KodeBarang.Items.Add("VG002") End Sub Sub Tabel() ListView.Columns.Add("No Pembelian", 90, HorizontalAlignment.Left) ListView.Columns.Add("Kode Barang", 80, HorizontalAlignment.Left) ListView.Columns.Add("Nama Barang", 80, HorizontalAlignment.Left) ListView.Columns.Add("Merk", 70, HorizontalAlignment.Left) ListView.Columns.Add("Harga", 60, HorizontalAlignment.Left) ListView.Columns.Add("Jumlah Beli", 70, HorizontalAlignment.Left) ListView.Columns.Add("Total Harga", 70, HorizontalAlignment.Left) ListView.View = View.Details ListView.GridLines = True ListView.FullRowSelect = True 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(Jumlah.Text) Lst.SubItems.Add(Total.Text) ListView.Items.Add(Lst) End Sub
Private Sub KodeBarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KodeBarang.SelectedIndexChanged Select Case KodeBarang.Text Case "TS001" NamaBarang.Text = "Flashdisk 4GB" Case "TS002" NamaBarang.Text = "Flashdisk 2GB" Case "VG001" NamaBarang.Text = "Flashdisk 4GB" Case "VG002" NamaBarang.Text = "Flashdisk 2GB" End Select If KodeBarang.Text = "TS001" Then Merk.Text = "Toshiba" ElseIf KodeBarang.Text = "TS002" Then Merk.Text = "Toshiba" ElseIf KodeBarang.Text = "VG001" Then Merk.Text = "V-Gen" ElseIf KodeBarang.Text = "VG002" Then Merk.Text = "V-Gen" 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 BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSimpan.Click IsiTabel() NoPembelian.Text = "" KodeBarang.Text = "" NamaBarang.Text = "" Merk.Text = "" Harga.Text = "" Jumlah.Text = "" Total.Text = "" End Sub
Private Sub BtnHapusData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusData.Click ListView.Items.Remove(ListView.SelectedItems(0)) End Sub
Private Sub BtnHapusSemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusSemua.Click ListView.Items.Clear() End Sub
Private Sub BtnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBersih.Click NoPembelian.Text = "" KodeBarang.Text = "" NamaBarang.Text = "" Merk.Text = "" Harga.Text = "" Jumlah.Text = "" Total.Text = "" End Sub
Private Sub Total_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Total.Click Total.Text = Harga.Text * Jumlah.Text End Sub
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click End End Sub
Private Sub Jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah.KeyPress Dim tombol As Integer If tombol = 13 Then Total_Click(sender, e) End If End Sub
0 komentar:
Posting Komentar