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
0 komentar:
Posting Komentar