Oleh: admin | 10/12/2012

Proses Simpan, Edit, Hapus, Batal, Keluar Visual Foxpro 9.0

Kali ini saya memposting bagaimana proses simpan, edit, hapus, batal, keluar pada Microsoft Visual foxpro 9. Penulis mengasumsikan bahwa para pembaca sudah memahami bagaimana proses pembuatan tabel, penggunaan object pada form.

Berikut gambar tabelnya :

Berikut gambar formnya :

Berikut kodenya :
Object Form1 Procedure Init

SET TALK OFF
SET DELETE on
SET EXCLUSIVE on
SET EXACT ON
IF !USED("tblhargabarang")
SELECT 1 
USE tblhargabarang EXCLUSIVE
ENDIF
thisform.txtkodeb.Value =''
thisform.txtnamab.Value =''
thisform.txthargab.Value =0  
thisform.txtnamab.Enabled = .F. 
thisform.txthargab.Enabled = .F.   
thisform.cmdsimpan.Enabled = .F.
thisform.cmdedit.Enabled = .F. 
thisform.cmdhapus.Enabled = .F.     
thisform.txtkodeb.SetFocus  

Object Form1 procedure Load

PUBLIC baru
baru =0

Object cmdsimpan procedure click

IF EMPTY(thisform.txtkodeb.Value)
   =MESSAGEBOX("Kode Barang belum diisi",0+64,"Info")
   RETURN
ENDIF
IF EMPTY(thisform.txtnamab.Value)
   =MESSAGEBOX("Nama Barang belum diisi",0+64,"Info")
   RETURN
ENDIF
IF EMPTY(thisform.txthargab.Value)
   =MESSAGEBOX("Harga Barang belum diisi",0+64,"Info")
   RETURN
ENDIF
SELECT tblpelanggan
SET ORDER To tag kodep
kdb=ALLTRIM(thisform.txtkodeb.Value)
nmb=ALLTRIM(thisform.txtnamab.Value)
hb= thisform.txthargab.Value
IF baru=0
  INSERT INTO tblhargabarang(kodeb,namab,hargab) values(kdb,nmb,hb)
  ELSE
  UPDATE tblhargabarang set namab=nmb,hargab=hb WHERE kodeb=kdb
  ENDIF
  thisform.cmdbatal.Click

Object cmdedit procedure click

this.Enabled = .F. 
thisform.cmdsimpan.Enabled = .T.  
baru = 1
thisform.txtkodeb.Enabled = .F. 
thisform.txtnamab.Enabled = .T. 
thisform.txthargab.Enabled = .T. 
thisform.txtnamab.SetFocus     

Object cmdhapus procedure click

IF MESSAGEBOX("Data ini mau dihapus?",4+32,"Konfirmasi")=7
thisform.cmdbatal.Click
ENDIF
SELECT tblhargabarang
SET ORDER TO tag kodeb
DELETE
thisform.cmdbatal.Click

Object cmdbatal procedure click

thisform.txtkodeb.Value =''
thisform.txtnamab.Value =''
thisform.txthargab.Value =0
thisform.txtnamab.Enabled = .F. 
thisform.txthargab.Enabled = .F. 
thisform.cmdsimpan.Enabled = .F.
thisform.cmdedit.Enabled = .F. 
thisform.cmdhapus.Enabled = .F.    
thisform.Refresh
thisform.txtkodeb.Enabled = .T.  
thisform.txtkodeb.SetFocus        

Object cmdkeluar procedure click

thisform.Release 

Gambar jadinya seperti berikut :

Semoga bermanfaat buat rekan-rekan


Responses

  1. Thx pak,,, terimakasih ats tolongNya

  2. sangat bermanfaat buat saya, Tq.

  3. ok makasih…

  4. thanks cantik..berguna bangwt tauu

  5. makasih atas penjelasannya, tapi saya kurang mengerti pada form procedure init, kegunaan set talk off sama set exclusive. Terus method baru tolong dijelaskan. Mhn penjelasannya

    • nanti akan dibahas pada artikel khusus, Insya Allah ada waktu.


Berikan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Kategori

Ikuti

Kirimkan setiap pos baru ke Kotak Masuk Anda.

%d blogger menyukai ini: