LATIHAN 33A
Public Class Latihan33A_36109005
Dim DT As New DataTable
Dim CM As New OleDb.OleDbCommand
Dim MM As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Private Sub T_36109005_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T_36109005.Click
If Latihan33B_36109005.Visible = False Then
Latihan33B_36109005.Show()
Else
Latihan33B_36109005.Activate()
End If
End Sub
Private Sub E_36109005_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles E_36109005.Click
If Latihan33B_36109005.Visible = False Then
Latihan33B_36109005.Show()
Else
Latihan33B_36109005.Activate()
End If
Latihan33B_36109005.t1_36109005.Text = DGV_36109005.CurrentRow.Cells("kodebarang").Value
Latihan33B_36109005.t2_36109005.Text = DGV_36109005.CurrentRow.Cells("namabarang").Value
Latihan33B_36109005.t3_36109005.Text = DGV_36109005.CurrentRow.Cells("hargajual").Value
Latihan33B_36109005.t4_36109005.Text = DGV_36109005.CurrentRow.Cells("jumlahbarang").Value
Latihan33B_36109005.KB_36109005.Text = DGV_36109005.CurrentRow.Cells("kodebarang").Value
End Sub
Private Sub H_36109005_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles H_36109005.Click
Dim ICHMI As String = "delete * from barang where kodebarang = '" & DGV_36109005.CurrentRow.Cells("kodebarang").Value & "'"
CM = New OleDb.OleDbCommand(ICHMI, MM)
MM.Open()
CM.ExecuteNonQuery()
MM.Close()
CM.Dispose()
Dim MILK As New OleDb.OleDbDataAdapter
MILK = New OleDb.OleDbDataAdapter("select * from barang", MM)
DT.Rows.Clear()
MILK.Fill(DT)
MILK.Dispose()
DGV_36109005.DataSource = DT
End Sub
Private Sub Latihan33A_36109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MILK As New OleDb.OleDbDataAdapter
MILK = New OleDb.OleDbDataAdapter("Select * from barang", MM)
DT.Rows.Clear()
MILK.Fill(DT)
MILK.Dispose()
DGV_36109005.DataSource = DT
End Sub
End Class
LATIHAN 33B
Public Class Latihan33B_36109005
Dim ISMI As New ByIskandar.CariKeDataBaseByIskandar
Dim OD As New OleDb.OleDbCommand
Dim DB As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Private Sub Simpan_36109005_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_36109005.Click
If KB_36109005.Text = "" Then
ISMI.AturPencarianDataBase("Barang", "KodeBarang", t1_36109005.Text, 1, DB)
If ISMI.JumlanBaris > 0 Then
MsgBox("Masukkan teks")
t1_36109005.Text = ""
Exit Sub
ElseIf t1_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t2_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t3_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t4_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
Dim ICHMI As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_36109005.Text & "','" & t2_36109005.Text & "'," & Val(t3_36109005.Text) & "," & Val(t4_36109005.Text) & ")"
OD = New OleDb.OleDbCommand(ICHMI, DB)
DB.Open()
OD.ExecuteNonQuery()
DB.Close()
OD.Dispose()
t1_36109005.Text = ""
t2_36109005.Text = ""
t3_36109005.Text = ""
t4_36109005.Text = ""
Else
If KB_36109005.Text <> t1_36109005.Text Then
ISMI.AturPencarianDataBase("Barang", "KodeBarang", t1_36109005.Text, 1, DB)
If ISMI.JumlanBaris > 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
End If
If t1_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t2_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t3_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
ElseIf t4_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
Dim ICHMI As String = "update barang set kodebarang = '" & t1_36109005.Text & "', namabarang = '" & t2_36109005.Text & "', hargajual = " & Val(t3_36109005.Text) & ", jumlahbarang = " & Val(t4_36109005.Text) & " where kodebarang = '" & KB_36109005.Text & "'"
OD = New OleDb.OleDbCommand(ICHMI, DB)
DB.Open()
OD.ExecuteNonQuery()
DB.Close()
OD.Dispose()
KB_36109005.Text = "-"
t1_36109005.Text = ""
t2_36109005.Text = ""
t3_36109005.Text = ""
t4_36109005.Text = ""
End If
End Sub
End Class
Tidak ada komentar:
Posting Komentar