KETENTUAN SOAL:
- Kode barang menentukan nama barang dan merk
- 2 digit karakter dari sebelah kiri menentukan merk barang.
- 3 digit karakter dari sebelah kanan adalah menentukan nama barang.
- Total harga muncul ketika terjadi penekanan Enter di jumlah beli.
- Total Harga = Harga * Jumlah Beli
Contoh : Kode Barang = TS001, Merk = Toshiba, Nama Barang = Flashdisk 4GB.
Kode Barang = TS002, Merk = Toshiba, Nama Barang = Flashdisk 2GB.
Kode Barang = VG001, Merk = V-Gen, Nama Barang = Flashdisk 4GB.
Kode Barang = VG002, Merk = V-Gen, Nama Barang = Flashdisk 2GB.
Ketentuan Harga :
Kode Barang
|
001
|
002
|
TS
|
105000
|
75000
|
VG
|
90000
|
60000
|
CODING PROGRAM:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BuatTabel()
txtNoPembelian.Focus()
End Sub
Sub DataBarang()
Select Case Microsoft.VisualBasic.Right(cmbKodeBarang.Text, 3)
Case Is = "001"
txtNamaBarang.Text = "Flashdisk 4GB"
Case Is = "002"
txtNamaBarang.Text = "Flashdisk 2GB"
End Select
Select Case Microsoft.VisualBasic.Left(cmbKodeBarang.Text, 2)
Case Is = "TS"
txtMerek.Text = "Toshiba"
Case Is = "VG"
txtMerek.Text = "V-Gen"
End Select
Select Case cmbKodeBarang.Text
Case Is = "TS001"
txtHarga.Text = 105000
Case Is = "TS002"
txtHarga.Text = 75000
Case Is = "VG001"
txtHarga.Text = 90000
Case Is = "VG002"
txtHarga.Text = 60000
End Select
End Sub
Sub CariTotal()
txtTotal.Text = txtHarga.Text * txtJumlah.Text
End Sub
Private Sub cmbKodeBarang_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cmbKodeBarang.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
Call DataBarang()
txtJumlah.Focus()
End If
End Sub
Private Sub txtJumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtJumlah.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
Call CariTotal()
btnSimpan.Focus()
End If
End Sub
Sub BuatTabel()
LV.Columns.Add("No.", 80, HorizontalAlignment.Center)
LV.Columns.Add("Kode", 80, HorizontalAlignment.Center)
LV.Columns.Add("Nama", 100, HorizontalAlignment.Left)
LV.Columns.Add("Merek", 90, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 80, HorizontalAlignment.Right)
LV.Columns.Add("Jumlah", 50, HorizontalAlignment.Center)
LV.Columns.Add("Total", 50, HorizontalAlignment.Right)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = txtNoPembelian.Text
Lst.SubItems.Add(cmbKodeBarang.Text)
Lst.SubItems.Add(txtNamaBarang.Text)
Lst.SubItems.Add(txtMerek.Text)
Lst.SubItems.Add(txtHarga.Text)
Lst.SubItems.Add(txtJumlah.Text)
Lst.SubItems.Add(txtTotal.Text)
LV.Items.Add(Lst)
End Sub
Sub HapusIsian()
txtNoPembelian.Text = ""
cmbKodeBarang.Text = ""
txtNamaBarang.Text = ""
txtMerek.Text = ""
txtHarga.Text = ""
txtJumlah.Text = ""
txtTotal.Text = ""
txtNoPembelian.Focus()
End Sub
Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
IsiTabel()
End Sub
Private Sub btnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBersih.Click
HapusIsian()
End Sub
Private Sub btnHapusSemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusSemua.Click
LV.Items.Clear()
End Sub
Private Sub btnHapusSatu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusSatu.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub btnSelesai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelesai.Click
End
End Sub
End Class
HASIL PROGRAM/OUTPUT