Frm Jumlah Les Saran

If bolTambah = True Then cmdSimpan.Visible = True cmdTambah.Visible = False cmdSimpan.SetFocus End If End If Set rsCari = Nothing Else MsgBox Data belum lengkap End If End If End If End Sub

6. Frm Jumlah Les

Dim rsKelas As Recordset Dim rsHari As Recordset Dim rsJumLes As Recordset Dim IDHari As Integer Dim IDKelas As Integer Dim IDLes As Integer Dim NmKelas, NmHari As String Dim bolAda As Boolean Sub CariID Set rsCari = New ADODB.Recordset rsCari.Open Select from JumlahLes order by IDLes desc, CN, adOpenDynamic, adLockOptimistic If Not rsCari.EOF Then IDLes = rsCariIDLes + 1 Else IDLes = 1 End If txtID.Text = IDLes Set rsCari = Nothing End Sub Private Sub cboHari_Click Set rsHari = New ADODB.Recordset rsHari.Open Select from Hari where NmHari= cboHari , CN, adOpenDynamic, adLockOptimistic If Not rsHari.EOF = True Then IDHari = rsHariIDHari If bolTambah = True Then Set rsJumLes = New ADODB.Recordset rsJumLes.Open Select from JumlahLes where IDKelas= IDKelas and IDHari= IDHari , CN, 1, 2 Universitas Sumatera Utara If Not rsJumLes.EOF Then bolAda = True Else bolAda = False End If Set rsJumLes = Nothing If bolAda = False Then cboJumlah.Enabled = True cboJumlah.SetFocus Else MsgBox data sudah ada cboHari = cboHari.SetFocus End If End If End If Set rsHari = Nothing End Sub Private Sub cboJumlah_Click If bolTambah = True Then cmdSimpan.Visible = True cmdTambah.Visible = False cmdSimpan.SetFocus End If End Sub Private Sub cboJumlah_KeyPressKeyAscii As Integer If KeyAscii = 13 Then cmdSimpan.SetFocus End If End Sub Private Sub cboKelas_Click Set rsKelas = New ADODB.Recordset rsKelas.Open Select from Kelas where NmKelas= cboKelas , CN, adOpenDynamic, adLockOptimistic If Not rsKelas.EOF = True Then IDKelas = rsKelasIDKelas cboHari.Enabled = True cboHari.SetFocus End If Set rsKelas = Nothing End Sub Sub Segar Set rsJumLes = New ADODB.Recordset Universitas Sumatera Utara rsJumLes.Open Select from JumlahLes order by IDLes asc, CN, 1, 2 If Not rsJumLes.EOF Then lv.ListItems.Clear Do While Not rsJumLes.EOF IDKelas = rsJumLesIDKelas IDHari = rsJumLesIDHari Set rsKelas = New ADODB.Recordset rsKelas.Open select from Kelas where IDKelas= IDKelas , CN, 1, 2 If Not rsKelas.EOF = True Then NmKelas = rsKelasNmKelas Else NmKelas = NoName End If Set rsKelas = Nothing Set rsHari = New ADODB.Recordset rsHari.Open Select from Hari where IDHari= IDHari , CN, adOpenDynamic, adLockOptimistic If Not rsHari.EOF = True Then NmHari = rsHariNmHari Else NmHari = NoName End If Set rsHari = Nothing Set j = lv.ListItems.Add, , rsJumLesIDLes j.SubItems1 = NmKelas j.SubItems2 = NmHari j.SubItems3 = rsJumLesJumlahLes rsJumLes.MoveNext If rsJumLes.EOF Then Exit Do End If Loop Else lv.ListItems.Clear End If Set rsJumLes = Nothing End Sub Private Sub cmdBatal_Click tambah = False ubah = False cari = False Call Bersih Universitas Sumatera Utara Call Segar txtID.Enabled = False cboJumlah.Enabled = False cboKelas.Enabled = False cboHari.Enabled = False Bersih batalTambah = False batalCari = False cmdUbah.Enabled = False cmdTambah.Enabled = True cmdCari.Enabled = True cmdHapus.Enabled = False cmdTambah.Visible = True cmdSimpan.Visible = False cmdTambah.SetFocus End Sub Private Sub cmdcari_Click cmdCari.Enabled = False cmdTambah.Enabled = False bolCari = True bolTambah = False lv.Enabled = True End Sub Private Sub cmdHapus_Click X = MsgBoxApa sudah yakin dihapus ?, vbYesNo If X = vbYes Then rsCari.Delete Call Segar Else MsgBox Data batal dihapus End If Call Bersih Set rsCari = Nothing cmdUbah.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Private Sub cmdKeluar_Click Unload Me End Sub Private Sub cmdSimpan_Click cmdSimpan.Visible = False Universitas Sumatera Utara cmdTambah.Visible = True cmdTambah.Enabled = True If IDKelas 0 And IDHari 0 And cboJumlah.Text Then Set rsSave = New ADODB.Recordset rsSave.Open JumlahLes, CN, 1, 2 rsSave.AddNew rsSaveIDLes = IDLes rsSaveIDKelas = IDKelas rsSaveIDHari = IDHari rsSaveJumlahLes = cboJumlah.Text rsSave.Update Set rsSave = Nothing Call Bersih Call Segar MsgBox Data sudah disimpan txtID.Enabled = False cboJumlah.Enabled = False cboKelas.Enabled = False cboHari.Enabled = False cmdUbah.Enabled = False cmdCari.Enabled = True cmdTambah.Visible = True cmdSimpan.Visible = False cmdHapus.Enabled = False cmdTambah.Enabled = True cmdTambah.SetFocus Else MsgBox Data belum lengkap End If End Sub Private Sub cmdTambah_Click cmdTambah.Visible = False cmdSimpan.Visible = True cmdUbah.Enabled = False cmdCari.Enabled = False Call CariID bolTambah = True bolCari = False cboKelas.Enabled = True cboKelas.SetFocus End Sub Private Sub cmdUbah_Click cmdUbah.Enabled = False cmdHapus.Enabled = False If bolUbah = True Then Universitas Sumatera Utara Me.Caption = Ubah Data Jumlah Les Set rsUpdate = New ADODB.Recordset rsUpdate.Open Update JumlahLes set JumlahLes= cboJumlah.Text where IDhari= IDHari and IDKelas= IDKelas , CN, 1, 2 Set rsUpdate = Nothing Call Bersih Call Segar MsgBox Data sudah diubah cmdTambah.Enabled = True cmdCari.Enabled = True Set rsUpdate = Nothing cmdTambah.SetFocus lv.Enabled = False End If End Sub Private Sub Form_Activate Call Segar txtID.Enabled = False cboJumlah.Enabled = False cboKelas.Enabled = False cboHari.Enabled = False Bersih batalTambah = False batalCari = False cmdUbah.Enabled = False cmdTambah.Visible = True cmdSimpan.Visible = False cmdHapus.Enabled = False cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Private Sub Form_Load Call Koneksi Set rsHari = New ADODB.Recordset rsHari.Open select from Hari order by IDHari asc, CN, 1, 2 Do Until rsHari.EOF cboHari.AddItem rsHariNmHari rsHari.MoveNext Loop Set rsHari = Nothing Set rsKelas = New ADODB.Recordset rsKelas.Open select from Kelas order by IDKelas asc, CN, 1, 2 Do Until rsKelas.EOF Universitas Sumatera Utara cboKelas.AddItem rsKelasNmKelas rsKelas.MoveNext Loop Set rsKelas = Nothing cboJumlah.AddItem 3 cboJumlah.AddItem 5 cboJumlah.AddItem 6 cboJumlah.AddItem 7 cboJumlah.AddItem 8 End Sub Sub Bersih txtID = cboJumlah = cboKelas = cboHari = batalTambah = False batalCari = False IDHari = 0 IDKelas = 0 IDLes = 0 bolAda = False lv.Enabled = False End Sub Private Sub lv_Click On Error Resume Next If bolCari = True Then bolTambah = False bolUbah = True IDLes = lv.ListItems.Itemlv.SelectedItem.Index.Text Set rsCari = New ADODB.Recordset rsCari.Open Select from JumlahLes where IDLes= IDLes , CN, adOpenDynamic, adLockOptimistic If Not rsCari.EOF = True Then txtID.Text = IDLes IDKelas = rsCariIDKelas IDHari = rsCariIDHari cboJumlah = rsCariJumlahLes Set rsKelas = New ADODB.Recordset rsKelas.Open select from Kelas where IDKelas= IDKelas , CN, 1, 2 If Not rsKelas.EOF = True Then cboKelas = rsKelasNmKelas Else cboKelas = NoName End If Universitas Sumatera Utara Set rsKelas = Nothing Set rsHari = New ADODB.Recordset rsHari.Open Select from Hari where IDHari= IDHari , CN, adOpenDynamic, adLockOptimistic If Not rsHari.EOF = True Then cboHari = rsHariNmHari Else cboHari = NoName End If Set rsHari = Nothing cboJumlah.Enabled = True cmdUbah.Enabled = True cmdHapus.Enabled = True Else MsgBox Data tidak ada End If Set rsCari = Nothing End If End Sub

7. Frm Kelas