Headlines News :
Home » » Perhitungan Penjualan Barang Menggunakan ListView Pada VB.Net 2008

Perhitungan Penjualan Barang Menggunakan ListView Pada VB.Net 2008

Written By Unknown on Sabtu, 07 Desember 2013 | 23.17

Mesran.Net


Oke kali ini saya akan memosting tentang penjualan dengan menggunakan ListView.
Nggak jauh beda dengan yang sebelumnya, hanya saja ada penambahan fungsi.

Langsung saja kita memasuki langkah demi langkahh yang akan kita lalui.
Asiiikkk  :D

Ini dia langkah-langkahnya


A. Rancangan Form Penjualan



B. Listing Koding Penjualan

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KodeBrg()
        Buattabel()
        Bersih()
        Nopembelian.Text = 1
    End Sub

    Sub CeKNoFaktur()
        Dim i As String
        i = 1
        If Nopembelian.Text = 1 Then
            Nopembelian.Text = i + 1
        Else
            Nopembelian.Text = Val(i) + Val(Nopembelian.Text)
        End If

    End Sub

    Sub Buattabel()
        With Lv
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details
            .Columns.Add("No Faktur", 80)
            .Columns.Add("Kode Brg", 100)
            .Columns.Add("Nama Brg", 160)
            .Columns.Add("Satuan", 100)
            .Columns.Add("Harga", 100)
            .Columns.Add("Jumlah Beli", 100)
            .Columns.Add("Total Harga", 120)
        End With
    End Sub

    Sub KodeBrg()
        Kode.Items.Add("TS001")
        Kode.Items.Add("TS002")
        Kode.Items.Add("VG001")
        Kode.Items.Add("VG002")
    End Sub

    Sub IsiTabel()
        Dim lst As New ListViewItem
        With lst
            .Text = Nopembelian.Text
            .SubItems.Add(Kode.Text)
            .SubItems.Add(Nama.Text)
            .SubItems.Add(Merk.Text)
            .SubItems.Add(Harga.Text)
            .SubItems.Add(Jumlah.Text)
            .SubItems.Add(Total.Text)
        End With
        Lv.Items.Add(lst)
        CekTotal()
    End Sub

    Sub Bersih()
        Kode.Text = ""
        Nama.Text = ""
        Merk.Text = ""
        Jumlah.Text = ""
        Harga.Text = ""
        Total.Text = ""
        Nopembelian.Enabled = False
        Total.Enabled = False : Nama.Enabled = False
        Merk.Enabled = False : Harga.Enabled = False : Totalbayar.Enabled = False
    End Sub

    Sub CekTotal()
        Dim bobot As Long
        Dim I As Integer
        bobot = 0
        For I = 0 To lv.Items.Count - 1
            bobot = bobot + Val(Lv.Items(I).SubItems(6).Text)
        Next
        Totalbayar.Text = "Rp. " & Format(bobot, "###,###,###")
    End Sub

    Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
        Dim x, y As String
        x = Strings.Left(Kode.Text, 2)
        y = Strings.Right(Kode.Text, 3)
        Select Case x
            Case "TS"
                Merk.Text = "Toshiba"
                Select Case y
                    Case "001"
                        Nama.Text = "FlashDisk 4GB"
                        Harga.Text = 105000
                    Case "002"
                        Nama.Text = "FlashDisk 2GB"
                        Harga.Text = 75000
                End Select
            Case "VG"
                Merk.Text = "V_Gen"
                Select Case y
                    Case "001"
                        Nama.Text = "FlashDisk 4GB"
                        Harga.Text = 90000
                    Case "002"
                        Nama.Text = "FlashDisk 2GB"
                        Harga.Text = 60000
                End Select
        End Select
        Jumlah.Focus()
    End Sub

    Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan.Click
        IsiTabel()
        Bersih()
        CeKNoFaktur()
    End Sub

    Private Sub Jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then
            e.Handled = True
        End If
    End Sub

    Private Sub Jumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jumlah.TextChanged
        If Jumlah.Text = "" Then
            Exit Sub
        Else
            Total.Text = Harga.Text * Jumlah.Text
        End If
    End Sub

    Private Sub Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click
        Lv.Items.Clear()
        Totalbayar.Text = ""
    End Sub

    Private Sub Batal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Batal.Click
        Bersih()
    End Sub

    Private Sub HapusData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HapusData.Click
        Lv.Items.Remove(Lv.SelectedItems(0))
        Dim bobot As Long
        Dim I As Integer
        bobot = 0
        For I = 0 To Lv.Items.Count - 1
            bobot = Val(Lv.Items(I).SubItems(6).Text) - bobot
        Next
        Totalbayar.Text = "Rp. " & Format(bobot, "###,###,###")
    End Sub

    Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        Me.Close()
    End Sub

End Class



C. Tampilan Hasil Penjualan


Gimana??
Mudah bukan??
Semoga bermanfaat y!

sekian dan Terima kasih :)
Share this post :

+ komentar + 6 komentar

4 Januari 2015 pukul 21.37

makasiiiii :D

29 Juli 2015 pukul 12.59

Mantap bro, Thanks !

14 Agustus 2015 pukul 20.48

terima kasih share ilmunya ,, semoga bermamfaat buat bangsa dan negara

23 Februari 2016 pukul 02.23

Buat datagrid bisa ga mas ?

18 April 2016 pukul 02.07

Om , kalau perhitungan tanpa melewati button. gimana caranya ya? saya sudah coba pakai function. tapi masih gagal. jadi ketika di inputkan data pada textbox hasil akan keluar pada label dan sudah terhitung secara otomatis. mohon pencerahannya

Posting Komentar

 
Support : Creating Website | | citrashare
Copyright © 2011. Citra Share - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger