Private Sub Form_Load()
Call OPENDB
Call Hapus
Call TampilNIP
End Sub
Sub Hapus()
NOBUKTI = ""
TANGGAL = Format(Now, "yyyy/MM/DD")
NIP = ""
NAMA = ""
BAGIAN = ""
JUMLAH = ""
CmdProses(1).Caption = "&Simpan"
Call RubahCMD(Me, True, False, False, False)
End Sub
Sub TampilNIP()
SQL = "select NIP from pegawai"
If RS.State = adStateOpen Then RS.Close
RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
If RS.RecordCount <> 0 Then
Do While Not RS.EOF
NIP.AddItem RS!NIP
RS.MoveNext
Loop
End If
End Sub
Private Sub NIP_click()
SQL = "select * from pegawai where NIP='" & NIP.Text & "'"
If RS.State = adStateOpen Then RS.Close
RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
If RS.RecordCount <> 0 Then
NAMA = RS!NAMA
BAGIAN = RS!BAGIAN
End If
End Sub
Private Sub NOBUKTI_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If NOBUKTI.Text = "" Then Exit Sub
SQL = "select * from gaji " & _
"where NoBukti='" & NOBUKTI & "'"
If RS.State = adStateOpen Then RS.Close
RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
If RS.RecordCount <> 0 Then
showDb
Call RubahCMD(Me, False, True, True, True)
CmdProses(1).Caption = "edit"
Else
x = NOBUKTI
Call Hapus
NOBUKTI = x
Call RubahCMD(Me, False, True, False, True)
End If
NOBUKTI.SetFocus
End If
End Sub
Sub showDb()
NOBUKTI = RS!NOBUKTI
TANGGAL = Format(RS!TANGGAL, "mm/dd/yyyy")
NIP = RS!NIP
JUMLAH = RS!JUMLAH
Call NIP_click
End Sub
Private Sub CmdProses_Click(Index As Integer)
Select Case Index
Case 0
Call Hapus
NIP.SetFocus
Case 1
If CmdProses(1).Caption = "&Simpan" Then
Call ProsesDB(0)
Else
Call ProsesDB(1)
End If
Case 2
x = MsgBox("Yakin RECORD PEGAWAI Akan Dihapus...!", vbQuestion + vbYesNo, "Pegawai")
If x = vbYes Then ProsesDB 2
Call Hapus
NIP.SetFocus
Case 3
Call Hapus
NIP.SetFocus
Case 4
Unload Me
End Select
End Sub
Sub ProsesDB(Log As Byte)
Select Case Log
Case 0
SQL = "INSERT INTO GAJI(NOBUKTI, TANGGAL, NIP, JUMLAH)" & _
" values('" & NOBUKTI.Text & _
"','" & TANGGAL.Text & _
"','" & NIP.Text & _
"','" & JUMLAH.Text & "')"
Case 1
SQL = "UPDATE GAJI SET NOBUKTI ='" & NOBUKTI.Text & "'," & _
"TANGGAL= '" & TANGGAL & "'," & _
" NIP = '" & NIP.Text & "'," & _
" JUMLAH = '" & JUMLAH.Text & "' " & _
" where NOBUKTI ='" & NOBUKTI.Text & "'"
Case 2
SQL = "DELETE FROM PEGAWAI WHERE NOBUKTI='" & NOBUKTI.Text & "'"
End Select
MsgBox "Pemorosesan RECORD Database telah berhasil...!", vbInformation, "Data Pegawai"
Db.Execute SQL, adCmdTable
Call Hapus
NOBUKTI.SetFocus
End Sub
Tidak ada komentar:
Posting Komentar