DISKRIPSI LATIHAN 12
A. Object-object dalam Latihan_12_36110030 :
1.
Object Label
Terdapat sebelas label (yang bertuliskan no pembelian,
nama barang, harga perunit, unit, tanggal, jumlah, total unit, total, no baris,
no pembelian, baris sekarang).
2.
Object
Textbox
Terdapat sembilan textbox (enama status input; tiga
status read only). Status input digunakan untuk memasukkan no pembelian, nama
barang, harga perunit, no baris. Status Read Only digunakan untuk menampilkan
hasil dari perkalian harga perunit dan unit, dan total unit serta jumlah dari
data yang dimasukkan dalam datagridview.
3.
Object
Button
Terdapat tujuh object button (Simpan, button Tampilkan
ada 3, dan button Hapus ada 3). Button simpan digunakan untuk memasukkan data
yang telah diinput ke dalam datagridview. Button tampilkan digunakan untuk
menampilkan data dalam datagridview ke dalam textbox tempat menginput data.
Sedangkan button hapus digunkan untuk menghapus data yang ada di dalam
datagridview.
Object DataGridView
Terdapat satu objek datagridview
yang digunakan untuk menampilkan data yang telah diinput dalam no pembelian,
nama barang, harga perunit, unit, jumlah, dan tanggal pembelian.
1
Object DateTimePicker
Terdapat
satu object datetimepicker yang digunakan untuk menentukan tanggal pembelian.
B. Script Unique
Untuk button Simpan, Tampilkan, dan Hapus:
Dim baris As DataRow
C. Even
Latihan_12_36110048_Load
HP_36110030.TextChanged, UNIT_36110030.TextChanged
SIMPAN_36110030_Click
T1_36110030_Click
H1_3611003o_Click
yhuya()
D. Property
Property TextBox ==> ReadOnly=True
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_12_36110030
Dim TABLE As New DataTable
Private Sub Latihan_12_36110030_Load(ByVal
sender As Object,
ByVal e As
System.EventArgs) Handles Me.Load
TABLE.Columns.Add(New DataColumn("No.
Pembelian", GetType(String)))
TABLE.Columns.Add(New DataColumn("Nama
Barang", GetType(String)))
TABLE.Columns.Add(New DataColumn("Harga
Perunit", GetType(Double)))
TABLE.Columns.Add(New DataColumn("Tanggal
Pembelian", GetType(Date)))
TABLE.Columns.Add(New DataColumn("Unit",
GetType(Integer)))
TABLE.Columns.Add(New DataColumn("Jumlah",
GetType(Double)))
DGV_36110030.DataSource = TABLE
Dim
kolom(1) As DataColumn
kolom(0) = TABLE.Columns("No. Pembelian")
TABLE.PrimaryKey = kolom
End Sub
Private Sub UNIT_36110030_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
UNIT_36110030.TextChanged
JUMLAH_36110030.Text =
Val(UNIT_36110030.Text) * Val(HP_36110030.Text)
End Sub
Private Sub SIMPAN_36110030_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles SIMPAN_36110046.Click
Dim
baris As DataRow
baris =
TABLE.Rows.Find(NP_36110030.Text)
If
baris Is Nothing
Then
baris = TABLE.NewRow
baris("No.
Pembelian") = NP_36110030.Text
baris("Nama
Barang") = NB_36110030.Text
baris("Harga
Perunit") = Val(HP_36110030.Text)
baris("Tanggal
Pembelian") = TGL_36110030.Value.Date
baris("Unit")
= Val(UNIT_36110030.Text)
baris("Jumlah")
= Val(JUMLAH_36110030.Text)
TABLE.Rows.Add(baris)
NP_36110030.Text = ""
NB_36110030.Text = ""
HP_36110030.Text = ""
UNIT_36110030.Text = ""
JUMLAH_36110030.Text = ""
Else : MsgBox("baris sudah ada")
JUMLAH_36110030.Text = ""
End If
yhuya()
End Sub
Private Sub T1_36110046_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles T1_36110030.Click
Dim
baris As DataRow
If
Val(NOBARIS_36110030.Text) <= TABLE.Rows.Count Then
baris =
TABLE.Rows(Val(NOBARIS_36110030.Text) - 1)
NP_36110030.Text = baris("No. Pembelian")
NB_36110030.Text = baris("Nama Barang")
HP_36110030.Text = baris("Harga Perunit")
TGL_36110030.Value = baris("Tanggal Pembelian")
UNIT_36110030.Text = baris("Unit")
JUMLAH_36110030.Text = baris("Jumlah")
Else
MsgBox("baris
terlalu besar")
End If
NOBARIS_36110030.Text = ""
End Sub
Private Sub H1_36110030_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles H1_36110030.Click
Dim
baris As DataRow
If
Val(NOBARIS_36110030.Text) <= TABLE.Rows.Count Then
baris =
TABLE.Rows(Val(NOBARIS_36110030.Text) - 1)
baris.Delete()
Else
MsgBox("no.
baris yang dimasukkan tidak ada")
End If
NOBARIS_36110030.Text = ""
yhuya()
End Sub
Private Sub T2_36110030_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles T2_36110030.Click
Dim
baris As DataRow
baris =
TABLE.Rows.Find(NOPEMB_36110030.Text)
If Not baris Is Nothing Then
NP_36110030.Text = baris("No. Pembelian")
NB_36110030.Text = baris("Nama Barang")
HP_36110030.Text = baris("Harga Perunit")
TGL_36110030.Value = baris("Tanggal Pembelian")
UNIT_36110030.Text = baris("Unit")
JUMLAH_36110030.Text = baris("Jumlah")
Else
MsgBox("no.
pembelian tidak ada")
End If
NOPEMB_36110030.Text = ""
End Sub
Private Sub H2_36110030_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles H2_36110030.Click
Dim
baris As DataRow
baris =
TABLE.Rows.Find(NOPEMB_36110030.Text)
If Not baris Is Nothing Then
baris.Delete()
NOPEMB_36110030.Text = ""
Else
MsgBox("no.
pembelian yang dimasukkan tidak ada")
NOPEMB_36110030.Text = ""
End If
yhuya()
End Sub
Private Sub T3_36110030_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles T3_36110030.Click
Dim
baris As DataRow
baris =
TABLE.DefaultView(BindingContext(TABLE).Position).Row
NP_36110030.Text = baris("No. Pembelian")
NB_36110030.Text = baris("Nama Barang")
HP_36110030.Text = baris("Harga Perunit")
TGL_36110030.Value = baris("Tanggal Pembelian")
UNIT_36110030.Text = baris("Unit")
JUMLAH_36110030.Text = baris("Jumlah")
End Sub
Private Sub H3_36110030_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles H3_36110030.Click
Dim
baris As DataRow
baris =
TABLE.DefaultView(BindingContext(TABLE).Position).Row
baris.Delete()
yhuya()
End Sub
Private Sub yhuya()
Dim tu,
total As Integer
For Each x As DataRow In TABLE.Rows
tu = tu + x("Unit")
total = total + x("Jumlah")
Next
TOTUNIT_36110030.Text = tu
TOT_36110030.Text = total
End Sub
Private Sub DGV_36110030_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DGV_36110030.CellContentClick
End Sub
End Class
6. KEMUDIAN
UJI PROGRAM
7. JIKA SUDAH
BERHASIL Save program anda
8. selesai
0 komentar:
Posting Komentar