1.
Klik Start lalu pilih Microsoft
Visual Studio 2008
2.
Lalu akan muncul jendela awal
Microsoft Visual Studio seperti di bawah ini.
3.
Lalu pilih New Project dan beri nama
serta pilih tempat folder untuk menyimpannya.
4.
Kemudian
buat form sesuai dengan form di bawah ini.
5.
Berikut
ini adalah rumus untuk menjalankan form di atas.
Public Class
Latihan_39_36110048
Dim bridgeRio As New OleDb.OleDbConnection("
Provider = microsoft.ace.oledb.12.0; data source = " &
Application.StartupPath & "\DataMajemuk.accdb")
Dim tabelRio As New DataTable
Private Sub
Latihan_39_36110048_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim truckRio As New OleDb.OleDbDataAdapter
truckRio = New OleDb.OleDbDataAdapter("Select
BARANG.KODEBARANG, BARANG.NAMABARANG, UNIT, HARGA, UNIT * HARGA As JUMLAH
" & _
"From DETAILTRANSAKSI Inner join BARANG on
DETAILTRANSAKSI.KODEBARANG = BARANG.KODEBARANG where NOTRANS = '"
& NO_36110048.Text & "'",
bridgeRio)
tabelRio.Rows.Clear()
truckRio.Fill(tabelRio)
truckRio.Dispose()
DGV_36110048.DataSource = tabelRio
End Sub
Private Sub Hitung()
Dim Jumlah As Integer = 0
For Each row As DataGridViewRow In
DGV_36110048.Rows
Jumlah =
Jumlah + row.Cells("Jumlah").Value
Next
TOTAL_36110048.Text = Jumlah
End Sub
Private Sub
DGV_36110048_CellEndEdit(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DGV_36110048.CellEndEdit
If e.ColumnIndex = 0 Then
DGV_36110048.CurrentRow.Cells("NAMABARANG").Value
= ""
DGV_36110048.CurrentRow.Cells("UNIT").Value
= 0
DGV_36110048.CurrentRow.Cells("HARGA").Value
= 0
DGV_36110048.CurrentRow.Cells("JUMLAH").Value
= 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG",
"KODEBARANG",
DGV_36110048.CurrentRow.Cells("KODEBARANG").Value,
1, bridgeRio)
If Pencari.JumlanBaris = 0 Then
MsgBox("Kode barang tersebut tidak ada")
If Latihan_383940_36110048.ShowDialog =
Windows.Forms.DialogResult.OK Then
DGV_36110048.CurrentRow.Cells("KODEBARANG").Value
= Latihan_383940_36110048.DGV_36110048.CurrentRow.Cells("KODEBARANG").Value
DGV_36110048.CurrentRow.Cells("NAMABARANG").Value
= Latihan_383940_36110048.DGV_36110048.CurrentRow.Cells("NAMABARANG").Value
Else
DGV_36110048.CurrentRow.Cells("KODEBARANG").Value
= ""
End If
Exit Sub
End If
DGV_36110048.CurrentRow.Cells("NAMABARANG").Value =
Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
ElseIf e.ColumnIndex = 2 Or
e.ColumnIndex = 3 Then
DGV_36110048.CurrentRow.Cells("JUMLAH").Value
= DGV_36110048.CurrentRow.Cells("UNIT").Value
* DGV_36110048.CurrentRow.Cells("HARGA").Value
Hitung()
End If
End Sub
Private Sub
SIMPAN_36110048_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SIMPAN_36110048.Click
If tabelRio.Rows.Count = 0 Then
MsgBox("Datanya Belum Ada, Masukkan Kode Barang, Unit dan
harganya")
Exit Sub
End If
Dim Periksa As New ByIskandar.CariKeDataBaseByIskandar
Periksa.AturPencarianDataBase("MASTERTRANSAKSI",
"NOTRANS", NO_36110048.Text, 1,
bridgeRio)
If Periksa.JumlanBaris > 0 Then
MsgBox("No Transaksi Sudah Ada, Masukkan No Transaksi yang
Lain")
Exit Sub
End If
Dim truckRio As New OleDb.OleDbCommand
truckRio = New OleDb.OleDbCommand("Insert
Into MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) "
& _
"Values ('" & NO_36110048.Text &
"', #" &
TGL_36110048.Value.Month & "/"
& TGL_36110048.Value.Day & "/"
& TGL_36110048.Value.Year & "#,
'" & JENIS_36110048.Text & "')",
bridgeRio)
bridgeRio.Open()
truckRio.ExecuteNonQuery()
bridgeRio.Close()
For Each row As DataRow In
tabelRio.Rows
truckRio = New OleDb.OleDbCommand("Insert
Into DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) " & _
"Values ('" & NO_36110048.Text &
"', '" & row("KODEBARANG") & "', " & row("UNIT")
& ", " & row("HARGA") & ")",
bridgeRio)
bridgeRio.Open()
truckRio.ExecuteNonQuery()
bridgeRio.Close()
Next
truckRio.Dispose()
NO_36110048.Text = ""
JENIS_36110048.Text = ""
tabelRio.Rows.Clear()
Hitung()
End Sub
End Class
6.
Setelah itu, jalankan programnya.
0 komentar:
Posting Komentar