VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmKelas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Kelas - [SMP Negeri 2] Medan.."
   ClientHeight    =   3885
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7080
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3885
   ScaleWidth      =   7080
   Begin MSComctlLib.ListView Lv1 
      Height          =   1575
      Left            =   120
      TabIndex        =   14
      Top             =   1320
      Width           =   6855
      _ExtentX        =   12091
      _ExtentY        =   2778
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   5
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "No"
         Object.Width           =   882
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Kode Kelas"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Nama Kelas"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "NIS"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   4
         Text            =   "Nama Siswa"
         Object.Width           =   4410
      EndProperty
   End
   Begin VB.TextBox txtNis 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1080
      MaxLength       =   7
      TabIndex        =   13
      Top             =   960
      Width           =   1095
   End
   Begin VB.CommandButton cmdTambah 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Tambah"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2040
      TabIndex        =   9
      Top             =   3360
      Width           =   945
   End
   Begin VB.CommandButton cmdSimpan 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Simpan"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   3000
      TabIndex        =   8
      Top             =   3360
      Width           =   945
   End
   Begin VB.CommandButton cmdEdit 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Edit"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   3960
      TabIndex        =   7
      Top             =   3360
      Width           =   945
   End
   Begin VB.CommandButton cmdTutup 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Tutup"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   5880
      TabIndex        =   6
      Top             =   3360
      Width           =   945
   End
   Begin VB.CommandButton cmdHapus 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Hapus"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   4920
      TabIndex        =   5
      Top             =   3360
      Width           =   945
   End
   Begin VB.TextBox txtKode 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1080
      TabIndex        =   1
      Top             =   240
      Width           =   1095
   End
   Begin VB.TextBox txtNamaKelas 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1080
      TabIndex        =   0
      Top             =   600
      Width           =   5055
   End
   Begin VB.Label lblNama 
      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            =   2280
      TabIndex        =   12
      Top             =   960
      Width           =   150
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "NIS:"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Index           =   3
      Left            =   600
      TabIndex        =   11
      Top             =   960
      Width           =   315
   End
   Begin VB.Line Line2 
      BorderColor     =   &H8000000D&
      X1              =   1920
      X2              =   6960
      Y1              =   3240
      Y2              =   3240
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H00FF8080&
      Height          =   855
      Index           =   1
      Left            =   1920
      Top             =   3000
      Width           =   5055
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackColor       =   &H80000018&
      Caption         =   "P r o s e s"
      ForeColor       =   &H00004000&
      Height          =   255
      Index           =   1
      Left            =   1920
      TabIndex        =   10
      Top             =   3000
      Width           =   5055
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Kode Kelas:"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Index           =   0
      Left            =   150
      TabIndex        =   4
      Top             =   240
      Width           =   840
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Nama Kelas:"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Index           =   1
      Left            =   105
      TabIndex        =   3
      Top             =   600
      Width           =   885
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "."
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   18
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   435
      Index           =   1
      Left            =   -15
      TabIndex        =   2
      Top             =   0
      Width           =   135
   End
End
Attribute VB_Name = "frmKelas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

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
    cmdEdit.Enabled = False
    cmdHapus.Enabled = False
    cmdTambah.Caption = "&Tambah"
    Bersih
    vEdit = False
    vTrans = False
    NotAktif
    
    lblNama.Caption = "--"
    Lv1.ListItems.Clear
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 Form_Load()
Ketengah Me
End Sub

Private Sub cmdTambah_Click()
    Me.MousePointer = 11
    If cmdTambah.Caption = "&Tambah" Then
        cmdTambah.Caption = "&Batal"
       Fokus txtKode
       Bersih
       
    Else
        Semula
    End If
    Me.MousePointer = 1
End Sub

Private Sub cmdTutup_Click()
Unload Me
End Sub

Private Sub cmdEdit_Click()
    Me.MousePointer = 11
    vEdit = True
    vTrans = True
    Fokus txtNamaKelas
    cmdEdit.Enabled = False
    cmdHapus.Enabled = False
    cmdTambah.Caption = "&Batal"
    cmdSimpan.Enabled = True
    Me.MousePointer = 1
End Sub

Private Sub cmdHapus_Click()
    Kata = MsgBox("Data Kelas : " & txtNamaKelas & " : Mau dihapus...", vbInformation + vbYesNo, "Warning....")
    If Kata = vbYes Then
        Me.MousePointer = 11
        Datasiswa.Execute "Delete From Kelas Where [kode Kelas]='" & txtKode.Text & "'"
        Semula
        Me.MousePointer = 1
    End If
End Sub



Private Sub cmdSimpan_Click()
Me.MousePointer = 1
   If Not vEdit Then
        Simpan
    Else
        Edit
    End If
Semula
Me.MousePointer = 1
End Sub


Private Sub Lv1_Click()
If Lv1.ListItems.Count <> 0 Then
txtKode.Text = Lv1.SelectedItem.SubItems(1)
txtNamaKelas.Text = Lv1.SelectedItem.SubItems(2)
txtNis.Text = Lv1.SelectedItem.SubItems(3)
lblNama.Caption = Lv1.SelectedItem.SubItems(4)
End If
End Sub

Private Sub Lv1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Lv1_Click
End Sub



Private Sub txtKode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If txtKode <> "" Then
        If Len(txtKode) <> 2 Then
            MsgBox "kode harus di input sebanyak 2 digit..."
            Fokus txtKode
            Exit Sub
        End If
        
        Me.MousePointer = 11
        Kata = "Select * from QKelas where [kode kelas] ='" & txtKode.Text & "'"
        Set TKelas = New ADODB.Recordset
            TKelas.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
            If TKelas.EOF Then
                TKelas.Close
                Set TKelas = Nothing
                Me.MousePointer = 1
                Fokus txtNamaKelas
                Exit Sub
            End If
            Data
            cmdEdit.Enabled = True
            cmdHapus.Enabled = True
            cmdTambah.Caption = "&Batal"
            cmdEdit.Enabled = True
            Fokus txtNamaKelas
            TKelas.Close
            Set TKelas = Nothing
            Me.MousePointer = 1
    End If
