Selasa, 24 Januari 2012

pak ini tugas latihan vb net data gaji pegawai
dan ini lah hasil kasus

latihan vb.net (darminah)


Public Class Form1
Dim LST As ListViewItem
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
jabatan.Items.Add("Mandor")
jabatan.Items.Add("Kepala bagian")
jabatan.Items.Add("Staf")

buat_table()

End Sub
Sub buat_table()
With LV
.Items.Clear()
.FullRowSelect = True
.GridLines = True
.View = View.Details

.Columns.Add("Jabatan", 100)
.Columns.Add("Gaji pokok", 100)
.Columns.Add("Tunjangan istri", 100, HorizontalAlignment.Center)
.Columns.Add("Tunjngan anak", 100, HorizontalAlignment.Left)
.Columns.Add("Pajak", 100, HorizontalAlignment.Left)
.Columns.Add("Gaji lembur", 100, HorizontalAlignment.Left)
.Columns.Add("Jam lembur", 100, HorizontalAlignment.Left)
.Columns.Add("Upah per jam", 100, HorizontalAlignment.Left)
.Columns.Add("Total gaji", 100, HorizontalAlignment.Left)

End With

End Sub
Sub simpan()
LST = Me.LV.Items.Add(Me.jabatan.Text)
LST.SubItems.Add(Me.gaji_pokok.Text)
LST.SubItems.Add(Me.tunjangan_istri.Text)
LST.SubItems.Add(Me.tunjangan_anak.Text)
LST.SubItems.Add(Me.pajak.Text)
LST.SubItems.Add(Me.gaji_lembur.Text)
LST.SubItems.Add(Me.jam_lembur.Text)
LST.SubItems.Add(Me.upah_per_jam.Text)
LST.SubItems.Add(Me.total_gaji.Text)
End Sub
Sub kosong()
jabatan.Text = ""
gaji_pokok.Text = ""
tunjangan_istri.Text = ""
tunjangan_anak.Text = ""
pajak.Text = ""
gaji_lembur.Text = ""
jam_lembur.Text = ""
upah_per_jam.Text = ""
total_gaji.Text = ""
gaji_pokok.Focus()

End Sub

Private Sub jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged

If jabatan.Text = "Mandor" Then
gaji_pokok.Text = "1750000"
ElseIf jabatan.Text = "Kepala bagian" Then
gaji_pokok.Text = "2500000"
ElseIf jabatan.Text = "Staf" Then
gaji_pokok.Text = "1250000"
Else
jabatan.Text = ""

End If
End Sub

Private Sub tunjangan_istri_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tunjangan_istri.TextChanged
tunjangan_istri.Text = Val(0.09) * Val(gaji_pokok.Text)

End Sub

Private Sub tunjangan_anak_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tunjangan_anak.TextChanged
tunjangan_anak.Text = Val(0.07) * Val(gaji_pokok.Text)

End Sub


Private Sub pajak_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pajak.TextChanged
pajak.Text = Val(0.015) - Val(gaji_pokok.Text)

End Sub

Private Sub btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnproses.Click
If jam_lembur.Text <> "" Then
pajak.Text = Val(0.015) - Val(gaji_pokok.Text)
gaji_lembur.Text = Val(jam_lembur.Text) * Val(upah_per_jam.Text)
Else
MessageBox.Show("jumlah tidak boleh kosong")
Exit Sub

End If 'callbyname(jam lembur_keypress)
End Sub

Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
Call simpan()

End Sub

Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
kosong()
gaji_pokok.Focus()

End Sub

Private Sub btnhapus_semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus_semua.Click
LV.Items.Clear()


End Sub

Private Sub btnhapus_data_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus_data.Click
If LV.SelectedItems.Count <> 0 Then

LV.Items.Remove(LV.SelectedItems(0))
Else
MsgBox("maaf anda belum" & "memilih yang mana mau dihapus")
End If
End Sub

Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
Dim tanya As String
tanya = MsgBox("Apakah Anda Yakin Ingin Keluar?" & vbCrLf & "Harus Yakin", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
Me.Close()
Else
Exit Sub
End If
End Sub

Private Sub gaji_lembur_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gaji_lembur.TextChanged
total_gaji.Text = Val(jabatan.Text) * Val(jam_lembur.Text)
End Sub

Private Sub total_gaji_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles total_gaji.TextChanged
total_gaji.Text = Val(gaji_pokok.Text) + Val(tunjangan_istri.Text) + Val(tunjangan_anak.Text) + Val(gaji_lembur.Text) - Val(pajak.Text)

End Sub
End Class

hal 33 (darminah)

Public Class Form1
Dim LST As ListViewItem
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Select Case kode.Text
Case "TS001"
Microsoft.VisualBasic.Right(kode.Text, 3)
nama.Text = "Flashdisk 4GB"
Microsoft.VisualBasic.Left(kode.Text, 2)
merk.Text = "Toshiba"
Case "TS002"
Microsoft.VisualBasic.Right(kode.Text, 3)
nama.Text = "Flashdisk 2GB"
Microsoft.VisualBasic.Left(kode.Text, 2)
merk.Text = "Toshiba"
Case "VG001"
Microsoft.VisualBasic.Right(kode.Text, 3)
nama.Text = "Flashdisk 4GB"
Microsoft.VisualBasic.Left(kode.Text, 2)
merk.Text = "V-Gen"
Case "VG002"
Microsoft.VisualBasic.Right(kode.Text, 3)
nama.Text = "Flashdisk 2GB"
Microsoft.VisualBasic.Left(kode.Text, 2)
merk.Text = "V-gen"
End Select

If kode.Text = "TS001" Then
harga.Text = "105000"
ElseIf kode.Text = "TS002" Then
harga.Text = "75000"
ElseIf kode.Text = "VG001" Then
harga.Text = "90000"
ElseIf kode.Text = "VG002" Then
harga.Text = "60000"
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kode.Items.Add("TS001")
kode.Items.Add("TS002")
kode.Items.Add("VG001")
kode.Items.Add("VG002")

buat_table()
kosong()

End Sub
Sub buat_table()
With LV
.Items.Clear()
.FullRowSelect = True
.GridLines = True
.View = View.Details

.Columns.Add("No Pembelian", 100)
.Columns.Add("Kode Barang", 100)
.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
.Columns.Add("Merk", 100, HorizontalAlignment.Left)
.Columns.Add(" Harga ", 100, HorizontalAlignment.Left)
.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Left)
.Columns.Add("Total Harga", 100, HorizontalAlignment.Left)

