Jumat, 18 November 2011

Latihan 31


Public Class Latihan31A_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 Latihan31A_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 Latihan31B_46109060.Visible = False Then
Latihan31B_46109060.Show()
Else
Latihan31B_46109060.Activate()
End If
Latihan31B_46109060.KB.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan31B_46109060.tb146109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan31B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan31B_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan31B_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value
End Sub
End Class






Public Class Latihan31B_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 KB.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='" & KB.Text & "'", conect)
conect.Open()
Fadli.ExecuteNonQuery()
conect.Close()
Fadli.Dispose()
KB.Text = ""
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan31A_46109060.ambildata()
Me.Close()
End Sub
Private Sub Latihan31B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class

Tidak ada komentar:

Posting Komentar