Source Code Contoh From Transaksi Penjualan VB .NET

Pada tutorial kali ini saya akan memberikan Logika dalam Membuat Form Transaksi Penjualan pada VB .NET. Koding form transaksi memang biasany...

Pada tutorial kali ini saya akan memberikan Logika dalam Membuat Form Transaksi Penjualan pada VB .NET. Koding form transaksi memang biasanya lebih panjang dari form master lainnya. Karena pada form transaksi lebih kompleks dan banyak yang harus di kendalikan pada Dataridview Visual Basic .NET agar form transaksi ini berjalan dengan semestinya.

Hasil dari from transaksi penjualan adalah seperti gambar dibawah ini :

Source Code Contoh From Transaksi Penjualan VB .NET

Bagaimana apakah anda tertarik untuk membuat Form transaksi diatas?

Berikut langkahnya :
Silahakn buka VB .NET anda
Bautlah sebuah project VB .NET
Jika sudah muncul Form1, silahkan design form1 seperti gambar dibawah ini :
Download Source Code Contoh From Transaksi Penjualan VB .NET
Pada gambar diatas terdapat :
DataGridView yang diganti namanya menjadi : dgvData
Button Tambah : btnAdd
Button Hapus : btnRemove
Label Total
dan TexBox : txtSumTotal

JIka sudah selesai membuat Form seperti gambar diatas,
Silahkan Masukan Koding pada Form1 dibawah ini :

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
Me.Text = "Contoh Form Transaksi Penjualan - www.javanetmedia.com"
txtSumTotal.Text = "0.00"
SetupGridView()
Dim row As String() = New String() {1, "BRG0001", "Nama Barang 1", 1, 0.0, 0.0}
' Add First Row
dgvData.Rows.Add(row)
' Focus
dgvData.Focus()
dgvData.CurrentCell = dgvData.Rows(dgvData.RowCount - 1).Cells(3)
' / Summary Cell Index = 5
CalSumTotal()
End Sub

' / --------------------------------------------------------------------------------
Private Sub SetupGridView()
With dgvData
.RowHeadersVisible = False
.AllowUserToAddRows = False
.AllowUserToDeleteRows = False
.AllowUserToResizeRows = False
.MultiSelect = False
.ReadOnly = False
' Columns Specified
dgvData.ColumnCount = 6
dgvData.Columns(0).Name = "No"
'dgvData.Columns(0).Visible = False ' Don't show Primary Key
dgvData.Columns(1).Name = "Kode_Barang"
dgvData.Columns(2).Name = "Nama_barang"
dgvData.Columns(3).Name = "Jumlah"
dgvData.Columns(3).ValueType = GetType(Integer)
dgvData.Columns(4).Name = "Harga"
dgvData.Columns(4).ValueType = GetType(Double)
dgvData.Columns(5).Name = "Total"
dgvData.Columns(5).ValueType = GetType(Double)
' Hidden column index 0 ... It's Primary Key for DataBase
.Columns("No").Visible = True ' False
.Columns("Kode_Barang").HeaderText = "Kode_Barang"
.Columns("Nama_Barang").HeaderText = "Nama_Barang"
.Columns("Jumlah").HeaderText = "Jumlah"
.Columns("Harga").HeaderText = "Harga"
' Total Column
With .Columns("Total")
.HeaderText = "Total"
.ReadOnly = True
.DefaultCellStyle.BackColor = System.Drawing.Color.LightGoldenrodYellow
.DefaultCellStyle.ForeColor = System.Drawing.Color.Red
.DefaultCellStyle.Font = New Font(dgvData.Font, FontStyle.Bold)
End With
' Adjust Column width
.Columns(0).Width = 35
.Columns(1).Width = dgvData.Width \ 5
.Columns(2).Width = dgvData.Width \ 5
.Columns(3).Width = dgvData.Width \ 5 - 20
.Columns(4).Width = dgvData.Width \ 5 - 20
.Columns(5).Width = dgvData.Width \ 5 ' + 2
' Header Own Style
With .ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(dgvData.Font, FontStyle.Bold)
End With
' Alignment only columns 3 to 5
For i As Byte = 3 To 5
' Header Alignment
.Columns(i).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
' Cell Alignment
.Columns(i).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
Next
End With
End Sub

' / --------------------------------------------------------------------------------
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
With dgvData
.Width = Me.Width - 22
End With
txtSumTotal.Left = Me.Width - (txtSumTotal.Width + 20)
Label1.Location = New Point(txtSumTotal.Left - Me.Label1.Width, txtSumTotal.Top + 3)
End Sub

' / --------------------------------------------------------------------------------
' / Add new row
Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim Position As Integer = dgvData.Rows.Count - 1
Dim LastRow = (From Items In dgvData.Rows.Cast(Of DataGridViewRow)() Select Items).ElementAt(Position)

Dim PK As Long = LastRow.Cells(0).Value + 1
Dim row As String() = New String() {PK, "BRG000" & PK, "Nama Barang " & PK, 1, 0.0, 0.0}
dgvData.Rows.Add(row)
' Focus
dgvData.CurrentCell = dgvData.Rows(dgvData.RowCount - 1).Cells(3)
dgvData.Focus()
' /
CalSumTotal()
End Sub

' / --------------------------------------------------------------------------------
' / Remove selected row
Private Sub btnDelRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
If dgvData.RowCount = 1 Then Exit Sub
dgvData.Rows.Remove(dgvData.CurrentRow)
dgvData.Refresh()
' /
CalSumTotal()
End Sub

' / --------------------------------------------------------------------------------
' / Calcualte sum of Total (Column Index = 5)
Private Sub CalSumTotal()
txtSumTotal.Text = "0.00"
For i As Byte = 0 To dgvData.RowCount - 1
' CDbl = Convert to Double
txtSumTotal.Text = CDbl(txtSumTotal.Text) + CDbl(dgvData.Rows(i).Cells(5).Value)
Next
txtSumTotal.Text = Format(CDbl(txtSumTotal.Text), "#,##0.00")
End Sub

' / --------------------------------------------------------------------------------
' / Before Edit Data
Private Sub dgvData_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvData.CellBeginEdit
Dim Quantity As Integer = dgvData.Rows(e.RowIndex).Cells(3).Value
Dim UnitPrice As Double = dgvData.Rows(e.RowIndex).Cells(4).Value
dgvData.Rows(e.RowIndex).Cells(5).Value = (Quantity * UnitPrice).ToString("#,##0.00")
' /
CalSumTotal()
End Sub

' / --------------------------------------------------------------------------------
' / After you press Enter
Private Sub dgvData_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvData.CellEndEdit

Select Case e.ColumnIndex
Case 3, 4 ' Column Index = 3 (Quantity), Column Index = 4 (UnitPrice)
' Quantity
' If Null Value
If IsDBNull(dgvData.Rows(e.RowIndex).Cells(3).Value) Then dgvData.Rows(e.RowIndex).Cells(3).Value = 0
Dim Quantity As Integer = dgvData.Rows(e.RowIndex).Cells(3).Value
' Keep original value in temporary. (Tag Properties)
dgvData.Tag = Quantity
If Quantity <= 0 Then
dgvData.Rows(e.RowIndex).Cells(3).Value = dgvData.Tag
Quantity = dgvData.Tag
End If

' UnitPrice
' If Null Value
If IsDBNull(dgvData.Rows(e.RowIndex).Cells(4).Value) Then dgvData.Rows(e.RowIndex).Cells(4).Value = 0.0
Dim UnitPrice As Double = dgvData.Rows(e.RowIndex).Cells(4).Value
dgvData.Tag = UnitPrice
If UnitPrice < 0 Then
dgvData.Rows(e.RowIndex).Cells(4).Value = dgvData.Tag
UnitPrice = dgvData.Tag
End If
' Quantity x UnitPrice
dgvData.Rows(e.RowIndex).Cells(5).Value = (Quantity * UnitPrice).ToString("#,##0.00")
CalSumTotal()
End Select
End Sub

' / --------------------------------------------------------------------------------
Private Sub dgvData_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvData.EditingControlShowing
Select Case dgvData.Columns(dgvData.CurrentCell.ColumnIndex).Name
' / Can use both ColumeIndex or Field Name
Case "Quantity", "UnitPrice"
RemoveHandler e.Control.KeyPress, AddressOf ValidKeyPress
AddHandler e.Control.KeyPress, AddressOf ValidKeyPress
End Select
End Sub

' / --------------------------------------------------------------------------------
Private Sub ValidKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
Dim tb As TextBox = sender
Select Case dgvData.CurrentCell.ColumnIndex
Case 3 ' Quantity is Integer
Select Case e.KeyChar
Case "0" To "9" ' digits 0 - 9 allowed
Case ChrW(Keys.Back) ' backspace allowed for deleting (Delete key automatically overrides)
Case ChrW(Keys.Delete) ' Delete key

Case Else ' everything else ....
' True = CPU cancel the KeyPress event
e.Handled = True ' and it's just like you never pressed a key at all
End Select

Case 4 ' UnitPrice is Double
Select Case e.KeyChar
Case "0" To "9"
' Allowed "."
Case "."
' can present "." only one
If InStr(tb.Text, ".") Then e.Handled = True

Case ChrW(Keys.Back)
Case ChrW(Keys.Delete)
Case Else
e.Handled = True

End Select
End Select
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Me.Dispose()
Application.Exit()
End Sub
End Class
Jika sudah silahkan anda Save dan Jalankan Project VB .NET anda

Demikian Source Code Contoh From Transaksi Penjualan VB .NET, semoga bermanfaat untuk anda
Silahkan KLIK DISINI untuk download Project diatas

Selain sebagai media informasi pemrograman, kami juga berbagi artikel terkait tips trik Android.

COMMENTS

Nama

add url,1,anak siantar,5,aplikasi,2,batak,1,bisnis,13,blogger,2,Bogor,1,budaya,3,Cafe,2,Coffe,1,CRUD,3,Crystal Report,6,Download,3,ef co id,1,english,1,facebook,7,Freelancer,2,hotel,2,informasi,38,inggris,1,iphone,1,Jaringan Komputer,3,jasa,2,jual beli,1,Kalendar,1,khas,1,komputer,8,kuliner,2,kursus,1,laptop,1,marketer,1,marketplace,11,Masehi,1,mobil,1,MUSIC AUDACITY,1,Neon Box,1,oyo,1,oyo penipuan,1,P2P,1,Pancawarna,1,perusahaan,2,produk,1,profesional,2,provider,1,review,2,roi,1,Router,1,seo,1,siantar,6,sistem operasi,2,Software,3,submit url,1,telkomsel,1,Template,1,Tenda 03,1,Tips Trik VB .Net,15,Tutorial,11,Tutorial C#,5,Tutorial Database,14,Tutorial VB .Net,35,Wifi,1,windows,22,
ltr
item
Boi Meningkat Belajar Digital x Komputer: Source Code Contoh From Transaksi Penjualan VB .NET
Source Code Contoh From Transaksi Penjualan VB .NET
https://2.bp.blogspot.com/-53tL3ubup-0/WhmQ2H78VYI/AAAAAAAACB0/Szv42Qq_sl0mScDceK8ljxuuakE9cZOPQCLcBGAs/w400-h233/vbnet-transaksi-2.PNG
https://2.bp.blogspot.com/-53tL3ubup-0/WhmQ2H78VYI/AAAAAAAACB0/Szv42Qq_sl0mScDceK8ljxuuakE9cZOPQCLcBGAs/s72-w400-c-h233/vbnet-transaksi-2.PNG
Boi Meningkat Belajar Digital x Komputer
https://www.boimeningkat.com/2017/11/source-code-contoh-from-transaksi.html
https://www.boimeningkat.com/
https://www.boimeningkat.com/
https://www.boimeningkat.com/2017/11/source-code-contoh-from-transaksi.html
true
5369156563580459666
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Daftar Ide Pokok