Dim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb") Dim dt As New DataTable
Private Sub Latihan35017_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim X As New OleDb.OleDbDataAdapter X = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & NO077.Text & "'", n) X.Fill(dt) X.Dispose() DGV035.DataSource = dt End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tambah.Click 'a' If KB077.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If Val(UNIT077.Text) = 0 Then MsgBox("Masukkan Harga barang") Exit Sub End If
If Val(HB077.Text) = 0 Then MsgBox("Masukkan jumlah barang") Exit Sub End If
'b' Dim dr As DataRow dr = dt.NewRow dr("KODEBARANG") = KB077.Text dr("UNIT") = UNIT077.Text dr("HARGA") = HB077.Text
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan.Click 'a' If NO077.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If JT077.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NO077.Text, 1, n) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim CM As New OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NO077.Text & "', #" & DateTimePicker.Value.Month & "/" & DateTimePicker.Value.Day & "/" & DateTimePicker.Value.Year & "#, '" & JT077.Text & "')", n) n.Open() CM.ExecuteNonQuery() n.Close()
'e' For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NO077.Text & "','" & X("KODEBARANG") & "', " & X("UNIT") & ", " & X("HARGA") & ")", n) n.Open() CM.ExecuteNonQuery() n.Close() CM.Dispose() Next
Muhammad nur
BalasHapusPublic Class Latihan035077
Dim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim dt As New DataTable
Private Sub Latihan35017_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & NO077.Text & "'", n)
X.Fill(dt)
X.Dispose()
DGV035.DataSource = dt
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tambah.Click
'a'
If KB077.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(UNIT077.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(HB077.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
'b'
Dim dr As DataRow
dr = dt.NewRow
dr("KODEBARANG") = KB077.Text
dr("UNIT") = UNIT077.Text
dr("HARGA") = HB077.Text
dt.Rows.Add(dr)
'c'
KB077.Text = ""
UNIT077.Text = ""
HB077.Text = ""
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan.Click
'a'
If NO077.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT077.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NO077.Text, 1, n)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NO077.Text & "', #" & DateTimePicker.Value.Month & "/" & DateTimePicker.Value.Day & "/" & DateTimePicker.Value.Year & "#, '" & JT077.Text & "')", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
'e'
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NO077.Text & "','" & X("KODEBARANG") & "', " & X("UNIT") & ", " & X("HARGA") & ")", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
CM.Dispose()
Next
'f'
NO077.Text = ""
JT077.Text = ""
'g'
dt.Rows.Clear()
End Sub
End Class
Komentar ini telah dihapus oleh pengarang.
BalasHapushttp://kartika139.blogspot.com/2011/11/latihan-35.html
BalasHapushttp://krisnasaman-teddybear.blogspot.com/2011/12/public-class-latihan3536109074-dim.html
BalasHapushttp://winnymatarru.blogspot.com/2011/12/latihan-35.html
BalasHapus36109057
BalasHapusfatma sari
http://fatmacmr.blogspot.com/2011/12/latihan-35.html
http://parubakcatherine.blogspot.com/2011/12/latihan-35.html
BalasHapushttp://meylin-meylanierlangga.blogspot.com/2011/12/latihan-35.html
BalasHapushttp://elayuck.blogspot.com/2011/12/latihan-35.html
BalasHapushttp://valenndut.blogspot.com/2011/12/latihan-35.html
BalasHapushttp://sarshe-sarshe.blogspot.com/2011/12/latihan2636109060.html
BalasHapushttp://nurulilmimustari.blogspot.com/2011/12/form-35.html
BalasHapushttp://urimoktaviana.blogspot.com/2011/12/latihan-35.html
BalasHapushttp://derielrangers.blogspot.com/2011/12/latihan-35-public-class-latihan35084.html
BalasHapushttp://pute991.blogspot.com/2011/12/latihan-35.html
BalasHapushttp://hantualis.blogspot.com/2011/12/form-35-apkom-4.html
BalasHapushttp://gunawanmustari.blogspot.com/2011/12/latihan-35.html
BalasHapus