Public Class Form39_36109010
Dim dt As New DataTable
Dim cm As New OleDb.OleDbCommand
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim hma As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form39_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("SELECT BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*HARGA AS JUMLAH FROM BARANG INNER JOIN DETAILTRANSAKSI ON BARANG.KODEBARANG = DETAILTRANSAKSI.KODEBARANG WHERE NOTRANS = '" & aa.Text & "'", hma)
a.Fill(dt)
a.Dispose()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("kodebarang")
dt.PrimaryKey = dc
dgv.DataSource = dt
End Sub
Private Sub dgv_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv.CellEndEdit
If dgv.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'If dgv.CurrentRow.Cells(0) = "KODEBARANG" Then (rumus lain)
'untuk mencari nama barang
dgv.CurrentRow.Cells("NAMABARANG").Value = ""
dgv.CurrentRow.Cells("UNIT").Value = 0
dgv.CurrentRow.Cells("HARGA").Value = 0
dgv.CurrentRow.Cells("JUMLAH").Value = 0
rusna.AturPencarianDataBase("barang", "kodebarang", dgv.CurrentRow.Cells("KODEBARANG").Value, 1, hma)
If rusna.JumlanBaris > 0 Then '(menampilkan nama barang jika kolom kode barang ditemukan oleh proses di atas
dgv.CurrentRow.Cells("NAMABARANG").Value = rusna.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv.CurrentRow.Cells("NAMABARANG").Value = ""
If Form38_39_40_36109010.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv.CurrentRow.Cells("KODEBARANG").Value = Form38_39_40_36109010.dgv.CurrentRow.Cells("KODEBARANG").Value
dgv.CurrentRow.Cells("NAMABARANG").Value = Form38_39_40_36109010.dgv.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dgv.Columns(e.ColumnIndex).Name = "UNIT" Or dgv.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv.CurrentRow.Cells("JUMLAH").Value = dgv.CurrentRow.Cells("UNIT").Value * dgv.CurrentRow.Cells("HARGA").Value
ical()
End If
End Sub
Private Sub ical()
Dim ical1 As Integer = 0
For Each ical2 As DataRow In dt.Rows
ical1 += ical2("JUMLAH")
Next
dd.Text = ical1
End Sub
Private Sub d_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles d.Click
If aa.Text.Length = 0 Then
MsgBox("Isi rong itu No Transaksinya")
Exit Sub
End If
If cc.Text.Length = 0 Then
MsgBox("Isi rong itu Jenis Transaksinya")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi rong itu datatable k")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", aa.Text, 1, hma)
If rusna.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & aa.Text & "',#" & bb.Value.Month & "/" & bb.Value.Day & "/" & bb.Value.Year & "#,'" & cc.Text & "')", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & aa.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
Next
cm.Dispose()
aa.Text = ""
cc.Text = ""
dd.Text = ""
dt.Rows.Clear()
ical()
End Sub
End Class
Tampilkan postingan dengan label Tugas. Tampilkan semua postingan
Tampilkan postingan dengan label Tugas. Tampilkan semua postingan
LATIHAN 38_39_40 APKOM 4
Public Class Form38_39_40_36109010
Dim dt As New DataTable
Dim virgo As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form38_39_40_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("SELECT * FROM BARANG", virgo)
dt.Rows.Clear()
a.Fill(dt)
a.Dispose()
dgv.DataSource = dt
End Sub
End Class
Dim dt As New DataTable
Dim virgo As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form38_39_40_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("SELECT * FROM BARANG", virgo)
dt.Rows.Clear()
a.Fill(dt)
a.Dispose()
dgv.DataSource = dt
End Sub
End Class
LATIHAN 38 APKOM 4
Public Class Form38_36109010
Dim dt As New DataTable
Dim cm As New OleDb.OleDbCommand
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim virgo As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form38_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*HARGA AS JUMLAH FROM BARANG INNER JOIN DETAILTRANSAKSI ON BARANG.KODEBARANG = DETAILTRANSAKSI.KODEBARANG WHERE NOTRANS = '" & NT_36109010.Text & "'", virgo)
a.Fill(dt)
a.Dispose()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("Kodebarang")
dt.PrimaryKey = dc
dgv.DataSource = dt
End Sub
Private Sub ningsi()
Dim ningsi1 As Integer = 0
For Each ical2 As DataRow In dt.Rows
ningsi1 += ical2("JUMLAH")
Next
TOT_36109010.Text = ningsi1
End Sub
Private Sub ff_Textchanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UNIT_36109010.TextChanged
JUMLAH_36109010.Text = Val(UNIT_36109010.Text) * Val(HARGA_36109010.Text)
End Sub
Private Sub ii_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH_36109010.Click
If KB_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu Kode Barang na..")
Exit Sub
End If
If NB_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu Kode Barang na..")
Exit Sub
End If
If Val(UNIT_36109010.Text) = 0 Then
MsgBox("Isi rong itu Unit na..")
Exit Sub
End If
If Val(HARGA_36109010.Text) = 0 Then
MsgBox("Isi rong itu Harga na..")
Exit Sub
End If
Dim dr As DataRow
dr = dt.Rows.Find(KB_36109010.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = KB_36109010.Text
dr("NAMABARANG") = NB_36109010.Text
dr("UNIT") = UNIT_36109010.Text
dr("HARGA") = HARGA_36109010.Text
dr("JUMLAH") = JUMLAH_36109010.Text
dt.Rows.Add(dr)
KB_36109010.Text = ""
UNIT_36109010.Text = ""
HARGA_36109010.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain")
End If
ningsi()
End Sub
Private Sub kk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN_36109010.Click
If NT_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu No Transaksi na..")
Exit Sub
End If
If JT_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu Jenis Transaksi na..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi rong itu datatable na..")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", NT_36109010.Text, 1, virgo)
If rusna.JumlanBaris > 0 Then
MsgBox("Adami No Transaksi seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & NT_36109010.Text & "',#" & TGL_36109010.Value.Month & "/" & TGL_36109010.Value.Day & "/" & TGL_36109010.Value.Year & "#,'" & JT_36109010.Text & "')", virgo)
virgo.Open()
cm.ExecuteNonQuery()
virgo.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", virgo)
virgo.Open()
cm.ExecuteNonQuery()
virgo.Close()
Next
cm.Dispose()
NT_36109010.Text = ""
JT_36109010.Text = ""
dt.Rows.Clear()
ningsi()
End Sub
Private Sub dd_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.Leave
If KB_36109010.Text.Length = 0 Then
Exit Sub
End If
rusna.AturPencarianDataBase("barang", "kodebarang", KB_36109010.Text, 1, virgo)
If rusna.JumlanBaris > 0 Then
KB_36109010.Text = rusna.DataTablenya.Rows(0).Item("KODEBARANG")
NB_36109010.Text = rusna.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang seperti itu tidak ada..")
If Form38_39_40_36109010.ShowDialog = Windows.Forms.DialogResult.OK Then
KB_36109010.Text = Form38_39_40_36109010.dgv.CurrentRow.Cells("kodebarang").Value
NB_36109010.Text = Form38_39_40_36109010.dgv.CurrentRow.Cells("namabarang").Value
Else
KB_36109010.Text = ""
End If
End If
End Sub
Private Sub dd_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.TextChanged
NB_36109010.Text = ""
UNIT_36109010.Text = ""
HARGA_36109010.Text = ""
End Sub
Private Sub gg_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HARGA_36109010.TextChanged
JUMLAH_36109010.Text = Val(UNIT_36109010.Text) * Val(HARGA_36109010.Text)
End Sub
End Class
Dim dt As New DataTable
Dim cm As New OleDb.OleDbCommand
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim virgo As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form38_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*HARGA AS JUMLAH FROM BARANG INNER JOIN DETAILTRANSAKSI ON BARANG.KODEBARANG = DETAILTRANSAKSI.KODEBARANG WHERE NOTRANS = '" & NT_36109010.Text & "'", virgo)
a.Fill(dt)
a.Dispose()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("Kodebarang")
dt.PrimaryKey = dc
dgv.DataSource = dt
End Sub
Private Sub ningsi()
Dim ningsi1 As Integer = 0
For Each ical2 As DataRow In dt.Rows
ningsi1 += ical2("JUMLAH")
Next
TOT_36109010.Text = ningsi1
End Sub
Private Sub ff_Textchanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UNIT_36109010.TextChanged
JUMLAH_36109010.Text = Val(UNIT_36109010.Text) * Val(HARGA_36109010.Text)
End Sub
Private Sub ii_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH_36109010.Click
If KB_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu Kode Barang na..")
Exit Sub
End If
If NB_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu Kode Barang na..")
Exit Sub
End If
If Val(UNIT_36109010.Text) = 0 Then
MsgBox("Isi rong itu Unit na..")
Exit Sub
End If
If Val(HARGA_36109010.Text) = 0 Then
MsgBox("Isi rong itu Harga na..")
Exit Sub
End If
Dim dr As DataRow
dr = dt.Rows.Find(KB_36109010.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = KB_36109010.Text
dr("NAMABARANG") = NB_36109010.Text
dr("UNIT") = UNIT_36109010.Text
dr("HARGA") = HARGA_36109010.Text
dr("JUMLAH") = JUMLAH_36109010.Text
dt.Rows.Add(dr)
KB_36109010.Text = ""
UNIT_36109010.Text = ""
HARGA_36109010.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain")
End If
ningsi()
End Sub
Private Sub kk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN_36109010.Click
If NT_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu No Transaksi na..")
Exit Sub
End If
If JT_36109010.Text.Length = 0 Then
MsgBox("Isi rong itu Jenis Transaksi na..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi rong itu datatable na..")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", NT_36109010.Text, 1, virgo)
If rusna.JumlanBaris > 0 Then
MsgBox("Adami No Transaksi seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & NT_36109010.Text & "',#" & TGL_36109010.Value.Month & "/" & TGL_36109010.Value.Day & "/" & TGL_36109010.Value.Year & "#,'" & JT_36109010.Text & "')", virgo)
virgo.Open()
cm.ExecuteNonQuery()
virgo.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", virgo)
virgo.Open()
cm.ExecuteNonQuery()
virgo.Close()
Next
cm.Dispose()
NT_36109010.Text = ""
JT_36109010.Text = ""
dt.Rows.Clear()
ningsi()
End Sub
Private Sub dd_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.Leave
If KB_36109010.Text.Length = 0 Then
Exit Sub
End If
rusna.AturPencarianDataBase("barang", "kodebarang", KB_36109010.Text, 1, virgo)
If rusna.JumlanBaris > 0 Then
KB_36109010.Text = rusna.DataTablenya.Rows(0).Item("KODEBARANG")
NB_36109010.Text = rusna.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang seperti itu tidak ada..")
If Form38_39_40_36109010.ShowDialog = Windows.Forms.DialogResult.OK Then
KB_36109010.Text = Form38_39_40_36109010.dgv.CurrentRow.Cells("kodebarang").Value
NB_36109010.Text = Form38_39_40_36109010.dgv.CurrentRow.Cells("namabarang").Value
Else
KB_36109010.Text = ""
End If
End If
End Sub
Private Sub dd_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.TextChanged
NB_36109010.Text = ""
UNIT_36109010.Text = ""
HARGA_36109010.Text = ""
End Sub
Private Sub gg_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HARGA_36109010.TextChanged
JUMLAH_36109010.Text = Val(UNIT_36109010.Text) * Val(HARGA_36109010.Text)
End Sub
End Class
LATIHAN 35 - 37 APKOM 4
LATIHAN 35
Public Class Form35_36109010
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim ningsi As New DataTable
Dim soe As New OleDb.OleDbCommand
Dim mickey As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'")
Private Sub Form35_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New OleDb.OleDbDataAdapter
r = New OleDb.OleDbDataAdapter("select KODEBARANG, UNIT, HARGA from detailtransaksi where notrans = '" & nt_36109010.Text & "'", mickey)
r.Fill(ningsi)
r.Dispose()
dgv.DataSource = ningsi
End Sub
Private Sub gg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang tidak terisi")
ElseIf Val(unit_36109010.Text) = 0 Then
MsgBox("unit tidak terisi")
ElseIf Val(harga_36109010.Text) = 0 Then
MsgBox("harga barang tidak terisi")
Exit Sub
End If
Dim dt As DataRow
dt = ningsi.NewRow
dt("KODEBARANG") = kb_36109010.Text
dt("UNIT") = unit_36109010.Text
dt("HARGA") = harga_36109010.Text
ningsi.Rows.Add(dt)
kb_36109010.Text = ""
unit_36109010.Text = ""
harga_36109010.Text = ""
End Sub
Private Sub hh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If nt_36109010.Text.Length = 0 Then
MsgBox("nomor transaksi harus terisi")
ElseIf jt_36109010.Text.Length = 0 Then
MsgBox("Isi rong Jenis Transaksi na..")
ElseIf ningsi.Rows.Count = 0 Then
MsgBox("data table tidak boleh kosong")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109010.Text, 1, mickey)
If rusna.JumlanBaris > 0 Then
MsgBox("nomor transaksi telah ada")
Exit Sub
End If
soe = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt_36109010.Text & "',#" & tgl_36109010.Value.Month & "/" & tgl_36109010.Value.Day & "/" & tgl_36109010.Value.Year & "#,'" & jt_36109010.Text & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
For Each x As DataRow In ningsi.Rows
soe = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
Next
soe.Dispose()
nt_36109010.Text = ""
jt_36109010.Text = ""
ningsi.Rows.Clear()
End Sub
End Class
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim ningsi As New DataTable
Dim soe As New OleDb.OleDbCommand
Dim mickey As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'")
Private Sub Form35_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New OleDb.OleDbDataAdapter
r = New OleDb.OleDbDataAdapter("select KODEBARANG, UNIT, HARGA from detailtransaksi where notrans = '" & nt_36109010.Text & "'", mickey)
r.Fill(ningsi)
r.Dispose()
dgv.DataSource = ningsi
End Sub
Private Sub gg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang tidak terisi")
ElseIf Val(unit_36109010.Text) = 0 Then
MsgBox("unit tidak terisi")
ElseIf Val(harga_36109010.Text) = 0 Then
MsgBox("harga barang tidak terisi")
Exit Sub
End If
Dim dt As DataRow
dt = ningsi.NewRow
dt("KODEBARANG") = kb_36109010.Text
dt("UNIT") = unit_36109010.Text
dt("HARGA") = harga_36109010.Text
ningsi.Rows.Add(dt)
kb_36109010.Text = ""
unit_36109010.Text = ""
harga_36109010.Text = ""
End Sub
Private Sub hh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If nt_36109010.Text.Length = 0 Then
MsgBox("nomor transaksi harus terisi")
ElseIf jt_36109010.Text.Length = 0 Then
MsgBox("Isi rong Jenis Transaksi na..")
ElseIf ningsi.Rows.Count = 0 Then
MsgBox("data table tidak boleh kosong")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109010.Text, 1, mickey)
If rusna.JumlanBaris > 0 Then
MsgBox("nomor transaksi telah ada")
Exit Sub
End If
soe = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt_36109010.Text & "',#" & tgl_36109010.Value.Month & "/" & tgl_36109010.Value.Day & "/" & tgl_36109010.Value.Year & "#,'" & jt_36109010.Text & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
For Each x As DataRow In ningsi.Rows
soe = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
Next
soe.Dispose()
nt_36109010.Text = ""
jt_36109010.Text = ""
ningsi.Rows.Clear()
End Sub
End Class
---------------------------------------------------------
LATIHAN 36
Public Class Form36_36109010
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim ningsi As New DataTable
Dim soe As New OleDb.OleDbCommand
Dim mickey As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'")
Private Sub Form36_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New OleDb.OleDbDataAdapter
r = New OleDb.OleDbDataAdapter("select KODEBARANG, UNIT, HARGA from detailtransaksi where notrans = '" & nt_36109010.Text & "'", mickey)
r.Fill(ningsi)
r.Dispose()
dgv.DataSource = ningsi
Dim dc(1) As DataColumn
dc(0) = ningsi.Columns("kodebarang")
ningsi.PrimaryKey = dc
End Sub
Private Sub gg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang tidak terisi")
ElseIf Val(unit_36109010.Text) = 0 Then
MsgBox("unit tidak terisi")
ElseIf Val(harga_36109010.Text) = 0 Then
MsgBox("harga barang tidak terisi")
Exit Sub
End If
Dim dt As DataRow
dt = ningsi.NewRow
dt("KODEBARANG") = kb_36109010.Text
dt("UNIT") = unit_36109010.Text
dt("HARGA") = harga_36109010.Text
ningsi.Rows.Add(dt)
kb_36109010.Text = ""
unit_36109010.Text = ""
harga_36109010.Text = ""
End Sub
Private Sub hh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If nt_36109010.Text.Length = 0 Then
MsgBox("nomor transaksi harus terisi")
ElseIf jt_36109010.Text.Length = 0 Then
MsgBox("Isi rong Jenis Transaksi na..")
ElseIf ningsi.Rows.Count = 0 Then
MsgBox("data table tidak boleh kosong")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109010.Text, 1, mickey)
If rusna.JumlanBaris > 0 Then
MsgBox("nomor transaksi telah ada")
Exit Sub
End If
soe = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt_36109010.Text & "',#" & tgl_36109010.Value.Month & "/" & tgl_36109010.Value.Day & "/" & tgl_36109010.Value.Year & "#,'" & jt_36109010.Text & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
For Each x As DataRow In ningsi.Rows
soe = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
Next
soe.Dispose()
nt_36109010.Text = ""
jt_36109010.Text = ""
ningsi.Rows.Clear()
End Sub
End Class
Dim rusna As New ByIskandar.CariKeDataBaseByIskandar
Dim ningsi As New DataTable
Dim soe As New OleDb.OleDbCommand
Dim mickey As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'")
Private Sub Form36_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New OleDb.OleDbDataAdapter
r = New OleDb.OleDbDataAdapter("select KODEBARANG, UNIT, HARGA from detailtransaksi where notrans = '" & nt_36109010.Text & "'", mickey)
r.Fill(ningsi)
r.Dispose()
dgv.DataSource = ningsi
Dim dc(1) As DataColumn
dc(0) = ningsi.Columns("kodebarang")
ningsi.PrimaryKey = dc
End Sub
Private Sub gg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang tidak terisi")
ElseIf Val(unit_36109010.Text) = 0 Then
MsgBox("unit tidak terisi")
ElseIf Val(harga_36109010.Text) = 0 Then
MsgBox("harga barang tidak terisi")
Exit Sub
End If
Dim dt As DataRow
dt = ningsi.NewRow
dt("KODEBARANG") = kb_36109010.Text
dt("UNIT") = unit_36109010.Text
dt("HARGA") = harga_36109010.Text
ningsi.Rows.Add(dt)
kb_36109010.Text = ""
unit_36109010.Text = ""
harga_36109010.Text = ""
End Sub
Private Sub hh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If nt_36109010.Text.Length = 0 Then
MsgBox("nomor transaksi harus terisi")
ElseIf jt_36109010.Text.Length = 0 Then
MsgBox("Isi rong Jenis Transaksi na..")
ElseIf ningsi.Rows.Count = 0 Then
MsgBox("data table tidak boleh kosong")
Exit Sub
End If
rusna.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109010.Text, 1, mickey)
If rusna.JumlanBaris > 0 Then
MsgBox("nomor transaksi telah ada")
Exit Sub
End If
soe = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt_36109010.Text & "',#" & tgl_36109010.Value.Month & "/" & tgl_36109010.Value.Day & "/" & tgl_36109010.Value.Year & "#,'" & jt_36109010.Text & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
For Each x As DataRow In ningsi.Rows
soe = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", mickey)
mickey.Open()
soe.ExecuteNonQuery()
mickey.Close()
Next
soe.Dispose()
nt_36109010.Text = ""
jt_36109010.Text = ""
ningsi.Rows.Clear()
End Sub
End Class
LATIHAN 37
Public Class Form37_36109010
Dim DT As New DataTable
Dim TA As New OleDb.OleDbCommand
Dim BI As New ByIskandar.CariKeDataBaseByIskandar
Dim ISMI As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form37_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & NT_36109010.Text & "'", ISMI)
DT.Rows.Clear()
a.Fill(DT)
a.Dispose()
Dim DC(1) As DataColumn
DC(0) = DT.Columns("kodebarang")
DT.PrimaryKey = DC
dgv_36109010.DataSource = DT
End Sub
Private Sub IMHI()
Dim IMHI1 As Integer = 0
For Each IMHI2 As DataRow In DT.Rows
IMHI1 += IMHI2("JUMLAH")
Next
Total.Text = IMHI1
End Sub
Private Sub UNIT_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UNIT_36109010.TextChanged
jumlah_36109010.Text = Val(UNIT_36109010.Text) * Val(Harga_36109010.Text)
End Sub
Private Sub KB_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.TextChanged
If KB_36109010.Text.Length = 0 Then
Exit Sub
End If
BI.AturPencarianDataBase("barang", "kodebarang", KB_36109010.Text, 1, ISMI)
If BI.JumlanBaris > 0 Then
KB_36109010.Text = BI.DataTablenya.Rows(0).Item("KODEBARANG")
NB_36109010.Text = BI.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang itu tidak ada..")
Exit Sub
End If
End Sub
Private Sub KB_36109005_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.TextChanged
NB_36109010.Text = ""
UNIT_36109010.Text = ""
Harga_36109010.Text = ""
End Sub
Private Sub tambah_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If KB_36109010.Text.Length = 0 Then
MsgBox("Kode Barang Belum Di isi")
Exit Sub
End If
If Val(UNIT_36109010.Text) = 0 Then
MsgBox("Kode Barang Belum Di isi")
Exit Sub
End If
If Val(Harga_36109010.Text) = 0 Then
MsgBox("Kode Barang Belum Di isi")
Exit Sub
End If
Dim DR As DataRow
DR = DT.Rows.Find(KB_36109010.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = KB_36109010.Text
DR("NAMABARANG") = NB_36109010.Text
DR("UNIT") = Val(UNIT_36109010.Text)
DR("HARGA") = Val(Harga_36109010.Text)
DR("JUMLAH") = Val(jumlah_36109010.Text)
DT.Rows.Add(DR)
KB_36109010.Text = ""
UNIT_36109010.Text = ""
Harga_36109010.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain...")
End If
IMHI()
End Sub
Private Sub simpan_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109010.Click
If NT_36109010.Text.Length = 0 Then
MsgBox("No Transaksi Belum Di isi")
Exit Sub
End If
If JT_36109010.Text.Length = 0 Then
MsgBox("Jenis Transaksi Belum Di isi")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("Isi datatable")
Exit Sub
End If
BI.AturPencarianDataBase("mastertransaksi", "notrans", NT_36109010.Text, 1, ISMI)
If BI.JumlanBaris > 0 Then
MsgBox("No Trans Seperti Itu Sudah Ada")
Exit Sub
End If
TA = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT_36109010.Text & "',#" & tgl_36109010.Value.Month & "/" & tgl_36109010.Value.Day & "/" & tgl_36109010.Value.Year & "#,'" & JT_36109010.Text & "')", ISMI)
ISMI.Open()
TA.ExecuteNonQuery()
ISMI.Close()
For Each x As DataRow In DT.Rows
TA = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", ISMI)
ISMI.Open()
TA.ExecuteNonQuery()
ISMI.Close()
Next
TA.Dispose()
NT_36109010.Text = ""
JT_36109010.Text = ""
DT.Rows.Clear()
IMHI()
End Sub
Private Sub Harga_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Harga_36109010.TextChanged
jumlah_36109010.Text = Val(UNIT_36109010.Text) * Val(Harga_36109010.Text)
End Sub
Private Sub jumlah_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah_36109010.TextChanged
jumlah_36109010.Text = Val(UNIT_36109010.Text) * Val(Harga_36109010.Text)
End Sub
End Class
Dim DT As New DataTable
Dim TA As New OleDb.OleDbCommand
Dim BI As New ByIskandar.CariKeDataBaseByIskandar
Dim ISMI As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form37_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & NT_36109010.Text & "'", ISMI)
DT.Rows.Clear()
a.Fill(DT)
a.Dispose()
Dim DC(1) As DataColumn
DC(0) = DT.Columns("kodebarang")
DT.PrimaryKey = DC
dgv_36109010.DataSource = DT
End Sub
Private Sub IMHI()
Dim IMHI1 As Integer = 0
For Each IMHI2 As DataRow In DT.Rows
IMHI1 += IMHI2("JUMLAH")
Next
Total.Text = IMHI1
End Sub
Private Sub UNIT_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UNIT_36109010.TextChanged
jumlah_36109010.Text = Val(UNIT_36109010.Text) * Val(Harga_36109010.Text)
End Sub
Private Sub KB_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.TextChanged
If KB_36109010.Text.Length = 0 Then
Exit Sub
End If
BI.AturPencarianDataBase("barang", "kodebarang", KB_36109010.Text, 1, ISMI)
If BI.JumlanBaris > 0 Then
KB_36109010.Text = BI.DataTablenya.Rows(0).Item("KODEBARANG")
NB_36109010.Text = BI.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang itu tidak ada..")
Exit Sub
End If
End Sub
Private Sub KB_36109005_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_36109010.TextChanged
NB_36109010.Text = ""
UNIT_36109010.Text = ""
Harga_36109010.Text = ""
End Sub
Private Sub tambah_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If KB_36109010.Text.Length = 0 Then
MsgBox("Kode Barang Belum Di isi")
Exit Sub
End If
If Val(UNIT_36109010.Text) = 0 Then
MsgBox("Kode Barang Belum Di isi")
Exit Sub
End If
If Val(Harga_36109010.Text) = 0 Then
MsgBox("Kode Barang Belum Di isi")
Exit Sub
End If
Dim DR As DataRow
DR = DT.Rows.Find(KB_36109010.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = KB_36109010.Text
DR("NAMABARANG") = NB_36109010.Text
DR("UNIT") = Val(UNIT_36109010.Text)
DR("HARGA") = Val(Harga_36109010.Text)
DR("JUMLAH") = Val(jumlah_36109010.Text)
DT.Rows.Add(DR)
KB_36109010.Text = ""
UNIT_36109010.Text = ""
Harga_36109010.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain...")
End If
IMHI()
End Sub
Private Sub simpan_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109010.Click
If NT_36109010.Text.Length = 0 Then
MsgBox("No Transaksi Belum Di isi")
Exit Sub
End If
If JT_36109010.Text.Length = 0 Then
MsgBox("Jenis Transaksi Belum Di isi")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("Isi datatable")
Exit Sub
End If
BI.AturPencarianDataBase("mastertransaksi", "notrans", NT_36109010.Text, 1, ISMI)
If BI.JumlanBaris > 0 Then
MsgBox("No Trans Seperti Itu Sudah Ada")
Exit Sub
End If
TA = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT_36109010.Text & "',#" & tgl_36109010.Value.Month & "/" & tgl_36109010.Value.Day & "/" & tgl_36109010.Value.Year & "#,'" & JT_36109010.Text & "')", ISMI)
ISMI.Open()
TA.ExecuteNonQuery()
ISMI.Close()
For Each x As DataRow In DT.Rows
TA = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT_36109010.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", ISMI)
ISMI.Open()
TA.ExecuteNonQuery()
ISMI.Close()
Next
TA.Dispose()
NT_36109010.Text = ""
JT_36109010.Text = ""
DT.Rows.Clear()
IMHI()
End Sub
Private Sub Harga_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Harga_36109010.TextChanged
jumlah_36109010.Text = Val(UNIT_36109010.Text) * Val(Harga_36109010.Text)
End Sub
Private Sub jumlah_36109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah_36109010.TextChanged
jumlah_36109010.Text = Val(UNIT_36109010.Text) * Val(Harga_36109010.Text)
End Sub
End Class
LATIHAN 31 - 34 APKOM 4
LATIHAN 31
Public Class Form31A_36109010
Dim rusna As New DataTable
Dim virgo As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form31B_36109010.Visible = False Then
Form31B_36109010.Show()
Else
Form31B_36109010.Activate()
End If
Form31B_36109010.KB.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form31B_36109010.KD_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form31B_36109010.NB_36109010.Text = dgv_36109010.CurrentRow.Cells("namabarang").Value
Form31B_36109010.JB_36109010.Text = dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form31B_36109010.HJ_36109010.Text = dgv_36109010.CurrentRow.Cells("hargajual").Value
End Sub
Private Sub Form31A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", virgo)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv_36109010.DataSource = rusna
End Sub
End Class
Dim rusna As New DataTable
Dim virgo As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form31B_36109010.Visible = False Then
Form31B_36109010.Show()
Else
Form31B_36109010.Activate()
End If
Form31B_36109010.KB.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form31B_36109010.KD_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form31B_36109010.NB_36109010.Text = dgv_36109010.CurrentRow.Cells("namabarang").Value
Form31B_36109010.JB_36109010.Text = dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form31B_36109010.HJ_36109010.Text = dgv_36109010.CurrentRow.Cells("hargajual").Value
End Sub
Private Sub Form31A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", virgo)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv_36109010.DataSource = rusna
End Sub
End Class
----------------------------------------------------------------------------------------------
Public Class Form31B_36109010
Dim nani As New ByIskandar.CariKeDataBaseByIskandar
Dim rusna As New OleDb.OleDbCommand
Dim virgo As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_36109010.Click
If KB.Text <> KD_36109010.Text Then
nani.AturPencarianDataBase("Barang", "KodeBarang", KD_36109010.Text, 1, virgo)
If nani.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If KD_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf NB_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf HJ_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf JB_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & KD_36109010.Text & "', namabarang = '" & NB_36109010.Text & "', hargajual = " & Val(HJ_36109010.Text) & ", jumlahbarang = " & Val(JB_36109010.Text) & " where kodebarang = '" & NB_36109010.Text & "'"
rusna = New OleDb.OleDbCommand(soe, virgo)
virgo.Open()
rusna.ExecuteNonQuery()
virgo.Close()
rusna.Dispose()
KB.Text = "-"
KD_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
Dim nani As New ByIskandar.CariKeDataBaseByIskandar
Dim rusna As New OleDb.OleDbCommand
Dim virgo As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_36109010.Click
If KB.Text <> KD_36109010.Text Then
nani.AturPencarianDataBase("Barang", "KodeBarang", KD_36109010.Text, 1, virgo)
If nani.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If KD_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf NB_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf HJ_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf JB_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & KD_36109010.Text & "', namabarang = '" & NB_36109010.Text & "', hargajual = " & Val(HJ_36109010.Text) & ", jumlahbarang = " & Val(JB_36109010.Text) & " where kodebarang = '" & NB_36109010.Text & "'"
rusna = New OleDb.OleDbCommand(soe, virgo)
virgo.Open()
rusna.ExecuteNonQuery()
virgo.Close()
rusna.Dispose()
KB.Text = "-"
KD_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
LATIHAN 32
Public Class Form32A_36109010
Dim dt As New DataTable
Dim virgo As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Public Sub rusna()
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("select * from barang", virgo)
dt.Rows.Clear()
a.Fill(dt)
a.Dispose()
End Sub
Private Sub Form32A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
rusna()
dgv_36109010.DataSource = dt
End Sub
Private Sub tambah_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If Form32B_36109010.Visible = False Then
Form32B_36109010.Show()
Else
Form32B_36109010.Activate()
End If
End Sub
Private Sub edit_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form32C_36109010.Visible = False Then
Form32C_36109010.Show()
Else
Form32C_36109010.Activate()
End If
Form32C_36109010.KB_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form32C_36109010.NB_36109010.Text = dgv_36109010.CurrentRow.Cells("namabarang").Value
Form32C_36109010.HJ_36109010.Text = dgv_36109010.CurrentRow.Cells("hargajual").Value
Form32C_36109010.JB_36109010.Text = dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form32C_36109010.KBL_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form32C_36109010.Show()
End Sub
End Class
Dim dt As New DataTable
Dim virgo As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Public Sub rusna()
Dim a As New OleDb.OleDbDataAdapter
a = New OleDb.OleDbDataAdapter("select * from barang", virgo)
dt.Rows.Clear()
a.Fill(dt)
a.Dispose()
End Sub
Private Sub Form32A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
rusna()
dgv_36109010.DataSource = dt
End Sub
Private Sub tambah_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If Form32B_36109010.Visible = False Then
Form32B_36109010.Show()
Else
Form32B_36109010.Activate()
End If
End Sub
Private Sub edit_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form32C_36109010.Visible = False Then
Form32C_36109010.Show()
Else
Form32C_36109010.Activate()
End If
Form32C_36109010.KB_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form32C_36109010.NB_36109010.Text = dgv_36109010.CurrentRow.Cells("namabarang").Value
Form32C_36109010.HJ_36109010.Text = dgv_36109010.CurrentRow.Cells("hargajual").Value
Form32C_36109010.JB_36109010.Text = dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form32C_36109010.KBL_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form32C_36109010.Show()
End Sub
End Class
--------------------------------------------------------------------------------------------------
Public Class Form32B_36109010
Dim arman As New ByIskandar.CariKeDataBaseByIskandar
Dim anto As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_36109010.Click
arman.AturPencarianDataBase("Barang", "KodeBarang", KB_36109010.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("kode barang telah ada")
KB_36109010.Text = ""
Exit Sub
ElseIf KB_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf NB_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf HJ_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf JB_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & KB_36109010.Text & "','" & NB_36109010.Text & "'," & Val(HJ_36109010.Text) & "," & Val(JB_36109010.Text) & ")"
anto = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
anto.ExecuteNonQuery()
ndut.Close()
anto.Dispose()
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
Dim arman As New ByIskandar.CariKeDataBaseByIskandar
Dim anto As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_36109010.Click
arman.AturPencarianDataBase("Barang", "KodeBarang", KB_36109010.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("kode barang telah ada")
KB_36109010.Text = ""
Exit Sub
ElseIf KB_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf NB_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf HJ_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf JB_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & KB_36109010.Text & "','" & NB_36109010.Text & "'," & Val(HJ_36109010.Text) & "," & Val(JB_36109010.Text) & ")"
anto = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
anto.ExecuteNonQuery()
ndut.Close()
anto.Dispose()
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
----------------------------------------------------------------------------------------------
Public Class Form32C_36109010
Dim arman As New ByIskandar.CariKeDataBaseByIskandar
Dim anto As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_36109010.Click
If KBL_36109010.Text <> KB_36109010.Text Then
arman.AturPencarianDataBase("Barang", "KodeBarang", KB_36109010.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If KB_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf NB_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf HJ_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf JB_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & KB_36109010.Text & "', namabarang = '" & NB_36109010.Text & "', hargajual = " & Val(HJ_36109010.Text) & ", jumlahbarang = " & Val(JB_36109010.Text) & " where kodebarang = '" & KBL_36109010.Text & "'"
anto = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
anto.ExecuteNonQuery()
ndut.Close()
anto.Dispose()
KBL_36109010.Text = "-"
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
Dim arman As New ByIskandar.CariKeDataBaseByIskandar
Dim anto As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_36109010.Click
If KBL_36109010.Text <> KB_36109010.Text Then
arman.AturPencarianDataBase("Barang", "KodeBarang", KB_36109010.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If KB_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf NB_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf HJ_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf JB_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & KB_36109010.Text & "', namabarang = '" & NB_36109010.Text & "', hargajual = " & Val(HJ_36109010.Text) & ", jumlahbarang = " & Val(JB_36109010.Text) & " where kodebarang = '" & KBL_36109010.Text & "'"
anto = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
anto.ExecuteNonQuery()
ndut.Close()
anto.Dispose()
KBL_36109010.Text = "-"
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
LATIHAN 33
Public Class Form33A_36109010
Dim rusna As New DataTable
Dim ningsi As New OleDb.OleDbCommand
Dim virgo As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub tambah_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If Form33B_36109010.Visible = False Then
Form33B_36109010.Show()
Else
Form33B_36109010.Activate()
End If
End Sub
Private Sub edit_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form33B_36109010.Visible = False Then
Form33B_36109010.Show()
Else
Form33B_36109010.Activate()
End If
Form33B_36109010.kbl_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form33B_36109010.kb_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form33B_36109010.nb_36109010.Text = dgv_36109010.CurrentRow.Cells("namabarang").Value
Form33B_36109010.jb_36109010.Text = dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form33B_36109010.hj_36109010.Text = dgv_36109010.CurrentRow.Cells("hargajual").Value
End Sub
Private Sub form33a_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", virgo)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv_36109010.DataSource = rusna
End Sub
Private Sub hapus_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109010.Click
Dim soe As String = "delete * from barang where kodebarang = '" & dgv_36109010.CurrentRow.Cells("kodebarang").Value & "'"
ningsi = New OleDb.OleDbCommand(soe, virgo)
virgo.Open()
ningsi.ExecuteNonQuery()
virgo.Close()
ningsi.Dispose()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", virgo)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv_36109010.DataSource = rusna
End Sub
End Class
Dim rusna As New DataTable
Dim ningsi As New OleDb.OleDbCommand
Dim virgo As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub tambah_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If Form33B_36109010.Visible = False Then
Form33B_36109010.Show()
Else
Form33B_36109010.Activate()
End If
End Sub
Private Sub edit_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form33B_36109010.Visible = False Then
Form33B_36109010.Show()
Else
Form33B_36109010.Activate()
End If
Form33B_36109010.kbl_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form33B_36109010.kb_36109010.Text = dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form33B_36109010.nb_36109010.Text = dgv_36109010.CurrentRow.Cells("namabarang").Value
Form33B_36109010.jb_36109010.Text = dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form33B_36109010.hj_36109010.Text = dgv_36109010.CurrentRow.Cells("hargajual").Value
End Sub
Private Sub form33a_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", virgo)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv_36109010.DataSource = rusna
End Sub
Private Sub hapus_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109010.Click
Dim soe As String = "delete * from barang where kodebarang = '" & dgv_36109010.CurrentRow.Cells("kodebarang").Value & "'"
ningsi = New OleDb.OleDbCommand(soe, virgo)
virgo.Open()
ningsi.ExecuteNonQuery()
virgo.Close()
ningsi.Dispose()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", virgo)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv_36109010.DataSource = rusna
End Sub
End Class
----------------------------------------------------------------------------------------
Public Class Form33B_36109010
Dim virgo As New ByIskandar.CariKeDataBaseByIskandar
Dim rusna As New OleDb.OleDbCommand
Dim mickey As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub SAVE_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE_36109010.Click
If kbl_36109010.Text = "" Then
virgo.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, mickey)
If virgo.JumlanBaris > 0 Then
MsgBox("kode barang telah ada")
kb_36109010.Text = ""
Exit Sub
ElseIf kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_36109010.Text & "','" & nb_36109010.Text & "'," & Val(hj_36109010.Text) & "," & Val(jb_36109010.Text) & ")"
rusna = New OleDb.OleDbCommand(soe, mickey)
mickey.Open()
rusna.ExecuteNonQuery()
mickey.Close()
rusna.Dispose()
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
Else
If kbl_36109010.Text <> kb_36109010.Text Then
virgo.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, mickey)
If virgo.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & kb_36109010.Text & "', namabarang = '" & nb_36109010.Text & "', hargajual = " & Val(hj_36109010.Text) & ", jumlahbarang = " & Val(jb_36109010.Text) & " where kodebarang = '" & kbl_36109010.Text & "'"
rusna = New OleDb.OleDbCommand(soe, mickey)
mickey.Open()
rusna.ExecuteNonQuery()
mickey.Close()
rusna.Dispose()
kbl_36109010.Text = "-"
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
End If
End Sub
End Class
Dim virgo As New ByIskandar.CariKeDataBaseByIskandar
Dim rusna As New OleDb.OleDbCommand
Dim mickey As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub SAVE_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE_36109010.Click
If kbl_36109010.Text = "" Then
virgo.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, mickey)
If virgo.JumlanBaris > 0 Then
MsgBox("kode barang telah ada")
kb_36109010.Text = ""
Exit Sub
ElseIf kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_36109010.Text & "','" & nb_36109010.Text & "'," & Val(hj_36109010.Text) & "," & Val(jb_36109010.Text) & ")"
rusna = New OleDb.OleDbCommand(soe, mickey)
mickey.Open()
rusna.ExecuteNonQuery()
mickey.Close()
rusna.Dispose()
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
Else
If kbl_36109010.Text <> kb_36109010.Text Then
virgo.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, mickey)
If virgo.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & kb_36109010.Text & "', namabarang = '" & nb_36109010.Text & "', hargajual = " & Val(hj_36109010.Text) & ", jumlahbarang = " & Val(jb_36109010.Text) & " where kodebarang = '" & kbl_36109010.Text & "'"
rusna = New OleDb.OleDbCommand(soe, mickey)
mickey.Open()
rusna.ExecuteNonQuery()
mickey.Close()
rusna.Dispose()
kbl_36109010.Text = "-"
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
End If
End Sub
End Class
LATIHAN 34
Public Class Form34A_36109010
Private Sub DAFTARBARANGToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem.Click
If Form34B_36109010.Visible = False Then
Form34B_36109010.MdiParent = Me
Form34B_36109010.Show()
Else
Form34B_36109010.Activate()
End If
End Sub
Private Sub INPUTBARANGToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.MdiParent = Me
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
If Form34B_36109010.Visible = False Then
Form34B_36109010.MdiParent = Me
Form34B_36109010.Show()
Else
Form34B_36109010.Activate()
End If
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.MdiParent = Me
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
End Sub
End Class
--------------------------------------------------------------------------------------------------
Public Class Form34B_36109010
Dim rusna As New DataTable
Dim ningsi As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Form34B_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", ndut)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv2_36109010.DataSource = rusna
End Sub
Private Sub tambah_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
End Sub
Private Sub hapus_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109010.Click
Dim soe As String = "delete * from barang where kodebarang = '" & dgv2_36109010.CurrentRow.Cells("kodebarang").Value & "'"
ningsi = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
ningsi.ExecuteNonQuery()
ndut.Close()
ningsi.Dispose()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", ndut)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv2_36109010.DataSource = rusna
End Sub
Private Sub edit_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
Form34C_36109010.KBL_36109010.Text = dgv2_36109010.CurrentRow.Cells("kodebarang").Value
Form34C_36109010.kb_36109010.Text = dgv2_36109010.CurrentRow.Cells("kodebarang").Value
Form34C_36109010.nb_36109010.Text = dgv2_36109010.CurrentRow.Cells("namabarang").Value
Form34C_36109010.jb_36109010.Text = dgv2_36109010.CurrentRow.Cells("jumlahbarang").Value
Form34C_36109010.hj_36109010.Text = dgv2_36109010.CurrentRow.Cells("hargajual").Value
End Sub
End Class------------------------------------------------------------------------------------------------------
Public Class Form34C_36109010
Dim mickey As New ByIskandar.CariKeDataBaseByIskandar
Dim rusna As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_36109010.Click
If KBL_36109010.Text = "" Then
mickey.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, ndut)
If mickey.JumlanBaris > 0 Then
MsgBox("kode barang telah ada")
kb_36109010.Text = ""
Exit Sub
ElseIf kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_36109010.Text & "','" & nb_36109010.Text & "'," & Val(hj_36109010.Text) & "," & Val(jb_36109010.Text) & ")"
rusna = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
rusna.ExecuteNonQuery()
ndut.Close()
rusna.Dispose()
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
Else
If KBL_36109010.Text <> kb_36109010.Text Then
mickey.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, ndut)
If mickey.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & kb_36109010.Text & "', namabarang = '" & nb_36109010.Text & "', hargajual = " & Val(hj_36109010.Text) & ", jumlahbarang = " & Val(jb_36109010.Text) & " where kodebarang = '" & KBL_36109010.Text & "'"
rusna = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
rusna.ExecuteNonQuery()
ndut.Close()
rusna.Dispose()
KBL_36109010.Text = "-"
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
End If
End Sub
End Class
Private Sub DAFTARBARANGToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem.Click
If Form34B_36109010.Visible = False Then
Form34B_36109010.MdiParent = Me
Form34B_36109010.Show()
Else
Form34B_36109010.Activate()
End If
End Sub
Private Sub INPUTBARANGToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.MdiParent = Me
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
If Form34B_36109010.Visible = False Then
Form34B_36109010.MdiParent = Me
Form34B_36109010.Show()
Else
Form34B_36109010.Activate()
End If
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.MdiParent = Me
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
End Sub
End Class
--------------------------------------------------------------------------------------------------
Public Class Form34B_36109010
Dim rusna As New DataTable
Dim ningsi As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub Form34B_36109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", ndut)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv2_36109010.DataSource = rusna
End Sub
Private Sub tambah_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109010.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
End Sub
Private Sub hapus_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109010.Click
Dim soe As String = "delete * from barang where kodebarang = '" & dgv2_36109010.CurrentRow.Cells("kodebarang").Value & "'"
ningsi = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
ningsi.ExecuteNonQuery()
ndut.Close()
ningsi.Dispose()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", ndut)
rusna.Rows.Clear()
adapter.Fill(rusna)
adapter.Dispose()
dgv2_36109010.DataSource = rusna
End Sub
Private Sub edit_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109010.Click
If Form34C_36109010.Visible = False Then
Form34C_36109010.Show()
Else
Form34C_36109010.Activate()
End If
Form34C_36109010.KBL_36109010.Text = dgv2_36109010.CurrentRow.Cells("kodebarang").Value
Form34C_36109010.kb_36109010.Text = dgv2_36109010.CurrentRow.Cells("kodebarang").Value
Form34C_36109010.nb_36109010.Text = dgv2_36109010.CurrentRow.Cells("namabarang").Value
Form34C_36109010.jb_36109010.Text = dgv2_36109010.CurrentRow.Cells("jumlahbarang").Value
Form34C_36109010.hj_36109010.Text = dgv2_36109010.CurrentRow.Cells("hargajual").Value
End Sub
End Class------------------------------------------------------------------------------------------------------
Public Class Form34C_36109010
Dim mickey As New ByIskandar.CariKeDataBaseByIskandar
Dim rusna As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")
Private Sub save_36109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_36109010.Click
If KBL_36109010.Text = "" Then
mickey.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, ndut)
If mickey.JumlanBaris > 0 Then
MsgBox("kode barang telah ada")
kb_36109010.Text = ""
Exit Sub
ElseIf kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_36109010.Text & "','" & nb_36109010.Text & "'," & Val(hj_36109010.Text) & "," & Val(jb_36109010.Text) & ")"
rusna = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
rusna.ExecuteNonQuery()
ndut.Close()
rusna.Dispose()
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
Else
If KBL_36109010.Text <> kb_36109010.Text Then
mickey.AturPencarianDataBase("Barang", "KodeBarang", kb_36109010.Text, 1, ndut)
If mickey.JumlanBaris > 0 Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
End If
If kb_36109010.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
ElseIf nb_36109010.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
ElseIf hj_36109010.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
ElseIf jb_36109010.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
Dim soe As String = "update barang set kodebarang = '" & kb_36109010.Text & "', namabarang = '" & nb_36109010.Text & "', hargajual = " & Val(hj_36109010.Text) & ", jumlahbarang = " & Val(jb_36109010.Text) & " where kodebarang = '" & KBL_36109010.Text & "'"
rusna = New OleDb.OleDbCommand(soe, ndut)
ndut.Open()
rusna.ExecuteNonQuery()
ndut.Close()
rusna.Dispose()
KBL_36109010.Text = "-"
kb_36109010.Text = ""
nb_36109010.Text = ""
hj_36109010.Text = ""
jb_36109010.Text = ""
End If
End Sub
End Class
LATIHAN 27 - 30 APKOM 4
LATIHAN 27
Dim rusna As New
ByIskandar.CariKeDataBaseByIskandar
Dim cm As New
OleDb.OleDbCommand
Dim hma As New
OleDb.OleDbConnection("PROVIDER =
MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" &
Application.StartupPath & "/Databarang.ACCDB")
Private Sub save_36109010_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles save_36109010.Click
If
KB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
NB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(HJ_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(JB_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
rusna.AturPencarianDataBase("Barang", "KodeBarang",
KB_36109010.Text, 1, hma)
If
rusna.JumlanBaris > 0 Then
MsgBox("Adami
kode barang seperti itu")
Exit
Sub
End If
cm = New
OleDb.OleDbCommand("insert into barang
(kodebarang, namabarang, hargajual, jumlahbarang) values ('" &
KB_36109010.Text & "','" &
NB_36109010.Text & "'," &
Val(HJ_36109010.Text) & ","
& Val(JB_36109010.Text) & ")",
hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
cm.Dispose()
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
LATIHAN 28
Public Class Form28A_36109010
Dim dt As New DataTable
Dim virgo As New
OleDb.OleDbConnection("PROVIDER =
MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" &
Application.StartupPath & "/Databarang.ACCDB")
Public Sub rusna()
Dim fm As New
OleDb.OleDbDataAdapter
fm = New
OleDb.OleDbDataAdapter("select * from
barang", virgo)
dt.Rows.Clear()
fm.Fill(dt)
fm.Dispose()
End Sub
Private Sub Form28A_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
rusna()
dgv_36109010.DataSource = dt
End Sub
Private Sub input_36109010_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles input_36109010.Click
If
Form28B_36109010.Visible = False Then
Form28B_36109010.Show()
Else
Form28B_36109010.Activate()
End If
End Sub
End Class
Public Class Form28B_36109010
Dim rusna As New
ByIskandar.CariKeDataBaseByIskandar
Dim cm As New
OleDb.OleDbCommand
Dim hma As New
OleDb.OleDbConnection("PROVIDER =
MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" &
Application.StartupPath & "/Databarang.ACCDB")
Private Sub SIMPAN_36109010_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles SIMPAN_36109010.Click
If
KB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
NB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(HJ_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(JB_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
rusna.AturPencarianDataBase("Barang", "KodeBarang",
KB_36109010.Text, 1, hma)
If
rusna.JumlanBaris > 0 Then
MsgBox("Adami
kode barang seperti itu")
Exit
Sub
End If
cm = New
OleDb.OleDbCommand("insert into barang
(kodebarang, namabarang, hargajual, jumlahbarang) values ('" &
KB_36109010.Text & "','" &
NB_36109010.Text & "'," &
Val(HJ_36109010.Text) & ","
& Val(JB_36109010.Text) & ")",
hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
cm.Dispose()
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
Form28A_36109010.rusna()
End Sub
End Class
LATIHAN 29
Public Class Form29_36109010
Dim cm As New
OleDb.OleDbCommand
Dim rusna As New
ByIskandar.CariKeDataBaseByIskandar
Dim virgo As New
OleDb.OleDbConnection("PROVIDER =
MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" &
Application.StartupPath & "/Databarang.ACCDB")
Private Sub simpan_36109010_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles simpan_36109010.Click
If
KB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
NB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(HJ_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(JB_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
AA_36109010.Text <> KB_36109010.Text Then
rusna.AturPencarianDataBase("Barang", "KodeBarang",
KB_36109010.Text, 1, virgo)
If
rusna.JumlanBaris > 0 Then
MsgBox("Adami
kode barang seperti itu")
Exit
Sub
End
If
End If
cm = New
OleDb.OleDbCommand("update barang set
kodebarang = '" & KB_36109010.Text & "', namabarang = '" &
NB_36109010.Text & "', hargajual = "
& Val(HJ_36109010.Text) & ",
jumlahbarang = " & Val(JB_36109010.Text) & " where kodebarang = '" & AA_36109010.Text
& "'", virgo)
virgo.Open()
cm.ExecuteNonQuery()
virgo.Close()
cm.Dispose()
AA_36109010.Text = ""
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
End Sub
End Class
LATIHAN 30
Public Class Form30A_36109010
Dim dt As New DataTable
Dim virgo As New
OleDb.OleDbConnection("PROVIDER =
MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" &
Application.StartupPath & "/Databarang.ACCDB")
Public Sub rusna()
Dim fm As New
OleDb.OleDbDataAdapter
fm = New
OleDb.OleDbDataAdapter("select * from
barang", virgo)
dt.Rows.Clear()
fm.Fill(dt)
fm.Dispose()
End Sub
Private Sub Form30A_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
rusna()
dgv_36109010.DataSource = dt
End Sub
Private Sub edit_36109010_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles edit_36109010.Click
If
Form30B_36109010.Visible = False Then
Form30B_36109010.Show()
Else
Form30B_36109010.Activate()
End If
Form30B_36109010.ganti_36109010.Text =
dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form30B_36109010.KB_36109010.Text =
dgv_36109010.CurrentRow.Cells("kodebarang").Value
Form30B_36109010.NB_36109010.Text =
dgv_36109010.CurrentRow.Cells("namabarang").Value
Form30B_36109010.HJ_36109010.Text =
dgv_36109010.CurrentRow.Cells("hargajual").Value
Form30B_36109010.JB_36109010.Text =
dgv_36109010.CurrentRow.Cells("jumlahbarang").Value
Form30B_36109010.Show()
End Sub
End Class
Dim rusna As New
ByIskandar.CariKeDataBaseByIskandar
Dim cm As New
OleDb.OleDbCommand
Dim virgo As New
OleDb.OleDbConnection("PROVIDER =
MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" &
Application.StartupPath & "/Databarang.ACCDB")
Private Sub simpan_36109010_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles simpan_36109010.Click
If
KB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
NB_36109010.Text.Length = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(HJ_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
Val(JB_36109010.Text) = 0 Then
MsgBox("Isi
rong itu yang kosong")
Exit
Sub
End If
If
ganti_36109010.Text <> NB_36109010.Text Then
rusna.AturPencarianDataBase("Barang", "KodeBarang",
KB_36109010.Text, 1, virgo)
If
rusna.JumlanBaris > 0 Then
MsgBox("Adami
kode barang seperti itu")
Exit
Sub
End
If
End If
cm = New
OleDb.OleDbCommand("update barang set
kodebarang = '" & KB_36109010.Text & "', namabarang = '" &
NB_36109010.Text & "', hargajual = "
& Val(HJ_36109010.Text) & ",
jumlahbarang = " & Val(JB_36109010.Text) & " where kodebarang = '" &
ganti_36109010.Text & "'",
virgo)
virgo.Open()
cm.ExecuteNonQuery()
virgo.Close()
cm.Dispose()
ganti_36109010.Text = ""
KB_36109010.Text = ""
NB_36109010.Text = ""
HJ_36109010.Text = ""
JB_36109010.Text = ""
Form30A_36109010.rusna()
End Sub
End Class
Langganan:
Postingan (Atom)
Blog Subscription
Search this blog
Mengenai Saya
Followers
Lencana Facebook
Popular Posts
Labels
- Tugas (8)
Labels
- Tugas (8)



