Anda di halaman 1dari 37

BAB IV

PEMBUATAN FORM UNTUK APLIKASI

Form digunakan untuk mengolah dan memproses data dalam suatu aplikasi. menambah
data, mengedit data, menghapus data, menampilkan data atau mencari data dapat
dilakukan melalui form dengan tampilan grafhics yang bagus. Sebuah form disimpan
dengan ekstensi.SCX
Contoh pembuatan program aplikasi pengolahan Data Stok Barang membutuhkan banyak
sekali form yang digunakan untuk mengolah data.

1. FORM ENTRY PETUGAS


Langkah membuat form entry data petugas adalah
1) Dari Project Manager klik tab Docs, sehingga menampilkan sub bagian
Form, Report dan Labels seperti gambar 4.1 dibawah ini

gambar 4.1 Kotak dialog Project Manager Pada Tab Document


2) Klik tombol command New, ketika New Form tampil klik New Form,
setelah itu akan tampil jendela Form Designer yang biasanya diikuti oleh
tampilnya Propertis dan Form Control. Jika jendela Propertis dan form Control
tidak tampil anda dapat menampilkannya melalui menu View dengan menandai
Submenu Form Control Toolbar dan Propertis
3) Kemudian aktifkan jendela Form Designer dengen mengklik satu kali
pada judul atas jendela tersebut, selanjutnya simpan form dengan memilih menu
File, Save dan ketikan nama form pada save form as dengan nama petugas
4) Setelah menyimpan form, tinggal menambah object-object yang
diperlukan dalam pembuatan form pengolahan data perugas. Object yang
diperlukan adalah object Label, Text Box, Command Button dan Control Grid.
Label Text Box Command Botton

Grid
Gambar 4.2 Tampilan designer Form
A. PROPERTIS OBJECT
Nama Propertis Nilai
Object
Form Caption Pengolahan Data Petugas
Name Petugas
Auto Center .T.
MDIForm .T.
ShowWindows 1-In Top-Level
Windowstate 0-Normal
Label1 Caption Kode Petugas
Label2 Caption Nama
Label3 Caption Jabatan
Label4 Caption Sandi
Text1 Name Txtkode
Maxlength 5
Text2 Name Txtnama
Maxlength 20
Text3 Name Txtjabatan
Maxlength 20
Text4 Name txtSandi
PassworChar *
Maxlength 25
Text5 Name Txtcari
Maxlength 20
Command1 Name Baru
Caption \<Baru
Command2 Name Simpan
Caption \<Simpan
Command3 Name Batal
Caption \<Batal
Command4 Name Rubah
Caption \<Rubah
Command5 Name Hapus
Caption \<Hapus
Command6 Name Atas
Caption |<
Cammand7 Name Mundur
Caption <
Command8 Name Maju
Caption >
Command9 Name Bawah
Caption >|
Command10 Name Cari
Caption \<Cari
Grid1 Name Grid1
ReadOnly .T.
RecordSource Petugas
Setelah Design Form selesai kemudian kita tinggal menuliskan code program sebagai
berikut :
B. PENULISAN CODE PROGRAM
1) Aktifkan Form dengan mengklik judul form, kemudian pilih
Activate Event pada properties form Klik Dua kali maka akan tampil jendela
tempat penulisan Code program seperti gambar dibawah ini.

gambar 4.3 Tempat penulisan Code program