End If
End Sub

Private Sub txtNamaKelas_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
        If txtNamaKelas = "" Then
            MsgBox "Nama Kelas harus di isi....", vbExclamation
            Fokus txtNamaKelas
            Exit Sub
        End If
        Me.MousePointer = 11
        Fokus txtNis
        Me.MousePointer = 1
    End If
End Sub




Private Sub txtNis_KeyDown(KeyCode As Integer, Shift As Integer)
If Not vEdit Then
         For i = 1 To Lv1.ListItems.Count
                    If txtNis.Text = Lv1.ListItems(i).SubItems(3) Then
                        MsgBox "NIS Sudah Ada pada daftar....", vbExclamation, "Ooops..."
                        txtNis.SetFocus
                        Exit Sub
                    End If
                Next
Else
    DataKelas
End If
End Sub

Private Sub txtNis_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If txtNis <> "" Then
        If Len(txtNis) <> 7 Then
            MsgBox "NIS harus di input sebanyak 7 digit..."
            Fokus txtNis
            Exit Sub
        End If
        
        
        Me.MousePointer = 11
        Kata = "Select * from Siswa where [NIS] ='" & txtNis.Text & "'"
        Set TKelas = New ADODB.Recordset
            TKelas.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
            If TKelas.EOF Then
                TKelas.Close
                Set TKelas = Nothing
                Me.MousePointer = 1
                MsgBox "NIS tidak terdaftar dalam data siswa....", vbExclamation
                Exit Sub
            End If
            lblNama.Caption = TKelas.Fields![Nama Siswa]
            TKelas.Close
            Set TKelas = Nothing
            Me.MousePointer = 1
            DataKelas
    End If
End If
                
End Sub

'Sub DaftarKelas()
'    With TKelas
'        txtNamaKelas = ![Kelas]
 '       txtNis = !NIS
 '       lblNama = ![Nama Siswa]
 '       txtKode = ![Kode Kelas]
 '   End With

'End Sub

Sub Simpan()
On Error GoTo Salah
    Me.MousePointer = 11
    
    Datasiswa.BeginTrans
    
    Datasiswa.Execute "Insert Into Kelas values ('" & txtKode.Text & "'," & _
    "'" & txtNamaKelas.Text & "')"
    Datasiswa.CommitTrans
    
    Datasiswa.BeginTrans
    
    For i = 1 To Lv1.ListItems.Count
        Datasiswa.Execute "Insert Into Ruang Values ('" & txtKode.Text & "'," & _
        "'" & Lv1.ListItems(i).SubItems(3) & "')"
    Next i
    Datasiswa.CommitTrans
    Me.MousePointer = 1
    Exit Sub
Salah:
    MsgBox "Data kelas tidak bisa di simpan...", vbInformation, "Data Error..."
End Sub

Sub Edit()
    On Error GoTo Salah
    Me.MousePointer = 11
    
    Datasiswa.BeginTrans
    Datasiswa.Execute "Update Kelas Set [Kelas]='" & txtNamaKelas.Text & "' where [kode Kelas]='" & txtKode.Text & "'"
    Datasiswa.CommitTrans
    Me.MousePointer = 1
    Exit Sub
Salah:
    MsgBox Err.Description
End Sub

Sub DataKelas()
If Not vEdit Then
            Set Vbutir = Lv1.ListItems.Add(, , Lv1.ListItems.Count + 1 & ".")
                    Vbutir.SubItems(1) = txtKode
                    Vbutir.SubItems(2) = txtNamaKelas
                    Vbutir.SubItems(3) = txtNis
                    Vbutir.SubItems(4) = lblNama
                    Kata = MsgBox("Masih Ada Data Kelas Siswa Yang mau di Input....", vbExclamation + vbYesNo, "Informasi")
                    If Kata = vbYes Then
                        txtNis = "": lblNama = ""
                        Fokus txtNis
                        Exit Sub
                    End If
                    cmdSimpan.Enabled = True
                    cmdSimpan.SetFocus
Else
    If Lv1.ListItems.Count > 0 Then
                    Lv1.ListItems.Remove Lv1.SelectedItem.Index
                For i = 1 To Lv1.ListItems.Count
                    Lv1.ListItems(i).Text = i & "."
                Next i
            End If
             Set Vbutir = Lv1.ListItems.Add(, , Lv1.ListItems.Count + 1 & ".")
                    Vbutir.SubItems(1) = txtKode
                    Vbutir.SubItems(2) = txtNamaKelas
                    Vbutir.SubItems(3) = txtNis
                    Vbutir.SubItems(4) = lblNama
                    cmdSimpan.Enabled = True
                    cmdSimpan.SetFocus
End If
End Sub


Sub Data()

    With TKelas
        txtKode = ![Kode kelas]
        txtNamaKelas = ![kelas]
        While Not TKelas.EOF
            Set Vbutir = Lv1.ListItems.Add(, , Lv1.ListItems.Count + 1 & ".")
            Vbutir.SubItems(1) = TKelas![Kode kelas]
            Vbutir.SubItems(2) = TKelas![kelas]
            Vbutir.SubItems(3) = TKelas![NIS]
            Vbutir.SubItems(4) = TKelas![Nama Siswa]
            TKelas.MoveNext
        Wend
    End With


End Sub
