Rabu, 25 Juli 2012

bikin form barang dengan Bahasa Pemprograman Voxpro


FORM BARANG
·         FORM
Init
PUBLIC baru,berhasil
baru=.t.
berhasil=.t.
            refresh
                        Scatter memvar
·         NEW.click
WITH thisform
      .txtKode.value=''
      .txtNama.value=''
      .txtHbeli.value=0
      .txtHjual.value=0
      .txtStok.value=0
      .cmbSatuan.value=''
      .buka()
      .txtKode.setfocus()
ENDWITH
baru=.t.

·         EDIT
Thisform.buka()
baru =.f.

·         SAVE
click
IF baru
      LOCATE FOR EMPTY(kode)
      IF !FOUND()
            APPEND BLANK
      ENDIF
endif

berhasil=.t.
GATHER memvar

IF berhasil
      thisform.tutup()
ELSe
      thisform.txtKode.SetFocus()
endif
thisform.Refresh()
                error
                                IF nerror==1884 then
      berhasil=.f.
      MESSAGEBOX('Kode '+m.kode+' sudah pernah digunakan.'+CHR(13)+'Masukkan kode lain',0+16,'Perhatian')
ELSE
      MESSAGEBOX('Terjadi kesalahan di nomor '+STR(nerror))
ENDIF

thisform.Refresh()

·         EDIT
Click
j=MESSAGEBOX('Anda yakin menghapus?',4+32,'Konfirmasi')
IF j==6
      DELETE
      IF berhasil=.t.
            PACK
            skip-1
            thisform.Refresh()
            MESSAGEBOX('Data sudah terhapus',0+64,'Informasi')
      endif
ELSE
      MESSAGEBOX('Data batal dihapus',0+64,'Informasi')
Endif

                Error
                                IF nerror==1539
                  berhasil=.f.
MESSAGEBOX('Maaf, tidak bisa dihapus'+CHR(13)+'Data sedang digunakan',0+48,'Perhatian')
ELSE
                  MESSAGEBOX('Terjadi kesalahan di nomor '+STR(nerror))
Endif

·         UNDO.click
thisform.tutup()
thisform.Refresh()

·         DELETE
Click
j=MESSAGEBOX('Anda yakin menghapus?',4+32,'Konfirmasi')
IF j==6
      DELETE
      IF berhasil=.t.
            PACK
            skip-1
            thisform.Refresh()
            MESSAGEBOX('Data sudah terhapus',0+64,'Informasi')
      endif
ELSE
      MESSAGEBOX('Data batal dihapus',0+64,'Informasi')
Endif
      Error
LPARAMETERS nError, cMethod, nLine
IF nerror==1539
      berhasil=.f.
      MESSAGEBOX('Maaf, tidak bisa dihapus'+CHR(13)+'Data sedang digunakan',0+48,'Perhatian')
ELSE
      MESSAGEBOX('Terjadi kesalahan di nomor '+STR(nerror))
endif

CARI BARANG
·         Txtkatakunci.interactivechange
IF !EMPTY(thisform.text1.Value)    
      IF thisform.combo1.Value='nama'
            SET FILTER TO UPPER(ALLTRIM(thisform.text1.value)) $UPPER(nama)
      ELSE
            SET FILTER TO UPPER(ALLTRIM(thisform.text1.value)) $UPPER(kode)
      ENDIF
ELSE
      SET FILTER TO
ENDIF
thisform.Refresh()


BELI
·         FORM
Init
SELECT barang
LOCATE FOR EMPTY(kode)
if !FOUND()
      APPEND BLANK
ENDIF

SELECT supplier
LOCATE FOR EMPTY(kodes)
IF !FOUND()
      APPEND blank
ENDIF


SET DATE BRITISH
PUBLIC kdlama
kdlama=.t.


SELECT beli
SET TALK OFF
SET DATE BRITISH
SET CENTURY on
SET SEPARATOR TO '.'
SET POINT TO ','
SET DELETED on
      Destroy
SELECT itemb
PACK
SELECT beli
Pack
      Refresh
thisform.text1.inputmask='999,999,999.-'
thisform.text1.Value=beli.total

·         Cmb.kodes
Interactivechange
KEYBOARD '{TAB}'
Lostvocus
thisform.refresh()

·         GRID1.Column1.text1àkode
Got Vocus
kdlama=itemb.kode

Valid
      IF !EMPTY(this.value)
            SELECT barang
            LOCATE FOR kode=this.Value
            IF FOUND()
                  IF this.Value != kdlama
                  SELECT itemb
                  replace itemb.qty WITH 1, itemb.harga WITH barang.hbeli,
                  itemb.jumlah WITH barang.hbeli
                  ENDIF
            ELSE
                  MESSAGEBOX('Maaf, kode '+this.value+' tidak
                  ada',0+16,'Perhatian')
                  this.value=''
                  SELECT itemb
                  replace itemb.qty WITH 0, itemb.harga WITH 0, itemb.jumlah
                  WITH 0
                  KEYBOARD '{leftarrow}'
            ENDIF
            SELECT itemb
            SUM itemb.jumlah TO thisform.txttotal.Value FOR
            itemb.no=thisform.txtno.value
endif

Lost Vocus
thisform.text1.InputMask='999,999,999.-'
thisform.text1.Value=thisform.txtTotal.value

Interactivechange
thisform.text1.InputMask=''
thisform.text1.Value=this.value

·         GRID1.Column3.text1àqty
Valid
replace itemb.jumlah WITH this.value*itemb.harga
SUM itemb.jumlah TO thisform.txttotal.Value FOR itemb.no=thisform.txtno.Value
Interactivechange & Lostvocus sama di GRID1.Column1.text1

·         GRID1.Column3.text1àharga
replace itemb.jumlah WITH itemb.qty*this.value
SUM itemb.jumlah TO thisform.txttotal.Value FOR itemb.no=thisform.txtno.Value
LOCATE FOR EMPTY(kode)
IF !FOUND()
      APPEND BLANK
ENDIF
replace itemb.no WITH thisform.txtno.Value
KEYBOARD '{DNARROW}'
Interactivechange & Lostvocus sama di GRID1.Column1.text1

·         NEW.click
SELECT beli
APPEND blank
replace tgl WITH DATE()
nomore=beli.no
SELECT itemb
LOCATE FOR EMPTY(kode)
      IF !FOUND()
            APPEND BLANK
      ENDIF
      replace no WITH nomore
thisform.buka()
thisform.Refresh()
thisform.cmbkodes.SetFocus()
SELECT beli

·         EDIT.click
SELECT itemb
LOCATE FOR no=thisform.txtno.Value
IF !FOUND()
      LOCATE FOR EMPTY(itemb.kode)
      IF !FOUND()
            APPEND BLANK
      ENDIF
      replace no WITH thisform.txtno.Value
ENDIF
SELECT itemb
SCAN FOR no=thisform.txtno.Value
      UPDATE barang SET stok=stok-itemb.qty WHERE kode=itemb.kode
ENDSCAN
SELECT beli
thisform.Refresh()
thisform.buka()
thisform.grid1.column1.SetFocus()

·         Undo.click
thisform.tutup()
thisform.Refresh()

·         DELETE
Click
IF j==6 then
      SELECT itemb
      SCAN FOR no=thisform.txtno.Value
            UPDATE barang SET stok=stok-itemb.qty WHERE
            kode=itemb.kode
            DELETE
      ENDSCAN
      SELECT beli
      DELETE
      MESSAGEBOX('Data telah terhapus',0+64,'Informasi')
      skip-1
      thisform.refresh()
ELSE
      MESSAGEBOX('Data batal dihapus',0+64,'Informasi')
endif
Error
IF nerror==1539
      berhasil=.f.
      MESSAGEBOX('Maaf, tidak bisa dihapus'+CHR(13)+'Data sedang
digunakan',0+48,'Perhatian')
ELSE
      MESSAGEBOX('Terjadi kesalahan di nomor '+STR(nerror))
endif

NOTABELI
·         Preview.click
tgl1=thisform.olecontrol1._Value
tgl2=thisform.olecontrol2._value
keterangan='Periode : '+DTOC(tgl1)+ ' s.d. '+ DTOC(tgl2)
SELECT notabeli
REQUERY()
IF !EOF()
      REPORT FORM rep_notabeli preview
ELSE
      MESSAGEBOX('Maaf, tidak ada data',0+48,'Perhatian')
endif

PROGRAMàUtama
SET DATE BRITISH
SET CENTURY on
SET TALK OFF
SET SEPARATOR TO '.'
SET POINT TO ','
SET EXCLUSIVE ON
PUBLIC kdlama, tgl1, tgl2, baru, keterangan
kdlama=''
tgl1=DATE()
tgl2=DATE()
baru=.t.
keterangan=''
MODIFY WINDOW screen title 'Inventory Engine' FILL FILE 'musikindo.jpg' NOMINIMIZE nogrow
ZOOM window screen max
DO menuku.mpr
READ events
SET SYSMENU TO DEFAULT

Tidak ada komentar:

Posting Komentar