Jika sudah tampil tuliskan Code dibawah ini
set delete on
select petugas
set order to kdptgs
count to ada
if ada >0
goto top
thisform.txtkdptgs.value=kdptgs
thisform.txtnmptgs.value=nmptgs
thisform.txtjabatan.value=jabatan
thisform.txtsandi.value=sandi
thisform.baru.enabled=.t.
thisform.rubah.enabled=.t.
thisform.hapus.enabled=.t.
thisform.cari.enabled=.t.
thisform.keluar.enabled=.t.
thisform.maju.enabled=.t.
thisform.mundur.enabled=.t.
else
thisform.txtkdptgs.value=" "
thisform. txtnmptgs.value=" "
thisform.txtjabatan.value=" "
thisform. txtsandi.value=" "
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
endif
thisform.txtkdptgs.enabled=.f.
thisform.txtnmptgs.enabled=.f.
thisform.txtjabatan.enabled=.f.
thisform.txtsandi.enabled=.f.
thisform.txtcari.visible=.f.
2) Aktifkan Tombol Baru dengan cara mengklik kemudian pada
propertiesnya pilih Click Event kemudian klik dua kali sehingga tampil jendela
penulisan code program kemudin tuliskan Code Program Tombol baru Clik di
bawah ini:
posisi=recno()
thisform.txtnmptgs.enabled=.t.
thisform.txtjabatan.enabled=.t.
thisform.txtsandi.enabled=.t.
thisform.txtkdptgs.value=" "
thisform. txtnmptgs.value=" "
thisform.txtjabatan.value=" "
thisform. txtsandi.value=" "
thisform.baru.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
thisform. txtnmptgs.setfocus()
3) Kemudian untuk Tombol simpan tuliskan code dibawah ini :
set delete off
if empty(thisform. txtkdptgs.value)
messagebox("Kode Petugas Harus DiIsi !",0+64,"Informasi")
else
vkdptgs=thisform. txtkdptgs.value
select petugas
set order to kdptgs
set filter to
seek vkdptgs
if found()
p=messagebox("Data Sudah Ada,Apakah Mau DiPerbaharui ?",4+64,"Info")
if p=6
recall
replace Kdptgs with thisform.txtkdptgs.value
replace nmptgs with thisform.txtnmptgs.value
replace jabatan with thisform.txtjabatan.value
replace sandi with thisform.txtsandi.value
endif
else
append blank
replace Kdptgs with thisform.txtkdptgs.value
replace nmptgs with thisform.txtnmptgs.value
replace jabatan with thisform.txtjabatan.value
replace sandi with thisform.txtsandi.value
endif
thisform.baru.enabled=.t.
thisform.rubah.enabled=.t.
thisform.hapus.enabled=.t.
thisform.cari.enabled=.t.
thisform.keluar.enabled=.t.
thisform.maju.enabled=.t.
thisform.mundur.enabled=.t.
set delete on
thisform.matiisian()
thisform. grid1.refresh()
thisform.txtkdptgs.enabled=.f.
thisform.txtnmptgs.enabled=.f.
thisform.txtjabatan.enabled=.f.
thisform.txtsandi.enabled=.f.
endif
4) Untuk Tombol Batal Clik Tuliskan Code program Dibawah
ini :
posisi=recno()
thisform.txtnmptgs.enabled=.t.
thisform.txtjabatan.enabled=.t.
thisform.txtsandi.enabled=.t.
thisform.txtkdptgs.value=" "
thisform. txtnmptgs.value=" "
thisform.txtjabatan.value=" "
thisform. txtsandi.value=" "
thisform.baru.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
thisform. txtnmptgs.setfocus()
5) Untuk Tombol Rubah Clik Tuliskan Code program Dibawah
ini :
posisi=recno()
thisform.txtnmptgs.enabled=.t.
thisform.txtjabatan.enabled=.t.
thisform.txtsandi.enabled=.t.
thisform.baru.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
thisform. txtkdptgs.enabled=.f.
thisform. txtnmptgs.setfocus()
6) Untuk Tombol hapus Clik Tuliskan Code program Dibawah ini
:
p=messagebox("Benar Mau DI Hapus?",4+32,"Info")
if p=6
delete
if eof()
goto bottom
else
skip
endif
thisform.ambildata()
thisform.grid1.refresh()
thisform.grid1.setfocus()
thisform.txtkdptgs.value=kdptgs
thisform.txtnmptgs.value=nmptgs
thisform.txtjabatan.value=jabatan
thisform.txtsandi.value=sandi
endif

7) Untuk Tombol Atas Clik Tuliskan Code program Dibawah ini :


select petugas
goto top
thisform.txtkdptgs.value=kdptgs
thisform.txtnmptgs.value=nmptgs
thisform.txtjabatan.value=jabatan
thisform.txtsandi.value=sandi
8) Untuk Tombol Mundur Clik Tuliskan Code program Dibawah
ini :
select petugas
if bof()
messagebox("Posisi sudah di awal file...!",0+64,"Informasi")
goto top
else
skip -1
endif
thisform.txtkdptgs.value=kdptgs
thisform.txtnmptgs.value=nmptgs
thisform.txtjabatan.value=jabatan
thisform.txtsandi.value=sandi
9) Untuk Tombol Maju Clik Tuliskan Code program Dibawah
ini :
select petugas
if .not. eof()
skip
else
messagebox("Posisi sudah di akhir file...!",0+64,"Informasi")
goto bottom
endif
thisform.txtkdptgs.value=kdptgs
thisform.txtnmptgs.value=nmptgs
thisform.txtjabatan.value=jabatan
thisform.txtsandi.value=sandi
10) Untuk Tombol Bawah Clik Tuliskan Code program Dibawah
ini :
select petugas
goto bottom
thisform.txtkdptgs.value=kdptgs
thisform.txtnmptgs.value=nmptgs
thisform.txtjabatan.value=jabatan
thisform.txtsandi.value=sandi
11) Untuk Tombol Keluar Clik Tuliskan Code program Dibawah
ini

select petugas
set filter to
if delete()
pack
endif
thisform.release()
2. FORM ENTRY SUPPLER
Untuk memulai membuat Form Supplaer langkah yang dilakukan sama seperti
membuat Form petugas. Desainglah form hingga seperti gambar dibawah ini :

Gambar 4.4 Tampilan Form Petugas


A. PROPERTI OBJECT
Nama Propertis Nilai
Object
Form Caption Pengolahan Data Supplier
Name Supplier
Auto Center .T.
MDIForm .T.
ShowWindows 1-In Top-Level
Windowstate 0-Normal
Label1 Caption Kode Supplier
Label2 Caption Nama
Label3 Caption Alamat
Label4 Caption Telp
Text1 Name Txtkode
Maxlength 9
Text2 Name Txtnama
Maxlength 20
Text3 Name TxtAlamat
Maxlength 40
Text4 Name txtTelp
PassworChar *
Maxlength 12
Text5 Name Txtcari
Maxlength 20
Command1 Name Baru
Caption \<Baru
Command2 Name Simpan
Caption \<Simpan
Command3 Name Batal
Caption \<Batal
Command4 Name Rubah
Caption \<Rubah
Command5 Name Hapus
Caption \<Hapus
Command6 Name Atas
Caption |<
Cammand7 Name Mundur
Caption <
Command8 Name Maju
Caption >
Command9 Name Bawah
Caption >|
Command10 Name Cari
Caption \<Cari
Grid1 Name Grid1
ReadOnly .T.
RecordSource Supplier

B. METHODE (PROSEDURE)
Methode (procedure) digunakan untuk mempermudah dalam penulisan code program,
agar tidak terjadi penulisan code secara berulang –ulang
Langkah-langkah dalam membuat procedure yaitu
1) Pilih Menu Form kemudian plih Submenu Methode kemudian
akan tampil windows New Methode seperti gambar dibawah ini

Gambar 4.5 Tampilan Form Petugas


2) Ketikan nama procedure pada Name kemudian klik Add
3) Untuk mengakhiri klik tombol Close

C. PENULISAN CODE PROGRAM


Untuk penulisan Code program sama seperti code program form petugas, namun pada
form ini kita menggunakan metode procedure

1) Prosedure Matiisian
thisform.txtkdsup.enabled=.f.
thisform.txtnmsup.enabled=.f.
thisform.txtalamat.enabled=.f.
thisform.txttlp.enabled=.f.
2) Prosedure Hidupisian
thisform.txtnmsup.enabled=.t.
thisform.txtalamat.enabled=.t.
thisform.txttlp.enabled=.t.
3) Prosedure Matitombol
thisform.baru.enabled=.f.
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
4) Prosedure Hidupl
thisform.baru.enabled=.t.
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform.rubah.enabled=.t.
thisform.hapus.enabled=.t.
thisform.cari.enabled=.t.
thisform.keluar.enabled=.t.
thisform.maju.enabled=.t.
thisform.mundur.enabled=.t.
5) Prosedure Bersihisian
thisform.txtkdsup.value=" "
thisform. txtnmsup.value=" "
thisform.txtalamat.value=" "
thisform. txttlp.value=" "
6) Prosedure ambildata
select suplier
thisform.txtkdsup.value=kdsup
thisform.txtnmsup.value=nmsup
thisform.txtalamat.value=alamat
thisform.txttlp.value=telp
7) Prosedure No
select suplier
set order to kdsup
goto bottom
if kdsup=space(9)
mkdptgs="SPL-00001"
else
mno=val(right(kdsup,5))+1
do case
case mno<10
mkdptgs="SPL-0000"+ltrim(str(mno))
case mno<100
mkdptgs="SPL-000"+ltrim(str(mno))
case mno<1000
mkdptgs="SPL-00"+ltrim(str(mno))
case mno<10000
mkdptgs="SPL-0"+ltrim(str(mno))
case mno<100000
mkdptgs="SPL-"+ltrim(str(mno))
endcase
endif
thisform.tXTKDsup.value=mkdptgs
8) Prosedure Simpandata
replace Kdsup with thisform.txtkdsup.value
replace nmsup with thisform.txtnmsup.value
replace alamat with thisform.txtalamat.value
replace telp with thisform.txttlp.value

9) Prosedure Active Form


set delete on
select petugas
set order to kdptgs
count to ada
if ada >0
goto top
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matitombol()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.txtcari.visible=.f.
10) Prosedure Tombol Baru Clik
posisi=recno()
thisform.hidupisian()
thisform.bersihlayar()
thisform.matitombol()
thisform.batal.enabled=.t.
thisform.simpan.enabled=.t.
thisform.no()
thisform. txtnmsup.setfocus()
11) Prosedure Simpan Clik
set delete off
if empty(thisform. txtkdsup.value)
messagebox("Kode Petugas Harus DiIsi !",0+64,"Informasi")
else
vkdptgs=thisform. txtkdsup.value
select suplier
set order to kdsup
set filter to
seek vkdptgs
if found()
p=messagebox("Data Sudah Ada,Apakah Mau DiPerbaharui ?",4+64,"Info")
if p=6
recall
thisform.simpandata()
endif
else
append blank
thisform.simpandata()
endif
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
set delete on
thisform.matiisian()
thisform. grid1.refresh()
endif
12) Prosedure Batal Clik
thisform.bersihlayar()
select suplier
set order to kdsup
count to ada
if ada > 0
goto posisi
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matiisian()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.txtcari.visible=.f.
13) Prosedure Rubah Clik
posisi=recno()
thisform.hidupisian()
thisform.matitombol()
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform. txtkdsup.enabled=.f.
thisform. txtnmsup.setfocus()
14) Prosedure Hapus Clik
p=messagebox("Benar Mau DI Hapus?",4+32,"Info")
if p=6
delete
if eof()
goto bottom
else
skip
endif
thisform.ambildata()
thisform.grid1.refresh()
thisform.grid1.setfocus()
endif
15) Prosedure Atas Clik
select suplier
goto top
thisform.ambildata()

16) Prosedure Mundur Clik


select suplier
if bof()
messagebox("Posisi sudah di awal file...!",0+64,"Informasi")
goto top
else
skip -1
endif
thisform.ambildata()
17) Prosedure Maju Clik
select suplier
if .not. eof()
skip
else
messagebox("Posisi sudah di akhir file...!",0+64,"Informasi")
goto bottom
endif
thisform.ambildata()
18) Prosedure Bawah Clik
select suplier
goto bottom
thisform.ambildata()
19) Prosedure cari Clik
thisform.txtcari.visible=.t.
thisform.txtcari.setfocus()
20) Prosedure Set Focus txtcari
if .not. empty(thisform.txtcari.value)
lacak=thisform.txtcari.value
select suplier
locate for upper(alltrim(substr(nmsup,1,len(nmsup))))=upper(alltrim(lacak))
if found()
thisform.ambildata()
set filter to upper(alltrim(substr(nmsup,1,len(lacak))))=upper(alltrim(lacak))
thisform.grid1.refresh()
else
messagebox("Data tidak ada/tidak ditemukan..!",0+64,"Informasi")
endif
thisform.txtcari.visible=.f.
endif
thisform.txtcari.value=""
21) Prosedure Keluar Clik
select suplier
set filter to
if delete()
pack
endif
thisform.release()

