Daftar Pegawai Private Sub Form_Activate Data User Option Explicit

cboGol.SetFocus End Sub Private Sub txtTglMasuk_Click txtNama.Enabled = True txtNama.SetFocus End Sub

5. Daftar Pegawai Private Sub Form_Activate

Me.WindowState = 2 cr.ReportFileName = App.Path \Laporan\RepDafPegawai.rpt cr.RetrieveDataFiles cr.Connect = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= _ App.Path \dbPegawai.mdb;Persist Security Info=False cr.WindowShowRefreshBtn = True cr.PrintReport cr.WindowState = crptMaximized cr.Action = 1 End Sub

6. Data User Option Explicit

Dim J As ListItem Dim rsUser As Recordset Dim UserID As String Private Sub cmdBatal_Click Mati Bersih Ubah = False Tambah = False Cari = False cmdUpdate.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Private Sub cmdCari_Click Cari = True End Sub Private Sub cmdCetak_Click frmDaftarUser.Show End Sub Private Sub cmdHapus_Click rsCari.Delete Set rsCari = Nothing Mati Bersih Segar MsgBox User sudah di hapus ... cmdUpdate.Enabled = False Universitas Sumatera Utara cmdHapus.Enabled = False cmdCari.Enabled = True cmdSimpan.Enabled = False cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Private Sub cmdKeluar_Click Unload Me End Sub Private Sub cmdSimpan_Click If Tambah = True Then Call Save End If End Sub Private Sub cmdTambah_Click Tambah = True cmdTambah.Enabled = False cmdSimpan.Visible = True cmdCari.Enabled = False cmdCari.Enabled = False txtUserID.Enabled = True txtUserID.SetFocus End Sub Private Sub cmdUpdate_Click If Ubah = True Then Set rsUbah = New ADODB.Recordset rsUbah.Open Update [UUser] Set Passwd = txtPasswd.Text _ where UserID = txtUserID.Text , CN, _ adOpenDynamic, adLockOptimistic MsgBox Data sudah Ubah Ubah = False Mati Bersih Segar Set rsUbah = Nothing cmdUpdate.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdSimpan.Enabled = False cmdTambah.Enabled = True cmdTambah.SetFocus End If End Sub Private Sub Form_Activate Cari = False Call Segar Mati Bersih cmdUpdate.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdSimpan.Enabled = False cmdTambah.Enabled = True Universitas Sumatera Utara cmdTambah.SetFocus End Sub Sub Mati txtUserID.Enabled = False txtPasswd.Enabled = False End Sub Sub Bersih txtUserID.Text = txtPasswd.Text = Ubah = False Tambah = False UserID = End Sub Private Sub Form_Load Koneksi End Sub Private Sub lv_Click On Error Resume Next If Cari = True Then UserID = lv.ListItems.Itemlv.SelectedItem.Index.Text Set rsCari = New ADODB.Recordset rsCari.Open Select from [uUser] where UserID= UserID _ , CN, adOpenDynamic, adLockOptimistic If Not rsCari.EOF = True Then txtUserID.Text = UserID txtPasswd.Text = rsCariPasswd Ubah = True cmdUpdate.Enabled = True cmdHapus.Enabled = True txtPasswd.Enabled = True txtPasswd.SetFocus Else MsgBox User tidak ada ... txtUserID.Text = txtPasswd.Text = End If End If End Sub Private Sub txtPasswd_KeyPressKeyAscii As Integer If KeyAscii = 13 Then If Tambah = True Then cmdSimpan.Enabled = True cmdTambah.Enabled = False cmdSimpan.SetFocus ElseIf Ubah = True Then cmdUpdate.Enabled = True cmdUpdate.SetFocus End If End If End Sub Sub Save Set rsUser = New ADODB.Recordset Universitas Sumatera Utara rsUser.Open Select from [uUser] where UserID= _ txtUserID.Text and Passwd= txtPasswd.Text , _ CN, adOpenDynamic, adLockOptimistic If Tambah = True Then If rsUser.EOF = True Then Set rsSimpan = New ADODB.Recordset rsSimpan.Open select from [uUser], _ CN, adOpenDynamic, adLockOptimistic rsSimpan.AddNew rsSimpan.FieldsUserID = txtUserID.Text rsSimpan.FieldsPasswd = txtPasswd.Text rsSimpan.Update Mati Bersih Segar MsgBox Data sudah tersimpan Tambah = False cmdUpdate.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdSimpan.Enabled = False cmdTambah.Enabled = True cmdTambah.SetFocus Else MsgBox User sudah ada ... txtPasswd.Text = txtUserID.Text = txtUserID.SetFocus End If End If End Sub Sub Segar lv.ListItems.Clear Set rsCari = New ADODB.Recordset rsCari.Open Select from uUser Order by UserID asc, CN, 1, 3 If Not rsCari.EOF = True Then Do While Not rsCari.EOF Set J = lv.ListItems.Add, , rsCariUserID J.SubItems1 = rsCariPasswd rsCari.MoveNext If rsCari.EOF Then Exit Do End If Loop End If Set rsCari = Nothing End Sub Private Sub txtUserId_KeyPressKeyAscii As Integer If KeyAscii = 13 Then If Tambah = True Then Set rsCari = New ADODB.Recordset rsCari.Open Select from [uUser] where UserID= _ txtUserID.Text , CN, 1,2 If rsCari.EOF = True Then txtPasswd.Enabled = True txtPasswd.SetFocus Else MsgBox User sudah ada ... txtUserID.Text = Universitas Sumatera Utara txtPasswd.Text = txtUserID.SetFocus End If ElseIf Cari = True Then Set rsCari = New ADODB.Recordset rsCari.Open Select from [uUser] where UserID= _ txtUserID.Text , CN, 1, 2 If rsCari.EOF = True Then MsgBox User belum ada ... txtUserID.Text = txtUserID.SetFocus Else txtPasswd.Text = rsCari.FieldsPasswd cmdUpdate.Enabled = True cmdHapus.Enabled = True cmdUpdate.SetFocus End If End If End If End Sub

7. Daftar User Private Sub Form_Activate