Anda di halaman 1dari 8

Dim adocon As ADODB.

Connection
Dim adorec As ADODB.Recordset

Private Sub cmd_back_Click()


Frame1.Visible = True
Frame2.Visible = False
Frame3.Visible = False
Picture1.Picture = LoadPicture("")
txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010
txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""
cmd_back.Visible = False
End Sub

Private Sub Form_Load()

'Call conection
Set adocon = New ADODB.Connection
adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\dhyvha\MATERI
KULIAH\Smester 3\Pemrograman Visual_P.Pri\Praktek\Biodata_Peg.mdb;Persist Security
Info=False"
Set adorec = New ADODB.Recordset
adorec.CursorLocation = adUseClient
adorec.Open "select * from biodata", adocon, adOpenDynamic, adLockOptimistic

Set DataGrid1.DataSource = adorec


DataGrid1.Refresh

cmd_back.Visible = False

'JENIS KELAMIN
COMBO_JK.Clear
COMBO_JK.AddItem "Laki-Laki"
COMBO_JK.AddItem "Perempuan"

'golongan
Combo_GOL.Clear
Combo_GOL.AddItem "IA"
Combo_GOL.AddItem "IIA" 'by moe dhyvha copyright @ 2010
Combo_GOL.AddItem "IIIA"

'agama
Combo_AG.Clear
Combo_AG.AddItem "ISLAM"
Combo_AG.AddItem "KRISTEN"
Combo_AG.AddItem "KATHOLIK"
Combo_AG.AddItem "HINDU"
Combo_AG.AddItem "BUDHA"
'status
Combo_st.Clear
Combo_st.AddItem "Kawin"
Combo_st.AddItem "Belum Kawin"
Combo_st.AddItem "Janda"
Combo_st.AddItem "Duda"

'kota
combo_kot.Clear
combo_kot.AddItem "Banyumas"
combo_kot.AddItem "Banjarnegara"
combo_kot.AddItem "Bandung"
combo_kot.AddItem "Tegal" 'by moe dhyvha copyright @ 2010
combo_kot.AddItem "Kendal"
combo_kot.AddItem "Wonosobo"
combo_kot.AddItem "Semarang"
combo_kot.AddItem "Yogyakarta"

'Provinsi
combo_prov.Clear
combo_prov.AddItem "Jawa Tengah"
combo_prov.AddItem "Jawa Timur"
combo_prov.AddItem "Jawa Barat"
combo_prov.AddItem "DKI Jakarta"
combo_prov.AddItem "DIY"
combo_prov.AddItem "Jambi"
combo_prov.AddItem "Denpasar"

End Sub
Private Sub cmd_batal_Click()
On Error GoTo salah
Dim pesan As String
pesan = MsgBox("Apakah anda akan menyimpan data yang telah di edit?", vbQuestion +
vbYesNo, "")
If pesan = vbYes Then

If txt_nip.Text = "" Then


GoTo salah
Else
If Not adorec.BOF Then adorec.MoveFirst
adorec.Find ("NIP = '" & txt_nip & "'")
If adorec.EOF Then adorec.AddNew

adorec("NIP") = txt_nip.Text
adorec("Gol") = Combo_GOL.Text
adorec("Nama") = txt_nama.Text
adorec("Tanggal Lahir") = DTPicker1.Value
adorec("Jenis Kelamin") = COMBO_JK.Text
adorec("Alamat") = txt_alamat.Text 'by moe dhyvha copyright @ 2010
adorec("Kota") = combo_kot.Text
adorec("Provinsi") = combo_prov.Text
adorec("Agama") = Combo_AG.Text
adorec("Status") = Combo_st.Text
adorec("Junak") = txt_junak.Text
adorec.Update
txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010
txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""
Frame3.Visible = False
End If

ElseIf pesan = vbNo Then


Frame3.Visible = False
Frame2.Visible = False
cmd_back.Visible = False
Frame4.Enabled = False
txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010
txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""

End If

cmd_back.Visible = False
'Frame1.Visible = True
'Frame3.Visible = False
'cmd_back.Visible = False
Exit Sub
salah:
salah = MsgBox("Isi dulu kolom yang masih kosong!!!", vbCritical, "Pastikan")
End Sub

Private Sub CMD_CETAK_Click()


DataReport1.Show
End Sub

Private Sub cmd_edit_Click()


Frame4.Enabled = True
Frame3.Visible = True
txt_nama.SetFocus
Frame2.Visible = False

End Sub

Private Sub cmd_find_Click()

txt_nip = InputBox("Masukan NIP yang dicari") 'by moe dhyvha copyright @


2010
If txt_nip = Cancel Then
Frame2.Visible = False
cmd_back.Visible = False
Frame3.Visible = False
txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010
txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""
Else
If Not adorec.BOF Then adorec.MoveFirst
adorec.Find ("NIP = '" & txt_nip & "'")
If Not adorec.EOF Then

