Membuat Form Input

form_input.JPG
Form Inputan Stock menggunakan Visual Foxpro,contoh pengisian formulir

DEFINE CLASS Trans4LoadObj AS FORM
autocenter = .T. && disable display at center of the screen
height = 350
width = 500
borderstyle = 0  && no border (unsizeable)
caption = “[Adj -] DO’s Penjualan ke Outlet”
closable = .F.   &&close disable ok
desktop = .T.
maxbutton = .F.  && Disable Maximize Button on the upper right corner
minbutton = .F.
MDIform = .F.
showwindow = 1   && In Top Level Form
windowtype = 1   && modeless
windowstate = 0  && normal
showtips = .T.   && This property will effect controls to show the tooltiptext if available
icon = ‘arppm.ico’

ADD OBJECT Dtl_grid AS Dtl_gridObj

*** Control Button ***
ADD OBJECT UEGB AS COMMANDGROUP;
WITH;
top = 300,;
left = 10,;
width = 425,;
height = 25,;
borderstyle = 0,;
visible=.T.
*** End of Control Button ***

ADD OBJECT sj_say AS LABEL;
WITH;
alignment = 0,;       && Left Alignment
top = 10,;
left = 10,;
width = 105,;
height = 20,;
caption = ‘No DO:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT sj_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 10,;
left = 115,;
width = 65,;
height = 18,;
margin = 0,;     && no margin
maxlength = 8,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Nomor DO Tarikan / 8 Karakter AlfaNumeric…. ‘

ADD OBJECT sjl_say AS LABEL;
WITH;
alignment = 0,;       && Left Alignment
top = 30,;
left = 10,;
width = 105,;
height = 20,;
caption = ‘Tgl Srt.Jalan:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT sjl_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 30,;
left = 115,;
width = 65,;
height = 18,;
margin = 0,;     && no margin
value = date(),;
maxlength = 10,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
enabled = .f.,;
tooltiptext = ‘Tanggal Surat Jalan… ‘

ADD OBJECT trm_say AS LABEL;
WITH;
alignment = 0,;       && Left Alignment
top = 50,;
left = 10,;
width = 105,;
height = 20,;
caption = ‘Tgl Kirim.Brg:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT trm_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 50,;
left = 115,;
width = 65,;
height = 18,;
margin = 0,;     && no margin
value = date(),;
maxlength = 10,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
enabled = .f.,;
fontbold = .T.,;
tooltiptext = ‘Tanggal Kirim Barang… ‘

ADD OBJECT mcustid_say AS LABEL;
WITH;
alignment = 0,;       && Left Alignment
top = 10,;
left = 185,;
width = 105,;
height = 20,;
caption = ‘Cust.Id:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT mcustid_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 10,;
left = 240,;
width = 88,;
height = 18,;
margin = 0,;     && no margin
maxlength = 20,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
enabled = .f.,;
tooltiptext = ‘Customer Id… ‘

ADD OBJECT custom_say AS LABEL;
WITH;
alignment = 0,;       && Left Alignment
top = 30,;
left = 185,;
width = 105,;
height = 20,;
caption = ‘Outlet:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT custom_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 30,;
left = 240,;
width = 250,;
height = 18,;
margin = 0,;     && no margin
maxlength = 150,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
enabled = .f.,;
fontbold = .T.,;
tooltiptext = ‘Nama Outlet Isu By… ‘

ADD OBJECT sales_say AS LABEL;
WITH;
alignment = 0,;       && Left Alignment
top = 50,;
left = 185,;
width = 105,;
height = 20,;
caption = ‘Sales:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT sales_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 50,;
left = 240,;
width = 200,;
height = 18,;
margin = 0,;     && no margin
maxlength = 50,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Sales Force By… ‘

ADD OBJECT adrs_get AS TEXTBOX;
WITH;
alignment = 0,;    && center
top = 290,;
left = 240,;
width = 250,;
height = 50,;
margin = 0,;     && no margin
maxlength = 500,;
format = ‘!’,;
fontname = ‘Arial’,;
forecolor= RGB(0,0,255),;
fontsize = 7,;
fontbold = .T.,;
tooltiptext = ‘Alamat Lengkap… ‘

* ======================
* event init / hendler
* ———————-
PROC Init()
SELECT dt_temp
SET ORDER TO 1
ZAP
FOR t = 1 TO 10
APPEND BLANK
NEXT
SET ORDER TO
GO top
ENDPROC

*** Init Event of COMMAND GROUP ***
PROC UEGB.init()
this.addobject(‘prosbutton’,’prosesObj’)
this.addobject(‘cleabutton’,’clearObj’)
this.addobject(‘prinbutton’,’printObj’)
this.addobject(‘exitbutton’,’exitObj’)
ENDPROC

***
PROCEDURE sj_get.init()
this.Parent.Dtl_grid.enabled = .f.
this.Parent.UEGB.prosbutton.enabled = .f.
this.Parent.UEGB.cleabutton.enabled = .f.
this.Parent.UEGB.prinbutton.enabled = .f.
this.setfocus
ENDPROC
PROCEDURE sj_get.lostfocus()
this.Enabled = .f.
ENDPROC
PROCEDURE sj_get.valid()
LOCAL msj,ids,slf
msj = this.value
SELECT iv_head
SET ORDER TO 1
SEEK msj+’D1′
IF FOUND()
this.Parent.sjl_get.value = iv_head.tgl_sj
this.Parent.sjl_get.enabled = .f.
this.Parent.trm_get.value = iv_head.tgl_kr
this.Parent.trm_get.enabled = .f.
this.Parent.mcustid_get.value = iv_head.custid
this.Parent.mcustid_get.enabled = .f.
this.Parent.custom_get.value = iv_head.expedisi
this.parent.custom_get.enabled =.f.
this.Parent.sales_get.value = iv_head.checker
this.Parent.sales_get.enabled = .f.
ids = iv_head.custid
SELECT customer
SET ORDER TO 1
SEEK ids
IF FOUND()
this.Parent.adrs_get.value = ALLTRIM(customer.name)+’ ‘+ALLTRIM(customer.address1)+’ ‘+ALLTRIM(customer.address2)+’ => ‘+ALLTRIM(customer.saddress1)+’ ‘+ALLTRIM(customer.saddress2)
ENDIF
this.Parent.adrs_get.enabled = .f.
this.Parent.UEGB.cleabutton.enabled =.t.
this.Parent.UEGB.prinbutton.enabled =.t.
SELECT dt_temp
ZAP
PACK
SELECT iv_deti
SET ORDER TO 1
GO top
DO WHILE !EOF()
IF oeno=msj .and. type =’D1′
SELECT dt_temp
APPEND BLANK
REPLACE item WITH iv_deti.item,pn WITH iv_deti.pn,desc WITH iv_deti.desc,qtyshp WITH iv_deti.qty
*****/sg
endif
SELECT iv_deti
skip
ENDDO
SELECT iv_temp
GO top
this.Parent.dtl_grid.refresh
this.Parent.dtl_grid.enabled = .t.
messagebox(“Nomor DO Penjualan “+ALLTRIM(msj)+” Sudah Ada !”,48,”Penting Perhatikan !”)
RETURN .t.
ELSE
SELECT dt_temp
ZAP
PACK
SELECT codet
SET ORDER TO 3
GO top
SET NEAR ON
SEEK msj
SET NEAR OFF
IF FOUND()
DO WHILE oeno = msj .and. !EOF()
SELECT dt_temp
APPEND BLANK
REPLACE item WITH codet.item,duedate WITH codet.duedate,pn WITH codet.pn,desc WITH codet.desc,qtyshp WITH codet.qtyshp,custid WITH codet.custid,customer WITH codet.customer
*****/sg
SELECT codet
skip
ENDDO
ELSE
messagebox(“Nomor DO Penjualan “+ALLTRIM(msj)+” Tidak Ada di Cas3 !”,48,”Penting Perhatikan !”)
RETURN .t.
ENDIF
SELECT dt_temp
GO top
ids = dt_temp.custid
this.Parent.sjl_get.value = dt_temp.duedate
this.Parent.trm_get.value = dt_temp.duedate
this.Parent.mcustid_get.value = dt_temp.custid
SELECT customer
SET ORDER TO 1
GO top
SEEK ids
IF FOUND()
this.parent.custom_get.value = customer.name
this.Parent.adrs_get.value = ALLTRIM(customer.name)+’ ‘+ALLTRIM(customer.address1)+’ ‘+ALLTRIM(customer.address2)+’ => ‘+ALLTRIM(customer.saddress1)+’ ‘+ALLTRIM(customer.saddress2)
ELSE
this.parent.custom_get.value = ”
ENDIF
SELECT comast
SET ORDER TO 1
SEEK msj
IF FOUND()
slf = comast.salesman
SELECT salesman
SET ORDER TO 1
SEEK slf
IF FOUND()
this.Parent.sales_get.value = slf+’ => ‘+salesman.name
ELSE
this.parent.sales_get.value = ”
ENDIF
ELSE
this.parent.sales_get.value = ”
ENDIF
this.Parent.trm_get.enabled = .t.
this.Parent.sales_get.enabled = .t.
this.Parent.dtl_grid.refresh
RETURN .t.
ENDIF
ENDPROC
PROCEDURE sales_get.lostfocus()
this.Parent.Dtl_grid.enabled = .t.
this.Parent.Dtl_grid.setfocus
this.Parent.UEGB.prosbutton.enabled = .t.
this.Parent.UEGB.cleabutton.enabled = .t.
this.Parent.UEGB.prinbutton.enabled = .t.
ENDPROC
PROCEDURE trm_get.valid
LOCAL tk,ts
ts = this.Parent.sjl_get.value
tk = this.value
IF tk >= ts
RETURN .t.
ELSE
messagebox(“Tanggal Kirim Lebih Muda dari Tgl Surat Jalan!”,48,”Penting Perhatikan !”)
RETURN .t.
ENDIF
ENDPROC
ENDDEFINE

DEFINE CLASS ProsesObj AS COMMANDBUTTON
caption = ‘\<Proses’
top = 0
left = 0
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Proses Posting…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
LOCAL msj,mtgl1,mtgl2,mnobi,mekpe,mcheq,okey
msj = this.Parent.parent.sj_get.value
mtgl1 = this.parent.parent.sjl_get.value
mtgl2 = this.Parent.parent.trm_get.value
mnobi = this.Parent.parent.mcustid_get.value
mekpe = this.Parent.parent.custom_get.value
mcheq = this.Parent.parent.sales_get.value
okey = messagebox(“Apakah Data Tersebut Sudah Benar & akan Prosess ?”,1,”Penting Perhatikan !”)
IF okey = 1
SELECT dt_temp
GO top
IF dt_temp.qtyshp < 0
messagebox(“Tidak Biasa Proses Karena No tersebut Berupa CN Penjualan!”,48,”Penting Perhatikan !”)
this.Parent.parent.sj_get.enabled = .t.
this.Parent.parent.sj_get.setfocus
RETURN .f.
ENDIF
SELECT iv_head
SET ORDER TO 1
SEEK msj+’D1′
IF !FOUND()
* to header history *
APPEND BLANK
REPLACE oeno WITH msj,type WITH ‘D1′,tgl_sj WITH mtgl1,tgl_kr WITH mtgl2,custid WITH mnobi,expedisi WITH mekpe,checker WITH mcheq
*****/sg
* to detail history & Master *
SELECT dt_temp
GO top
DO WHILE !EOF()
IF dt_temp.qtyshp = 0 .or. EMPTY(dt_temp.item) .or. EMPTY(dt_temp.pn)
*
ELSE
SELECT iv_deti
SET ORDER TO 1
SEEK msj+’D1′+dt_temp.item+dt_temp.pn
IF !FOUND()
APPEND BLANK
REPLACE oeno WITH msj,type WITH ‘D1′,tgl WITH mtgl2, item WITH dt_temp.item,pn WITH dt_temp.pn,desc WITH dt_temp.desc, qty WITH dt_temp.qtyshp
*****/sg
ENDIF
SELECT iv_mast
SET ORDER TO 1
SEEK DTOS(mtgl2)+dt_temp.pn
IF !FOUND()
APPEND BLANK
REPLACE tgl WITH mtgl2,pn WITH dt_temp.pn,desc WITH dt_temp.desc,ou_coe_d1 WITH dt_temp.qtyshp
*****/sg
ELSE
REPLACE ou_coe_d1 WITH ou_coe_d1+dt_temp.qtyshp
*****/sg
ENDIF
ENDIF
SELECT dt_temp
skip
ENDDO
messagebox(“Prosess Complete,Exit untuk Selesai “,48,”Pesan”)
this.Parent.parent.sj_get.enabled = .t.
this.Parent.parent.sj_get.setfocus
this.Parent.parent.Dtl_grid.enabled = .f.
this.Parent.prosbutton.enabled = .f.
this.Parent.cleabutton.enabled = .f.
this.Parent.prinbutton.enabled = .f.
* clear form *
this.Parent.parent.sj_get.value = ”
this.Parent.parent.mcustid_get.value = ”
this.Parent.parent.custom_get.value = ”
this.Parent.parent.sales_get.value = ”
this.Parent.parent.adrs_get.value = ”
SELECT dt_temp
SET ORDER TO 1
ZAP
FOR t = 1 TO 10
APPEND BLANK
NEXT
SET ORDER TO
GO top
ELSE
messagebox(“Surat Jalan DO Penjualan Nomor “+ALLTRIM(msj)+” Sudah Ada !”,48,”Pesan!”)
this.Parent.parent.Dtl_grid.setfocus
endif
ELSE
this.Parent.parent.Dtl_grid.setfocus
ENDIF
ENDPROC
ENDDEFINE

DEFINE CLASS ClearObj AS COMMANDBUTTON
caption = ‘\<Clear’
top = 0
left = 52
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Clearing Form – New Entry…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
* clearing form *
SELECT dt_temp
SET ORDER TO 1
ZAP
FOR t = 1 TO 10
APPEND BLANK
NEXT
SET ORDER TO
GO top
this.Parent.parent.Dtl_grid.enabled = .f.
this.Parent.prosbutton.enabled = .f.
this.Parent.cleabutton.enabled = .f.
this.Parent.prinbutton.enabled = .f.
this.Parent.parent.mcustid_get.value=”
this.Parent.parent.custom_get.value=”
this.Parent.parent.sj_get.value=”
this.Parent.parent.adrs_get.value = ”
this.Parent.parent.sales_get.value = ”
this.Parent.parent.sj_get.enabled=.t.
this.Parent.parent.sj_get.setfocus
ENDPROC
ENDDEFINE

DEFINE CLASS PrintObj AS COMMANDBUTTON
caption = ‘P\<rint’
top = 0
left = 104
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Printing Form…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
*
ENDPROC
ENDDEFINE

DEFINE CLASS ExitObj AS COMMANDBUTTON
caption = ‘E\<xit’
top = 0
left = 155
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Exit…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
CLOSE DATABASES
this.parent.parent.release()
ENDPROC
ENDDEFINE

DEFINE CLASS gridcolumn1 AS COLUMN
bound = .T.
resizable = .F.
fontname = ‘Arial’
fontsize = 8
fontbold = .F.
selectonentry = .T.
visible = .T.

ADD OBJECT text1 AS TEXTBOX

