Public Class Latihan30A_46109060
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=060")
Dim ambil As New DataTable
Public Sub ambildata()
Dim data As New OleDb.OleDbDataAdapter
data = New OleDb.OleDbDataAdapter("SELECT* FROM BARANG", conect)
ambil.Rows.Clear()
data.Fill(ambil)
data.Dispose()
End Sub
Private Sub Latihan30A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = ambil
End Sub
Private Sub Button1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan30B_46109060.Visible = False Then
Latihan30B_46109060.Show()
Else
Latihan30B_46109060.Activate()
End If
Latihan30B_46109060.kb46109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan30B_46109060.tb146109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan30B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan30B_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan30B_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value
End Sub
End Class
Public Class Latihan30B_46109060
Dim Conect 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 Button1.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
If kb46109060.Text <> tb146109060.Text Then
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", tb146109060.Text, 1, Conect)
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
End If
Dim Fadli As New OleDb.OleDbCommand
Fadli = New OleDb.OleDbCommand("update BARANG set KODEBARANG ='" & tb146109060.Text & "', NAMABARANG = '" & tb246109060.Text & "', HARGAJUAL=" & Val(tb346109060.Text) & ", JUMLAHBARANG=" & Val(tb446109060.Text) & " where KODEBARANG='" & kb46109060.Text & "'", Conect)
Conect.Open()
Fadli.Dispose()
kb46109060.Text = ""
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan30A_46109060.ambildata()
Me.Close()
End Sub
Private Sub Latihan30B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Tidak ada komentar:
Posting Komentar