Form 33A
Public Class Form33A_36109023
Dim dt As New DataTable
Dim cm As New OleDb.OleDbCommand
Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Private Sub Form33A_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cc As New OleDb.OleDbDataAdapter
cc = New OleDb.OleDbDataAdapter("Select * from barang", ame)
dt.Rows.Clear()
cc.Fill(dt)
cc.Dispose()
dgv36109023.DataSource = dt
End Sub
Private Sub tambah36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah36109023.Click
If Form33B_36109023.Visible = False Then
Form33B_36109023.Show()
Else
Form33B_36109023.Activate()
End If
End Sub
Private Sub edit36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit36109023.Click
If Form33B_36109023.Visible = False Then
Form33B_36109023.Show()
Else
Form33B_36109023.Activate()
End If
Form33B_36109023.t1_36109023.Text = dgv36109023.CurrentRow.Cells("kodebarang").Value
Form33B_36109023.t2_36109023.Text = dgv36109023.CurrentRow.Cells("namabarang").Value
Form33B_36109023.t3_36109023.Text = dgv36109023.CurrentRow.Cells("hargajual").Value
Form33B_36109023.t4_36109023.Text = dgv36109023.CurrentRow.Cells("jumlahbarang").Value
Form33B_36109023.KB.Text = dgv36109023.CurrentRow.Cells("kodebarang").Value
End Sub
Private Sub hapus36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus36109023.Click
Dim bb As String = "delete * from barang where kodebarang = '" & dgv36109023.CurrentRow.Cells("kodebarang").Value & "'"
cm = New OleDb.OleDbCommand(bb, ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
cm.Dispose()
Dim cc As New OleDb.OleDbDataAdapter
cc = New OleDb.OleDbDataAdapter("select * from barang", ame)
dt.Rows.Clear()
cc.Fill(dt)
cc.Dispose()
dgv36109023.DataSource = dt
End Sub
End Class
Form 33B
Public Class Form33B_36109023
Dim amelia As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If KB.Text = "" Then
amelia.AturPencarianDataBase("Barang", "KodeBarang", t1_36109023.Text, 1, ame)
If amelia.JumlanBaris > 0 Then
MsgBox("Masukkan teks")
t1_36109023.Text = ""
Exit Sub
ElseIf t1_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t2_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t3_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t4_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
Dim aa As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_36109023.Text & "','" & t2_36109023.Text & "'," & Val(t3_36109023.Text) & "," & Val(t4_36109023.Text) & ")"
cm = New OleDb.OleDbCommand(aa, ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
cm.Dispose()
t1_36109023.Text = ""
t2_36109023.Text = ""
t3_36109023.Text = ""
t4_36109023.Text = ""
Else
If KB.Text <> t1_36109023.Text Then
amelia.AturPencarianDataBase("Barang", "KodeBarang", t1_36109023.Text, 1, ame)
If amelia.JumlanBaris > 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
End If
If t1_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t2_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t3_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t4_36109023.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
Dim bb As String = "update barang set kodebarang = '" & t1_36109023.Text & "', namabarang = '" & t2_36109023.Text & "', hargajual = " & Val(t3_36109023.Text) & ", jumlahbarang = " & Val(t4_36109023.Text) & " where kodebarang = '" & KB.Text & "'"
cm = New OleDb.OleDbCommand(bb, ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
cm.Dispose()
KB.Text = "-"
t1_36109023.Text = ""
t2_36109023.Text = ""
t3_36109023.Text = ""
t4_36109023.Text = ""
End If
End Sub
End Class
Senin, 28 November 2011
Form 33
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar