Sub Hapus()
NIP.Enabled = True
ClearFORM Me
Call RubahCMD(Me, True, False, False, False)
CmdProses(1).Caption = "&Simpan"
End Sub
Sub ProsesDB(Log As Byte)
Select Case Log
Case 0
SQL = "INSERT INTO Pegawai(NIP, Nama, TempatLhr, TanggalLhr, Pendidikan, Bagian, Status)" & _
" values('" & NIP.Text & _
"','" & NAMA.Text & _
"','" & TEMPAT.Text & _
"','" & TANGGAL.Text & _
"','" & PENDIDIKAN.Text & _
"','" & BAGIAN.Text & _
"','" & STATUS.Text & "')"
Case 1
ctgl = Mid(TANGGAL.Text, 7, 4) & "-" & Mid(TANGGAL.Text, 4, 2) & "-" & Mid(TANGGAL.Text, 1, 2)
SQL = "UPDATE Pegawai SET Nama ='" & NAMA.Text & "'," & _
" TempatLhr = '" & TEMPAT.Text & "'," & _
" TanggalLhr = '" & ctgl & "'," & _
" Pendidikan = '" & PENDIDIKAN.Text & "'," & _
" Bagian = '" & BAGIAN.Text & "'," & _
" Status = '" & STATUS.Text & "' " & _
" where NIP ='" & NIP.Text & "'"
Case 2
SQL = "DELETE FROM Pegawai WHERE NIP='" & NIP.Text & "'"
End Select
MsgBox "Pemorosesan RECORD Database telah berhasil...!", vbInformation, "Data Pegawai"
Db.Execute SQL, adCmdTable
Call Hapus
Adodc1.Refresh
NIP.SetFocus
End Sub
Sub Tampilpegawai()
On Error Resume Next
NIP.Text = RS!NIP
NAMA.Text = RS!NAMA
TEMPAT.Text = RS!TempatLhr
TANGGAL.Text = RS!TanggalLhr
PENDIDIKAN.Text = RS!PENDIDIKAN
BAGIAN.Text = RS!BAGIAN
STATUS.Text = RS!STATUS
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
Private Sub Form_Load()
Call OPENDB
Call Hapus
BAGIAN.AddItem "HRD"
BAGIAN.AddItem "HUMAS"
BAGIAN.AddItem "KEUANGAN"
PENDIDIKAN.AddItem "DIPLOMA III"
PENDIDIKAN.AddItem "STRATA I"
PENDIDIKAN.AddItem "STRATA II"
STATUS.AddItem "MENIKAH"
STATUS.AddItem "TIDAK MENIKAH"
End Sub
Private Sub NIP_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If NIP.Text = "" Then
MsgBox "Masukkan NIP Pegawai !", vbInformation, "Pegawai"
NIP.SetFocus
Exit Sub
End If
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
Tampilpegawai
Call RubahCMD(Me, False, True, True, True)
CmdProses(1).Caption = "&Edit"
NIP.Enabled = False
Else
x = NIP.Text
Call Hapus
NIP.Text = x
Call RubahCMD(Me, False, True, False, True)
CmdProses(1).Caption = "&Simpan"
End If
NAMA.SetFocus
End If
End Sub
Tidak ada komentar:
Posting Komentar