Public Class Latihan28A_46109060
Dim fadli As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OleDb:database password=060")
Dim fadli As New DataTable
Public Sub ambildata()
Dim data As New OleDb.OleDbDataAdapter
data = New OleDb.OleDbDataAdapter("SELECT*from BARANG", fadli)
fadli.Rows.Clear()
data.Fill(fadli)
data.Dispose()
End Sub
Private Sub Latihan28A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = fadli
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan28B_46109060.Visible = False Then
Latihan28B_46109060.Show()
Else
Latihan28B_46109060.Activate()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
Public Class Latihan28B_46109060
Dim fadli As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=060")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If tb146109060.Text.Length = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If tb246109060.Text.Length = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If Val(tb346109060.Text) = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If Val(tb446109060.Text) = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", tb146109060.Text, 1, fadli)
If PENCARI.JumlanBaris > 0 Then
MsgBox("the data has been exist please insert new data")
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Exit Sub
End If
Dim Fadli As New OleDb.OleDbCommand
Fadli = New OleDb.OleDbCommand("INSERT INTO BARANG(KODEBARANG,NAMABARANG,HARGAJUAL,JUMLAHBARANG)VALUES ('" & tb146109060.Text & "','" & tb246109060.Text & "'," & Val(tb346109060.Text) & "," & Val(tb446109060.Text) & " )", fadli)
fadli.Open()
Fadli.ExecuteNonQuery()
fadli.Close()
Fadli.Dispose()
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan28A_46109060.ambildata()
Me.Close()
End Sub
End Class
Tidak ada komentar:
Posting Komentar