Created
October 27, 2017 15:25
-
-
Save vbcupu/d5b807f9e2b189534187a41cd2003de7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub cmdBatal_Click() | |
Call BersihForm | |
End Sub | |
Private Sub cmdHapus_Click() | |
strSQL = "Delete from Mahasiswa where NIM = '" & txtNIM.Text & "'" | |
Call execCmd(dbCmd, strSQL) | |
Call BersihForm | |
FillGrid | |
End Sub | |
Private Sub cmdSimpan_Click() | |
strSQL = "select Nim from mahasiswa where Nim = '" & txtNIM.Text & "';" | |
Call bukaRs(strSQL, rs) | |
If rs.EOF = True Or rs.BOF = True Then | |
strSQL = "Insert into Mahasiswa (Nim, Nama, Alamat, TempatLahir, TglLahir, Kota, IdFakultas) values " & _ | |
"('" & txtNIM.Text & "', '" & txtNama.Text & "', '" & txtAlamat.Text & "', '" & txtTempatLahir.Text & "', '" & dtpTglLahir.Value & "', '" & txtKota.Text & "')" | |
Call execCmd(dbCmd, strSQL) | |
Else | |
strSQL = "Update Mahasiswa set Nama = '" & txtNama.Text & "', Alamat = '" & txtAlamat.Text & "', TempatLahir = '" & txtTempatLahir & "', TglLahir = '" & dtpTglLahir.Value & "', Kota = '" & txtKota.Text & "' Where Nim = '" & txtNIM.Text & "'" | |
Call execCmd(dbCmd, strSQL) | |
End If | |
Call BersihForm | |
FillGrid | |
End Sub | |
Private Sub DataGrid1_Click() | |
If DataGrid1.ApproxCount < 1 Then Exit Sub | |
With DataGrid1 | |
txtNIM.Text = .Columns("Nim").Value | |
txtNama.Text = .Columns("Nama").Value | |
txtAlamat.Text = .Columns("Alamat").Value | |
txtTempatLahir.Text = .Columns("TempatLahir").Text | |
dtpTglLahir.Value = .Columns("TglLahir").Value | |
txtKota.Text = .Columns("Kota").Text | |
End With | |
cmdHapus.Enabled = True | |
End Sub | |
Private Sub dtpTglLahir_KeyDown(KeyCode As Integer, Shift As Integer) | |
If KeyCode = vbKeyReturn Then txtKota.SetFocus | |
End Sub | |
Private Sub Form_Load() | |
Call OpenConnection | |
Call BersihForm | |
FillGrid | |
End Sub | |
Private Sub BersihForm() | |
txtNIM.Text = "" | |
txtNama.Text = "" | |
txtAlamat.Text = "" | |
txtKota.Text = "" | |
txtTempatLahir.Text = "" | |
dtpTglLahir.Value = Now | |
cmdHapus.Enabled = False | |
FillGrid | |
End Sub | |
Private Sub txtAlamat_KeyPress(KeyAscii As Integer) | |
If KeyAscii = 13 Then txtTempatLahir.SetFocus | |
End Sub | |
Private Sub txtCariAlamat_Change() | |
FillGrid | |
End Sub | |
Private Sub txtCariNama_Change() | |
FillGrid | |
End Sub | |
Private Sub txtKota_KeyPress(KeyAscii As Integer) | |
If KeyAscii = 13 Then cmdSimpan.SetFocus | |
End Sub | |
Private Sub txtNama_KeyPress(KeyAscii As Integer) | |
If KeyAscii = 13 Then txtAlamat.SetFocus | |
End Sub | |
Private Sub txtTempatLahir_KeyPress(KeyAscii As Integer) | |
If KeyAscii = 13 Then dtpTglLahir.SetFocus | |
End Sub | |
Public Sub FillGrid() | |
strSQL = "select a.Nim, a.Nama, a.TempatLahir, a.TglLahir, a.Alamat, a.Kota from Mahasiswa as a where a.Nama like '%" & txtCariNama.Text & "%' and a.Alamat like '%" & txtCariAlamat.Text & "%'" | |
Call bukaRs(strSQL, rs) | |
Set DataGrid1.DataSource = rs | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment