Jumat, 07 Januari 2011

Form Seting



Code programnya:
Option Explicit

Private koneksi As ADODB.Connection
Dim rstabel As New ADODB.Recordset


Private Function konek() As Boolean
    On Error GoTo out
        Set koneksi = New ADODB.Connection
        koneksi.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DbSekolah.mdb;Persist Security Info=False"
        koneksi.CursorLocation = adUseClient
        konek = True
out:
End Function


Sub bersih()
     TxtJurusan.Text = ""
     TxtKeahlian.Text = ""
     TxtSPP.Text = ""
     TxtPraktek.Text = "0"
     TxtOsis.Text = "0"
     TxtUjian.Text = "0"
     TxtLap.Text = "0"
     TxtAdm.Text = "0"
End Sub


Sub Aktif()
     TxtJurusan.Enabled = True
     TxtKeahlian.Enabled = True
     TxtSPP.Enabled = True
     TxtPraktek.Enabled = True
     TxtOsis.Enabled = True
     TxtUjian.Enabled = True
     TxtLap.Enabled = True
     TxtAdm.Enabled = True
End Sub


Sub pasif()
     TxtJurusan.Enabled = False
     TxtKeahlian.Enabled = False
     TxtSPP.Enabled = False
     TxtPraktek.Enabled = False
     TxtOsis.Enabled = False
     TxtUjian.Enabled = False
     TxtLap.Enabled = False
     TxtAdm.Enabled = False
End Sub


Private Sub CmdBatal_Click()
bersih
pasif
CmdSimpan.Caption = "Baru"
CmdEdit.Caption = "Edit"
CmdHapus.Enabled = True
CmdSimpan.Enabled = True
End Sub


Private Sub CmdEdit_Click()
If CmdEdit.Caption = "Edit" Then
TxtID.Enabled = True
TxtID.SetFocus
Aktif
CmdEdit.Caption = "Up Date"
CmdSimpan.Enabled = False
CmdHapus.Enabled = False
Else
If MsgBox("Anda yakin data sudah benar", vbQuestion + vbYesNo) = vbYes Then
With Adodc1.Recordset
.Fields("Jurusan") = TxtJurusan.Text
.Fields("SPP") = TxtSPP.Text
.Fields("Praktek") = TxtPraktek.Text
.Fields("Osis") = TxtOsis.Text
.Fields("Ujian") = TxtUjian.Text
.Fields("Praktek_Lap") = TxtLap.Text
.Fields("Administrasi") = TxtAdm.Text
.Update
End With
Adodc1.Refresh
DataGrid1.Refresh
MsgBox "Data telah di Update!", vbInformation + vbOKOnly = vbIgnore
Call CmdBatal_Click
End If
End If
End Sub


Private Sub CmdExit_Click()
If MsgBox("Yakin mau keluar?", vbQuestion + vbYesNo) = vbYes Then
        Unload Me
    End If
End Sub


Private Sub CmdHapus_Click()
Dim x As String
x = MsgBox(("Anda Yakin data ingin di hapus?"), vbYesNo + vbCritical)
If x = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
DataGrid1.ReBind
DataGrid1.Refresh
MsgBox "Data  telah di Hapus!", vbInformation + vbOKOnly = vbIgnore
End If
End Sub


Private Sub CmdSimpan_Click()
If CmdSimpan.Caption = "Baru" Then
CmdSimpan.Caption = "Simpan"
Aktif
TxtJurusan.SetFocus
Else
If MsgBox("Anda yakin data sudah benar", vbQuestion + vbYesNo) = vbYes Then
If Trim$(TxtJurusan.Text) = "" Then
        MsgBox "Jurusan  harus di isi!", vbExclamation
        TxtJurusan.SetFocus
        Exit Sub
    ElseIf TxtKeahlian.Text = "" Then
        MsgBox "Program Keahlian Harus di isi!", vbExclamation
        TxtKeahlian.SetFocus
        Exit Sub
    ElseIf TxtSPP.Text = "" Then
        MsgBox "SPP harus di isi!", vbExclamation
        TxtSPP.SetFocus
        Exit Sub
    End If
With Adodc1.Recordset
.AddNew
.Fields("Jurusan") = TxtJurusan.Text
.Fields("Progm_Keahlian") = TxtKeahlian.Text
.Fields("SPP") = TxtSPP.Text
.Fields("Praktek") = TxtPraktek.Text
.Fields("Osis") = TxtOsis.Text
.Fields("Ujian") = TxtUjian.Text
.Fields("Praktek_Lap") = TxtLap.Text
.Fields("Administrasi") = TxtAdm.Text
.Update
End With
Adodc1.Refresh
DataGrid1.Refresh
MsgBox "Data telah di Simpan!", vbInformation + vbOKOnly = vbIgnore
Call CmdBatal_Click
End If
End If
End Sub


Private Sub Form_Load()
If Not konek() Then
        MsgBox "Gak bisa terhubung ke database!", vbCritical
        End
    End If
    Adodc1.ConnectionString = koneksi.ConnectionString
    Adodc1.RecordSource = "Seting"
    Set DataGrid1.DataSource = Adodc1
End Sub


Private Sub TxtAdm_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call CmdSimpan_Click
End If
End Sub


Private Sub TxtID_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Adodc1.Recordset.Find "ID='" + TxtID.Text + "'", , adSearchForward, 1
If Not Adodc1.Recordset.EOF Then
     TxtJurusan.Text = Adodc1.Recordset!Jurusan
     TxtKeahlian.Text = Adodc1.Recordset!Progm_Keahlian
     TxtSPP.Text = Adodc1.Recordset!SPP
     TxtPraktek.Text = Adodc1.Recordset!Praktek
     TxtOsis.Text = Adodc1.Recordset!Osis
     TxtUjian.Text = Adodc1.Recordset!Ujian
     TxtLap.Text = Adodc1.Recordset!Praktek_Lap
     TxtAdm.Text = Adodc1.Recordset!Administrasi
Else
     MsgBox "Maaf, Data Tidak Ditemukan!"
End If
End If
End Sub
Private Sub TxtJurusan_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Adodc1.Recordset.Find "Jurusan='" + TxtJurusan.Text + "'", , adSearchForward, 1
If Not Adodc1.Recordset.EOF Then
    MsgBox "Maaf, Jurusan Keahlian ini sudah ada!"
Else
   TxtKeahlian.SetFocus
End If
End If
End Sub


Private Sub TxtKeahlian_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtSPP.SetFocus
End If
End Sub



Private Sub TxtLap_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtAdm.SetFocus
End If
End Sub


Private Sub TxtOsis_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtUjian.SetFocus
End If
End Sub


Private Sub TxtPraktek_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtOsis.SetFocus
End If
End Sub


Private Sub TxtSPP_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtPraktek.SetFocus
End If
End Sub


Private Sub TxtUjian_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtLap.SetFocus
End If
End Sub




NEXT---->


Pembayaran SPP.rar
Program_Pembayaran_SPP.pdf

Tidak ada komentar:

Posting Komentar