bab7 hal3

bab7 hal2

bab7 hal1

bab6 hal3

bab6 hal2

bab6 hal1

tugas 27-34 Muh. Fahrul (46109005)

Public Class LATIHAN027012

Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If

cari.AturPencarianDataBase("BARANG", "KODEBARANG", t146109005.Text, 1, conect)

If cari.JumlanBaris > 0 Then
MsgBox("kode sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into BARANG (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t146109005.Text & "','" & t246109005.Text & "'," & Val(t346109005.Text) & "," & Val(t446109005.Text) & ")", conect)

conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()

t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
Public Class LATIHAN028A012
Dim koneksi As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim arul As New DataTable
Dim baris As Damomow
Private Sub latihan1546109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim testing As New OleDb.OleDbDataAdapter
testing = New OleDb.OleDbDataAdapter("select * from barang", koneksi)
testing.Fill(arul)
DataGridView1.DataSource = arul
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If LATIHAN028B012.Visible = False Then
LATIHAN028B012.Show()
Else
LATIHAN028B012.Activate()
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Public Class LATIHAN028B012
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If


cari.AturPencarianDataBase("BARANG", "KODEBARANG", t146109005.Text, 1, conect)

If cari.JumlanBaris > 0 Then
MsgBox("kode sudah ada")
Exit Sub
End If


Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into BARANG (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t146109005.Text & "','" & t246109005.Text & "'," & Val(t346109005.Text) & "," & Val(t446109005.Text) & ")", conect)

conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()

t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
Public Class LATIHAN029012
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If


cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb.Text, 1, conect)

If cari.JumlanBaris = False Then
MsgBox("kode tidak ada")
Exit Sub
End If

Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("UPDATE BARANG SET kodebarang = '" & t146109005.Text & "', namabarang = '" & t246109005.Text & "', hargajual = " & Val(t346109005.Text) & ", jumlahbarang = " & Val(t446109005.Text) & " where kodebarang ='" & kb.Text & "'", conect)

conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()

kb.Text = ""
t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
blic Class LATIHAN030A012
Dim koneksi As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim arul As New DataTable
Private Sub latihan1546109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim testing As New OleDb.OleDbDataAdapter
testing = New OleDb.OleDbDataAdapter("select * from barang", koneksi)
testing.Fill(arul)
DataGridView1.DataSource = arul
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If LATIHAN030B012.Visible = False Then
LATIHAN030B012.Show()
Else
LATIHAN030B012.Activate()
End If
End Sub
End Class
Public Class LATIHAN030B012
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If


cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb.Text, 1, conect)

If cari.JumlanBaris = False Then
MsgBox("kode tidak ada")
Exit Sub
End If

Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("UPDATE BARANG SET kodebarang = '" & t146109005.Text & "', namabarang = '" & t246109005.Text & "', hargajual = " & Val(t346109005.Text) & ", jumlahbarang = " & Val(t446109005.Text) & " where kodebarang ='" & kb.Text & "'", conect)

conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()

kb.Text = ""
t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
Public Class Latihan031A012
Dim koneksi As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim arul As New DataTable
Dim baris As Damomow
Private Sub latihan1546109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim testing As New OleDb.OleDbDataAdapter
testing = New OleDb.OleDbDataAdapter("select * from barang", koneksi)
testing.Fill(arul)
DataGridView1.DataSource = arul
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan031B012.Visible = False Then
Latihan031B012.Show()
Else
Latihan031B012.Activate()
End If
Latihan031B012.t146109005.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
Latihan031B012.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
Latihan031B012.t246109005.Text = DataGridView1.CurrentRow.Cells("NamaBarang").Value
Latihan031B012.t346109005.Text = DataGridView1.CurrentRow.Cells("Hargajual").Value
Latihan031B012.t446109005.Text = DataGridView1.CurrentRow.Cells("jumlahbarang").Value
End Sub
End Class
Public Class Latihan031B012
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If

Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("UPDATE BARANG SET kodebarang = '" & t146109005.Text & "', namabarang = '" & t246109005.Text & "', hargajual = " & Val(t346109005.Text) & ", jumlahbarang = " & Val(t446109005.Text) & " where kodebarang ='" & ToolStripStatusLabel1.Text & "'", conect)

conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()

t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
Public Class LATIHAN032A012
Dim koneksi As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim arul As New DataTable
Dim baris As Damomow
Private Sub latihan1546109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim testing As New OleDb.OleDbDataAdapter
testing = New OleDb.OleDbDataAdapter("select * from barang", koneksi)
testing.Fill(arul)
DataGridView1.DataSource = arul
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If LATIHAN032C012.Visible = False Then
LATIHAN032C012.Show()
Else
LATIHAN032C012.Activate()
End If
LATIHAN032C012.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN032C012.t146109005.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN032C012.t246109005.Text = DataGridView1.CurrentRow.Cells("NamaBarang").Value
LATIHAN032C012.t346109005.Text = DataGridView1.CurrentRow.Cells("Hargajual").Value
LATIHAN032C012.t446109005.Text = DataGridView1.CurrentRow.Cells("jumlahbarang").Value
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If LATIHAN032B012.Visible = False Then
LATIHAN032B012.Show()
Else
LATIHAN032B012.Activate()
End If
LATIHAN032B012.t146109005.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN032B012.t246109005.Text = DataGridView1.CurrentRow.Cells("NamaBarang").Value
LATIHAN032B012.t346109005.Text = DataGridView1.CurrentRow.Cells("Hargajual").Value
LATIHAN032B012.t446109005.Text = DataGridView1.CurrentRow.Cells("jumlahbarang").Value
End Sub
End Class

Public Class LATIHAN032B012
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("PsTambahBarang", conect)
cm.CommandType = CommandType.StoredProcedure
cm.Parameters.Add(New OleDb.OleDbParameter("pKodeBarang", t146109005.Text))
cm.Parameters.Add(New OleDb.OleDbParameter("pNamaBarang", t246109005.Text))
cm.Parameters.Add(New OleDb.OleDbParameter("pPersawal", Val(t346109005.Text)))
cm.Parameters.Add(New OleDb.OleDbParameter("pHargajual", Val(t446109005.Text)))
conect.Open()
cm.ExecuteNonQuery()
conect.Close()
cm.Dispose()

