Tuesday, 21 May 2013
Tugas Pemrograman List View
Inilah program yang list view dari hasil penggajian pada pegawai dengan hasil yang sudah ada seperti gambar dibawah ini pada Microsoft Visual Studio 2008.
Untuk menampilkan hasil seperti tu pertama-tama buatlah dahulu form tabel sesuai yang di atas. kemudian masukkan program atau script seperti dibawah ini.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 1 To 4
Janak.Items.Add(i)
Next i
For i = 1 To 10
Jlembur.Items.Add(i)
Next i
Nik.Items.Add("001")
Nik.Items.Add("002")
Nik.Items.Add("003")
jabatan.Items.Add("MANDOR")
jabatan.Items.Add("KEPALA BAGIAN")
jabatan.Items.Add("STAFF")
status.Items.Add("MENIKAH")
status.Items.Add("TIDAK MENIKAH")
buattabel()
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = Nik.Text
lst.SubItems.Add(nama.Text)
lst.SubItems.Add(jabatan.Text)
lst.SubItems.Add(gaji.Text)
lst.SubItems.Add(status.Text)
lst.SubItems.Add(Tistri.Text)
lst.SubItems.Add(Janak.Text)
lst.SubItems.Add(Tanak.Text)
lst.SubItems.Add(Jlembur.Text)
lst.SubItems.Add(Hlembur.Text)
lst.SubItems.Add(pajak.Text)
lst.SubItems.Add(Total.Text)
Lv.Items.Add(lst)
End Sub
Sub buattabel()
Lv.Columns.Add("NIK", 40, HorizontalAlignment.Center)
Lv.Columns.Add("NAMA", 100, HorizontalAlignment.Center)
Lv.Columns.Add("JABATAN", 80, HorizontalAlignment.Center)
Lv.Columns.Add("GAJI", 80, HorizontalAlignment.Center)
Lv.Columns.Add("STATUS", 70, HorizontalAlignment.Center)
Lv.Columns.Add("Tunj ISTRI", 80, HorizontalAlignment.Center)
Lv.Columns.Add("JUMLAH ANAK", 90, HorizontalAlignment.Center)
Lv.Columns.Add("Tunj ANAK", 80, HorizontalAlignment.Center)
Lv.Columns.Add("JAM LEMBUR", 100, HorizontalAlignment.Center)
Lv.Columns.Add("HONOR LEMBUR", 100, HorizontalAlignment.Center)
Lv.Columns.Add("PAJAK", 75, HorizontalAlignment.Center)
Lv.Columns.Add("TOTAL GAJI", 80, HorizontalAlignment.Center)
Lv.View = View.Details
Lv.GridLines = True
End Sub
Private Sub jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged
Select Case jabatan.Text
Case "MANDOR" : gaji.Text = 1750000
Case "KEPALA BAGIAN" : gaji.Text = 2500000
Case "STAFF" : gaji.Text = 1250000
End Select
pajak.Text = 0.15 * gaji.Text
End Sub
Private Sub Nik_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nik.SelectedIndexChanged
Select Case Nik.Text
Case "001" : nama.Text = "Budi"
Case "002" : nama.Text = "Ani"
Case "003" : nama.Text = "Dedi"
End Select
End Sub
Private Sub status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles status.SelectedIndexChanged
Select Case status.Text
Case "MENIKAH" : Tistri.Text = 0.09 * gaji.Text
Case "TIDAK MENIKAH" : Tistri.Text = 0
End Select
End Sub
Private Sub BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSimpan.Click
isitabel()
Nik.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
Tistri.Text = ""
Janak.Text = ""
Tanak.Text = ""
Jlembur.Text = ""
Hlembur.Text = ""
pajak.Text = ""
Total.Text = ""
End Sub
Private Sub BtnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnProses.Click
If jabatan.Text = "MANDOR" Then
Hlembur.Text = 7500
ElseIf jabatan.Text = "KEPALA BAGIAN" Then
Hlembur.Text = 10000
ElseIf jabatan.Text = "STAFF" Then
Hlembur.Text = 5000
Else
Hlembur.Text = 0
End If
Total.Text = Val(Hlembur.Text) + Val(gaji.Text) + Val(Tistri.Text) + Val(Tanak.Text) - Val(pajak.Text)
End Sub
Private Sub BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapus.Click
Lv.Items.Clear()
End Sub
Private Sub BtnDataDiPilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDataDiPilih.Click
Lv.Items.Remove(Lv.SelectedItems(0))
End Sub
Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
End
End Sub
Private Sub BtnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBersih.Click
Nik.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
Tistri.Text = ""
Janak.Text = ""
Tanak.Text = ""
Jlembur.Text = ""
Hlembur.Text = ""
pajak.Text = ""
Total.Text = ""
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Lv_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Lv.SelectedIndexChanged
End Sub
Private Sub Total_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Total.TextChanged
End Sub
Private Sub Janak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Janak.SelectedIndexChanged
If Janak.Text >= 2 And status.Text = "MENIKAH" Then
Tanak.Text = 0.07 * gaji.Text
ElseIf Janak.Text = 1 And status.Text = "MENIKAH" Then
Tanak.Text = 0.03 * gaji.Text
Else
Tanak.Text = 0
End If
End Sub
End Class
Kalau sudah script di atas dibuat maka jalankan dengan menekan F5 pada keyboard.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment