Public Class tugas28a46109033
Dim konek As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=2121990")
Dim itik As New DataTable
Public Sub ambil()
Dim tm As New OleDb.OleDbDataAdapter
tm = New OleDb.OleDbDataAdapter("SELECT*from BARANG", konek)
itik.Rows.Clear()
tm.Fill(itik)
tm.Dispose()
End Sub
Private Sub tugas28a46109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambil()
DataGridView146109033.DataSource = itik
End Sub
Private Sub Button146109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109033.Click
If tugas28b46109033.Visible = False Then
tugas28b46109033.Show()
Else
tugas28b46109033.Activate()
End If
End Sub
Private Sub Button246109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button246109033.Click
Me.Close()
End Sub
End Class
Public Class tugas28b46109033
Dim konek As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=2121990")
Private Sub Button146109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109033.Click
If t146109033.Text.Length = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If t246109033.Text.Length = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If Val(t346109033.Text) = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If Val(t446109033.Text) = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", t146109033.Text, 1, konek)
If PENCARI.JumlanBaris > 0 Then
MsgBox("the data has been exist please insert new data")
t146109033.Text = ""
t246109033.Text = ""
t346109033.Text = ""
t446109033.Text = ""
Exit Sub
End If
Dim itik As New OleDb.OleDbCommand
itik = New OleDb.OleDbCommand("INSERT INTO BARANG(KODEBARANG,NAMABARANG,HARGAJUAL,JUMLAHBARANG)VALUES ('" & t146109033.Text & "','" & t246109033.Text & "'," & Val(t346109033.Text) & "," & Val(t446109033.Text) & " )", konek)
konek.Open()
itik.ExecuteNonQuery()
konek.Close()
itik.Dispose()
t146109033.Text = ""
t246109033.Text = ""
t346109033.Text = ""
t446109033.Text = ""
tugas28a46109033.ambil()
Me.Close()
End Sub
End Class
Tidak ada komentar:
Posting Komentar