txt_nama.Text = adorec.Fields("NAMA")
Combo_GOL.Text = adorec.Fields("GOL")
DTPicker1.Value = adorec.Fields("Tanggal Lahir")
COMBO_JK.Text = adorec.Fields("Jenis Kelamin")
txt_alamat.Text = adorec.Fields("Alamat")
combo_kot.Text = adorec.Fields("Kota")
combo_prov.Text = adorec.Fields("Provinsi")
Combo_AG.Text = adorec.Fields("Agama")
Combo_st.Text = adorec.Fields("Status")
txt_junak.Text = adorec.Fields("Junak")

If Not Dir$(App.Path & "\foto\" & txt_nip & ".jpg") = "" Then
Picture1.Picture = LoadPicture(App.Path & "\foto\" & txt_nip & ".jpg")
Else
Picture1.Picture = LoadPicture("")
End If

Frame2.Visible = True
cmd_back.Visible = True
Frame4.Enabled = False

Else
MsgBox "Data tidak ketemu", vbInformation + vbOKOnly, ""
Frame2.Visible = False

Frame2.Visible = True
cmd_back.Visible = True
Frame4.Enabled = False

End If
End If
'cmd_find.Enabled = False 'by moe dhyvha, copyright@ 2010
'cmd_hapus.Enabled = True

End Sub

Private Sub cmd_hapus_Click()

Dim pesan As String


pesan = MsgBox("Apa Anda Yakin Akan Menghapus Data Ini?", vbYesNo + vbQuestion,
"Pastikan")
If pesan = 6 Then
adorec.Delete
adorec.Update
txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010
txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""

Frame2.Visible = False
Else
Frame2.Visible = False
Frame1.Visible = True
End If

End Sub

Private Sub cmd_input_Click()


Frame4.Enabled = True
txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010
txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""
txt_nip.SetFocus
Frame3.Visible = True
cmd_back.Visible = True
End Sub

Private Sub cmd_out_Click()


Dim KELUAR As String
Dim pesan As String
Dim Pesan2 As String
pesan = MsgBox("Yakinkah anda mau keluar?", vbOKCancel + vbQuestion, "Pastikan")
'by moe dhyvha copyright @ 2010
If pesan = vbOK Then
Pesan2 = MsgBox("TERIMA KASIH TELAH MENGGUNAKAN APLIKASI INI", vbOKOnly
+ vbInformation, "")
If Pesan2 = vbOK Then Unload Me
If pesan = vbCancel Then txt_nip.SetFocus
End If
End Sub

Private Sub cmd_simpan_Click()


On Error GoTo salah
If txt_nip.Text = "" Then
GoTo salah
Else
If Not adorec.BOF Then adorec.MoveFirst
adorec.Find ("NIP = '" & txt_nip & "'")
If adorec.EOF Then adorec.AddNew

adorec("NIP") = txt_nip.Text
adorec("Gol") = Combo_GOL.Text
adorec("Nama") = txt_nama.Text
adorec("Tanggal Lahir") = DTPicker1.Value
adorec("Jenis Kelamin") = COMBO_JK.Text
adorec("Alamat") = txt_alamat.Text 'by moe dhyvha copyright @ 2010
adorec("Kota") = combo_kot.Text
adorec("Provinsi") = combo_prov.Text
adorec("Agama") = Combo_AG.Text
adorec("Status") = Combo_st.Text
adorec("Junak") = txt_junak.Text
adorec.Update

txt_nip.Text = "" 'by moe dhyvha, copy right@ 2010


txt_nama.Text = ""
Combo_GOL.Text = ""
txt_alamat.Text = ""
txt_junak.Text = ""
COMBO_JK.Text = ""
combo_kot.Text = ""
combo_prov.Text = ""
Combo_AG.Text = ""
Combo_st.Text = ""
'txt_nip.SetFocus

Picture1.Picture = LoadPicture("")
cmd_back.Visible = False

End If
cmd_input.SetFocus
Frame3.Visible = False
Exit Sub
salah:
salah = MsgBox("Isi dulu kolom yang masih kosong!!!", vbCritical, "Pastikan")
End Sub

Private Sub Combo_AG_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
Combo_st.SetFocus
End If
End Sub

Private Sub COMBO_JK_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
DTPicker1.SetFocus 'by moe dhyvha copyright @ 2010
End If
End Sub

Private Sub combo_kot_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
combo_prov.SetFocus
End If
End Sub

Private Sub combo_prov_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
Combo_AG.SetFocus
End If
End Sub

Private Sub Combo_st_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
txt_junak.SetFocus
End If
End Sub

Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
txt_alamat.SetFocus
End If
End Sub

Private Sub txt_alamat_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
combo_kot.SetFocus
End If
End Sub

Private Sub txt_junak_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
cmd_simpan.SetFocus
End If
End Sub

Private Sub txt_nama_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 13 Then
COMBO_JK.SetFocus 'by moe dhyvha copyright @ 2010
End If
End Sub

Private Sub txt_nip_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Combo_GOL.SetFocus 'by moe dhyvha copyright @ 2010
End If
End Sub
Private Sub Combo_GOL_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txt_nama.SetFocus 'by moe dhyvha copyright @ 2010
End If
End Sub

Anda mungkin juga menyukai