Selasa, 22 Februari 2011

Hari ke 31 PI

PENAMBAHAN CODING AUTO NUMBER + INSERT INTO

Private Sub Command_Click(Index As Integer)
Select Case Index
Case 0 ' TAMBAH


    kosong True
    Text(0) = AutoNum("S", 5, "siswa", "kde_siswa")
    Text(0).Enabled = True
    st = True
    Text(0).SetFocus
    Call aktif
    enbTombol False, True, False, False, True, False, True
    Command(5).Visible = False
Case 1 'SIMPAN
If cek = True Then
            MsgBox "Isikan Data Dengan Benar!", vbInformation, "Kosong"
            Exit Sub
            End If
        ya = MsgBox("Apakah Anda yakin data ini akan Anda simpan?", vbQuestion + vbYesNo, "Simpan")
        If ya = vbYes Then
            Set rs = ConnAPP.Execute("SELECT * FROM Siswa WHERE Kde_Siswa = '" & Text(0).Text & "'")
            If Not rs.EOF Then
                rs.Close
                Set rs = ConnAPP.Execute("UPDATE Siswa set NIS='" & Text(1).Text & "',Nama='" & Text(2).Text & "',Tmpt='" & Text(3).Text & "',TL='" & DTPicker1 & "',Alamat='" & Text(4).Text & "', Masuk='" & Text(2).Text & "',Keluar='" & Text(2).Text & "',Sex='" & Combo(0) & "',Agama='" & Combo(1) & "' WHERE Kde_Siswa = '" & Text(0).Text & "'")
                MsgBox "Berhasil Disimpan", vbInformation + vbOKOnly, "Simpan"
                Else
                rs.Close
                Set rs = ConnAPP.Execute("insert into Siswa(Kde_Siswa,NIS,Nama,Sex,Tmpt, TL, Agama,Alamat, Masuk, Keluar)values('" & Text(0) & "','" & Text(1) & "','" & Text(2) & "','" & Combo(0) & "','" & Text(3) & "','" & DTPicker1 & "','" & Combo(1) & "','" & Text(4) & "','" & Text(5) & "','" & Text(6) & "')")
                MsgBox "Berhasil Disimpan", vbInformation + vbOKOnly, "Simpan"
                End If

          
            Call tampil
            enbTombol True, False, False, False, True, False, True
            Command(6).Visible = True
      End If

Case 4 'KELUAR
Unload Me

Case 5 'BATAL
Unload Me
End Select
End Sub

Tidak ada komentar:

Posting Komentar