Deskripsi Form Latihan 32C
Pada form
latihan 32C ada 4 object yang digunakan yaitu Label, Text
Box, Button dan Status strip.
Object Label
Terdapat 5 label
pada form latihan 32C (edit data, kode
barang, nama barang, harga jual, dan
jumlah barang).
Object TextBox
Terdapat 4 object textbox (status input) yang digunakan
dalam menginput data.
Object Button
Terdapat 1
object button (simpan). Tombol simpan digunakan untuk menyimpan data yang telah
diedit.
Object StatusStrip
Ada 2
statusstrip yang digunakan (kode barang lama dan -). “-“akan menampilkan kode barang yang akan diubah.
Script Unique
Pada Latihan ini
tidak ada script yang baru, secara keseluruhan script telah ada pada
latihan-latihan sebelumnya.
Even
Click
Langkah-Langkah
Penyelesaian Form Latihan_32C_46110002
·
Buka folder project yang telah dibuat.
·
Click project kemudian pilih add windows form
·
Buat form "Latihan_32C_46110002" pada name kemudian
click add
·
Buat form seperti berikut dengan menggunakan object Label, Text
Box, Button dan Status strip.
·
Setelah itu beri nama object Text
Box, Button dan Status strip pada properties
·
Lalu masukkan text pada properties untuk object Label, Button dan Status strip.
·
Klik kanan, view kode lalu masukkan rumus
Public Class Latihan_32C_46110002
Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\DataBarang.ACCDB")
Private Sub SIMPAN_46110002_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN_46110002.Click
If KB_46110002.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If NB_46110002.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(HJ_46110002.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(JB_46110002.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If GANTI_46110002.Text <> KB_46110002.Text Then
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", KB_46110002.Text, 1, Jalan)
If PENCARI.JumlanBaris > 0 Then
MsgBox("The data has been exist please insert new data")
KB_46110002.Text = " "
NB_46110002.Text = " "
HJ_46110002.Text = " "
JB_46110002.Text = " "
Exit Sub
End If
End If
Dim Cm As New OleDb.OleDbCommand
Cm = New OleDb.OleDbCommand("Update BARANG set kodebarang ='" & KB_46110002.Text & "', namabarang = '" & NB_46110002.Text & "', hargajual=" & Val(HJ_46110002.Text) & ", jumlahbarang=" & Val(JB_46110002.Text) & " where kodebarang='" & GANTI_46110002.Text & "'", Jalan)
Jalan.Open()
Cm.ExecuteNonQuery()
Jalan.Close()
Cm.Dispose()
GANTI_46110002.Text = "-"
KB_46110002.Text = " "
NB_46110002.Text = " "
HJ_46110002.Text = " "
JB_46110002.Text = " "
Latihan_32A_46110002.ambildata()
Me.Close()
End Sub
End Class
Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\DataBarang.ACCDB")
Private Sub SIMPAN_46110002_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN_46110002.Click
If KB_46110002.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If NB_46110002.Text.Length = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(HJ_46110002.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If Val(JB_46110002.Text) = 0 Then
MsgBox("Plase Insert Your Text")
Exit Sub
End If
If GANTI_46110002.Text <> KB_46110002.Text Then
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", KB_46110002.Text, 1, Jalan)
If PENCARI.JumlanBaris > 0 Then
MsgBox("The data has been exist please insert new data")
KB_46110002.Text = " "
NB_46110002.Text = " "
HJ_46110002.Text = " "
JB_46110002.Text = " "
Exit Sub
End If
End If
Dim Cm As New OleDb.OleDbCommand
Cm = New OleDb.OleDbCommand("Update BARANG set kodebarang ='" & KB_46110002.Text & "', namabarang = '" & NB_46110002.Text & "', hargajual=" & Val(HJ_46110002.Text) & ", jumlahbarang=" & Val(JB_46110002.Text) & " where kodebarang='" & GANTI_46110002.Text & "'", Jalan)
Jalan.Open()
Cm.ExecuteNonQuery()
Jalan.Close()
Cm.Dispose()
GANTI_46110002.Text = "-"
KB_46110002.Text = " "
NB_46110002.Text = " "
HJ_46110002.Text = " "
JB_46110002.Text = " "
Latihan_32A_46110002.ambildata()
Me.Close()
End Sub
End Class
Langkah-Langkah
Menjalankan Form Latihan 32
·
Klik star debugging, trus klik latihan 32
·
Maka akan muncul hasil seperti ini
·
Lalu click “EDIT” maka akan muncul
latihan 31C
·
Click “simpan” untuk menyimpan data yang telah diedit.








0 komentar:
Posting Komentar