3. FORM ENTRY JENIS BARANG


Prosedure/code form jenis barang pada dasarnya sama dengan pembuanatan form
data Petugas , hanya objek yang digunakan lebih sedikit. Designlah form data jenis
barang seperti gambar dibawah ini atau menurut kreativitas anda masing –masing.

Gambar 4.6 Tampilan Form Jenis Barang


A. PROPERTI OBJECT
Nama Propertis Nilai
Object
Form Caption Pengolahan Data Jenis Barang
Name Jenis
Auto Center .T.
MDIForm .T.
ShowWindows 1-In Top-Level
Windowstate 0-Normal
Label1 Caption Kode Jenis
Label2 Caption Jenis
Text1 Name Txtkode
Maxlength 9
Text2 Name TxtJenis
Maxlength 30
Text5 Name Txtcari
Maxlength 30
Command1 Name Baru
Caption \<Baru
Command2 Name Simpan
Caption \<Simpan
Command3 Name Batal
Caption \<Batal
Command4 Name Rubah
Caption \<Rubah
Command5 Name Hapus
Caption \<Hapus
Command6 Name Atas
Caption |<
Cammand7 Name Mundur
Caption <
Command8 Name Maju
Caption >
Command9 Name Bawah
Caption >|
Command10 Name Cari
Caption \<Cari
Grid1 Name Grid1
ReadOnly .T.
RecordSource jenis

B. PENULISAN CODE PROGRAM


Untuk penulisan Code program data jenis barang sama seperti code program form
petugas yaitu kita menggunakan methode prosedure
1) Prosedure Matiisian
thisform.txtkodejns.enabled=.f.
thisform.txtjenis.enabled=.f.
2) Prosedure Hidupisian
thisform.txtkodejns.enabled=.t.
thisform.txtjenis.enabled=.t.
3) Prosedure Matitombol
thisform.baru.enabled=.f.
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
4) Prosedure Hiduptombol
thisform.baru.enabled=.t.
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform.rubah.enabled=.t.
thisform.hapus.enabled=.t.
thisform.cari.enabled=.t.
thisform.keluar.enabled=.t.
thisform.maju.enabled=.t.
thisform.mundur.enabled=.t.
5) Prosedure Bersihlayar
thisform.txtkodejns.value=" "
thisform. txtjenis.value=" "

6) Prosedure ambildata
thisform.txtkodejns.value=kdjns
thisform.txtjenis.value=jenis
7) Prosedure No
select jenis
set order to kdjns
goto bottom
if kdJNs=space(9)
mkdjns="KYP-00001"
else
mno=val(right(kdjns,5))+1
do case
case mno<10
mkdjns="KYP-0000"+ltrim(str(mno))
case mno<100
mkdjns="KYP-000"+ltrim(str(mno))
case mno<1000
mkdjns="KYP-00"+ltrim(str(mno))
case mno<10000
mkdjns="KYP-0"+ltrim(str(mno))
case mno<100000
mkdjns="KYP-"+ltrim(str(mno))
endcase
endif
thisform.tXTKODEJNS.value=mkdjns
8) Prosedure Simpandata
replace Kdjns with thisform.txtkodejns.value
replace jenis with thisform.txtjenis.value
9) Prosedure Active Form
set delete on
select jenis
set order to kdjns
count to ada
if ada >0
goto top
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matitombol()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.txtcari.visible=.f.
10) Prosedure Tombol Baru Clik
posisi=recno()
thisform.hidupisian()
thisform.bersihlayar()
thisform.matitombol()
thisform.batal.enabled=.t.
thisform.simpan.enabled=.t.
THISFORM.NO()
thisform. txtjenis.setfocus()
11) Prosedure Simpan Clik
set delete off
if empty(thisform. txtkodejns.value)
messagebox("Kode Jenis Barang Harus DiIsi !",0+64,"Informasi")
else
vkdjns=thisform. txtkodejns.value
select jenis
set order to kdjns
set filter to
seek vkdjns
if found()
p=messagebox("Data Sudah Ada,Apakah Mau DiPerbaharui ?",4+64,"Info")
if p=6
recall
thisform.simpandata()
endif
else
append blank
thisform.simpandata()
endif
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
set delete on
thisform.matiisian()
thisform. grid1.refresh()
endif
12) Prosedure Batal Clik
thisform.bersihlayar()
select jenis
set order to kodejns
count to ada
if ada > 0
goto posisi
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matiisian()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.txtcari.visible=.f.
13) Prosedure Rubah Clik
posisi=recno()
thisform.hidupisian()
thisform.matitombol()
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform. txtkdjenis.enabled=.f.
thisform. txtjenis.setfocus()
14) Prosedure Hapus Clik
p=messagebox("Benar Mau DI Hapus?",4+32,"Info")
if p=6
delete
if eof()
goto bottom
else
skip
endif
thisform.ambildata()
thisform.grid1.refresh()
thisform.grid1.setfocus()
endif
15) Prosedure Atas Clik
select jenis
goto top
thisform.ambildata()
16) Prosedure Mundur Clik
select jenis
if bof()
messagebox("Posisi sudah di awal file...!",0+64,"Informasi")
goto top
else
skip -1
endif
thisform.ambildata()
17) Prosedure Maju Clik
select jenis
if .not. eof()
skip
else
messagebox("Posisi sudah di akhir file...!",0+64,"Informasi")
goto bottom
endif
thisform.ambildata()

18) Prosedure Bawah Clik


select jenis
goto bottom
thisform.ambildata()
19) Prosedure cari Clik
thisform.txtcari.visible=.t.
thisform.txtcari.setfocus()
20) Prosedure Set Focus txtcari
if .not. empty(thisform.txtcari.value)
lacak=thisform.txtcari.value
select jns
locate for upper(alltrim(substr(jenis,1,len(jenis))))=upper(alltrim(lacak))
if found()
thisform.ambildata()
set filter to upper(alltrim(substr(jenis,1,len(lacak))))=upper(alltrim(lacak))
thisform.grid1.refresh()
else
messagebox("Data tidak ada/tidak ditemukan..!",0+64,"Informasi")
endif
thisform.txtcari.visible=.f.
endif
thisform.txtcari.value=""
21) Prosedure Keluar Clik
select jenis
set filter to
if delete()
pack
endif
thisform.release()
4. FORM ENTRY BARANG
Prosedure/code form barang pada dasarnya sama dengan pembuanatan form yang
lainnya , hanya objek yang digunakan lebih banyak. Desaignlah formdata jenis
barang seperti gambar dibawah ini atau menurut kreativitas anda masing –masing.

Gambar 4.7 Tampilan Form Barang


A. PROPERTI OBJECT

Nama Propertis Nilai


Object
Form Caption Pengolahan Data Barang
Name Barang
Auto Center .T.
MDIForm .T.
ShowWindows 1-In Top-Level
Windowstate 0-Normal
Label1 Caption Kode Barang
Label2 Caption Barang
Label3 Caption Kode Jenis
Label4 Caption Harga Beli
Label5 Caption Harga Jual
Label6 Caption Jumlah
Label7 Caption Stok Min
Text1 Name txtKodebrg
Maxlength 9
Text2 Name Txtnama
Maxlength 30
Combo1 Name Txtkodejns
RowSource Jenis.kdjns
Text3 Name txthrgjual
Text4 Name txthrgbeli
Text5 Name Txtjumlah
Text6 Name txtstokmin
Command1 Name Baru
Caption \<Baru
Cammand2 Name Simpan
Caption \<Simpan
Command3 Name Batal
Caption \<Batal
Command4 Name Hapus
Caption \<Hapus
Command5 Name Rubah
Caption \<Rubah
Command6 Name Atas
Caption |<
Command7 Name Mundur
Caption <
Command7 Name Maju
Caption >
Command8 Name Bawah
Caption >|
Command9 Name Cari
Caption \<Cari
Command10 Name Keluar
Caption \<keluar
Grid1 Name Grid1
ReadOnly .T.
RecordSource barang

B. PENULISAN CODE PROGRAM


Untuk penulisan Code program data barang sama seperti code program form lainnya
yaitu kita menggunakan methode procedure
1) Prosedure Matiisian
thisform.txtkodebrg.enabled=.f.
thisform.txtnama.enabled=.f.
thisform.txtkdjns.enabled=.f.
thisform.txtjumlah.enabled=.f.
thisform.txthrgjual.enabled=.f.
thisform.txthrgbeli.enabled=.f.
thisform.txtstokmin.enabled=.f.
2) Prosedure Hidupisian
thisform.txtkodebrg.enabled=.t.
thisform.txtnama.enabled=.t.
thisform.txtkdjns.enabled=.t.
thisform.txtjumlah.enabled=.t.
thisform.txthrgjual.enabled=.t.
thisform.txthrgbeli.enabled=.t.
thisform.txtstokmin.enabled=.t.
3) Prosedure Matitombol
thisform.baru.enabled=.f.
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
4) Prosedure Hiduptombol
thisform.baru.enabled=.t.
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform.rubah.enabled=.t.
thisform.hapus.enabled=.t.
thisform.cari.enabled=.t.
thisform.keluar.enabled=.t.
thisform.maju.enabled=.t.
thisform.mundur.enabled=.t.
5) Prosedure Bersihlayar
thisform.txtkodebrg.value=" "
thisform.txtkdjns.value=" "
thisform.txtnama.value=" "
thisform.txtkdjns.value=" "
thisform.txtjumlah.value=0
thisform.txthrgjual.value=0
thisform.txthrgbeli.value=0
thisform.txtstokmin.value=0
6) Prosedure ambildata
select barang
thisform.txtkdkodebrg.value=kodebrg
thisform.txtnama.value=barang
thisform.txtkdjns.value=kdjns
thisform.txtjumlah.value=jmlstok
thisform.txthrgjual.value=hrgjual
thisform.txthrgbeli.value=hrgbeli
thisform.txtstokmin.value=stokmin
7) Prosedure No
select barang
set order to kodebrg
goto bottom
if kodebrg=space(9)
mkodebrg="KY-000001"
else
mno=val(right(kodebrg,6))+1
do case
case mno<10
mkodebrg="KY-00000"+ltrim(str(mno))
case mno<100
mkodebrg="KY-0000"+ltrim(str(mno))
case mno<1000
mkodebrg="KY-000"+ltrim(str(mno))
case mno<10000
mkodebrg="KY-00"+ltrim(str(mno))
case mno<100000
mkodebrg="KY-0"+ltrim(str(mno))
case mno<1000000
mkodebrg="KY-"+ltrim(str(mno))
endcase
endif
thisform.tXTKodebrg.value=mkodebrg
8) Prosedure Simpandata
replace Kodebrg with thisform.txtkodebrg.value
replace barang with thisform.txtnama.value
replace Kdjns with thisform.txtkdjns.value
replace hrgjual with thisform.txthrgjual.value
replace hrgbeli with thisform.txthrgbeli.value
replace jmlstok with thisform.txtstokmin.value
replace stokmin with thisform.txtstokmin.value
9) Prosedure Active Form
set delete on
select barang
set order to k0debrg
count to ada
if ada >0
goto top
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matitombol()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.txtcari.visible=.f.
10) Prosedure Tombol Baru Clik
posisi=recno()
thisform.hidupisian()
thisform.bersihlayar()
thisform.matitombol()
thisform.batal.enabled=.t.
thisform.simpan.enabled=.t.
Thisform.no()
thisform. txtkodebrg.setfocus()