End With
End Sub
Sub simpan()
LST = Me.lv.Items.Add(Me.no.Text)
LST.SubItems.Add(Me.kode.Text)
LST.SubItems.Add(Me.nama.Text)
LST.SubItems.Add(Me.merk.Text)
LST.SubItems.Add(Me.harga.Text)
LST.SubItems.Add(Me.jumlah.Text)
LST.SubItems.Add(Me.tharga.Text)

End Sub


Sub kosong()
nama.Text = ""
no.Text = ""
kode.Text = ""
merk.Text = ""
harga.Text = ""
jumlah.Text = ""
tharga.Text = ""
no.Focus()
End Sub



Private Sub btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusdata.Click
If lv.SelectedItems.Count <> 0 Then

lv.Items.Remove(lv.SelectedItems(0))
Else
MsgBox("maaf anda belum" & "memilih yang mana mau dihapus")
End If
End Sub

Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
Call simpan()
End Sub

Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
kosong()
no.Focus()

End Sub

Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
Dim tanya As String
tanya = MsgBox("Apakah Anda Yakin Ingin Keluar?" & vbCrLf & "Harus Yakin", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
Me.Close()
Else
Exit Sub
End If
End Sub

Private Sub btnhapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapussemua.Click
lv.Items.Clear()
End Sub

Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
tharga.Text = Val(jumlah.Text) * Val(harga.Text)
End Sub

End Class

hal 32 (darminah)

Public Class Form1
Dim LST As ListViewItem
Private Sub npm_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles npm.TextChanged
Dim x As String
tahun.Text = "20" & Microsoft.VisualBasic.Left(npm.Text, 2)
x = Microsoft.VisualBasic.Mid(npm.Text, 3, 1)
If x = "1" Then
jenjang.Text = "Diploma I"
ElseIf x = "2" Then
jenjang.Text = "Diploma III"
ElseIf x = "3" Then
jenjang.Text = "Strata I"
End If

x = Microsoft.VisualBasic.Mid(npm.Text, 4, 2)
If x = "01" Then
jurusan.Text = "Manajemen Informatika"
ElseIf x = "02" Then
jurusan.Text = "Sistem Informasi"
ElseIf x = "03" Then
jurusan.Text = "Teknik Komputer"
ElseIf x = "04" Then
jurusan.Text = "Akuntansi"
End If
End Sub

Private Sub nangka_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nangka.TextChanged
If nangka.Text >= 90 Then
nhuruf.Text = "A"
ElseIf nangka.Text >= 80 Then
nhuruf.Text = "B"
ElseIf nangka.Text >= 70 Then
nhuruf.Text = "C"
ElseIf nangka.Text = "60" Then
nhuruf.Text = "D"
Else
nhuruf.Text = "E"
End If
End Sub

Private Sub btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusdata.Click
If LV.SelectedItems.Count <> 0 Then

LV.Items.Remove(LV.SelectedItems(0))
Else
MsgBox("maaf anda belum" & "memilih yang mana mau dihapus")
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buat_table()
kosong()

End Sub
Sub buat_table()
With LV
.Items.Clear()
.FullRowSelect = True
.GridLines = True
.View = View.Details

.Columns.Add("npm", 100)
.Columns.Add("Nama", 100)
.Columns.Add("jurusan", 100, HorizontalAlignment.Center)
.Columns.Add("jenjang", 100, HorizontalAlignment.Left)
.Columns.Add(" Tahun Masuk ", 100, HorizontalAlignment.Left)
.Columns.Add("nilai Angka", 100, HorizontalAlignment.Left)
.Columns.Add("nilai Huruf", 100, HorizontalAlignment.Left)

End With
End Sub
Sub simpan()
LST = Me.LV.Items.Add(Me.NPM.Text)
LST.SubItems.Add(Me.NAMA.Text)
LST.SubItems.Add(Me.JURUSAN.Text)
LST.SubItems.Add(Me.jenjang.Text)
LST.SubItems.Add(Me.tahun.Text)
LST.SubItems.Add(Me.nangka.Text)
LST.SubItems.Add(Me.nhuruf.Text)

End Sub


Sub kosong()
NPM.Text = ""
NAMA.Text = ""
JURUSAN.Text = ""
jenjang.Text = ""
tahun.Text = ""
nangka.Text = ""
nhuruf.Text = ""
NPM.Focus()
End Sub

Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
Call simpan()
End Sub

Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
kosong()
npm.Focus()

End Sub

Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
Dim tanya As String
tanya = MsgBox("Apakah Anda Yakin Ingin Keluar?" & vbCrLf & "Harus Yakin", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
Me.Close()
Else
Exit Sub
End If
End Sub
End Class