Jumat, 18 November 2011

Latihan 33


Public Class Latihan33A_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 cari As New DataTable
Public Sub ambildata()
Dim data As New OleDb.OleDbDataAdapter
data = New OleDb.OleDbDataAdapter("select * from barang", conect)
cari.Rows.Clear()
data.Fill(cari)
data.Dispose()
End Sub
Private Sub Latihan33A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = cari
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan33B_46109060.Visible = False Then
Latihan33B_46109060.Show()
Else
Latihan33B_46109060.Activate()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan33B_46109060.Visible = False Then
Latihan33B_46109060.Show()
Else
Latihan33B_46109060.Activate()
End If
Latihan33B_46109060.KB.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan33B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan33B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan33B_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan33B_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim fadli As New OleDb.OleDbCommand
fadli = New OleDb.OleDbCommand("DELETE * FROM BARANG WHERE KODEBARANG='" & dgv46109060.CurrentRow.Cells("KODEBARANG").Value & "'", conect)
conect.Open()
fadli.ExecuteNonQuery()
conect.Close()
fadli.Dispose()
ambildata()
End Sub
End Class






Public Class Latihan33B_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 cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If tb146109060.Text.Length = 0 Then
MsgBox("Kode Barang Belum Terisi Pak")
Exit Sub
End If
If tb246109060.Text.Length = 0 Then
MsgBox("Nama Barang Belum Terisi Pak")
Exit Sub
End If
If Val(tb346109060.Text) = 0 Then
MsgBox("Harga Jual Belum Terisi Pak")
Exit Sub
End If
If Val(tb446109060.Text) = 0 Then
MsgBox("Jumlah Barang Belum Terisi Pak")
Exit Sub
End If
cari.AturPencarianDataBase("barang", "kodebarang", tb146109060.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("Kode Sudah Ada Pak")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into barang(kodebarang,namabarang,hargajual,jumlahbarang) Values('" & tb146109060.Text & "','" & tb246109060.Text & "'," & Val(tb346109060.Text) & "," & Val(tb446109060.Text) & ")", conect)
conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan33A_46109060.ambildata()
End Sub
Private Sub Latihan33B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class

Tidak ada komentar:

Posting Komentar