Public Class Form27
Dim Rachmiyati As New ByIskandar.CariKeDataBaseByIskandar
Dim ami 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_36109022_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109022.Click
MsgBox("isikan dlue eh")
Exit Sub
End If
If nb_36109022.Text.Length = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
If Val(hj_36109022.Text) = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
If Val(jb_36109022.Text) = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
Rachmiyati.AturPencarianDataBase("Barang", "KodeBarang", kb_36109022.Text, 1, hma)
If Rachmiyati.JumlanBaris > 0 Then
MsgBox("sudah ada yang seperti itu")
Exit Sub
End If
ami = New OleDb.OleDbCommand("insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_36109022.Text & "','" & nb_36109022.Text & "'," & Val(hj_36109022.Text) & "," & Val(jb_36109022.Text) & ")", hma)
hma.Open()
ami.ExecuteNonQuery()
hma.Close()
ami.Dispose()
kb_36109022.Text = ""
nb_36109022.Text = ""
hj_36109022.Text = ""
jb_36109022.Text = ""
End Sub
End Class
LATIHAN 28A
Public Class Form28A
Dim aya As New DataTable
Dim ami As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Public Sub rahmi()
Dim aku As New OleDb.OleDbDataAdapter
aku = New OleDb.OleDbDataAdapter("select * from BARANG", ami)
aya.Rows.Clear()
aku.Fill(aya)
aku.Dispose()
End Sub
Private Sub Form28A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
rahmi()
Tampil_36109022.DataSource = aya
End Sub
Private Sub input_36109022_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles input_36109022.Click
If Form28B.Visible = False Then
Form28B.Show()
Else
Form28B.Activate()
End If
End Sub
Private Sub tutup_36109022_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tutup_36109022.Click
Close()
End Sub
End Class
LATIHAN 28B
Public Class Form28B
Dim Rachmiyati As New ByIskandar.CariKeDataBaseByIskandar
Dim ami 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_36109022_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109022.Click
If kb_36109022.Text.Length = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
If nb_36109022.Text.Length = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
If Val(hj_36109022.Text) = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
If Val(jb_36109022.Text) = 0 Then
MsgBox("isikan dlue eh")
Exit Sub
End If
Rachmiyati.AturPencarianDataBase("Barang", "KodeBarang", kb_36109022.Text, 1, hma)
If Rachmiyati.JumlanBaris > 0 Then
MsgBox("sudah ada yang seperti itu")
Exit Sub
End If
ami = New OleDb.OleDbCommand("insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_36109022.Text & "','" & nb_36109022.Text & "'," & Val(hj_36109022.Text) & "," & Val(jb_36109022.Text) & ")", hma)
hma.Open()
ami.ExecuteNonQuery()
hma.Close()
ami.Dispose()
kb_36109022.Text = ""
nb_36109022.Text = ""
hj_36109022.Text = ""
jb_36109022.Text = ""
Form28A.rahmi()
End Sub
End Class