Dim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb") Dim dt As New DataTable Dim dr As DataRow
Private Sub Latihan36017_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= '" & NOTRANS077.Text & "'", n) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DGV036.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' dr = dt.Rows.Find(KB077.Text)
If dr Is Nothing Then dr = dt.NewRow dr("KODEBARANG") = KB077.Text Else MsgBox("Maaf kode barang sudah ada") Exit Sub End If
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan.Click 'a' If NOTRANS077.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", NOTRANS077.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 ('" & NOTRANS077.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 ('" & NOTRANS077.Text & "','" & X("KODEBARANG") & "', " & X("UNIT") & ", " & X("HARGA") & ")", n) n.Open() CM.ExecuteNonQuery() n.Close() CM.Dispose() Next
Public Class latihan_036_36109058 Dim yunha As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb") Dim dt As New DataTable Dim dr As DataRow
Private Sub latihan_036_36109058Load(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= '" & a058.Text & "'", yunha) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
dgv1.DataSource = dt End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click 'a' If c058.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If Val(d058.Text) = 0 Then MsgBox("Masukkan Harga barang") Exit Sub End If
If Val(ee058.Text) = 0 Then MsgBox("Masukkan jumlah barang") Exit Sub End If
'b' dr = dt.Rows.Find(c058.Text)
If dr Is Nothing Then dr = dt.NewRow dr("KODEBARANG") = c058.Text Else MsgBox("Maaf kode barang sudah ada") Exit Sub End If
Muhammad Nur
BalasHapusPublic Class Latihan036077
Dim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Latihan36017_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= '" & NOTRANS077.Text & "'", n)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DGV036.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'
dr = dt.Rows.Find(KB077.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = KB077.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
'c'
dr = dt.NewRow
dr("KODEBARANG") = KB077.Text
dr("UNIT") = UNIT077.Text
dr("HARGA") = HB077.Text
dt.Rows.Add(dr)
'd'
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
BalasHapus'a'
If NOTRANS077.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", NOTRANS077.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 ('" & NOTRANS077.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 ('" & NOTRANS077.Text & "','" & X("KODEBARANG") & "', " & X("UNIT") & ", " & X("HARGA") & ")", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
CM.Dispose()
Next
'f'
NOTRANS077.Text = ""
JT077.Text = ""
'g'
dt.Rows.Clear()
End Sub
End Class
Komentar ini telah dihapus oleh pengarang.
BalasHapusPublic Class latihan_036_36109058
BalasHapusDim yunha As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub latihan_036_36109058Load(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= '" & a058.Text & "'", yunha)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
dgv1.DataSource = dt
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
'a'
If c058.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(d058.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(ee058.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
'b'
dr = dt.Rows.Find(c058.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = c058.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
'c'
dr = dt.NewRow
dr("KODEBARANG") = c058.Text
dr("UNIT") = d058.Text
dr("HARGA") = ee058.Text
dt.Rows.Add(dr)
'd'
c058.Text = ""
d058.Text = ""
ee058.Text = ""
End Sub
http://kartika139.blogspot.com/2011/11/latihan-36.html
BalasHapushttp://krisnasaman-teddybear.blogspot.com/2011/12/latihan36.html
BalasHapushttp://winnymatarru.blogspot.com/2011/12/latihan-36.html
BalasHapus(36109057)
BalasHapusfatma sari
http://fatmacmr.blogspot.com/2011/12/latihan-36.html
http://parubakcatherine.blogspot.com/2011/12/latihan-36.html
BalasHapushttp://elayuck.blogspot.com/2011/12/latihan-36.html
BalasHapushttp://valenndut.blogspot.com/2011/12/latihan-36.html
BalasHapushttp://sarshe-sarshe.blogspot.com/2011/12/latihan03636109060.html
BalasHapushttp://urimoktaviana.blogspot.com/2011/12/latihan-36.html
BalasHapushttp://derielrangers.blogspot.com/2011/12/form-36.html
BalasHapushttp://pute991.blogspot.com/2011/12/latihan-36.html
BalasHapushttp://hantualis.blogspot.com/2011/12/form-36-apkom-4.html
BalasHapushttp://gunawanmustari.blogspot.com/2011/12/latihan-36.html
BalasHapus