t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
Public Class LATIHAN032C012
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Val(t146109005.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If t246109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(t346109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(t446109005.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("UPDATE BARANG SET kodebarang = '" & t146109005.Text & "', namabarang = '" & t246109005.Text & "', hargajual = " & Val(t346109005.Text) & ", jumlahbarang = " & Val(t446109005.Text) & " where kodebarang ='" & ToolStripStatusLabel1.Text & "'", conect)

conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()

t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""

End Sub
End Class
Public Class LATIHAN033A012
Dim koneksi As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=280765")
Dim arul As New DataTable
Dim angkut As New OleDb.OleDbCommand
Dim testing As New OleDb.OleDbDataAdapter
Private Sub latihan1546109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
testing = New OleDb.OleDbDataAdapter("select * from barang", koneksi)
testing.Fill(arul)
DataGridView1.DataSource = arul
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If LATIHAN033B012.Visible = False Then
LATIHAN033B012.Show()
Else
LATIHAN033B012.Activate()
End If
LATIHAN033B012.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN033B012.t146109005.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN033B012.t246109005.Text = DataGridView1.CurrentRow.Cells("NamaBarang").Value
LATIHAN033B012.t346109005.Text = DataGridView1.CurrentRow.Cells("Hargajual").Value
LATIHAN033B012.t446109005.Text = DataGridView1.CurrentRow.Cells("jumlahbarang").Value
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim heril As String = "delete * from barang where kodebarang = '" & DataGridView1.CurrentRow.Cells("kodebarang").Value & "'"
angkut = New OleDb.OleDbCommand(heril, koneksi)
koneksi.Open()
angkut.ExecuteNonQuery()
koneksi.Close()
angkut.Dispose()
testing = New OleDb.OleDbDataAdapter("select * from barang", koneksi)
testing.Fill(arul)
DataGridView1.DataSource = arul
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If LATIHAN033B012.Visible = False Then
LATIHAN033B012.Show()
Else
LATIHAN033B012.Activate()
End If
LATIHAN033B012.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN033B012.t146109005.Text = DataGridView1.CurrentRow.Cells("KodeBarang").Value
LATIHAN033B012.t246109005.Text = DataGridView1.CurrentRow.Cells("NamaBarang").Value
LATIHAN033B012.t346109005.Text = DataGridView1.CurrentRow.Cells("Hargajual").Value
LATIHAN033B012.t446109005.Text = DataGridView1.CurrentRow.Cells("jumlahbarang").Value
End Sub
End Class

Public Class LATIHAN033B012
Dim koneksi As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\DATABARANG.accdb;jet OLEDB:database password=280765")
Dim angkut As New OleDb.OleDbCommand
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If t146109005.Text.Length = 0 Then
MsgBox("kode barang harus tercantum")
Exit Sub
End If
If t246109005.Text.Length = 0 Then
MsgBox("nama barang harus tercantum")
Exit Sub
End If
If t346109005.Text.Length = 0 Then
MsgBox("harga jual harus tercantum")
Exit Sub
End If
If t446109005.Text.Length = 0 Then
MsgBox("jumlah barang harus tercantum")
Exit Sub
End If
If ToolStripStatusLabel1.Text <> t146109005.Text Then
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("PsTambahBarang", koneksi)
cm.CommandType = CommandType.StoredProcedure
cm.Parameters.Add(New OleDb.OleDbParameter("pKodeBarang", t146109005.Text))
cm.Parameters.Add(New OleDb.OleDbParameter("pNamaBarang", t246109005.Text))
cm.Parameters.Add(New OleDb.OleDbParameter("pPersawal", Val(t346109005.Text)))
cm.Parameters.Add(New OleDb.OleDbParameter("pHargajual", Val(t446109005.Text)))
koneksi.Open()
cm.ExecuteNonQuery()
koneksi.Close()
cm.Dispose()

t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""
Else
cari.AturPencarianDataBase("Barang", "KodeBarang", ToolStripStatusLabel1.Text, 1, koneksi)
If cari.JumlanBaris = False Then
MsgBox("kode barang tidak dapat diupdate")
Exit Sub
End If
Dim ubah As String = "update barang set kodebarang = '" & t146109005.Text & "', namabarang = '" & t246109005.Text & "', hargajual = " & Val(t346109005.Text) & ", jumlahbarang = " & Val(t446109005.Text) & " where kodebarang = '" & ToolStripStatusLabel1.Text & "'"
angkut = New OleDb.OleDbCommand(ubah, koneksi)
koneksi.Open()
angkut.ExecuteNonQuery()
koneksi.Close()
angkut.Dispose()
t146109005.Text = ""
t246109005.Text = ""
t346109005.Text = ""
t446109005.Text = ""
End If
End Sub
End Class
LATIHAN 34A
Public Class Latihan34A_46109005
Private Sub DAFTARBARANGToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem.Click
If LATIHAN34B_46109005.Visible = False Then
LATIHAN34B_46109005.MdiParent = Me.MdiParent
LATIHAN34B_46109005.Show()
Else
LATIHAN34B_46109005.Activate()
End If
End Sub
Private Sub INPUTBARANGToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem.Click
If LATIHAN34C_46109005.Visible = False Then
LATIHAN34C_46109005.MdiParent = Me.MdiParent
LATIHAN34C_46109005.Show()
Else
LATIHAN34C_46109005.Activate()
End If
End Sub

Private Sub ToolStripButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
If LATHAN34B_46109005.Visible = False Then
LATIHAN34B_46109005.MdiParent = Me.MdiParent
LATIHAN34B_46109005.Show()
Else
LATIHAN34B_46109005.Activate()
End If
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
If LATIHAN34C_46109005.Visible = False Then
LATIHAN34c_46109005.MdiParent = Me.MdiParent
LATIHAN34C_46109005.Show()
Else
LATIHAN34C_46109005.Activate()
End If
End Sub
End Class
LATIHAN 34B
Public Class LATIHAN34B_46109005
Dim JEMBATAN As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb")
Dim ARUL As New DataTable
Public Sub PB()
Dim PERINTAH As New OleDb.OleDbDataAdapter
PERINTAH = New OleDb.OleDbDataAdapter("select * from barang", JEMBATAN)
ARUL.Rows.Clear()
PERINTAH.Fill(ARUL)
PERINTAH.Dispose()

End Sub


Private Sub LATIHAN34B_46109005_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
PB()
DGV_46109005.DataSource = ARUL
End Sub

Private Sub BT_46109005_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BT_46109005.Click
If Latihan34C_46109005.Visible = False Then
Latihan34C_46109005.Show()
Else
Latihan34C_46109005.Activate()
End If
End Sub

Private Sub BT2_46109005_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BT2_46109005.Click
If Latihan34C_46109005.Visible = False Then
Latihan34C_46109005.Show()
Else
Latihan34C_46109005.Activate()
End If
Latihan34C_46109005.KB1_46109005.Text = DGV_46109005.CurrentRow.Cells("KODEBARANG").Value
Latihan34C_46109005.KB2_46109005.Text = DGV_46109005.CurrentRow.Cells("KODEBARANG").Value
Latihan34C_46109005.NB_46109005.Text = DGV_46109005.CurrentRow.Cells("NAMABARANG").Value
Latihan34C_46109005.HJ_46109005.Text = DGV_46109005.CurrentRow.Cells("HARGAJUAL").Value
Latihan34C_46109005.JB_46109005.Text = DGV_46109005.CurrentRow.Cells("JUMLAHBARANG").Value()
End Sub
End Class


LATIHAN 34C
Public Class LATIHAN34C_46109005
Dim JEMBATAN As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\databarang.accdb")
Dim cari As New ByIskandar.CariKeDataBaseByIskandar

Private Sub RT()
If KB_46109005.Text.Length = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If NB_46109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(HJ_46109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(JB_46109005.Text) = 0 Then
MsgBox("JUMLAH BELUM TERISI")
Exit Sub
End If

cari.AturPencarianDataBase("barang", "kode barang", KB_46109005.Text, 1, JEMBATAN)

If cari.JumlanBaris > 0 Then
MsgBox("kode sudah ada")
Exit Sub
End If

Dim PERINTAH As New OleDb.OleDbCommand
PERINTAH = New OleDb.OleDbCommand("insert into barang(kodebarang,namabarang,hargajual,jumlahbarang) Values('" & KB_46109005.Text & "','" & NB_46109005.Text & "'," & Val(HJ_46109005.Text) & "," & Val(JB_46109005.Text) & ")", JEMBATAN)

JEMBATAN.Open()
PERINTAH.ExecuteNonQuery()
JEMBATAN.Close()
PERINTAH.Dispose()

KB_46109005.Text = ""
NB_46109005.Text = ""
HJ_46109005.Text = ""
JB_46109005.Text = ""

Latihan33A_46109005.PB()
End Sub

Private Sub EDIT()
If KB_46109005.Text.Length = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If

If NB_46109005.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If

If Val(HJ_46109005.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If

If Val(JB_46109005.Text) = 0 Then
MsgBox("JUMLAH BELUM TERISI")
Exit Sub
End If

If KB_46109005.Text <> KB_46109005.Text Then
cari.AturPencarianDataBase("barang", "kode barang", KB_46109005.Text, 1, JEMBATAN)

If cari.JumlahBaris > 0 Then
MsgBox("kode sudah ada")
Exit Sub
End If


Dim MOMO As New OleDb.OleDbCommand
MOMO = New OleDb.OleDbCommand("update barang set kodebarang ='" & KB2_46109005.Text & "',namabarang='" & NB_46109005.Text & "',hargajual=" & Val(HJ_46109005.Text) & ", jumlahbarang=" & Val(JB_46109005.Text) & "where kodebarang='" & KB1_46109015.Text & "'", JEMBATAN)

JEMBATAN.Open()
MOMO.ExecuteNonQuery()
JEMBATAN.Close()
MOMO.Dispose()

KB2_46109005.Text = ""
NB_46109005.Text = ""
HJ_46109005.Text = ""
JB_46109005.Text = ""
KB1_46109015.Text = "-"

End Sub

Private Sub BT_46109005_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BT_46109005.Click
If KB1_46109005.Text = "-" Then
TAMBAH()
Else
EDIT()
End If
End Sub
End Class