Buatlah program untuk menampilkan hasil ke listview untuk kasus Latihan Listview Perhitungan Penjualan Barang
SOAL NO 1
.
LISTING PROGRAM:
Public Class Form1
Sub BuatTabel()
LV.Columns.Add("No Pembelian",
100, HorizontalAlignment.Left)
LV.Columns.Add("Kode Barang",
80, HorizontalAlignment.Left)
LV.Columns.Add("Nama Barang",
120, HorizontalAlignment.Left)
LV.Columns.Add("Merk", 70,
HorizontalAlignment.Left)
LV.Columns.Add("Harga", 50,
HorizontalAlignment.Left)
LV.Columns.Add("Jumlah Beli",
120, HorizontalAlignment.Left)
LV.Columns.Add("Total Harga",
120, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = No_pembelian.Text
Lst.SubItems.Add(kode_barang.Text)
Lst.SubItems.Add(nama_barang.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jumlah_beli.Text)
Lst.SubItems.Add(total_harga.Text)
LV.Items.Add(Lst)
End Sub
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
BuatTabel()
kode_barang.Items.Add("TS001")
kode_barang.Items.Add("TS002")
kode_barang.Items.Add("VG001")
kode_barang.Items.Add("VG002")
Me.Text = "SAMLYOT
HUTASOIT"
End Sub
Private Sub
btn_proses_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_proses.Click
MsgBox("APAKAH ANDA YAKIN
MENPROSES?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
total_harga.Text = harga.Text * jumlah_beli.Text
End Sub
Private Sub
btn_simpankelistview_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_simpankelistview.Click
MsgBox("APAKAH ANDA YAKIN MENYIMPAN KE
LISVIEW?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
IsiTabel()
End Sub
Private Sub
btn_hapusdatayangdipilih_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_hapusdatayangdipilih.Click
MsgBox("APAKAH ANDA YAKIN
MENGHAPUS?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub
btn_hapussemuadata_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_hapussemuadata.Click
MsgBox("APAKAH ANDA YAKIN
MENGHAPUS?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
LV.Items.Clear()
End Sub
Private Sub
kode_barang_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
kode_barang.SelectedIndexChanged
Dim x As String
x
= Microsoft.VisualBasic.Left(kode_barang.Text, 2)
Select Case x
Case "TS"
: nama_barang.Text = "Flashdisk 4GB"
Case "VG"
: nama_barang.Text = "Flashdisk 2GB"
End Select
Dim y As String
y
= Microsoft.VisualBasic.Mid(kode_barang.Text, 3)
Select Case y
Case "001"
: merk.Text = "Toshiba"
Case "002"
: merk.Text = "V-Gen"
End Select
If kode_barang.Text = "TS001"
Then
harga.Text = "105000"
ElseIf kode_barang.Text = "TS002"
Then
harga.Text = "75000"
ElseIf kode_barang.Text = "VG001"
Then
harga.Text = "90000"
ElseIf kode_barang.Text = "VG002"
Then
harga.Text = "60000"
End If
End Sub
Private Sub
btn_baru_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_baru.Click
MsgBox("APAKAH ANDA YAKIN
MEMBUATBARU?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
No_pembelian.Text = ""
kode_barang.Text = ""
nama_barang.Text = ""
merk.Text = ""
harga.Text = ""
jumlah_beli.Text = ""
total_harga.Text = ""
End Sub
Private Sub
No_pembelian_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
No_pembelian.TextChanged
If No_pembelian.Text = "1"
Then
kode_barang.Text = "TS001"
ElseIf No_pembelian.Text = "2"
Then
kode_barang.Text = "TS002"
ElseIf No_pembelian.Text = "3"
Then
kode_barang.Text = "VG001"
ElseIf No_pembelian.Text = "4"
Then
End If
End Sub
Private Sub
btn_keluar_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_keluar.Click
MsgBox("APAKAH ANDA YAKIN KELUAR?",
MsgBoxStyle.Question + MsgBoxStyle.YesNo)
Me.Close()
End Sub
End Class
SOAL NO 2
.
LISTING PROGRAM
Public Class
penjualan_TV
Private Sub
penjualan_TV_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
MyBase.Load
nama_barang.items.add("POLYTRON")
nama_barang.Items.Add("SONY")
nama_barang.Items.Add("LUCYSTAR")
Me.Text = "SAMLYOT
HUTASOIT"
End Sub
Private Sub
nama_barang_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
nama_barang.SelectedIndexChanged
If nama_barang.Text = "POLYTRON"
Then
harga.Text = "1500000"
ElseIf nama_barang.Text = "SONY"
Then
harga.Text = "2000000"
ElseIf nama_barang.Text = "LUCYSTAR"
Then
harga.Text = "1000000"
End If
End Sub
Private Sub
btn_proses_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btn_proses.Click
total_harga.Text = harga.Text * jumlah_jual.Text
If total_harga.Text < 1500000 Then
discount.Text = 0.1 * total_harga.Text
ElseIf total_harga.Text > 2000000 Then
discount.Text = 0.2 * total_harga.Text
ElseIf total_harga.Text > 1000000 Then
discount.Text = 0.3 * total_harga.Text
Else
total_harga.Text = Val(discount.Text) * Val(total_harga.Text)
End If
total_pembayaran.Text = total_harga.Text - discount.Text
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button1.Click
nama_barang.Text = ""
harga.Text = ""
jumlah_jual.Text = ""
total_harga.Text = ""
discount.Text = ""
total_pembayaran.Text = ""
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button2.Click
MsgBox("APAKAH ANDA YAKIN KELUAR?",
MsgBoxStyle.Question + MsgBoxStyle.YesNo)
Me.Close()
End Sub
End Class
NAMA: SAMLYOT HUTASOIT
NPM : 1111155
selamat : http://mesran.net/quiz.html
Tidak ada komentar:
Posting Komentar