11) Prosedure Simpan Clik


set delete off
if empty(thisform. txtkodebrg.value)
messagebox("Kode Barang Harus DiIsi !",0+64,"Informasi")
else
vkdbrg=thisform. txtkodebrg.value
select barang
set order to kodebrg
set filter to
seek vkdbrg
if found()
p=messagebox("Data Sudah Ada,Apakah Mau DiPerbaharui ?",4+64,"Info")
if p=6
recall
thisform.simpandata()
endif
else
append blank
thisform.simpandata()
endif
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
set delete on
thisform.matiisian()
thisform. grid1.refresh()
endif
12) Prosedure Batal Clik
thisform.bersihlayar()
select barang
set order to kodebrg
count to ada
if ada > 0
goto posisi
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matiisian()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.txtcari.visible=.f.
13) Prosedure Rubah Clik
posisi=recno()
thisform.hidupisian()
thisform.matitombol()
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform. txtkodebrg.enabled=.f.
thisform. txtbarang.setfocus()
14) Prosedure Hapus Clik
p=messagebox("Benar Mau DI Hapus?",4+32,"Info")
if p=6
delete
if eof()
goto bottom
else
skip
endif
thisform.ambildata()
thisform.grid1.refresh()
thisform.grid1.setfocus()
endif
15) Prosedure Atas Clik
select barang
goto top
thisform.ambildata()
16) Prosedure Mundur Clik
select barang
if bof()
messagebox("Posisi sudah di awal file...!",0+64,"Informasi")
goto top
else

skip -1
endif
thisform.ambildata()

17) Prosedure Maju Clik


select barang
if .not. eof()
skip
else
messagebox("Posisi sudah di akhir file...!",0+64,"Informasi")
goto bottom
endif
thisform.ambildata()
18) Prosedure Bawah Clik
select barang
goto bottom
thisform.ambildata()
19) Prosedure cari Clik
thisform.txtcari.visible=.t.
thisform.txtcari.setfocus()
20) Prosedure Set Focus txtcari
if .not. empty(thisform.txtcari.value)
lacak=thisform.txtcari.value
select barang
locate for upper(alltrim(substr(barang,1,len(barang))))=upper(alltrim(lacak))
if found()
thisform.ambildata()
set filter to upper(alltrim(substr(barang,1,len(lacak))))=upper(alltrim(lacak))
thisform.grid1.refresh()
else
messagebox("Data tidak ada/tidak ditemukan..!",0+64,"Informasi")
endif
thisform.txtcari.visible=.f.
endif
thisform.txtcari.value=""
21) Prosedure Keluar Clik
select barang
set filter to
if delete()
pack
endif
thisform.release()

5. FORM BARANG MASUK


Untuk memulai membuat Form Barang Masuk langkah yang dilakukan sama seperti
membuat Form lainnya. Desainglah form hingga seperti gambar dibawah ini :

Gambar 4.8 Tampilan Form Barang Masuk


A. PROPERTI OBJECT
Nama Propertis Nilai
Object
Form Caption Transaksi Barang Masuk
Name Masuk
Auto Center .T.
MDIForm .T.
ShowWindows 1-In Top-Level
Windowstate 0-Normal
Label1 Caption No Nota Masuk
Label2 Caption Tanggal
Label3 Caption Kode Petugas
Label4 Caption Kode Supplier
Text1 Name txtnonmsk
Maxlength 10
Text2 Name Txttglmsk
Maxlength 8
Combo1 Name Txtkdptgs
Combo2 Name txtkdsup
Text4 Name txtnmsup
Text3 Name Txtnmptgs
Text5 Name Txtcari
Maxlength 20
Command1 Name Baru
Caption \<Baru
Command2 Name Simpan
Caption \<Simpan
Command3 Name Batal
Caption \<Batal
Command4 Name Rubah
Caption \<Rubah
Command5 Name Hapus
Caption \<Hapus
Command6 Name Atas
Caption |<
Cammand7 Name Mundur
Caption <
Command8 Name Maju
Caption >
Command9 Name Bawah
Caption >|
Command10 Name Cari
Caption \<Cari
Grid1 Name Grid1
ReadOnly .T.
RecordSource rincimsk

B. PENULISAN CODE PROGRAM


Untuk penulisan Code program sama seperti code program form yang lainnya, namun
pada form ini kita menggunakan metode procedure
1) Prosedure Matiisian
thisform.txttglmsk.enabled=.f.
thisform.txtkdptgs.enabled=.f.
thisform.txtnmptgs.enabled=.f.
thisform.txtkdsup.enabled=.f.
thisform.txtnmsup.enabled=.f.
2) Prosedure Hidupisian
thisform.txttglmsk.enabled=.t.
thisform.txtkdptgs.enabled=.t.
thisform.txtnmptgs.enabled=.t.
thisform.txtkdsup.enabled=.t.
thisform.txtnmsup.enabled=.t.
3) Prosedure Matitombol
thisform.baru.enabled=.f.
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.rubah.enabled=.f.
thisform.hapus.enabled=.f.
thisform.cari.enabled=.f.
thisform.keluar.enabled=.f.
thisform.maju.enabled=.f.
thisform.mundur.enabled=.f.
4) Prosedure Hiduptombol
thisform.baru.enabled=.t.
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform.rubah.enabled=.t.
thisform.hapus.enabled=.t.
thisform.cari.enabled=.t.
thisform.keluar.enabled=.t.
thisform.maju.enabled=.t.
thisform.mundur.enabled=.t.
5) Prosedure Bersihlayar
thisform.txtnonmsk.value=" "
thisform. txttglmsk.value=ctod("../../..")
thisform.txtkdptgs.value=" "
thisform. txtnmptgs.value=" "
thisform.txtkdsup.value=" "
thisform.txtnmsup.value=" "
6) Prosedure ambildata
select petugas
set filter to
set order to kdptgs
mkdptgs=thisform.txtkdptgs.value
seek mkdptgs
if found()
thisform.txtnmptgs.value=nmptgs
else
thisform.txtnmptgs.value=""
endif
select suplier
set filter to
set order to kdsup
mkdsup=thisform.txtkdsup.value
seek mkdsup
if found()
thisform.txtnmsup.value=nmsup
else
thisform.txtnmsup.value=""
endif
select masuk
thisform.txtnonmsk.value=nonmsk
thisform.txttglmsk.value=tglmsk
thisform.txtkdptgs.value=kdPTGS
thisform.txtkdsup.value=kdsup
7) Prosedure No
select masuk
set order to nonmsk
goto bottom
if nonmsk=space(10)
mnonmsk="MSK-000001"
else
mno=val(right(nonmsk,6))+1
do case
case mno<10
mnonmsk="MSK-00000"+ltrim(str(mno))
case mno<100
mnonmsk="MSK-0000"+ltrim(str(mno))
case mno<1000
mnonmsk="msk-000"+ltrim(str(mno))
case mno<10000
mnonmsk="MSK-00"+ltrim(str(mno))
case mno<100000
mnonmsk="MSK-0"+ltrim(str(mno))
case mno<1000000
mnonmsk="MSK-"+ltrim(str(mno))
endcase
endif
thisform.tXTnonmsk.value=mnonmsk
8) Prosedure Simpandata
replace nonmsk with thisform.txtnonmsk.value
replace kdptgs with thisform.txtkdptgs.value
replace tglmsk with thisform.txttglmsk.value
replace kdsup with thisform.txtkdsup.value
9) Prosedure Active Form
set delete on
select masuk
set order to nonmsk
count to ada
if ada >0
goto top
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matitombol()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.txtcari.visible=.f.
10) Prosedure Tombol Baru Clik
posisi=recno()
thisform.hidupisian()
thisform.bersihlayar()
thisform.matitombol()
thisform.batal.enabled=.t.
thisform.simpan.enabled=.t.
thisform.no()
thisform.txttglmsk.value=date()
thisform. txtkdptgs.setfocus()
11) Prosedure Simpan Clik
set delete off
if empty(thisform. txtnonmsk.value)
messagebox("no nota masuk harus diisi !",0+64,"informasi")
else
vnonmsk=thisform. txtnonmsk.value
select masuk
set order to nonmsk
set filter to
seek vnonmsk
if found()
p=messagebox("data sudah ada,apakah mau diperbaharui ?",4+64,"info")
if p=6
recall
thisform.simpandata()
endif
else
append blank
thisform.simpandata()
endif
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
set delete on
thisform.matiisian()
thisform. grid1.refresh()
endif
qbersih=2
mnonmsk=thisform.txtnonmsk.value
mtglmsk=thisform.txttglmsk.value
mkdptgs=thisform.txtkdptgs.value
mkdsup=thisform.txtkdsup.value
if empty(mnonmsk).or. empty(mtglmsk)
messagebox("data harus diisi !",0+64,"info")
else
do form rincimasuk
endif
thisform.ambildata()

12) Prosedure Batal Clik


thisform.bersihlayar()
select masuk
set order to nonmsk
count to ada
if ada > 0
goto TOP
thisform.ambildata()
thisform.hiduptombol()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
else
thisform.bersihlayar()
thisform.matiisian()
thisform.baru.enabled=.t.
thisform.keluar.enabled=.t.
endif
thisform.matiisian()
thisform.simpan.enabled=.f.
thisform.batal.enabled=.f.
thisform.txtcari.visible=.f.

13) Prosedure Rubah Clik


posisi=recno()
thisform.hidupisian()
thisform.matitombol()
thisform.simpan.enabled=.t.
thisform.batal.enabled=.t.
thisform. txtnonmsk.enabled=.f.
thisform. txttxtnmptgs.setfocus()
14) Prosedure Hapus Clik
tanya=messagebox("Yakin menghapus data ini..!",4+32,"Konfirmasi")
if tanya=6
select rincimsk
delete
cek=thisform.txtnonmsk.value
select masuk
delete all for nonmsk=cek
select rincimsk
endif
thisform.bersihlayar()
if .not. eof
skip
if eof()
goto bottom
endif
else
goto bottom
endif
thisform.grid1.refresh()
thisform.grid1.setfocus()
thisform.grid2.refresh()
thisform.ambildata()
15) Prosedure Atas Clik
select masuk
goto top
thisform.ambildata()
16) Prosedure Mundur Clik
select masuk
if bof()
messagebox("Posisi sudah di awal file...!",0+64,"Informasi")
goto top
else
skip -1
endif
thisform.ambildata()
17) Prosedure Maju Clik
select masuk
if .not. eof()
skip
else
messagebox("Posisi sudah di akhir file...!",0+64,"Informasi")
goto bottom
endif
thisform.ambildata()
18) Prosedure Bawah Clik
select masuk
goto bottom
thisform.ambildata()
19) Prosedure cari Clik
thisform.txtcari.visible=.t.
thisform.txtcari.setfocus()
20) Prosedure Set Focus txtcari
if .not. empty(thisform.txtcari.value)
lacak=thisform.txtcari.value
select masuk
locate for upper(alltrim(substr(nonmsk,1,len(nonmsk))))=upper(alltrim(lacak))
if found()
thisform.ambildata()
set filter to upper(alltrim(substr(nonmsk,1,len(lacak))))=upper(alltrim(lacak))
thisform.grid1.refresh()
else
messagebox("Data tidak ada/tidak ditemukan..!",0+64,"Informasi")
endif
thisform.txtcari.visible=.f.
endif
thisform.txtcari.value=""
21) Prosedure Keluar Clik
select masuk
set filter to
if delete()
pack
endif
thisform.release()

6. FORM BARANG RINCI BARANG MASUK


Untuk memulai membuat Form Rinci Barang Masuk langkah yang dilakukan sama
seperti membuat Form lainnya. Desainglah form hingga seperti gambar dibawah ini :

Gambar 4.9 Tampilan Form Rinci Barang Masuk

A. PROPERTI OBJECT
Nama Propertis Nilai
Object
Form Caption Transaksi Rinci Barang Masuk
Name Rinci Barang Masuk
Auto Center .T.
MDIForm .T.
ShowWindows 1-In Top-Level
Windowstate 0-Normal
Label1 Caption No Nota Masuk
Combo1 Caption Kode Barang
Label3 Caption Harga
Label4 Caption Jumlah
Text1 Name txtnonmsk
Maxlength 10
Combo1 Name TxtKdbrg
Text2 Name Txthrgmsk
Maxlength 10
Text3 Name Txtjumlah
Maxlength 10
Text4 Name Txtnmbarang
Text5 Name Txtcari
Maxlength 10
Command1 Name Baru
Caption \<Baru
Command2 Name Simpan
Caption \<Simpan
Command3 Name Batal
Caption \<Batal
Command4 Name Rubah
Caption \<Rubah
Command5 Name Hapus
Caption \<Hapus
Command6 Name Atas
Caption |<
Cammand7 Name Mundur
Caption <
Command8 Name Maju
Caption >
Command9 Name Bawah
Caption >|
Command10 Name Cari
Caption \<Cari
Grid1 Name Grid1
ReadOnly .T.
RecordSource rincimsk
B. PENULISAN CODE PROGRAM
Untuk penulisan Code program sama seperti code program form yang lainnya, namun
pada form ini kita menggunakan metode procedure
1) Prosedure Active Form
select barang
thisform.txtnonmsk.value=mnonmsk
thisform.txthrgmsk.value=0
thisform.txtjmlmsk.value=0
2) Prosedure Form Init
public mnonmsk,mhrgmsk,mkdkayu,mqtymsk
balik=0
3) Prosedure Ok Clik
balik=1
mkdbrg=thisform.txtkdbrg.value
mnonmsk=thisform.txtnonmsk.value
mjmlmsk=thisform.txtjmlmsk.value
mhrgmsk=thisform.txthrgmsk.value
select barang
set filter to
seek mkodebrg
if found()
replace jmlstok with jmlstok + mjmlmsk
replace hrgjual with mhrgmsk
endif
select rincimsk
set filter to
set order to nonmsk
locate for nonmsk=mnonmsk .and. kodebrg=mkdbrg
if found()
replace nonmsk with mnonmsk
replace jmlmsk with mjmlmsk
replace kodebrg with mkdbrg
replace hrgmsk with mhrgmsk
else
append blank
replace nonmsk with mnonmsk
replace jmlmsk with mjmlmsk
replace kodebrg with mkdbrg
replace hrgmsk with mhrgmsk
endif
thisform.txthrgmsk.value=0
thisform.txtjmlmsk.value=0
thisform.txtkdbrg.value=""
thisform.txtkdbrg.setfocus()
4) Prosedure keluar Clik
select rincimsk
set filter to
thisform.release()
5) Prosedure txtkodebrg Lost Focus Clik
mkdbrg=thisform.txtkdbrg.value
select barang
set filter to
set order to kodebrg
seek mkdbrg
if found()
thisform.txtnmbarang.value=nmbarang
thisform.txthrgmsk.value=hrgbeli
else
thisform.txtnmbarang.value=""
thisform.txthrgmsk.value=0
endif