Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

VB Database Lanjut : Form Dosen

Berikut ini program pada Form Dosen.

Listing Program FrmDosen

Sub Hapus()
    NIDN.Enabled = True
    NIDN.Text = ""
    NAMA.Text = ""
    JENJANG.Text = ""
    KEAHLIAN.Text = ""
    
    Call RubahCMD(True, False, False, False)
    CmdProses(1).Caption = "&Simpan"
End Sub

Sub ProsesDB(Log As Byte)
   Select Case Log
        Case 0
            SQL = "INSERT INTO Dosen(NIDN, Nama, JENJANG, KEAHLIAN)" & _
                " values('" & NIDN.Text & _
                "','" & NAMA.Text & _
                "','" & JENJANG.Text & _
                "','" & KEAHLIAN.Text & "')"
        Case 1
            SQL = "UPDATE Dosen SET Nama ='" & NAMA.Text & "'," & _
                  " JENJANG = '" & JENJANG.Text & "'," & _
                  " KEAHLIAN = '" & KEAHLIAN.Text & "' " & _
                  " where NIDN ='" & NIDN.Text & "'"
        Case 2
            SQL = "DELETE FROM Dosen WHERE NIDN='" & NIDN.Text & "'"
    End Select
    MsgBox "Pemorosesan RECORD Database telah berhasil...!", vbInformation, "Data Dosen"
    Db.Execute SQL, adCmdTable
    Call Hapus
    Adodc1.Refresh
    NIDN.SetFocus
End Sub

Sub TampilDosen()
    On Error Resume Next
    NIDN.Text = RS!NIDN
    NAMA.Text = RS!NAMA
    JENJANG.Text = RS!JENJANG
    KEAHLIAN.Text = RS!KEAHLIAN
    
    Call RubahCMD(False, True, True, True)
    CmdProses(1).Caption = "&Edit"
    NIDN.Enabled = False
End Sub

Private Sub CmdProses_Click(Index As Integer)
Select Case Index
    Case 0
        Call Hapus
        NIDN.SetFocus
    Case 1
        If CmdProses(1).Caption = "&Simpan" Then
            Call ProsesDB(0)
        Else
            Call ProsesDB(1)
        End If
    Case 2
        x = MsgBox("Yakin RECORD Dosen Akan Dihapus...!", vbQuestion + vbYesNo, "Dosen")
        If x = vbYes Then ProsesDB 2
    Case 3
        Call Hapus
        NIDN.SetFocus
    Case 4
        Unload Me
    End Select
End Sub

Private Sub Form_Load()
    Call OPENDB
    Call Hapus
    
    KEAHLIAN.AddItem "Teknologi Sistem Informasi"
    KEAHLIAN.AddItem "Ilmu Komputer"
    KEAHLIAN.AddItem "Manajemen"
    KEAHLIAN.AddItem "Akuntansi"
    KEAHLIAN.AddItem "Matematika"
    KEAHLIAN.AddItem "Teknik Informatika"
    JENJANG.AddItem "S1"
    JENJANG.AddItem "S2"
    JENJANG.AddItem "S3"
End Sub

Private Sub NIDN_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If NIDN.Text = "" Then
            MsgBox "Masukkan NIDN Dosen !", vbInformation, "Dosen"
            NIDN.SetFocus
            Exit Sub
        End If
        SQL = "SELECT * FROM Dosen WHERE NIDN='" & NIDN.Text & "'"
        If RS.State = adStateOpen Then RS.Close
        RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
        If RS.RecordCount <> 0 Then
            TampilDosen
        Else
            x = NIDN.Text
            Call Hapus
            NIDN.Text = x
            Call RubahCMD(False, True, False, True)
            CmdProses(1).Caption = "&Simpan"
        End If
        NAMA.SetFocus
    End If
End Sub


Sub RubahCMD(L0 As Boolean, L1 As Boolean, L2 As Boolean, L3 As Boolean)
    CmdProses(0).Enabled = L0
    CmdProses(1).Enabled = L1
    CmdProses(2).Enabled = L2
    CmdProses(3).Enabled = L3
End Sub

Filed under: Pemrograman VB, Perkuliahan, ,

5 Responses

  1. NAMA : FRIDOLIN MANURUNG
    NPM :0902178
    KELAS :MI_M0914

  2. andie.ofie says:

    lohhh Pak…Judul Utama…ne opo pakk…

  3. andie.ofie says:

    Pak…..ada aplikasi yg uda jadi nggak…neuh….so lw mau download dari awal ampek akhir dimana ya pak……thank yu… :))

Terima kasih telah memberikan komentar anda.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives Per Tahun

Sponsored

C&C Online Shop

Blog Stats

  • 355,762 sejak 12 Jan 2011

User’s Online


My Music

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 223 other followers

May 2011
M T W T F S S
« Apr   Jun »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
%d bloggers like this: