Powered By Blogger

Jumat, 02 Desember 2011

Latihan 28

Public Class Latihan28B
Dim nini As New ByIskandar.CariKeDataBaseByIskandar
Dim rani As New OleDb.OleDbCommand
Dim nisa As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")


Private Sub simpan_008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_008.Click
If kb_008.Text.Length = 0 Then
MsgBox("Isi dulue itu yang kosong")
Exit Sub
End If

If nb_008.Text.Length = 0 Then
MsgBox("Isi dulue itu yang kosong")
Exit Sub
End If

If Val(hj_008.Text) = 0 Then
MsgBox("Isi dulue itu yang kosong")
Exit Sub
End If

If Val(jb_008.Text) = 0 Then
MsgBox("Isi dulue itu yang kosong")
Exit Sub
End If

nini.AturPencarianDataBase("Barang", "KodeBarang", kb_008.Text, 1, nisa)
If nini.JumlanBaris > 0 Then
MsgBox("Adami kode barang seperti itu")
Exit Sub
End If

rani = New OleDb.OleDbCommand("insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & kb_008.Text & "','" & nb_008.Text & "'," & Val(hj_008.Text) & "," & Val(jb_008.Text) & ")", nisa)
nisa.Open()
rani.ExecuteNonQuery()
nisa.Close()
rani.Dispose()

kb_008.Text = ""
nb_008.Text = ""
hj_008.Text = ""
jb_008.Text = ""
End Sub

End Class