LATIHAN_40A_36110030
Deskripsi Latihan_40A_36110030
A. Object-object dalam Latihan_40A_36110030:
1. Object Label
Terdapat satu label (yang bertuliskan data
transaksi).
2. Object Button
Terdapat tiga object button (Hapus, Tambah,
dan Edit). Tombol hapus digunakan untuk menghapus data yang dipilih pada
datagridview. Tombol tambah digunakan untuk menambah data barang. Tombol edit
digunakan untuk mengedit barang yang dipilih pada datagridview. Jika tombol
tambah atau edit diklik, makan akan muncul form Latihan_40B_36110030.
3. Object DataGridView
Terdapat dua object datagridview.
Datagridview1 digunakan untuk menampilkan data notrans, tanggal transaksi, dan
jenis transaksi. Datagridview2 digunakan untuk menampilkan notrans, kode
barang, nama barang, harga, unit, dan jumlah.
B. Script Unique
Untuk script, silahkan lihat selengkapnya
pada Langkah-Langkah Latihan_40A_36110030.
C. Even
Isi()
Latihan_40A_36110030_Load
HAPUS_36110030_Click
TAMBAH_36110030_Click
EDIT_36110030_Click
PROSEDUR PENYELESAIAN LATIHAN 40 A
1.KLIK STAR KEMUDIAN PILIH
MICROSOFT VISUAL STUDIO 2008
2.KEMUDIAN KLIK NEW PROJECT PADA FILE
6. KEMUDIAN UJI PROGRAM
3.KEMUDIAN KLIK ADD UNTUK MENAMBAHKAN PROJECT
4.
KEMUDIAN BUATLAH FORM SEPERTI DIBAWAH INI :
5.KEMUDIAN MASUKAN RUMUS :
Public Class Latihan_40A_36110030
Dim bridgeYhuya As NewOleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath &"\datamajemuk.accdb;Jet OLEDB:Database Password=hma")
Dim tabelYhuya1 As New DataTable
Dim tabelYhuya2 As New DataTable
Dim setYhuya As New DataSet
Dim Binding As New BindingSource
Dim Binding2 As New BindingSource
Public Sub Isi()
Dim truckYhuya As New OleDb.OleDbDataAdapter
tabelYhuya2.Rows.Clear()
tabelYhuya1.Rows.Clear()
truckYhuya = New OleDb.OleDbDataAdapter("Select
* " & _
"From MASTERTRANSAKSI", bridgeYhuya)
truckYhuya.Fill(tabelYhuya1)
truckYhuya = New OleDb.OleDbDataAdapter("Select
NOTRANS, DETAILTRANSAKSI.KODEBARANG, NAMABARANG, HARGA, UNIT, UNIT * HARGA As
JUMLAH " & _
"From DETAILTRANSAKSI Inner Join BARANG on
DETAILTRANSAKSI.KODEBARANG = BARANG.KODEBARANG", bridgeYhuya)
truckYhuya.Fill(tabelYhuya2)
truckYhuya.Dispose()
End Sub
Private Sub Latihan_40A_3611004a_Load(ByVal senderAs Object, ByVal e As System.EventArgs) Handles Me.Load
Isi()
DGV1_36110030.DataSource = tabelYhuya1
DGV2_36110030.DataSource = tabelYhuya2
setYhuya.Tables.Add(tabelYhuya1)
setYhuya.Tables.Add(tabelYhuya2)
tabelYhuya1.TableName = "Induk"
tabelYhuya2.TableName = "Sub"
setYhuya.Relations.Add(New DataRelation("Relasi", setYhuya.Tables("Induk").Columns("NOTRANS"), setYhuya.Tables("Sub").Columns("NOTRANS")))
Binding.DataSource = setYhuya
Binding.DataMember = "Induk"
Binding2.DataSource = Binding
Binding2.DataMember = "Relasi"
DGV1_36110030.DataSource = Binding
DGV2_36110030.DataSource = Binding2
End Sub
Private Sub HAPUS_36110030_Click(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesHAPUS_36110030.Click
Dim truckYhuya As New OleDb.OleDbCommand
truckYhuya = New OleDb.OleDbCommand("Delete
* From MASTERTRANSAKSI Where NOTRANS = '" &
DGV1_36110030.CurrentRow.Cells("NOTRANS").Value & "'", bridgeYhuya)
If MsgBox("Apakah Anda
Yakin Menghapusnya?", MsgBoxStyle.YesNo) =
MsgBoxResult.Yes Then
bridgeYhuya.Open()
truckYhuya.ExecuteNonQuery()
truckYhuya = New OleDb.OleDbCommand("Delete
* From DETAILTRANSAKSI Where NOTRANS = '" &
DGV1_36110030.CurrentRow.Cells("NOTRANS").Value & "'", bridgeYhuya)
truckYhuya.ExecuteNonQuery()
bridgeYhuya.Close()
truckYhuya.Dispose()
End If
Isi()
End Sub
Private Sub TAMBAH_36110030_Click(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesTAMBAH_36110030.Click
If Latihan_40B_36110030.Visible = False Then
Latihan_40B_36110030.Show()
Else
Latihan_40B_36110030.Activate()
Latihan_40B_36110030.WindowState = FormWindowState.Normal
Latihan_40B_36110030.NOLAMA_36110030.Text ="-"
End If
Latihan_40B_36110030.NO_36110030.Text = ""
Latihan_40B_36110030.JENIS_36110030.Text = ""
Latihan_40B_36110030.TOTAL_36110030.Text = ""
Latihan_40B_36110030.SelectData()
Latihan_40B_36110030.Hitung()
End Sub
Private Sub EDIT_36110030_Click(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesEDIT_36110030.Click
If Latihan_40B_36110030.Visible = False Then
Latihan_40B_36110030.Show()
Else
Latihan_40B_36110030.Activate()
Latihan_40B_36110030.WindowState = FormWindowState.Normal
End If
Latihan_40B_36110030.NO_36110030.Text = DGV1_36110030.CurrentRow.Cells("NOTRANS").Value
Latihan_40B_36110030.NOLAMA_36110030.Text = DGV1_36110030.CurrentRow.Cells("NOTRANS").Value
Latihan_40B_36110030.JENIS_36110030.Text = DGV1_36110030.CurrentRow.Cells("JENISTRANSAKSI").Value
Latihan_40B_36110030.SelectData()
Latihan_40B_36110030.Hitung()
End Sub
End Class
7. JIKA SUDAH
BERHASIL Save program anda
8. selesai
0 komentar:
Posting Komentar