DISKIPSI LATIHAN 33 B
Latihan_32B_36110030
A.
Object-object dalam Latihan_32B_36110030 :
1. Object Label
Terdapat
empat label (yang bertuliskan kode barang, nama barang, harga jual, dan jumlah
barang).
2. Object
Textbox
Terdapat
empat textbox yang semuanya merupakan status input. Status input digunakan
untuk memasukkan nilai: kode barang, nama barang, harga jual, dan jumlah barang
yang akan disimpan ke dalam form BARANG di Ms Access.
3. Object
Button
Terdapat
satu object button (Simpan). Button Simpan digunakan untuk menyimpan data
barang baru yang telah diinput. Data barang baru ini merupakan data barang yang
telah dipilih untuk diedit dari datagridview pada form Latihan_32A_36110030.
B.
Script Unique
Untuk script, dapat dilihat secara
menyeluruh pada Prosedur Penyelesaian Latihan_32B_36110030.
C.
Even
SIMPAN_36110030_Click
PROSEDUR PENYELESAIAN LATIHAN 33 B
1.KLIK STAR KEMUDIAN PILIH
MICROSOFT VISUAL STUDIO 2008
2.KEMUDIAN KLIK NEW PROJECT PADA FILE
3.KEMUDIAN KLIK ADD UNTUK MENAMBAHKAN PROJECT
4. KEMUDIAN BUATLAH FORM SEPERTI DIBAWAH INI :
5.KEMUDIAN MASUKAN RUMUS :
Public Class Latihan_33b_36110030
Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =E:\semester 5\Apkom 4\LATIHAN 27-34 SIMPAN EDIT DELETE DATA\databarang.accdb;jet oledb:database password=hma")
Dim ambil As New DataTable
Private Sub tambah()
Dim Cm As New OleDb.OleDbCommand
Cm = New OleDb.OleDbCommand("INSERT INTO BARANG (KODEBARANG, NAMABARANG, HARGAJUAL, JUMLAHBARANG) VALUES ('" & kb46110003.Text & "','" & nb46110003.Text & "', " & Val(hj46110003.Text) & "," & Val(jb46110003.Text) & ")", Jalan)
Jalan.Open()
Cm.ExecuteNonQuery()
Jalan.Close()
Cm.Dispose()
Latihan_33a_36110030.yhuya()
End Sub
Private Sub replace()
Dim Cm As New OleDb.OleDbCommand
Cm = New OleDb.OleDbCommand("Update BARANG set kodebarang ='" & Kode1_36110030.Text & "', namabarang = '" & Nama_36110030.Text & "', hargajual=" & Val(Harga_36110030.Text) & ", jumlahbarang=" & Val(Jumlah_36110030.Text) & " where kodebarang='" & kode2_36110030.Text & "'", Jalan)
Jalan.Open()
Cm.ExecuteNonQuery()
Jalan.Close()
Cm.Dispose()
Latihan_33a_36110030.yhuya()
End Sub
Private Sub simpan_36110030_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_36110030.Click
If Kode1_36110030.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Nama_36110030.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(Harga_36110030.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(Jumlah_36110030.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", Kode1_36110030, 1, Jalan)
If PENCARI.JumlanBaris > 0 Then
MsgBox("The data has been exist please insert new data")
Kode1_36110030.Text = " "
Nama_36110030.Text = " "
Harga_36110030.Text = " "
Jumlah_36110030.Text = " "
Exit Sub
End If
If Kode1_36110030.Text = "-" Then
tambah()
Else
replace()
End If
Kode1_36110030.Text = " "
Nama_36110030.Text = " "
Harga_36110030.Text = " "
Jumlah_36110030.Text = " "
Me.Close()
End Sub
End Class
Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =E:\semester 5\Apkom 4\LATIHAN 27-34 SIMPAN EDIT DELETE DATA\databarang.accdb;jet oledb:database password=hma")
Dim ambil As New DataTable
Private Sub tambah()
Dim Cm As New OleDb.OleDbCommand
Cm = New OleDb.OleDbCommand("INSERT INTO BARANG (KODEBARANG, NAMABARANG, HARGAJUAL, JUMLAHBARANG) VALUES ('" & kb46110003.Text & "','" & nb46110003.Text & "', " & Val(hj46110003.Text) & "," & Val(jb46110003.Text) & ")", Jalan)
Jalan.Open()
Cm.ExecuteNonQuery()
Jalan.Close()
Cm.Dispose()
Latihan_33a_36110030.yhuya()
End Sub
Private Sub replace()
Dim Cm As New OleDb.OleDbCommand
Cm = New OleDb.OleDbCommand("Update BARANG set kodebarang ='" & Kode1_36110030.Text & "', namabarang = '" & Nama_36110030.Text & "', hargajual=" & Val(Harga_36110030.Text) & ", jumlahbarang=" & Val(Jumlah_36110030.Text) & " where kodebarang='" & kode2_36110030.Text & "'", Jalan)
Jalan.Open()
Cm.ExecuteNonQuery()
Jalan.Close()
Cm.Dispose()
Latihan_33a_36110030.yhuya()
End Sub
Private Sub simpan_36110030_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_36110030.Click
If Kode1_36110030.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Nama_36110030.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(Harga_36110030.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(Jumlah_36110030.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", Kode1_36110030, 1, Jalan)
If PENCARI.JumlanBaris > 0 Then
MsgBox("The data has been exist please insert new data")
Kode1_36110030.Text = " "
Nama_36110030.Text = " "
Harga_36110030.Text = " "
Jumlah_36110030.Text = " "
Exit Sub
End If
If Kode1_36110030.Text = "-" Then
tambah()
Else
replace()
End If
Kode1_36110030.Text = " "
Nama_36110030.Text = " "
Harga_36110030.Text = " "
Jumlah_36110030.Text = " "
Me.Close()
End Sub
End Class
6.
KEMUDIAN UJI PROGRAM
7. JIKA SUDAH
BERHASIL Save program anda
8. selesai
0 komentar:
Posting Komentar