VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmSiswa 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Data Siswa - [SMP Negeri 2] Medan.."
   ClientHeight    =   4050
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7605
   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     =   4050
   ScaleWidth      =   7605
   Begin VB.ComboBox cmbAgama 
      Enabled         =   0   'False
      Height          =   315
      ItemData        =   "frmSiswa.frx":0000
      Left            =   3360
      List            =   "frmSiswa.frx":0013
      TabIndex        =   29
      Top             =   1200
      Width           =   1575
   End
   Begin VB.ComboBox cmbKerjaIbu 
      Enabled         =   0   'False
      Height          =   315
      ItemData        =   "frmSiswa.frx":0040
      Left            =   4320
      List            =   "frmSiswa.frx":0050
      TabIndex        =   28
      Top             =   2640
      Width           =   1815
   End
   Begin VB.TextBox txtCari 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   240
      TabIndex        =   26
      Top             =   3600
      Width           =   2055
   End
   Begin VB.CommandButton cmdTambah 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Tambah"
      Height          =   405
      Left            =   2640
      TabIndex        =   23
      Top             =   3480
      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            =   3600
      TabIndex        =   22
      Top             =   3480
      Width           =   945
   End
   Begin VB.CommandButton cmdEdit 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Edit"
      Enabled         =   0   'False
      Height          =   405
      Left            =   4560
      TabIndex        =   21
      Top             =   3480
      Width           =   945
   End
   Begin VB.CommandButton cmdTutup 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Tutup"
      Height          =   405
      Left            =   6480
      TabIndex        =   20
      Top             =   3480
      Width           =   945
   End
   Begin VB.CommandButton cmdHapus 
      BackColor       =   &H00D8E9EC&
      Caption         =   "&Hapus"
      Enabled         =   0   'False
      Height          =   405
      Left            =   5520
      TabIndex        =   19
      Top             =   3480
      Width           =   945
   End
   Begin VB.ComboBox cmbKerjaAyah 
      Enabled         =   0   'False
      Height          =   315
      ItemData        =   "frmSiswa.frx":0070
      Left            =   1620
      List            =   "frmSiswa.frx":007D
      TabIndex        =   17
      Top             =   2640
      Width           =   1815
   End
   Begin VB.TextBox txtNamaIbu 
      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            =   1620
      TabIndex        =   14
      Top             =   2280
      Width           =   5895
   End
   Begin VB.TextBox txtNamaAyah 
      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            =   1620
      TabIndex        =   12
      Top             =   1920
      Width           =   5895
   End
   Begin VB.TextBox txtAlamat 
      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            =   1620
      TabIndex        =   10
      Top             =   1560
      Width           =   5895
   End
   Begin VB.ComboBox cmbKelamin 
      Enabled         =   0   'False
      Height          =   315
      ItemData        =   "frmSiswa.frx":0099
      Left            =   1620
      List            =   "frmSiswa.frx":00A3
      TabIndex        =   8
      Top             =   1200
      Width           =   1095
   End
   Begin MSComCtl2.DTPicker DTAnggal 
      Height          =   300
      Left            =   4920
      TabIndex        =   6
      Top             =   840
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   529
      _Version        =   393216
      Enabled         =   0   'False
      CheckBox        =   -1  'True
      Format          =   19595265
      CurrentDate     =   39278
   End
   Begin VB.TextBox txtTempat 
      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            =   1620
      TabIndex        =   4
      Top             =   840
      Width           =   3135
   End
   Begin VB.TextBox txtKode 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   1620
      MaxLength       =   7
      TabIndex        =   1
      Top             =   120
      Width           =   1095
   End
   Begin VB.TextBox txtNama 
      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            =   1620
      TabIndex        =   0
      Top             =   450
      Width           =   5895
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "No. Induk Siswa"
      Height          =   195
      Index           =   10
      Left            =   240
      TabIndex        =   27
      Top             =   3360
      Width           =   1155
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H00FF8080&
      Height          =   855
      Index           =   0
      Left            =   120
      Top             =   3120
      Width           =   2295
   End
   Begin VB.Line Line1 
      BorderColor     =   &H80000002&
      X1              =   120
      X2              =   2400
      Y1              =   3360
      Y2              =   3360
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackColor       =   &H80000018&
      Caption         =   "C a r i"
      ForeColor       =   &H00004000&
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   25
      Top             =   3120
      Width           =   2295
   End
   Begin VB.Line Line2 
      BorderColor     =   &H8000000D&
      X1              =   2520
      X2              =   7560
      Y1              =   3360
      Y2              =   3360
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H00FF8080&
      Height          =   855
      Index           =   1
      Left            =   2520
      Top             =   3120
      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            =   2520
      TabIndex        =   24
      Top             =   3120
      Width           =   5055
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Kerja Ibu:"
      Height          =   195
      Index           =   9
      Left            =   3480
      TabIndex        =   18
      Top             =   2640
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Kerja Ayah:"
      Height          =   195
      Index           =   8
      Left            =   600
      TabIndex        =   16
      Top             =   2640
      Width           =   855
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Nama Ibu"
      Height          =   195
      Index           =   7
      Left            =   765
      TabIndex        =   15
      Top             =   2280
      Width           =   690
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Nama Ayah:"
      Height          =   195
      Index           =   6
      Left            =   570
      TabIndex        =   13
      Top             =   1920
      Width           =   885
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Alamat:"
      Height          =   195
      Index           =   5
      Left            =   900
      TabIndex        =   11
      Top             =   1560
      Width           =   555
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Agama:"
      Height          =   195
      Index           =   4
      Left            =   2760
      TabIndex        =   9
      Top             =   1200
      Width           =   555
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Jenis Kelamin:"
      Height          =   195
      Index           =   3
      Left            =   450
      TabIndex        =   7
      Top             =   1200
      Width           =   1005
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Tempat/ Tgl Lahir:"
      Height          =   195
      Index           =   1
      Left            =   150
      TabIndex        =   5
      Top             =   840
      Width           =   1305
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "* NIS:"
      Height          =   195
      Index           =   0
      Left            =   1005
      TabIndex        =   3
      Top             =   210
      Width           =   450
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Nama Siswa:"
      Height          =   195
      Index           =   2
      Left            =   540
      TabIndex        =   2
      Top             =   450
      Width           =   915
   End
End
Attribute VB_Name = "frmSiswa"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


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
    txtCari.Enabled = True
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 cmbAgama_Click()
If cmbAgama.Text <> "" Then
        Fokus txtAlamat
        Exit Sub
    End If
End Sub

Private Sub cmbAgama_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If cmbAgama.Text <> "" Then
        Fokus txtAlamat
        Exit Sub
    End If
End If
End Sub

Private Sub cmbAgama_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(cmbAgama, KeyAscii, True, Ubah)
End Sub

Private Sub cmbPendidikan_Click()
If cmbPendidikan.Text <> "" Then
    cmbAgama.Enabled = True
    cmbAgama.SetFocus
    Exit Sub
End If
    
End Sub



Private Sub cmbKelamin_Click()
If cmbKelamin.Text <> "" Then
    cmbAgama.Enabled = True
    cmbAgama.SetFocus
End If
End Sub

Private Sub cmbKelamin_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(cmbKelamin, KeyAscii, True, Ubah)
End Sub

Private Sub cmbKerjaAyah_Click()
If cmbKerjaAyah.Text <> "" Then
    cmbKerjaIbu.Enabled = True
    cmbKerjaIbu.SetFocus
    Exit Sub
End If
    
End Sub

Private Sub cmbKerjaAyah_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If cmbKerjaAyah.Text <> "" Then
    cmbKerjaIbu.Enabled = True
    cmbKerjaIbu.SetFocus
    Exit Sub
End If
End If
End Sub

Private Sub cmbKerjaAyah_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(cmbKerjaAyah, KeyAscii, True, Ubah)
End Sub

Private Sub cmbKerjaIbu_Click()
If cmbKerjaIbu.Text <> "" Then
    cmdSimpan.Enabled = True
    cmdSimpan.SetFocus
    Exit Sub
End If
End Sub

Private Sub cmbKerjaIbu_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If cmbKerjaIbu.Text <> "" Then
    cmdSimpan.Enabled = True
    cmdSimpan.SetFocus
    Exit Sub
End If
End If
End Sub

Private Sub cmbKerjaIbu_KeyPress(KeyAscii As Integer)
KeyAscii = AutoComplete(cmbKerjaIbu, KeyAscii, True, Ubah)
End Sub

Private Sub cmdEdit_Click()
    Me.MousePointer = 11
    vEdit = True
    vTrans = True
    Fokus txtNama
    cmdEdit.Enabled = False
    cmdHapus.Enabled = False
    cmdTambah.Caption = "&Batal"
    cmdSimpan.Enabled = True
    Me.MousePointer = 1
End Sub

Private Sub cmdHapus_Click()
    Kata = MsgBox("Data Siswa : " & txtNama & " : Mau dihapus...", vbInformation + vbYesNo, "Warning....")
    If Kata = vbYes Then
        Me.MousePointer = 11
        Datasiswa.Execute "Delete From Siswa Where [NIS]='" & txtKode.Text & "'"
        Semula
        Me.MousePointer = 1
        MsgBox "Data Siswa sudah berhasil di hapus....", vbExclamation
    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 cmdTambah_Click()
    Me.MousePointer = 11
    If cmdTambah.Caption = "&Tambah" Then
        cmdTambah.Caption = "&Batal"
       Fokus txtKode
       Bersih
       txtCari.Enabled = False
    Else
        Semula
    End If
    Me.MousePointer = 1
End Sub

Private Sub cmdTutup_Click()
Unload Me
End Sub

Private Sub DTTanggal_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        cmbPendidikan.Enabled = True
        cmbPendidikan.SetFocus
        Exit Sub
    End If
        
End Sub

Private Sub DTAnggal_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    cmbKelamin.Enabled = True
    cmbKelamin.SetFocus
End If
End Sub

Private Sub Form_Activate()
    cmdTambah.SetFocus
End Sub

Private Sub Form_Load()
    Ketengah Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If Not vTrans Then
        cmdTutup_Click
    Else
        Kata = MsgBox("Data Siswa ini belum di simpan..." & vbCrLf & _
                    "Apakah data Siswa ini mau di simpan...", vbQuestion + vbYesNo, "Informasi")
        If Kata = vbYes Then
            cmdSimpan.Enabled = True
            cmdSimpan_Click
            Unload Me
        Else
        Unload Me
        End If
    End If
    
End Sub


Private Sub txtAlamat_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If txtAlamat = "" Then
            MsgBox "Alamat Siswa harus di isi...", vbInformation
            Fokus txtAlamat
            Exit Sub
        End If
        Fokus txtNamaAyah
    End If
End Sub

Private Sub txtCari_Change()
If Len(txtCari) = 7 Then
    Me.MousePointer = 11
    Kata = "Select * from Siswa Where NIS='" & txtCari.Text & "'"
    Set TSiswa = New ADODB.Recordset
        TSiswa.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
        If TSiswa.EOF Then
            TSiswa.Close
            Set TSiswa = Nothing
            Me.MousePointer = 1
            MsgBox "NIS tidak ditemukan dalam Tabel Siswa...", vbInformation, "NIS Invalid.."
            Fokus txtCari
            Exit Sub
        End If
        DaftarSiswa
        cmdHapus.Enabled = True
        cmdEdit.Enabled = True
        cmdTambah.Caption = "&Batal"
        TSiswa.Close
        Set TSiswa = Nothing
        Me.MousePointer = 1
End If
End Sub

Private Sub txtNama_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If txtNama = "" Then
            MsgBox "Nama Siswa harus di isi....", vbExclamation
            Fokus txtNama
            Exit Sub
        End If
        Me.MousePointer = 11
        Fokus txtTempat
        Me.MousePointer = 1
    End If
End Sub

Private Sub txtNama_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("a") & Chr(13) _
     And KeyAscii <= Asc("z") & Chr(13) _
     Or (KeyAscii >= Asc("A") & Chr(13) _
     And KeyAscii <= Asc("Z") & Chr(13) _
     Or KeyAscii = vbKeyBack _
     Or KeyAscii = vbKeyDelete _
     Or KeyAscii = vbKeySpace)) Then
        Beep
        KeyAscii = 0
   End If
End Sub

Private Sub txtKode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If txtKode <> "" Then
        If Len(txtKode) <> 7 Then
            MsgBox "NIS harus di input sebanyak 7 digit..."
            Fokus txtKode
            Exit Sub
        End If
        
        Me.MousePointer = 11
        Kata = "Select * from Siswa where NIS ='" & txtKode.Text & "'"
        Set TSiswa = New ADODB.Recordset
            TSiswa.Open Kata, Datasiswa, adOpenDynamic, adLockPessimistic
            If TSiswa.EOF Then
                TSiswa.Close
                Set TSiswa = Nothing
                Me.MousePointer = 1
                Fokus txtNama
                Exit Sub
            End If
            DaftarSiswa
            cmdEdit.Enabled = True
            cmdHapus.Enabled = True
            cmdTambah.Caption = "&Batal"
            cmdEdit.Enabled = True
            Fokus txtNama
            TSiswa.Close
            Set TSiswa = Nothing
            Me.MousePointer = 1
    End If
End If
End Sub


Private Sub txtNamaAyah_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If txtNamaAyah <> "" Then
        Fokus txtNamaIbu
        Exit Sub
    End If
End If
End Sub

Private Sub txtNamaIbu_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If txtNamaIbu <> "" Then
        cmbKerjaAyah.Enabled = True
        cmbKerjaAyah.SetFocus
        Exit Sub
    End If
End If
End Sub

Private Sub txtTempat_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If txtTempat = "" Then
            MsgBox "Tempat Lahir harus di isi....", vbExclamation
            Fokus txtTempat
            Exit Sub
        End If
        DTAnggal.Enabled = True
        DTAnggal.SetFocus
    End If
End Sub

Sub DaftarSiswa()
    With TSiswa
        txtKode = ![NIS]
        txtNama = ![Nama Siswa]
        txtNamaAyah = ![Nama Ayah]
        txtNamaIbu = ![Nama Ibu]
        cmbKerjaAyah = ![Kerja Ayah]
        cmbKerjaIbu = ![Kerja Ibu]
        txtAlamat = ![Alamat]
        txtTempat = ![Tempat Lahir]
        DTAnggal.Value = Format(![Tgl lahir], "dd/mm/yyyy")
        
        cmbAgama = ![Agama]
        cmbKelamin = ![JK]
        
    End With
End Sub

Sub Simpan()
    On Error GoTo Salah
    Datasiswa.BeginTrans
    
    Datasiswa.Execute "Insert into Siswa values ('" & txtKode.Text & "','" & txtNama.Text & "'," & _
    "'" & DTAnggal.Value & "','" & txtTempat.Text & "','" & cmbKelamin.Text & "','" & cmbAgama.Text & "'," & _
    "'" & txtAlamat.Text & "','" & txtNamaAyah.Text & "','" & txtNamaIbu.Text & "','" & cmbKerjaAyah.Text & "'," & _
    "'" & cmbKerjaIbu.Text & "')"
    
    Datasiswa.CommitTrans
    
    Exit Sub
Salah:
    MsgBox "Data Siswa tidak bisa di simpan..., Ada Kesalahan...!", vbInformation
End Sub

Sub Edit()
    On Error GoTo Salah
        
        Datasiswa.BeginTrans
                
       Datasiswa.Execute "Update Siswa Set [Nama Siswa]='" & txtNama.Text & "',[Tgl lahir]='" & _
       DTAnggal.Value & "',[tempat lahir]='" & txtTempat.Text & "',JK='" & cmbKelamin.Text & "',[Agama]='" & _
       cmbAgama.Text & "',Alamat='" & txtAlamat.Text & "',[Nama Ayah]='" & txtNamaAyah.Text & "',[Nama Ibu]='" & _
       txtNamaIbu.Text & "',[kerja Ayah]='" & cmbKerjaAyah.Text & "',[Kerja Ibu]='" & cmbKerjaIbu.Text & "' where NIS='" & txtKode.Text & "'"
       Datasiswa.CommitTrans
       
       Exit Sub
Salah:
       MsgBox " Data Siswa tidak bisa di edit..., Ada data yang Salah...!", vbExclamation
       
End Sub


