Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

VB Database Lanjutan : Form Mata Kuliah

Berikut ini form Master Matakuliah.
Listing Program FrmMatakuliah

Sub Hapus()
    KODE.Enabled = True
    KODE.Text = ""
    NAMA.Text = ""
    SKS.Text = ""
    SEMESTER.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 MataKuliah(KODE, Nama, SKS, SEMESTER)" & _
                " values('" & KODE.Text & _
                "','" & NAMA.Text & _
                "','" & SKS.Text & _
                "','" & SEMESTER.Text & "')"
        Case 1
            SQL = "UPDATE MataKuliah SET Nama ='" & NAMA.Text & "'," & _
                  " SKS = '" & SKS.Text & "'," & _
                  " SEMESTER = '" & SEMESTER.Text & "' " & _
                  " where KODE ='" & KODE.Text & "'"
        Case 2
            SQL = "DELETE FROM MataKuliah WHERE KODE='" & KODE.Text & "'"
    End Select
    MsgBox "Pemorosesan RECORD Database telah berhasil...!", vbInformation, "Data MataKuliah"
    Db.Execute SQL, adCmdTable
    Call Hapus
    Adodc1.Refresh
    KODE.SetFocus
End Sub

Sub TampilMataKuliah()
    On Error Resume Next
    KODE.Text = RS!KODE
    NAMA.Text = RS!NAMA
    SKS.Text = RS!SKS
    SEMESTER.Text = RS!SEMESTER
    
    Call RubahCMD(False, True, True, True)
    CmdProses(1).Caption = "&Edit"
    KODE.Enabled = False
End Sub

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

Private Sub Form_Load()
    Call OPENDB
    Call Hapus
    
    SEMESTER.AddItem "I"
    SEMESTER.AddItem "II"
    SEMESTER.AddItem "III"
    SEMESTER.AddItem "IV"
    SEMESTER.AddItem "V"
    SEMESTER.AddItem "VI"
    SKS.AddItem "2"
    SKS.AddItem "3"
    SKS.AddItem "4"
End Sub

Private Sub KODE_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If KODE.Text = "" Then
            MsgBox "Masukkan KODE MataKuliah !", vbInformation, "MataKuliah"
            KODE.SetFocus
            Exit Sub
        End If
        SQL = "SELECT * FROM MataKuliah WHERE KODE='" & KODE.Text & "'"
        If RS.State = adStateOpen Then RS.Close
        RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
        If RS.RecordCount <> 0 Then
            TampilMataKuliah
        Else
            x = KODE.Text
            Call Hapus
            KODE.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,

2 Responses

  1. andie.ofie says:

    Pak…aplikasinya…dimana Pak…di download kok nggag ada ya Pakkk….

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: