Monday, October 6, 2008

Using User Event ( ue_add) to define or adding rows

I usually use this script in windows ancestor by define custom event ( user event), this script prepare the windows for adding rows

If dw_1.AcceptText() = -1 then
MessageBox('Message','Header not complete...')
return
end if

dw_1.enabled=true
dw_1.Object.DataWindow.ReadOnly = false

If (dw_1.modifiedcount() > 0 Or dw_1.deletedCount() > 0) and &
imn_mymenu.m_file.m_save.enabled then
if messagebox("Informasi","Data harus disimpan terlebih "+&
"dahulu...Simpan?", Question!,YesNo!,2) = 1 then
triggerevent("ue_save")
end if
end if
dw_1.reset()

dw_1.scrolltorow(dw_1.insertrow(0))

if hdr_autoinc = true then
header_id ++
dw_1.SetItem(dw_1.GetRow(),hdr_pk1,header_id)
dw_1.SetTabOrder(hdr_pk1,0)
dw_1.SetColumn(hdr_set)
Else
dw_1.SetTabOrder(hdr_pk1,10)
If hdr_pk2 <> '' then
dw_1.SetTabOrder(hdr_pk2,20)
End if
If hdr_pk3 <> '' then
dw_1.SetTabOrder(hdr_pk3,30)
End if
dw_1.SetColumn(hdr_pk1)
dw_1.SetFocus()
End if
ibl_add = true

No comments: