Latihan 29
Public Class Latihan29_36109005
Dim MINNI As New OleDb.OleDbCommand
Dim ISMI As New ByIskandar.CariKeDataBaseByIskandar
Dim MICKY 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 t1_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If t2_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If Val(t3_36109005.Text) = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If Val(t4_36109005.Text) = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If kb_36109005.Text <> t1_36109005.Text Then
ISMI.AturPencarianDataBase("Barang", "KodeBarang", t1_36109005.Text, 1, MICKY)
If ISMI.JumlanBaris > 0 Then
MsgBox("Kode Barang Sudah Ada")
Exit Sub
End If
End If
MINNI = New OleDb.OleDbCommand("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 & "'", MICKY)
MICKY.Open()
MINNI.ExecuteNonQuery()
MICKY.Close()
MINNI.Dispose()
kb_36109005.Text = ""
t1_36109005.Text = ""
t2_36109005.Text = ""
t3_36109005.Text = ""
t4_36109005.Text = ""
End Sub
End Class
Latihan 30A
Public Class Latihan30A_36109005
Dim DT As New DataTable
Dim ICHMI As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
Public Sub ISMI()
Dim AD As New OleDb.OleDbDataAdapter
AD = New OleDb.OleDbDataAdapter("select * from barang", ICHMI)
DT.Rows.Clear()
AD.Fill(DT)
AD.Dispose()
End Sub
Private Sub Latihan30A_36109005_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ISMI()
DGV_36109005.DataSource = DT
End Sub
Private Sub EDIT_36109005_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EDIT_36109005.Click
If Latihan30B_36109005.Visible = False Then
Latihan30B_36109005.Show()
Else
Latihan30B_36109005.Activate()
End If
Latihan30B_36109005.kb_36109005.Text = DGV_36109005.CurrentRow.Cells("kodebarang").Value
Latihan30B_36109005.t1_36109005.Text = DGV_36109005.CurrentRow.Cells("kodebarang").Value
Latihan30B_36109005.t2_36109005.Text = DGV_36109005.CurrentRow.Cells("namabarang").Value
Latihan30B_36109005.t3_36109005.Text = DGV_36109005.CurrentRow.Cells("hargajual").Value
Latihan30B_36109005.t4_36109005.Text = DGV_36109005.CurrentRow.Cells("jumlahbarang").Value
Latihan30B_36109005.Show()
End Sub
End Class
Latihan 30B
Public Class Latihan30B_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 t1_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If t2_36109005.Text.Length = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If Val(t3_36109005.Text) = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If Val(t4_36109005.Text) = 0 Then
MsgBox("Masukkan teks")
Exit Sub
End If
If kb_36109005.Text <> t1_36109005.Text Then
ISMI.AturPencarianDataBase("Barang", "KodeBarang", t1_36109005.Text, 1, DB)
If ISMI.JumlanBaris > 0 Then
MsgBox("Kode Barang Sudah Ada")
Exit Sub
End If
End If
OD = New OleDb.OleDbCommand("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 & "'", DB)
DB.Open()
OD.ExecuteNonQuery()
DB.Close()
OD.Dispose()
kb_36109005.Text = ""
t1_36109005.Text = ""
t2_36109005.Text = ""
t3_36109005.Text = ""
t4_36109005.Text = ""
Latihan30A_36109005.ISMI()
End Sub
End Class
Tidak ada komentar:
Posting Komentar