Pages

Pages - Menu

Saturday, December 6, 2014

Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net

Tutorial Membuat Program Penjualan Barang menggunakan VB.Net




Source Codenya :

Public Class Form1

    Sub Buat_Table()
        LV.Columns.Add("No Pembeli", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Kode Barang", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Merk", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Harga", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
        LV.View = View.Details
        LV.GridLines = True
        LV.FullRowSelect = True
    End Sub

    Sub Isi_Table()
        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
        Kode_Barang.Items.Add("VG001")
        Kode_Barang.Items.Add("VG002")
        Kode_Barang.Items.Add("TS001")
        Kode_Barang.Items.Add("TS002")

        Call Buat_Table()
    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 = Mid(Kode_Barang.Text, 1, 2)
        Select Case x
            Case "VG"
                Merk.Text = "V-GEN"
            Case "TS"
                Merk.Text = "Toshiba"
        End Select

        x = Mid(Kode_Barang.Text, 3, 3)
        Select Case x
            Case "001"
                Nama_Barang.Text = "Flashdisk 4GB"
            Case "002"
                Nama_Barang.Text = "Flashdisk 2GB"
        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 Jumlah_Beli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah_Beli.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Total_Harga.Text = Harga.Text * Jumlah_Beli.Text
        End If
    End Sub

    Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
        Call Isi_Table()
    End Sub

    Private Sub btnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBersih.Click
        No_Pembelian.Text = ""
        Kode_Barang.Text = ""
        Nama_Barang.Text = ""
        Merk.Text = ""
        Harga.Text = ""
        Jumlah_Beli.Text = ""
        Total_Harga.Text = ""
    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 btnHapusPilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusPilih.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub

    Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
        Me.Close()
    End Sub
End Class


Gambar Hasilnya :


Demikian Postingan saya, semoga bermanfaat untuk kita semua !!!

0 comments:

Post a Comment