Berikut contoh aplikasi sederhana berkaitan dengan menyimpan, merubah ataupun menghapus data menggunakan Foxpro. Misalnya mengenai data siswa.
Langkah-langkahnya :
1. Buat table terlebih dahulu dan beri nama tbLatihan
Nama type Character Width 20
Alamat type Character Width 45
2. Buat desain Form nya.
Buat dua command isi dengan Save dan Delete
3. Klik di Form Procedure Init
Thisform.txtNama.Value=""
Thisform.txtAlamat.Value=""
4. Klik di Form ProcedureLoad
PARAMETERS coba
IF EMPTY(coba) THEN
pOrder='Nama'
5. Klik di Form Procedure Load
SET SAFETY OFF
SET TALK OFF
SET DELETED ON
IF ! USED(tbLatihan) THEN
USE "..\Database\tbLatihan" SHARED IN 0
ENDIF
SELECT * FROM tbLatihan INTO CURSOR tb_Grid READWRITE
6. Klik di command Save Procedure click
mNama =Thisform.txtNama.Value
mAlamat=Thisform.txtAlamat.Value
IF coba=0 THEN
INSERT INTO tbLatihan(Nama, Alamat) VALUES (mNama, mAlamat)
MESSAGEBOX("Data baru sudah tersimpan...!",32+4,"Perhatian...")
ENDIF
7. Klik di command Delete Procedure click
IF MESSAGEBOX("Yakin Data Akan Dihapus...?",32+4,"Konfirmasi...")=6 THEN
DELETE FROM tbLatihan WHERE ALLTRIM(Nama)==mNama
Thisform.Refresh
ENDIF
8. Di command Exit Procedure click
Thisform. Release
Langkah-langkahnya :
1. Buat table terlebih dahulu dan beri nama tbLatihan
Nama type Character Width 20
Alamat type Character Width 45
2. Buat desain Form nya.
Buat dua command isi dengan Save dan Delete
3. Klik di Form Procedure Init
Thisform.txtNama.Value=""
Thisform.txtAlamat.Value=""
4. Klik di Form ProcedureLoad
PARAMETERS coba
IF EMPTY(coba) THEN
pOrder='Nama'
5. Klik di Form Procedure Load
SET SAFETY OFF
SET TALK OFF
SET DELETED ON
IF ! USED(tbLatihan) THEN
USE "..\Database\tbLatihan" SHARED IN 0
ENDIF
SELECT * FROM tbLatihan INTO CURSOR tb_Grid READWRITE
6. Klik di command Save Procedure click
mNama =Thisform.txtNama.Value
mAlamat=Thisform.txtAlamat.Value
IF coba=0 THEN
INSERT INTO tbLatihan(Nama, Alamat) VALUES (mNama, mAlamat)
MESSAGEBOX("Data baru sudah tersimpan...!",32+4,"Perhatian...")
ENDIF
7. Klik di command Delete Procedure click
IF MESSAGEBOX("Yakin Data Akan Dihapus...?",32+4,"Konfirmasi...")=6 THEN
DELETE FROM tbLatihan WHERE ALLTRIM(Nama)==mNama
Thisform.Refresh
ENDIF
8. Di command Exit Procedure click
Thisform. Release
0 komentar:
Post a Comment
Form komentar ini tanpa moderasi dan verifikasi, karena itu dimohon jangan kirim SPAM atau SARA.
Terima Kasih