Anda di halaman 1dari 8

Public Class UAS

Dim INPUT As Integer


Dim index_code, Alamat_Terakhir As Short
Dim Total_GAJI, GAJI_POKOK, JUMLAH_LEMBUR, TUNJ_KEL, TUNJ_ANAK, JML_PjK, JML_ANAK As
Double
Dim i, counter, idx As Short
Dim Array_NIK(100) As String
Dim Array_NAMA(100) As String
Dim Array_JABATAN(100) As String
Dim Array_GAJI(100) As Integer
Dim Array_STATUS(100) As String
Dim Array_ANAK(100) As Integer
Dim Array_TUJKEL(100) As Integer
Dim Array_TUNJANAK(100) As Integer
Dim Array_PAJAK(100) As Integer
Dim Array_LEMBUR(100) As Integer
Dim Array_GAJILEMBUR(100) As Integer

Sub create_array()
Array_NIK(1) = "10012311"
Array_NIK(2) = "10145622"
Array_NIK(3) = "10278933"
Array_NIK(4) = "10301244"

Array_NAMA(1) = "ANDRI"
Array_NAMA(2) = "JHANI"
Array_NAMA(3) = "GALIH"
Array_NAMA(4) = "FAJAR"

Array_JABATAN(1) = "Direktur"
Array_JABATAN(2) = "Kepala Direksi"
Array_JABATAN(3) = "Staf"
Array_JABATAN(4) = "Office Boy"

Array_GAJI(1) = 5000000
Array_GAJI(2) = 3000000
Array_GAJI(3) = 1500000
Array_GAJI(4) = 1000000

Array_STATUS(1) = "Belum Menikah"


Array_STATUS(2) = "Menikah"
Array_STATUS(3) = "Belum Menikah"
Array_STATUS(4) = "Menikah"

Array_ANAK(1) = "0"
Array_ANAK(2) = "2"
Array_ANAK(3) = "0"
Array_ANAK(4) = "1"

Array_TUJKEL(1) = 0
Array_TUJKEL(2) = 300000
Array_TUJKEL(3) = 0
Array_TUJKEL(4) = 100000

Array_TUNJANAK(1) = 0
Array_TUNJANAK(2) = 300000
Array_TUNJANAK(3) = 0
Array_TUNJANAK(4) = 50000

Array_PAJAK(1) = 100000
Array_PAJAK(2) = 60000
Array_PAJAK(3) = 30000
Array_PAJAK(4) = 20000

End Sub
Sub Tampilkan_Array_Pertama()
txnik.Text = Array_NIK(1)
nama.Text = Array_NAMA(1)
txjabatan.Text = Array_JABATAN(1)
gaji.Text = Array_GAJI(1)
Cmbstatus.Text = Array_STATUS(1)
pajak.Text = Array_PAJAK(1)
index_code = 1
End Sub
Sub Tampilkan_Array_Terakhir()
txnik.Text = Array_NIK(Alamat_Terakhir)
nama.Text = Array_NAMA(Alamat_Terakhir)
txjabatan.Text = Array_JABATAN(Alamat_Terakhir)
gaji.Text = Array_GAJI(Alamat_Terakhir)
Cmbstatus.Text = Array_STATUS(Alamat_Terakhir)
pajak.Text = Array_PAJAK(Alamat_Terakhir)
index_code = Alamat_Terakhir

End Sub

Sub insert_array()
Array_NIK(i) = txnik.Text
Array_NAMA(i) = nama.Text
Array_JABATAN(i) = txjabatan.Text
Array_GAJI(i) = gaji.Text
Array_STATUS(i) = Cmbstatus.Text
Array_PAJAK(i) = pajak.Text
i += 1
Alamat_Terakhir += 1
End Sub
Sub cek_array_pakah_sudah_full()
If Alamat_Terakhir = INPUT Then
Btnsave.Enabled = False
Btncreate.Enabled = True
Cmbstatus.Enabled = True
Cmbstatus.Text = ""
Call Tampilkan_Array_Pertama()
End If
End Sub
Sub search_array()
counter = 0
While (counter <= Alamat_Terakhir) And
(Array_NIK(counter) <> TXSEARCH.Text)
counter += 1
End While
If Array_NIK(counter) = TXSEARCH.Text Then
idx = counter
Else
idx = 0

End If
If idx = 0 Then
Label_hasil.Text = "Tidak Ada"
Else
Label_hasil.Text = "Ada"
txnik.Text = Array_NIK(idx)
nama.Text = Array_NAMA(idx)
txjabatan.Text = Array_JABATAN(idx)
gaji.Text = Array_GAJI(idx)
Cmbstatus.Text = Array_STATUS(idx)
index_code = idx
End If
End Sub

Sub buat_tabel()
Lv.GridLines = True
Lv.View = View.Details
Lv.FullRowSelect = True
Lv.Columns.Add("NIK", 80, HorizontalAlignment.Center)
Lv.Columns.Add("Nama", 90, HorizontalAlignment.Left)
Lv.Columns.Add("Jabatan", 80, HorizontalAlignment.Center)
Lv.Columns.Add("Gaji Pokok", 90, HorizontalAlignment.Left)
Lv.Columns.Add("Status", 90, HorizontalAlignment.Left)
Lv.Columns.Add("Anak", 70, HorizontalAlignment.Center)
Lv.Columns.Add("Tunj.Keluarga", 100, HorizontalAlignment.Left)
Lv.Columns.Add("Tunj.Anak", 90, HorizontalAlignment.Left)
Lv.Columns.Add("Pajak", 80, HorizontalAlignment.Left)
Lv.Columns.Add("Lembur", 70, HorizontalAlignment.Center)
Lv.Columns.Add("Gaji Lembur", 85, HorizontalAlignment.Left)
Lv.Columns.Add("Total Gaji", 100, HorizontalAlignment.Left)
Lv.View = View.Details
Lv.GridLines = True
Lv.FullRowSelect = True
Lv.BackColor = Color.Aquamarine

End Sub
Sub isi_tabel()
Dim ist As New ListViewItem
ist.Text = txnik.Text
ist.SubItems.Add(nama.Text)
ist.SubItems.Add(txjabatan.Text)
ist.SubItems.Add(gaji.Text)
ist.SubItems.Add(Cmbstatus.Text)
ist.SubItems.Add(TXANAK.Text)
ist.SubItems.Add(tunjangan.Text)
ist.SubItems.Add(TXTUNJANAK.Text)
ist.SubItems.Add(pajak.Text)
ist.SubItems.Add(lembur.Text)
ist.SubItems.Add(TextBox1.Text)
ist.SubItems.Add(totalgaji.Text)
Lv.Items.Add(ist)
End Sub
Sub bersih()
txnik.Text = ""
nama.Text = ""
txjabatan.Text = ""
gaji.Text = ""
Cmbstatus.Text = ""
TXANAK.Text = ""
tunjangan.Text = ""
TXTUNJANAK.Text = ""
pajak.Text = ""
lembur.Text = ""
totalgaji.Text = ""
PictureBox1.Hide()
End Sub
Sub item()
Cmbstatus.Items.Add("Menikah")
Cmbstatus.Items.Add("Belum Menikah")

End Sub
Private Sub UAS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Call buat_tabel()
Call item()
Call create_array()
Call Tampilkan_Array_Pertama()
index_code = 1
i = 5
Alamat_Terakhir = 4
Btnsave.Enabled = False
totalgaji.Enabled = False
TXANAK.Text = INPUT
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnkeluar.Click
Dim k As String
k = MsgBox("Apakah anda yakin ingin keluar", MsgBoxStyle.YesNo)
If k = vbYes Then
Me.Close()
End If

End Sub
Private Sub Cmbstatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Cmbstatus.SelectedIndexChanged
Select Case Cmbstatus.Text
Case "Menikah" : tunjangan.Text = 0.1 * gaji.Text
TXANAK.Enabled = True
Case "Belum Menikah" : tunjangan.Text = 0
End Select
If Cmbstatus.Text = "Belum Menikah" Then
TXANAK.Enabled = False
TXTUNJANAK.Enabled = False

End If
End Sub

Private Sub TXANAK_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TXANAK.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 48) And (tombol <= 57)) Or (tombol = 8)) Then
e.Handled = True
MessageBox.Show("input salah", "pesan")
Else
If TXANAK.Text = "1" Then
TXTUNJANAK.Text = 0.05 * gaji.Text
ElseIf TXANAK.Text = "2" Then
TXTUNJANAK.Text = 0.1 * gaji.Text
Else
If TXANAK.Text = "3" Then
TXTUNJANAK.Text = 0.1 * gaji.Text
Else
If TXANAK.Text = "4" Then
TXTUNJANAK.Text = 0.1 * gaji.Text

End If
End If
End If
End If

End Sub

Private Sub btnproses_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnproses.Click
totalgaji.Text = Val(gaji.Text) + Val(tunjangan.Text) + Val(TXTUNJANAK.Text) +
Val(TextBox1.Text) - Val(pajak.Text)
End Sub

Private Sub Btnsimpan_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Btnsimpan.Click
Call isi_tabel()
End Sub
Private Sub lembur_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lembur.TextChanged
If txjabatan.Text = "Kepala Direksi" Then
TextBox1.Text = Val(lembur.Text) * 20000
ElseIf txjabatan.Text = "Direktur" Then
TextBox1.Text = Val(lembur.Text) * 25000
ElseIf txjabatan.Text = "Staf" Then
TextBox1.Text = Val(lembur.Text) * 15000
ElseIf txjabatan.Text = "Office Boy" Then
TextBox1.Text = Val(lembur.Text) * 10000
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click

Lv.Items.Remove(Lv.SelectedItems(0))
End Sub
Private Sub first_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles first.Click
Call Tampilkan_Array_Pertama()
End Sub
Private Sub last_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles last.Click
Call Tampilkan_Array_Terakhir()
End Sub
Private Sub btn_prev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_prev.Click
If index_code <= 1 Then
MsgBox("Ini yang pertama", MsgBoxStyle.Information, "Pesan")
Else
index_code -= 1
txnik.Text = Array_NIK(index_code)
nama.Text = Array_NAMA(index_code)
txjabatan.Text = Array_JABATAN(index_code)
gaji.Text = Array_GAJI(index_code)
Cmbstatus.Text = Array_STATUS(index_code)
TXANAK.Text = Array_ANAK(index_code)
TXTUNJANAK.Text = Array_TUNJANAK(index_code)
tunjangan.Text = Array_TUJKEL(index_code)
pajak.Text = Array_PAJAK(index_code)

End If
End Sub
Private Sub btn_next_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_next.Click
If index_code >= Alamat_Terakhir Then
MsgBox("Ini data yang terakhir", MsgBoxStyle.Information, "Pesan")
Else
index_code += 1
txnik.Text = Array_NIK(index_code)
nama.Text = Array_NAMA(index_code)
txjabatan.Text = Array_JABATAN(index_code)
gaji.Text = Array_GAJI(index_code)
Cmbstatus.Text = Array_STATUS(index_code)
TXANAK.Text = Array_ANAK(index_code)
TXTUNJANAK.Text = Array_TUNJANAK(index_code)
tunjangan.Text = Array_TUJKEL(index_code)
pajak.Text = Array_PAJAK(index_code)

End If
End Sub
Private Sub Btncreate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btncreate.Click
Btnsave.Enabled = True
Btncreate.Enabled = False
txt_new.Enabled = False
INPUT = txt_new.Text + Alamat_Terakhir
Call bersih()
txnik.Focus()
txt_new.Text = ""
End Sub
Private Sub Btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Btnsave.Click
Call insert_array()
Call bersih()
txnik.Focus()
Call cek_array_pakah_sudah_full()
txt_new.Enabled = True

End Sub
Private Sub Btnsearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btnsearch.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
ProgressBar1.Value += 1
If ProgressBar1.Value = 100 Then
Label_hasil.Enabled = False
ProgressBar1.Value = 0
Call search_array()

End If
End Sub
Private Sub txnik_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txnik.TextChanged
Dim x As String
x = Microsoft.VisualBasic.Left(txnik.Text, 3)
Select Case x
Case "100" : nama.Text = "ANDRI"
Case "101" : nama.Text = "JHANI"
Case "102" : nama.Text = "GALIH"
Case "103" : nama.Text = "FAJAR"
End Select
x = Microsoft.VisualBasic.Mid(txnik.Text, 4, 3)
Select Case x
Case "123"
txjabatan.Text = "Direktur"
gaji.Text = 5000000
Case "456"
txjabatan.Text = "Kepala Direksi"
gaji.Text = 3000000
Case "789"
txjabatan.Text = "Staf"
gaji.Text = 1500000
Case "012"
txjabatan.Text = "Office Boy"
gaji.Text = 1000000
End Select
x = Microsoft.VisualBasic.Right(txnik.Text, 2)
Select Case x
Case "11"
PictureBox1.Load("contoh.png")
Case "22"
PictureBox1.Load("jhani.png")
Case "33"
PictureBox1.Load("kd.png")
Case "44"
PictureBox1.Load("ob.png")
End Select
pajak.Text = 0.02 * Val(gaji.Text)
End Sub

Private Sub TXANAK_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TXANAK.TextChanged
If TXANAK.Text = "1" Then
TXTUNJANAK.Text = 0.05 * gaji.Text
ElseIf TXANAK.Text = "2" Then
TXTUNJANAK.Text = 0.1 * gaji.Text
Else
If TXANAK.Text = "3" Then
TXTUNJANAK.Text = 0.1 * gaji.Text
Else
If TXANAK.Text = "4" Then
TXTUNJANAK.Text = 0.1 * gaji.Text
End If
End If
End If

End Sub

Private Sub gaji_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles gaji.TextChanged
pajak.Text = 0.02 * Val(gaji.Text)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Lv.Items.Clear()
End Sub
End Class