Sunday, December 8, 2013

Latihan Listview Perhitungan Penjualan Barang

Kasus Pemrograman : latihan listview perhitungan penjualan barang.

Design Form seperti gambar di bawah



Ketentuan :
-    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


NB : Agar tampilan program diatas lebih keren bisa anda
memasukkan image ke button pada vb net.

Created By : Tutorial Program VB Net



Berikut Listing Programnya :

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        kode_brg.Items.Add("TS001")
        kode_brg.Items.Add("TS002")
        kode_brg.Items.Add("VG001")
        kode_brg.Items.Add("VG002")
        ListView1.Columns.Add("No", 30, HorizontalAlignment.Center)
        ListView1.Columns.Add("Kode Barang", 80, HorizontalAlignment.Center)
        ListView1.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
        ListView1.Columns.Add("Merk", 50, HorizontalAlignment.Center)
        ListView1.Columns.Add("Harga Barang", 100, HorizontalAlignment.Center)
        ListView1.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
        ListView1.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
        ListView1.GridLines = True
        ListView1.FullRowSelect = True
        ListView1.View = View.Details
    End Sub

    Private Sub kode_brg_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode_brg.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kode_brg.Text, 2)
        If x = "TS" Then
            merk.Text = "Toshiba"
        ElseIf x = "VG" Then
            merk.Text = "V-Gen"
        End If
        x = Microsoft.VisualBasic.Right(kode_brg.Text, 3)
        If x = "001" Then
            nama_brg.Text = "Flashdisk 4GB"
        ElseIf x = "002" Then
            nama_brg.Text = "Flashdisk 2GB"
        End If
        If kode_brg.Text = "TS001" Then
            harga.Text = "105000"
        ElseIf kode_brg.Text = "TS002" Then
            harga.Text = "75000"
        ElseIf kode_brg.Text = "VG001" Then
            harga.Text = "90000"
        ElseIf kode_brg.Text = "VG002" Then
            harga.Text = "60000"
        End If
    End Sub

    Private Sub jumlah_beli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah_beli.KeyPress
        If e.KeyChar = Chr(13) Then
            total_hrg.Text = jumlah_beli.Text * harga.Text
        End If
    End Sub

    Private Sub btn_hps_pilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_hps_pilih.Click
        ListView1.Items.Remove(ListView1.SelectedItems(0))
    End Sub

    Private Sub btn_simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_simpan.Click
        Dim simpan As New ListViewItem
        simpan.Text = no_pembelian.Text
        simpan.SubItems.Add(kode_brg.Text)
        simpan.SubItems.Add(nama_brg.Text)
        simpan.SubItems.Add(merk.Text)
        simpan.SubItems.Add(harga.Text)
        simpan.SubItems.Add(jumlah_beli.Text)
        simpan.SubItems.Add(total_hrg.Text)
        ListView1.Items.Add(simpan)
    End Sub

    Private Sub btn_hps_semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_hps_semua.Click
        ListView1.Items.Clear()
    End Sub

    Private Sub btn_bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_bersih.Click
        no_pembelian.Text = ""
        kode_brg.Text = ""
        nama_brg.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlah_beli.Text = ""
        total_hrg.Text = ""
    End Sub

    Private Sub btn_keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_keluar.Click
        End
    End Sub
End Class

No comments: