Kamis, 06 Februari 2014

Absensi Pegawai









Private Sub Command1_Click() 'data pegawai
NIPpegawai = InputBox("Ketik NIP.Pegawai baru : ", "Periksa NIP.Baru")
If NIPpegawai = Empty Then Exit Sub
Adodc1.Recordset.Find "NIP='" & NIPpegawai & "'", , adSearchForward, 1
If Not Adodc1.Recordset.EOF Then
MsgBox "Rekord anggota sudah ada !", vbOKOnly, "Periksa NIP.Baru"
Adodc2.RecordSource = "Select * from Absensi where NIP='" & NIPpegawai & "'"
Adodc2.Refresh
DataGrid1.Refresh
Exit Sub
End If
Adodc1.Recordset.AddNew
Text1.Text = NIPpegawai
Adodc2.RecordSource = "Select * from Absensi where NIP='" & NIPpegawai & "'"
Adodc2.Refresh
DataGrid1.Refresh
Text2.SetFocus
End Sub
Private Sub Command2_Click() ' simpan data
Adodc1.Recordset.UpdateBatch
End Sub
Private Sub Command3_Click() ' koreksi data
CariNIP = InputBox("Ketik NIP.Pegawai : ", "Cari NIP.Pegawai")
If CariNIP = Empty Then Exit Sub
Adodc1.Recordset.Find "NIP='" & CariNIP & "'", , adSearchForward, 1
If Adodc1.Recordset.EOF Then
MsgBox "Rekord anggota belum ada !", vbOKOnly, "Cari NIP.Pegawai"
Exit Sub
End If
Adodc1.Recordset.Update
Text1.Text = nocari
Adodc2.RecordSource = "Select * from Absensi where NIP='" & CariNIP & "'"
Adodc2.Refresh
DataGrid1.Refresh
Text2.SetFocus
End Sub
Private Sub Command4_Click() 'Hapus data pegawai
hapus = MsgBox("Apakah anda yakin akan menghapus?", vbYesNo + vbDefaultButton2, "Hapus Pegawai")
If hapus = vbYes Then
On Error Resume Next
If Adodc2.Recordset.RecordCount > 0 Then
Adodc2.Recordset.MoveFirst
Do Until Adodc2.Recordset.AbsolutePosition = adPosEOF
Adodc2.Recordset.Delete
Adodc2.Recordset.MoveNext
Loop
Adodc2.Refresh
DataGrid1.Refresh
End If
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
End If
End Sub
Private Sub Command5_Click() ' hapus data absaen
hapus = MsgBox("Apakah anda yakin akan menghapus rekord Absensi?", vbYesNo + vbDefaultButton2, "Hapus Angsuran")
If hapus = vbYes Then
On Error Resume Next
Adodc2.Recordset.Delete
Adodc2.Recordset.MoveNext
End If
End Sub

 Private Sub Command6_Click() 'Sakit
Adodc2.Recordset.AddNew
Adodc2.Recordset!TglAbsen = Format(Date, "dd-mmm-yyyy")
Adodc2.Recordset!NIP = Text1
Adodc2.Recordset!Sakit = "S"
If Adodc2.Recordset!Sakit = "S" Then
Adodc2.Recordset!Masuk = "T"
Adodc2.Recordset!Izin = "T"
Adodc2.Recordset!Alpha = "T"
Adodc2.Recordset.UpdateBatch
Adodc2.Refresh
DataGrid1.Refresh
End If
End Sub
Private Sub Command7_Click() ' masuk
Adodc2.Recordset.AddNew
Adodc2.Recordset!TglAbsen = Format(Date, "dd-mmm-yyyy")
Adodc2.Recordset!NIP = Text1
Adodc2.Recordset!Masuk = "M"
If Adodc2.Recordset!Masuk = "M" Then
Adodc2.Recordset!Sakit = "T"
Adodc2.Recordset!Izin = "T"
Adodc2.Recordset!Alpha = "T"
Adodc2.Recordset.UpdateBatch
Adodc2.Refresh
DataGrid1.Refresh
End If
End Sub
Private Sub Command8_Click() 'izin
Adodc2.Recordset.AddNew
Adodc2.Recordset!TglAbsen = Format(Date, "dd-mmm-yyyy")
Adodc2.Recordset!NIP = Text1
Adodc2.Recordset!Izin = "I"
If Adodc2.Recordset!Izin = "I" Then
Adodc2.Recordset!Masuk = "T"
Adodc2.Recordset!Sakit = "T"
Adodc2.Recordset!Alpha = "T"
Adodc2.Recordset.UpdateBatch
Adodc2.Refresh
DataGrid1.Refresh
End If
End Sub
Private Sub Command9_Click() 'alpha
Adodc2.Recordset.AddNew
Adodc2.Recordset!TglAbsen = Format(Date, "dd-mmm-yyyy")
Adodc2.Recordset!NIP = Text1
Adodc2.Recordset!Alpha = "A"
If Adodc2.Recordset!Alpha = "A" Then
Adodc2.Recordset!Masuk = "T"
Adodc2.Recordset!Sakit = "T"
Adodc2.Recordset!Izin = "T"
Adodc2.Recordset.UpdateBatch
Adodc2.Refresh
DataGrid1.Refresh
End If
End Sub
Private Sub Form_Load()
Text5 = Format(Date, "dd-mmm-yyyy")
End Sub
Private Sub Text1_Change()
On Error Resume Next
Adodc2.RecordSource = "Select * from Absensi where NIP='" & Text1.Text & "'"
Adodc2.Refresh
DataGrid1.Refresh
End Sub

Tidak ada komentar: