Anda di halaman 1dari 5

GET_DATA.PRG

procedure get_data parameters perintah, kursor LOCAL mkoneksi,cekdrv,mhasil

SQLSETPROP(0,"ConnectTimeOut",7)

SQLSETPROP(0,"DispLogin",3)

mkoneksi=sqlconnect("mahasiswa","root","unigha") if mkoneksi<=0 then Messagebox("Gagal Melakukan Koneksi Ke server"+chr(13)+; "(Server Tidak Online)",16,"Informasi") QUIT

else

mhasil=sqlexec(mkoneksi,perintah,kursor) if mhasil=-1 then sqlrollback(mkoneksi) messagebox("Terjadinya error transfer data. "+; "Start program ini lagi!"+perintah)

endif

sqldisconnect(mkoneksi)

ENDIF release mkoneksi RELEASE cekdrv RELEASE mhasil Endproc

TRANSAKSI.PRG

procedure transaksi parameters perintah LOCAL mkoneksi,cekdrv,mhasil

SQLSETPROP(0,"ConnectTimeOut",7)

SQLSETPROP(0,"DispLogin",3)

mkoneksi=sqlconnect("mahasiswa","root","unigha") if mkoneksi<=0 then Messagebox("Gagal Melakukan Koneksi Ke server"+chr(13)+; "(Server Tidak Online)",16,"Informasi") QUIT

else

mhasil=sqlexec(mkoneksi,perintah) if mhasil=-1 then sqlrollback(mkoneksi) messagebox("Terjadinya error "+str(mhasil)+" transfer data. Koneksi:"+str(mkoneksi)+; "Start program ini lagi! "+perintah)

endif

sqldisconnect(mkoneksi)

ENDIF release mkoneksi RELEASE cekdrv RELEASE mhasil endproc

1

Luas Kode Fakultas 2 digit Luas Nama Fakultas 35 digit Form – Init SET EXCLUSIVE ON

Luas Kode Fakultas

2 digit

Luas Nama Fakultas 35 digit

Form – Init

SET EXCLUSIVE ON thisform.batal.Enabled=.f. thisform.baru.Enabled=.t. thisform.hapus.Enabled=.f. thisform.rubah.Enabled=.f. thisform.simpan.Enabled=.f. cCurrentProcedure = SYS(16,1) nPathStart = AT(":",cCurrentProcedure)- 1 nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart) SET DEFAULT TO (SUBSTR(cCurrentProcedure, nPathStart, nLenofPath)) SET PATH TO (SUBSTR(cCurrentProcedure, nPathStart, nLenofPath)) SET CENTURY ON SET DATE TO ITALIAN SET NEAR ON SET EXACT ON SET ANSI ON

tHISFORM.List1.CLEAR

THISFORM.List_1

Form – List_1

strSQL="Select * from fakultas order by kode_fakultas" DO get_data WITH strSQL,"dapat" GO top IF RECCOUNT()>0 THEN

X=0

DO WHILE !EOF()

X=X+1

THISFORM.LIST1.AddListItem(kode_fakultas,x,1)

THISFORM.LIST1.AddListItem(nama_fakultas,x,2)

ENDIF

ENDDO

SKIP

2

CLOSE TABLES ALL

Text1 – Valid

vKode_fakultas =thisform.text1.value thisform.simpan.Enabled=.t. thisform.batal.Enabled=.t. thisform.baru.Enabled=.f. IF vkode_fakultas="" thisform.simpan.Enabled=.f. endif

strSQL="Select * from fakultas where kode_fakultas='"+vKode_fakultas+"'" DO get_data WITH strSQL,"dapat" if reccount()>0 then

thisform.text2.Enabled=.f.

thisform.simpan.Enabled=.f.

Thisform.Text1.Value=Kode_fakultas

Thisform.Text2.Value=nama_fakultas

thisform.batal.Enabled=.t.

thisform.hapus.Enabled=.t.

thisform.rubah.Enabled=.t.

ELSE

 

thisform.text2.Enabled=.t.

ENDIF

Simpan – Click

vkode_fakultas=Thisform.Text1.Value

vnama_fakultas=Thisform.Text2.Value

strSQL="Select * from fakultas where kode_fakultas='"+vkode_fakultas+"'" DO get_data WITH strSQL,"dapat" If reccount()>0 then strSQL="Update fakultas Set kode_fakultas='"+vkode_fakultas+"',nama_fakultas='"+vnama_fakultas+"'; Where

kode_fakultas='"+Vkode_fakultas+"'" DO transaksi WITH strSQL Else strSQL="insert into fakultas (kode_fakultas,nama_fakultas); values ('"+vkode_fakultas+"','"+vnama_fakultas+"')" DO transaksi WITH strSQL Endif

thisform.list1.Refresh

Thisform.kosong thisform.baru.Enabled=.f. thisform.simpan.Enabled=.F. thisform.HAPUS.Enabled=.F. thisform.RUBAH.Enabled=.F. thisform.batal.Enabled=.f.

thisform.list_1

Thisform.text1.Setfocus

Rubah – Click

thisform.text2.Enabled=.t.

thisform.text2.SetFocus

thisform.batal.Enabled=.t.

thisform.hapus.Enabled=.f.

thisform.rubah.Enabled=.f.

thisform.simpan.Enabled=.t.

3

Baru – Click

thisform.kosong thisform.hapus.Enabled=.f. thisform.rubah.Enabled=.f. thisform.simpan.Enabled=.f. thisform.baru.Enabled=.f. thisform.batal.Enabled=.f.

thisform.text2.Enabled=.f.

thisform.text1.SetFocus

Form – Kosong

thisform.text1.Value=""

thisform.text2.Value=""

Hapus – Click

vkode_fakultas=thisform.text1.value

vnama_fakultas=thisform.text2.value

strSQL="select * from nama_fakultas where kode_fakultas='"+vkode_fakultas+"'" DO get_data WITH strSQL,"dapat" select dapat if reccount()<=0 then return

endif yakin=messagebox("yakin ingin di hapus",32+4,"Konfirmasi") if yakin=7 then return

endif close table all

strsql="delete from fakultas where kode_fakultas='"+vkode_fakultas+"'" DO get_data WITH strSQL,"dapat"

thisform.list1.Clear

thisform.list_1

thisform.kosong thisform.baru.Enabled=.t. thisform.simpan.Enabled=.F. thisform.HAPUS.Enabled=.F. thisform.RUBAH.Enabled=.F. thisform.batal.Enabled=.f.

thisform.text1.SetFocus

thisform.Refresh

Batal – Click

thisform.hapus.Enabled=.f. thisform.rubah.Enabled=.f. thisform.simpan.Enabled=.f. thisform.baru.Enabled=.t. thisform.batal.Enabled=.f. thisform.kosong

thisform.text1.SetFocus

Exit – Click

thisform.Release

List1 – Click

THISFORM.TEXT1.VALUE=THIS.VALUE

thisform.TEXT1.VALID

4

DATABASE

Koneksi

: MAHASISWA

TEBEL NAME

: FAKULTAS

ISI TABEL L :

1.kode_fakultas varchar 2 2.nama_fakultas varchar 35 : mahasiswa

Server

: localhost

User

: root

Password

: unigha

Hasil desain form:

DATABASE Koneksi : MAHASISWA TEBEL NAME : FAKULTAS ISI TABEL L : 1.kode_fakultas varchar 2 2.nama_fakultas

5