VERSION 5.00
Begin VB.Form frmWali 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Data - Wali Kelas"
   ClientHeight    =   2385
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6255
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2385
   ScaleWidth      =   6255
   Begin VB.TextBox Text2 
      Enabled         =   0   'False
      Height          =   285
      Left            =   2280
      MaxLength       =   4
      TabIndex        =   12
      Top             =   120
      Width           =   495
   End
   Begin VB.TextBox Text1 
      Enabled         =   0   'False
      Height          =   285
      Left            =   1440
      MaxLength       =   4
      TabIndex        =   11
      Top             =   120
      Width           =   495
   End
   Begin VB.ComboBox cmbNIP 
      Enabled         =   0   'False
      Height          =   315
      Left            =   1440
      TabIndex        =   7
      Top             =   840
      Width           =   1335
   End
   Begin VB.ComboBox CmbKelas 
      Enabled         =   0   'False
      Height          =   315
      Left            =   1440
      TabIndex        =   6
      Top             =   480
      Width           =   1335
   End
   Begin VB.CommandButton cmdTutup 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Tutup"
      Height          =   405
      Left            =   2160
      TabIndex        =   2
      Top             =   1800
      Width           =   945
   End
   Begin VB.CommandButton cmdSimpan 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Simpan"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   1200
      TabIndex        =   1
      Top             =   1800
      Width           =   945
   End
   Begin VB.CommandButton cmdTambah 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Tambah"
      Height          =   405
      Left            =   240
      TabIndex        =   0
      Top             =   1800
      Width           =   945
   End
   Begin VB.Line Line2 
      BorderColor     =   &H8000000D&
      X1              =   120
      X2              =   3240
      Y1              =   1680
      Y2              =   1680
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "/"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   2055
      TabIndex        =   13
      Top             =   120
      Width           =   105
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Tahun Ajaran:"
      Height          =   195
      Index           =   3
      Left            =   360
      TabIndex        =   10
      Top             =   120
      Width           =   1035
   End
   Begin VB.Label LblPegawai 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "--"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C25418&
      Height          =   195
      Left            =   2880
      TabIndex        =   9
      Top             =   840
      Width           =   150
   End
   Begin VB.Label LblKelas 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "--"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C25418&
      Height          =   195
      Left            =   2880
      TabIndex        =   8
      Top             =   480
      Width           =   150
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H00FF8080&
      Height          =   855
      Index           =   1
      Left            =   120
      Top             =   1440
      Width           =   3135
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "NIP:"
      Height          =   195
      Index           =   1
      Left            =   1080
      TabIndex        =   5
      Top             =   840
      Width           =   315
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Kode Kelas:"
      Height          =   195
      Index           =   0
      Left            =   555
      TabIndex        =   4
      Top             =   480
      Width           =   840
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackColor       =   &H80000018&
      Caption         =   "P r o s e s"
      ForeColor       =   &H00004000&
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   3
      Top             =   1440
      Width           =   3135
   End
End
Attribute VB_Name = "frmWali"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmbKelas_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If cmbKelas.Text <> "" Then
        Me.MousePointer = 11
        Kata = "Select * from kelas where [kode Kelas]='" & cmbKelas.Text & "'"
        Set TGuru = New ADODB.Recordset
            TGuru.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
            If TGuru.EOF Then
                TGuru.Close
                Set TGuru = Nothing
                Me.MousePointer = 1
                MsgBox "Kelas = " & cmbKelas.Text & " tidak terdaftar...", vbExclamation
                cmbKelas.SetFocus
                Exit Sub
            End If
            LblKelas = TGuru![kelas]
            TGuru.Close
            Set TGuru = Nothing
            DaftarGuru
            cmbNIP.Enabled = True
            cmbNIP.SetFocus
            Me.MousePointer = 1
        End If
    End If
End Sub

Private Sub CmbKelas_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(cmbKelas, KeyAscii, True, Ubah)

End Sub

Private Sub cmbNIP_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If cmbNIP.Text <> "" Then
        Me.MousePointer = 11
        Kata = "Select * from guru where NIP='" & cmbNIP.Text & "'"
        Set TGuru = New ADODB.Recordset
            TGuru.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
            If TGuru.EOF Then
                TGuru.Close
                Set TGuru = Nothing
                Me.MousePointer = 1
                MsgBox "NIP = " & cmbNIP.Text & " tidak terdaftar...", vbExclamation
                cmbNIP.SetFocus
                Exit Sub
            End If
            LblPegawai = TGuru![Nama Guru]
            TGuru.Close
            Set TGuru = Nothing
            cmdSimpan.Enabled = True
            cmdSimpan.SetFocus
            Me.MousePointer = 1
        End If
    End If
End Sub

Private Sub cmdSimpan_Click()
 On Error GoTo Salah
    Me.MousePointer = 11
    Dim Tahun As String
    Tahun = Text1.Text & "/" & Text2.Text
    Datasiswa.BeginTrans
    
    Datasiswa.Execute "Insert Into [Wali Kelas] values ('" & Tahun & "'," & _
    "'" & cmbNIP.Text & "','" & cmbKelas.Text & "')"
    Datasiswa.CommitTrans
    Me.MousePointer = 1
    Semula
    Exit Sub
Salah:
    MsgBox "Data Wali Kelas tidak bisa di simpan...", vbInformation
    Semula
End Sub

Private Sub Form_Load()
Ketengah Me
End Sub

Private Sub Text1_Change()
If Len(Text1.Text) = 4 Then
    Fokus Text2
    Text2.Text = Val(Text1.Text) + 1
    Exit Sub
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
     And KeyAscii <= Asc("9") & Chr(13) _
     Or KeyAscii = vbKeyBack _
     Or KeyAscii = vbKeyDelete) Then
        Beep
        KeyAscii = 0
   End If
End Sub

Private Sub Text2_Change()
If Len(Text2.Text) = 4 Then
    If Text1.Text > Text2.Text Then
        MsgBox "Isikan Tahun Ajaran dengan benar....", vbInformation
        Fokus Text2
        Exit Sub
    End If
End If
End Sub



Sub Bersih()
Dim Control
For Each Control In Me.Controls
    If TypeOf Control Is TextBox Then
        Control.Text = ""
    End If
Next Control
End Sub

Sub Semula()
    cmdSimpan.Enabled = False
    cmdTambah.Caption = "&Tambah"
    Bersih
    vEdit = False
    vTrans = False
    NotAktif
    LblPegawai = "--"
    LblKelas = "--"
End Sub

Sub NotAktif()
Dim Control
For Each Control In Me.Controls
    If TypeOf Control Is TextBox Then
        Control.Enabled = False
    End If
    If TypeOf Control Is ComboBox Then
        Control.Enabled = False
    End If
Next Control
End Sub


Private Sub CmbNIP_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(cmbNIP, KeyAscii, True, Ubah)

End Sub

Private Sub cmdTambah_Click()
    Me.MousePointer = 11
    If cmdTambah.Caption = "&Tambah" Then
        cmdTambah.Caption = "&Batal"
       Fokus Text1
       Bersih
    Else
        Semula
    End If
    Me.MousePointer = 1
End Sub

Private Sub cmdTutup_Click()
Unload Me
End Sub

Sub DaftarGuru()
Me.MousePointer = 11
    Set TGuru = New ADODB.Recordset
        Kata = "Select * from Guru Order By [NIP]"
        TGuru.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
        cmbNIP.Clear
        If Not TGuru.EOF Then
           TGuru.MoveFirst
           While Not TGuru.EOF
                cmbNIP.AddItem TGuru![NIP]
                TGuru.MoveNext
            Wend
        End If
        TGuru.Close
        Set TGuru = Nothing

    Me.MousePointer = 1

End Sub

Sub DaftarKelas()
Me.MousePointer = 11
    Set TGuru = New ADODB.Recordset
        Kata = "Select * from Kelas Order By [kode Kelas]"
        TGuru.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
        cmbKelas.Clear
        If Not TGuru.EOF Then
           TGuru.MoveFirst
           While Not TGuru.EOF
                cmbKelas.AddItem TGuru![Kode Kelas]
                TGuru.MoveNext
            Wend
        End If
        TGuru.Close
        Set TGuru = Nothing

    Me.MousePointer = 1

End Sub

Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If Len(Text2.Text) = 4 Then
        If Text1.Text > Text2.Text Then
            MsgBox "Isikan Tahun Ajaran dengan benar....", vbInformation
            Fokus Text2
            Exit Sub
        End If
        cmbKelas.Enabled = True
        cmbKelas.SetFocus
        DaftarKelas
    End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
     And KeyAscii <= Asc("9") & Chr(13) _
     Or KeyAscii = vbKeyBack _
     Or KeyAscii = vbKeyDelete) Then
        Beep
        KeyAscii = 0
   End If
End Sub
