Program Penjualan Pada Visual Basic Net menggunakan DataGridView

Selamat Pagi . . .!!!


Terimakasih telah berkunjung di Blog nalopin.com.
Pagi ini 
nalopin.com berbagi artikel  Program Penjualan Pada Visual Basic Net menggunakan DataGridView.
DataGridView merupakan salah satu Tool yang ada pada Visual Basic Net berfungsi untuk pengembangan suatu program maupun aplikasi.

Berikut langkah-langkah pembuatan
Program Penjualan Pada Visual Basic Net menggunakan DataGridView :
  • Desainlah di Form anda seperti gambar di bawah ini
  •  Setelah selesai mendesain, Ketiklah koding di bawah ini
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            For i = 1 To 4
                ComboBox1.Items.Add("A" & "0" & i)
            Next
            With DataGridView1
                .ColumnCount = 5
                .Columns(0).Name = "Kode Barang"
                .Columns(1).Name = "Nama Barang"
                .Columns(2).Name = "Harga"
                .Columns(3).Name = "Jumlah"
                .Columns(4).Name = "Total Harga"
            End With
        End Sub
        Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
            Dim Kode As String = DataGridView1.Rows(e.RowIndex).Cells(0).Value
            Dim Jumlah As String = DataGridView1.Rows(e.RowIndex).Cells(3).Value
            Dim total As Double = 0
            If Jumlah = "" Then
                DataGridView1.Rows(e.RowIndex).Cells(3).Value = 0
            End If

            Select Case Kode
                Case "A-001"
                    DataGridView1.Rows(e.RowIndex).Cells(1).Value = "Playstation 1"
                    DataGridView1.Rows(e.RowIndex).Cells(2).Value = 250000
                Case "A-002"
                    DataGridView1.Rows(e.RowIndex).Cells(1).Value = "Playstation 2"
                    DataGridView1.Rows(e.RowIndex).Cells(2).Value = 1150000
                Case "A-003"
                    DataGridView1.Rows(e.RowIndex).Cells(1).Value = "Playstation 3"
                    DataGridView1.Rows(e.RowIndex).Cells(2).Value = 2450000
                Case "A-004"
                    DataGridView1.Rows(e.RowIndex).Cells(1).Value = "Playstation 4"
                    DataGridView1.Rows(e.RowIndex).Cells(2).Value = 4850000
                Case Else
                    DataGridView1.Rows(e.RowIndex).Cells(1).Value = ""
                    DataGridView1.Rows(e.RowIndex).Cells(2).Value = 0
            End Select
            DataGridView1.Rows(e.RowIndex).Cells(4).Value = DataGridView1.Rows(e.RowIndex).Cells(2).Value * Jumlah

            For i = 0 To DataGridView1.Rows.Count - 1
                total = total + DataGridView1.Rows(i).Cells(4).Value
            Next
            TextBox2.Text = total
        End Sub
        Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
            Dim Kode As String = DataGridView1.Columns(0).HeaderText
            If Kode = "Kode Barang" Then
                Dim autoText As TextBox = TryCast(e.Control, TextBox)
                If autoText IsNot Nothing Then
                    autoText.AutoCompleteMode = AutoCompleteMode.Suggest
                    autoText.AutoCompleteSource = AutoCompleteSource.CustomSource
                    Dim DataCollection As New AutoCompleteStringCollection()
                    addKode(DataCollection)
                    autoText.AutoCompleteCustomSource = DataCollection
                End If
            End If
        End Sub

        Public Sub addKode(ByVal col As AutoCompleteStringCollection)
            For i = 1 To 4
                col.Add("A-" & "00" & i)
            Next
        End Sub

        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            Select Case ComboBox1.Text
                Case "A01" : TextBox1.Text = "Mesran M.Kom"
                Case "A02" : TextBox1.Text = "Mariani Nainggolan"
                Case "A03" : TextBox1.Text = "Nasib Marbun"
                Case "A04" : TextBox1.Text = "Aldyan"
                Case Else : TextBox1.Text = ""
            End Select
        End Sub

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            DataGridView1.Rows.Clear()
            ComboBox1.Text = ""
            TextBox1.Text = ""
            TextBox2.Text = ""
        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Me.Close()
        End Sub
    End Class
  • Tekan F5 untuk menjalan Program !!!

 
 
Sekian Artikel Program Penjualan Pada Visual Basic Net menggunakan DataGridView. Semoga bermanfaat.

Berlangganan update artikel terbaru via email:

Tampilkan Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel