MenuUtama.Show End If
End Sub Private Sub Form_Activate
txtPass = txtUser =
txtUser.SetFocus End Sub
Private Sub Form_Load Koneksi
End Sub Private Sub txtPass_KeyPressKeyAscii As Integer
If KeyAscii = 13 Then cmdOk.Enabled = True
cmdOk.SetFocus End If
End Sub Private Sub txtUser_KeyPressKeyAscii As Integer
If KeyAscii = 13 Then txtPass.Locked = False
txtPass.SetFocus End If
End Sub 3. Logout
mnuFile.Enabled = False mnuAbsen.Enabled = False
mnuLap.Enabled = False bolLogon = False
4. Data Pegawai Option Explicit
Dim J As ListItem Dim IDPegawai As Integer
Dim bolOk As Boolean Dim rsPegawai As Recordset
Sub CariID Set rsCari = New ADODB.Recordset
rsCari.Open Select from Pegawai order by IDPegawai desc, CN, 1, 2 If Not rsCari.EOF Then
IDPegawai = rsCariIDPegawai + 1 Else
IDPegawai = 1 End If
Set rsCari = Nothing Set rsSimpan = New ADODB.Recordset
rsSimpan.Open Pegawai, CN, 1, 2 rsSimpan.AddNew
rsSimpanIDPegawai = IDPegawai rsSimpanStatusRec = 1
rsSimpan.Update Set rsSimpan = Nothing
End Sub Private Sub cmdClose_Click
Unload Me
Universitas Sumatera Utara
End Sub Private Sub cboGol_Click
cboJabatan.Enabled = True cboJabatan.SetFocus
End Sub Private Sub cboJabatan_Click
If Tambah = True Then cmdSimpan.Enabled = True
cmdSimpan.SetFocus End If
End Sub Private Sub cboJK_Click
If cboJK.Text = Laki-Laki Then Label19.Caption = Nama Istri
Else Label19.Caption = Nama Suami
End If cboStatusKawin.Enabled = True
cboStatusKawin.SetFocus End Sub
Private Sub cboStatusKawin_Click If cboStatusKawin.Text = Kawin Then
txtNmPasangan.Enabled = True txtNmPasangan.SetFocus
Else txtNmPasangan.Text = -
txtTempLahir.Enabled = True txtTempLahir.SetFocus
End If End Sub
Private Sub cmdBatal_Click Call Bersih
Call Mati cmdTambah.Enabled = True
cmdSimpan.Enabled = False cmdCari.Enabled = True
cmdEdit.Enabled = False cmdHapus.Enabled = False
cmdBatal.Enabled = True cmdTambah.SetFocus
End Sub Private Sub cmdCari_Click
Cari = True End Sub
Private Sub cmdEdit_Click cmdEdit.Enabled = False
cmdHapus.Enabled = False If Ubah = True Then
X = MsgBoxData Anggota mau di Edit ?, vbYesNo
Universitas Sumatera Utara
If X = vbYes Then Timer1.Enabled = True
Set rsUbah = New ADODB.Recordset Set rsUbah = New ADODB.Recordset
rsUbah.Open Update Pegawai SET Nama = txtNama.Text _
, Alamat= txtAlamat.Text , _ TglMasuk= FormattxtTglMasuk.Value, dd-mm-yyyy _
,TglLahir= FormattxtTglLahir.Value, _ dd-mm-yyyy , _
noKTP= txtNoKTP.Text , JK= LeftcboJK.Text,_ ,StatusKawin= LeftcboStatusKawin.Text, 1 _
, _Nama_Pasangan= txtNmPasangan.Text _ ,Jabatan= LeftcboJabatan.Text, 1 , _
Gol= LeftcboGol.Text, 1 , NoTelp= _ txtNoTelp.Text ,NoHP= txtNoHP.Text , _
TempLahir= txtTempLahir.Text where _ IDPegawai = IDPegawai , CN, 1, 2
Set rsUbah = Nothing Call Mati
Call Bersih Call Segar
cmdTambah.Enabled = True cmdSimpan.Enabled = False
cmdCari.Enabled = True cmdEdit.Enabled = False
cmdHapus.Enabled = False cmdBatal.Enabled = True
cmdTambah.SetFocus Else
Call Mati Call Bersih
Call Segar cmdTambah.Enabled = True
cmdSimpan.Enabled = False cmdCari.Enabled = True
cmdEdit.Enabled = False cmdHapus.Enabled = False
cmdBatal.Enabled = True cmdTambah.SetFocus
End If End If
End Sub Private Sub cmdHapus_Click
cmdHapus.Enabled = False Set rsHapus = New ADODB.Recordset
rsHapus.Open Delete from Pegawai where IDPegawai= IDPegawai _
, CN, 1, 2 Set rsHapus = Nothing
Call Segar Call Mati
Call Bersih cmdTambah.Enabled = True
cmdSimpan.Enabled = False cmdCari.Enabled = True
cmdEdit.Enabled = False cmdHapus.Enabled = False
Universitas Sumatera Utara
cmdBatal.Enabled = True cmdTambah.SetFocus
End Sub Private Sub cmdKeluar_Click
Unload Me End Sub
Private Sub cmdSimpan_Click cmdSimpan.Enabled = False
X = MsgBoxData anggota mau disimpan ?, vbYesNo If X = vbYes Then
If txtNama.Text Then If IDPegawai 0 Then
If txtAlamat.Text Then If cboJK.Text Then
If txtTempLahir.Text Then If cboStatusKawin.Text Then
If txtNoKTP.Text Then If txtNmPasangan.Text Then
If cboJabatan.Text Then bolOk = True
Else bolOk = False
End If Else
bolOk = False End If
Else bolOk = False
End If Else
bolOk = False End If
Else bolOk = False
End If Else
bolOk = False End If
Else bolOk = False
End If Else
bolOk = False End If
Else bolOk = False
End If If bolOk = True Then
Set rsUbah = New ADODB.Recordset rsUbah.Open Update Pegawai SET Nama = txtNama.Text _
, Alamat= txtAlamat.Text ,NIP= txtNIP.Text _ , _TglMasuk= FormattxtTglMasuk.Value, _
dd-mm-yyyy ,TglLahir= FormattxtTglLahir.Value, dd-mm-yyyy , _
noKTP= txtNoKTP.Text , JK= LeftcboJK.Text, _ 1 ,StatusKawin= LeftcboStatusKawin.Text, 1_
Universitas Sumatera Utara
, Nama_Pasangan= txtNmPasangan.Text _ ,Jabatan= LeftcboJabatan.Text, 1 ,Gol= _
LeftcboGol.Text, 1 , noTelp= txtNoTelp.Text _ ,NoHP= txtNoHP.Text , TempLahir= _
txtTempLahir.Text ,StatusRec= where IDPegawai _ = IDPegawai , CN, 1, 2
Set rsUbah = Nothing Call Segar
Call Mati Call Bersih
cmdTambah.Enabled = True cmdSimpan.Enabled = False
cmdCari.Enabled = True cmdEdit.Enabled = False
cmdHapus.Enabled = False cmdBatal.Enabled = True
cmdTambah.SetFocus Else
MsgBox Data belum lengkap ........ End If
End If End Sub
Private Sub cmdTambah_Click Tambah = True
Cari = False cmdTambah.Enabled = False
Call CariID txtTglMasuk.Value = FormatNow, dd-mm-yyyy
cmdSimpan.Enabled = True txtNIP.Enabled = True
txtNIP.SetFocus End Sub
Private Sub Form_Activate Call Mati
Call Bersih Call Segar
cmdTambah.Enabled = True cmdSimpan.Enabled = False
cmdCari.Enabled = True cmdEdit.Enabled = False
cmdHapus.Enabled = False cmdBatal.Enabled = True
cmdTambah.SetFocus End Sub
Private Sub Form_Load Call Koneksi
cboStatusKawin.AddItem Kawin cboStatusKawin.AddItem Belum
cboJK.AddItem Laki-Laki cboJK.AddItem Perempuan
cboJabatan.AddItem 1.Kepala Dinas cboJabatan.AddItem 2.Kepala Seksi
cboJabatan.AddItem 3.Staff cboGol.AddItem 1.I
cboGol.AddItem 2.II
Universitas Sumatera Utara
cboGol.AddItem 3.III cboGol.AddItem 4.IV
End Sub Private Sub Form_UnloadCancel As Integer
Call Bersih End Sub
Private Sub lv1_Click If Cari = True Then
IDPegawai = lv1.ListItems.Itemlv1.SelectedItem.Index.Text Set rsCari = New ADODB.Recordset
rsCari.Open Select from Pegawai where IDPegawai= _
IDPegawai , CN, adOpenDynamic, adLockOptimistic If Not rsCari.EOF = True Then
txtNama = rsCariNama txtNIP = rsCariNIP
txtAlamat = rsCarialamat If rsCariJK = L Then
cboJK = Laki-Laki Label19.Caption = Nama Istri
Else cboJK = Perempuan
Label19.Caption = Nama Suami End If
txtTempLahir = rsCariTempLahir If rsCaristatuskawin = K Then
cboStatusKawin = Kawin Else
cboStatusKawin = Belum End If
txtNoKTP = rsCariNoKTP txtNmPasangan = rsCariNama_Pasangan
txtNoTelp.Text = rsCariNoTelp txtNoHP.Text = rsCariNoHP
If rsCarijabatan = 1 Then cboJabatan = 1.Kepala Dinas
ElseIf rsCarijabatan = 2 Then cboJabatan = 2.Kepala Seksi
ElseIf rsCarijabatan = 3 Then cboJabatan = 3.Staff
End If If rsCariGol = 1 Then
cboGol = 1.I ElseIf rsCariGol = 2 Then
cboGol = 2.II ElseIf rsCariGol = 3 Then
cboGol = 3.III Else
cboGol = 4.IV End If
Call Hidup Ubah = True
Universitas Sumatera Utara
cmdEdit.Enabled = True cmdHapus.Enabled = True
Else MsgBox User tidak ada ...
Call Bersih End If
End If End Sub
Sub Segar lv1.ListItems.Clear
Set rsCari = New ADODB.Recordset rsCari.Open Select from Pegawai Order by IDPegawai asc, _
CN, 1, 3 If Not rsCari.EOF = True Then
Do While Not rsCari.EOF Set J = lv1.ListItems.Add, , rsCariIDPegawai
J.SubItems1 = rsCariNIP J.SubItems2 = rsCariTglMasuk
J.SubItems3 = rsCariNama J.SubItems4 = rsCarialamat
J.SubItems5 = rsCariNoTelp J.SubItems6 = rsCariNoHP
J.SubItems7 = rsCariNoKTP rsCari.MoveNext
If rsCari.EOF Then Exit Do
End If Loop
End If Set rsCari = Nothing
End Sub Private Sub Timer1_Timer
Frame3.Visible = True Bar1.Value = Bar1.Value + 10
lblSaving.Caption = Bar1.Value If Bar1.Value = 100 Then
Timer1.Enabled = False Frame3.Visible = False
Bar1.Value = 0 End If
End Sub Private Sub txtAlamat_KeyPressKeyAscii As Integer
If KeyAscii = 13 Then txtNoKTP.Enabled = True
txtNoKTP.SetFocus End If
End Sub Private Sub txtNama_KeyPressKeyAscii As Integer
If KeyAscii = 13 Then txtAlamat.Enabled = True
txtAlamat.SetFocus End If
End Sub Sub Mati
txtNIP.Enabled = False
Universitas Sumatera Utara
txtNama.Enabled = False txtAlamat.Enabled = False
cboJK.Enabled = False txtTempLahir.Enabled = False
txtTglLahir.Enabled = False cboStatusKawin.Enabled = False
txtNoKTP.Enabled = False txtNoTelp.Enabled = False
txtNoHP.Enabled = False txtNmPasangan.Enabled = False
cboJabatan.Enabled = False cboGol.Enabled = False
txtTglMasuk.Enabled = False End Sub
Sub Hidup txtNIP.Enabled = True
txtNama.Enabled = True txtAlamat.Enabled = True
cboJK.Enabled = True txtTempLahir.Enabled = True
txtTglLahir.Enabled = True cboStatusKawin.Enabled = True
txtNoKTP.Enabled = True txtNoTelp.Enabled = True
txtNoHP.Enabled = True txtNmPasangan.Enabled = True
cboJabatan.Enabled = True cboGol.Enabled = True
txtTglMasuk.Enabled = True End Sub
Sub Bersih txtNama =
IDPegawai = 0 txtNIP =
txtAlamat = cboJK =
txtTempLahir = cboStatusKawin =
txtNoKTP = txtNmPasangan =
txtNoTelp = txtNoHP =
cboJabatan.Text = cboGol.Text =
txtTglMasuk.Value = FormatNow, dd-mm-yyyy txtTglLahir.Value = FormatNow, dd-mm-yyyy
Cari = False Tambah = False
Set rsHapus = New ADODB.Recordset rsHapus.Open Delete from Pegawai where StatusRec=1, CN, 1, 2
Set rsHapus = Nothing End Sub
Private Sub txtNIP_KeyPressKeyAscii As Integer If KeyAscii = 13 Then
Universitas Sumatera Utara
txtTglMasuk.Enabled = True txtTglMasuk.SetFocus
End If End Sub
Private Sub txtNmPasangan_KeyPressKeyAscii As Integer If KeyAscii = 13 Then
txtTempLahir.Enabled = True txtTempLahir.SetFocus
End If End Sub
Private Sub txtNoHP_KeyPressKeyAscii As Integer If KeyAscii = 13 Then
cboJK.Enabled = True cboJK.SetFocus
End If If Not KeyAscii = Asc0 And KeyAscii = Asc9 Or KeyAscii _
= vbKeyBack Or KeyAscii = Asc. Or KeyAscii = 13 Then Beep
MsgBox Isi dengan angka 0-9 KeyAscii = 0
End If End Sub
Private Sub txtnoKTP_KeyPressKeyAscii As Integer If KeyAscii = 13 Then
txtNoTelp.Enabled = True txtNoTelp.SetFocus
End If If Not KeyAscii = Asc0 And KeyAscii = Asc9 Or KeyAscii _
= vbKeyBack Or KeyAscii = Asc. Or KeyAscii = 13 Then Beep
MsgBox Isi dengan angka 0-9 KeyAscii = 0
End If End Sub
Private Sub txtNoTelp_KeyPressKeyAscii As Integer If KeyAscii = 13 Then
txtNoHP.Enabled = True txtNoHP.SetFocus
End If If Not KeyAscii = Asc0 And KeyAscii = Asc9 Or KeyAscii _
= vbKeyBack Or KeyAscii = Asc. Or KeyAscii = 13 Then Beep
MsgBox Isi dengan angka 0-9 KeyAscii = 0
End If End Sub
Private Sub txtTempLahir_KeyPressKeyAscii As Integer If KeyAscii = 13 Then
txtTglLahir.Enabled = True txtTglLahir.SetFocus
End If End Sub
Private Sub txtTglLahir_Click cboGol.Enabled = True
Universitas Sumatera Utara
cboGol.SetFocus End Sub
Private Sub txtTglMasuk_Click txtNama.Enabled = True
txtNama.SetFocus End Sub
5. Daftar Pegawai Private Sub Form_Activate