Menu ini adalah untuk menambahkan data kelas yang nantinya akan digunakan untuk proses pengolahan data akademik.
➢ Klik Add untuk menambahkan data kelas baru, Kode Kelas akan muncul otomatis mengikuti data terakhir yang ada di dalam database
➢ Klik Save untuk menyimpan data kelas baru ➢ Klik Cancel untuk membatalkan proses
➢ Klik baris kelas lalu klik Edit untuk mengubah data kelas ➢ Klik Delete untuk menghapus data kelas
➢ Klik Find untuk mencari data kelas maka data di dalam grid hanya akan muncul sesuai dengan data yang dicari saja
➢ Klik Exit untuk keluar dari form data kelas
Coding Program Data Kelas
Dim tambah As Boolean Sub isicmbnig()
Call koneksi
35 cmbnik.Clear
Do While Not rsguru.EOF cmbnik.AddItem rsguru!nik rsguru.MoveNext
Loop End Sub Sub nonaktif()
Dim kontrol As Control
For Each kontrol In Me.Controls
If TypeOf kontrol Is TextBox Then kontrol.Enabled = False Next Toolbar1.Buttons(1).Enabled = True Toolbar1.Buttons(2).Enabled = False Toolbar1.Buttons(3).Enabled = False Toolbar1.Buttons(4).Enabled = False Toolbar1.Buttons(5).Enabled = False Toolbar1.Buttons(6).Enabled = True Toolbar1.Buttons(7).Enabled = True cmbstatus.Enabled = False cmbjurusan.Enabled = False cmbnik.Enabled = False End Sub Sub aktif()
Dim kontrol As Control
For Each kontrol In Me.Controls
If TypeOf kontrol Is TextBox Then kontrol.Enabled = True Next
36 Toolbar1.Buttons(2).Enabled = True Toolbar1.Buttons(3).Enabled = True Toolbar1.Buttons(4).Enabled = False Toolbar1.Buttons(5).Enabled = False Toolbar1.Buttons(6).Enabled = False Toolbar1.Buttons(7).Enabled = True cmbstatus.Enabled = True cmbjurusan.Enabled = True cmbnik.Enabled = True End Sub Sub bersih()
For Each kontrol In Me.Controls
If TypeOf kontrol Is TextBox Then kontrol.Text = "" Next
cmbstatus = "Status Kelas" cmbjurusan.Text = "Jurusan" cmbnik.Text = "Wali Kelas" End Sub
Sub tampilgrid() Call koneksi
rskelas.Open "select * from kelas", KON Set grid.DataSource = rskelas
aturgrid End Sub
Sub simpankelas() Dim a As String
Save = "insert into kelas values('" & txtkode.Text & "','" & txtkelas.Text & "','" & txtmax.Text & "','" & cmbstatus.Text & "','" & cmbnik.Text & "','" & cmbjurusan.Text & "')"
37 End Sub
Sub updatekelas()
ubah = "update kelas set nik='" & cmbnik.Text & "',max_siswa='" & txtmax.Text & "',status_kelas='" & cmbstatus.Text & "' where id_kelas='" & txtkode.Text & "'" KON.Execute ubah
End Sub
Private Sub cmbjurusan_keypress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") And (KeyAscii >= Asc("a") And KeyAscii <= Asc("z") And KeyAscii = 46 And KeyAscii = 127 Or KeyAscii = vbKeyBack)) Then KeyAscii = 0
End Sub
Private Sub cmbnik_Click() Call koneksi
rskelas.Open "select * from kelas where nik='" & cmbnik.Text & "'", KON With rskelas
If .BOF And .EOF Then Exit Sub
Else
MsgBox "Guru sudah menjadi wali kelas!!", vbInformation, "Informasi" cmbnik.Text = ""
cmbnik.SetFocus End If
End With End Sub
38
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") And (KeyAscii >= Asc("a") And KeyAscii <= Asc("z") And KeyAscii = 46 And KeyAscii = 127 Or KeyAscii = vbKeyBack)) Then KeyAscii = 0
End Sub
Private Sub cmbstatus_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") And (KeyAscii >= Asc("a") And KeyAscii <= Asc("z") And KeyAscii = 46 And KeyAscii = 127 Or KeyAscii = vbKeyBack)) Then KeyAscii = 0
End Sub
Sub isicmbjurusan() Call koneksi
rsjurusan.Open "select * from jurusan", KON cmbjurusan.Clear
Do While Not rsjurusan.EOF
cmbjurusan.AddItem rsjurusan!kode_jurusan rsjurusan.MoveNext
Loop End Sub
Private Sub Form_Load() tampilgrid isicmbjurusan nonaktif bersih isicmbnig End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Button.Index = 1 Then
39 bersih
tambah = True txtkode.SetFocus
ElseIf Button.Index = 2 Then
If txtkode.Text = "" Or txtkelas.Text = "" Or txtmax.Text = "" Or cmbstatus = "" Or cmbnik.Text = "" Or cmbjurusan.Text = "" Then
MsgBox "Silahkan Lengkapi Data!!", vbInformation, "Informasi" If cmbjurusan.Text = "" Then
cmbjurusan.SetFocus ElseIf txtkode.Text = "" Then txtkode.SetFocus
ElseIf txtkelas.Text = "" Then txtkelas.SetFocus
ElseIf txtmax.Text = "" Then txtmax.SetFocus
ElseIf cmbstatus.Text = "" Then cmbstatus.SetFocus
ElseIf cmbnik.Text = "" Then cmbnik.SetFocus
End If Exit Sub End If
If tambah = True Then simpankelas
grid.Refresh Form_Load
ElseIf tambah = False Then updatekelas
40 Form_Load
End If
ElseIf Button.Index = 3 Then Form_Load
ElseIf Button.Index = 4 Then tambah = False aktif txtkode.Enabled = False txtkelas.SetFocus Toolbar1.Buttons(3).Enabled = True Toolbar1.Buttons(2).Enabled = True Toolbar1.Buttons(1).Enabled = False Toolbar1.Buttons(4).Enabled = False Toolbar1.Buttons(5).Enabled = False Toolbar1.Buttons(6).Enabled = False ElseIf Button.Index = 5 Then
Call koneksi
rskelas.Open "select * from kelas ", KON With rskelas
If Not (.BOF And .EOF) Then
h = MsgBox("Hapus Data Kelas ?", vbQuestion + vbYesNo, "Konfirmasi") If h = vbYes Then
hapus = "delete from kelas where id_kelas='" & txtkode.Text & "'" KON.Execute (hapus)
grid.Refresh Form_Load Else
41 End If
End If End With grid.Refresh
ElseIf Button.Index = 6 Then txtcari.Enabled = True txtcari.SetFocus
ElseIf Button.Index = 7 Then Unload data_kelas menu_utama.Enabled = True menu_utama.Show End If End Sub Sub aturgrid() grid.ColWidth(0) = 0 grid.ColWidth(1) = 1250 grid.ColWidth(2) = 1750 grid.ColWidth(3) = 1200 grid.ColWidth(4) = 1500 grid.ColWidth(5) = 1200 grid.ColWidth(6) = 1500
grid.TextMatrix(0, 1) = "Id Kelas" grid.TextMatrix(0, 2) = "Kelas" grid.TextMatrix(0, 3) = "Max Siswa" grid.TextMatrix(0, 4) = "Status Kelas" grid.TextMatrix(0, 5) = "Wali Kelas" grid.TextMatrix(0, 6) = "Jurusan" End Sub
42 Sub tampilkelas()
Call koneksi
rskelas.Open "select * from kelas where id_kelas like '%" & txtcari.Text & "%'", KON Set grid.DataSource = rskelas
aturgrid End Sub Sub sqlkelas()
sql1 = "select * from kelas where id_kelas like '%" & txtcari.Text & "%' order by id_kelas asc" KON.Execute (sql1)
End Sub
Private Sub grid_Click() a = grid.Row
kode = grid.TextMatrix(a, 1) Call koneksi
rskelas.Open "select * from kelas ", KON With rskelas
txtkode.Text = kode
kelas = "select * from kelas where id_kelas='" & txtkode & "'" Set rskelas = KON.Execute(kelas)
txtkelas.Text = rskelas.Fields("kelas") txtmax.Text = rskelas.Fields("max_siswa") cmbstatus.Text = rskelas.Fields("status_kelas") cmbjurusan.Text = rskelas.Fields("kode_jurusan") cmbnik.Text = rskelas.Fields("nik") Toolbar1.Buttons(4).Enabled = True Toolbar1.Buttons(5).Enabled = True End With
43 End Sub
Private Sub txtkode_KeyPress(KeyAscii As Integer) Call koneksi
KeyAscii = Asc(UCase(Chr(KeyAscii))) If KeyAscii = 13 Then
rskelas.Open "SELECT * FROM kelas WHERE id_kelas='" & txtkode & "'", KON With rskelas
If .BOF And .EOF Then
psn = MsgBox("Kode kelas " + txtkode + " Data Baru", vbInformation, "KONFIRMASI") txtkelas = ""
txtmax.Text = "" cmbstatus = "" txtkelas.SetFocus Else
MsgBox "Kode kelas Sudah Ada", vbInformation, "Info" txtkode.Text = "" txtkode.SetFocus End If End With End If End Sub
Private Sub txtnama_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then
cmbstatus.SetFocus txtnama.Enabled = False End If
44 End Sub
Private Sub txtcari_Change() Call koneksi
Call tampilkelas Call sqlkelas End Sub
45