PROCEDURE text1.init
this.margin = 0
this.borderstyle = 0
this.fontname = this.parent.fontname
this.fontsize = this.parent.fontsize
this.fontbold = this.parent.fontbold
ENDPROC
ENDDEFINE

DEFINE CLASS gridcolumn2 AS COLUMN
bound = .T.
resizable = .F.
fontname = ‘Arial’
fontsize = 8
fontbold = .F.
selectonentry = .T.
visible = .T.

ADD OBJECT text1 AS TEXTBOX

PROCEDURE text1.init()
this.margin = 0
this.borderstyle = 0
this.fontname = this.parent.fontname
this.fontsize = this.parent.fontsize
this.fontbold = this.parent.fontbold
ENDPROC
PROCEDURE text1.valid()
LOCAL nilai
nilai = this.value
IF nilai < 0
MESSAGEBOX(“Nilai tidak boleh Negatif”,48,”Pesan”)
RETURN .f.
ELSE
RETURN .t.
ENDIF
ENDPROC
ENDDEFINE

DEFINE CLASS Dtl_gridObj AS GRID
top = 80
left = 10
width = 480
height = 200
columncount = 0             && start setting the columncount property with 0
allowaddnew = .F.           && disallow adding new record to the table
allowheadersizing = .F.     && disallow resizing the header at run time
allowrowsizing = .F.        && disallow resizing the row size at run time
headerheight = 18
rowheight = 18
scrollbars = 2              && Vertical only
recordmark = .F.            && hide record mark column on the grid
deletemark = .F.            && hide delete mark column on the grid
recordsourcetype = 1        && Use Alias to specified the table
recordsource = ‘dt_temp’    && Alias name : ‘dt_temp’

PROCEDURE init
this.addobject(‘column1′,’gridcolumn1′)
WITH this.column1
.controlsource = ‘dt_temp.item’
.width = 30
.alignment = 1
.readonly = .T.               && Read Only Column
.enabled = .T.                && enabled the column to get focus
WITH .header1                 && Header
.caption = ‘Item’
.alignment = 2             && center
.fontname = ‘Arial’
.fontsize = 8
.fontbold = .T.
ENDWITH
ENDWITH

this.addobject(‘column2′,’gridcolumn1′)
WITH this.column2
.controlsource = ‘dt_temp.pn’
.width = 90
.alignment = 0                && left
.readonly = .T.               && Read Only Column
.enabled = .T.                && enabled the column to get focus
WITH .header1                 && Header
.caption = ‘Part’
.alignment = 2             && center
.fontname = ‘Arial’
.fontsize = 8
.fontbold = .T.
ENDWITH
ENDWITH

this.addobject(‘column3′,’gridcolumn1′)
WITH this.column3
.controlsource = ‘dt_temp.desc’
.width = 250
.alignment = 0                && right
.readonly = .T.               && Read Only Column
.enabled = .T.                && enabled the column to get focus
WITH .header1                 && Header
.caption = ‘Desc’
.alignment = 2             && center
.fontname = ‘Arial’
.fontsize = 8
.fontbold = .T.
ENDWITH
ENDWITH

this.addobject(‘column4′,’gridcolumn2′)
WITH this.column4
.controlsource = ‘dt_temp.qtyshp’
.width = 80
.alignment = 1                && right
.inputmask = ’9999.9999′
.readonly = .F.               && Read Only Column
.enabled = .T.                && enabled the column to get focus
WITH .header1                 && Header
.caption = ‘Qty’
.alignment = 2             && center
.fontname = ‘Arial’
.fontsize = 8
.fontbold = .T.
ENDWITH
ENDWITH
ENDDEFINE

About these ads
This entry was posted in Programming. Bookmark the permalink.

One Response to Membuat Form Input

  1. havban says:

    Duh panjang sekali untuk program seperti itu..

    Apa tidak ada layering dan re-using object?

    /:)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s