Hi there,
I'm trying to change a record, and then add New record to the same table.
I did it using the Xdialog, and the data are reflected in the sub-form.
However, I would need to press F9 to save the content to the table.
Did I do anything wrong with the script below...???
Or did I used the Change_Begin ... Change_End & Enter_Begin ... Enter_End incorrectly??? any suggestions...
I'm trying to change a record, and then add New record to the same table.
I did it using the Xdialog, and the data are reflected in the sub-form.
However, I would need to press F9 to save the content to the table.
Did I do anything wrong with the script below...???
Or did I used the Change_Begin ... Change_End & Enter_Begin ... Enter_End incorrectly??? any suggestions...
PHP Code:
'Date Created: 21-Feb-2008 20:29:00 PM
'Last Updated: 22-Feb-2008 12:59:13 AM
'Created By :
'Updated By :
'Create an XDialog dialog box to prompt for parameters.
'In order to evaluate expressions using the eval() function, in the context of
'the current form, the "form_name" variable is defined.
DIM form_name as C
if is_object(topparent.this) then
form_name = topparent.name()+".this"
else
form_name = ""
end if
dim t1 as P
t1 = table.get("EStkloc")
t1.fetch_first()
'Stkloc Values ...
DIM SHARED Vlocno AS c
VLocno = topparent:Browse4:Stklocno.value
trace.WriteLn("Vlocno = "+Vlocno )
DIM SHARED Vstkinno AS c
Vstkinno = topparent:Browse4:Stkinno.value
trace.WriteLn("Vstkinno = "+Vstkinno)
DIM SHARED Vsupno AS c
Vsupno = topparent:Browse4:Supno.value
Trace.WriteLn("Vsupno = "+Vsupno)
DIM SHARED Vprodno AS c
Vprodno = topparent:Browse4:Prodno.value
DIM SHARED VStklocdate AS d
VStkLocdate = topparent:Browse4:Stklocdate.value
DIM SHARED VStklocatn AS c
VStkLocatn = topparent:Browse4:Stkloclocations.value
DIM SHARED VLocind AS n
VLocind = topparent:Browse4:Stklocind2.value
dim shared recnum as N
dim thiskey as C
DIM SHARED VLocDate as D
DIM SHARED VLoc as C
DIM SHARED VTag as C
DIM SHARED varC_result as C
DELETE expression_result
expression_result = eval("date()",form_name)
VLocDate = convert_type(expression_result,"D")
VLoc = ""
heading_string = "Select TAG"
footer_string = "3333"
ok_button_label = "&OK"
cancel_button_label = "&Cancel"
DIM VLoc_rl_def as C
VLoc_rl_def = "k=rackloc,{keylist_build(\"H=.025,1:21[STORE]\",''+Raklocnam,left(''+Raklocnam,21))}{.t. .and. unique_key_value()}"
DIM VTag_rl_def_orig as C
VTag_rl_def_orig = "k=rackloc,{keylist_build(\"H=.025,1:21[Rack Tag]\",''+Rakloctag,left(''+Rakloctag,21))}{Raklocnam = [varC->VLoc]}"
DIM VTag_rl_def as C
VTag_rl_def = replace_parameters(VTag_rl_def_orig,local_variables())
varC_result = ui_dlg_box("Locations",<<%dlg%
{region}
{text=36,1:heading_string};
{endregion};
{region}
Stkloc No:| {text=Vlocno};
Stkin No:| {text=Vstkinno};
Sup No| {text=Vsupno};
Prod No| {text=Vprodno};
Loc Date| {text=Vstklocdate};
Locations| {text=Vstklocatn};
{lf};
{endregion};
{region}
Select STORE:| [%@VLoc_rl_def%.21VLoc!VLoc_changed];
Select TAG:| [%@VTag_rl_def%.21VTag];
{endregion};
{region}
{text=36,1:footer_string};
{endregion};
{line=1,0};
{region}
<15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
{endregion};
%dlg%,<<%code%
'
''
'''
' BELOW three sets of IF...END IF, which are used to "CHANGE" focus for the input
' Dialog box selection criteria...
'''
''
'
if left(a_dlg_button,9) = "VLocDate" then
if a_dlg_button = "VLocDate_killfocus" then
VLocDate = ctod(dtoc(VLocDate))
end if
a_dlg_button = ""
end if
If a_dlg_button = "VLocDate_changed" then
VTag_rl_def = replace_parameters(VTag_rl_def_orig,local_variables())
a_dlg_button = ""
end if
If a_dlg_button = "VLoc_changed" then
VTag_rl_def = replace_parameters(VTag_rl_def_orig,local_variables())
a_dlg_button = ""
end if
'
''
'''
' On "OK" pressed, the following statements will be executed. Otherwise, the Dialog
' box will keep displaying.
'''
''
'
If a_dlg_button = "OK" then
dim indx_1 as P
indx_1 = t1.index_primary_put("Reloc")
'Browse2/Stkin Values ...
DIM SHARED VB2NO AS c
VB2NO = topparent:Browse2:Stkinno.value
DIM SHARED VB2BAL AS n
VB2BAL = Topparent:Browse2:Withdraw.value
DIM SHARED VB2QTY AS n
VB2QTY = topparent:Browse2:Qty_in.value
thiskey = Alltrim(VB2NO)+","+VLocind
trace.WriteLn("tis key = "+thiskey)
recnum = t1.fetch_find(thiskey)
Trace.WriteLn("LocInput3 RECNUM = "+recnum)
Trace.WriteLn("END>>>")
IF recnum > 0 then
'record exits
ui_msg_box("Record Exists","Only one record may be assigned here.",UI_INFORMATION_SYMBOL+UI_OK)
IF (VB2Qty - VB2Bal) <= 0 then
ui_msg_box("EMPTY RECORD","Stock empty or Dummy record... Please select a Valid Record.",UI_INFORMATION_SYMBOL+UI_OK)
END
end if
trace.WriteLn("STARTS ... ")
t1.fetch_first()
t1.change_begin(.t.)
' t1.stkloclocations = VTag
t1.stkchgdate = date()
t1.stklocind2 = 2
t1.change_end(.t.)
Trace.WriteLn("Change = "+t1.stkchgdate)
't1.fetch_eof()
sleep(2)
t1.enter_begin(.t.)
Trace.WriteLn("NEW REC")
t1.stkinno = Vstkinno
t1.supno = Vsupno
t1.Prodno = Vprodno
t1.Stklocdate = date()
t1.Stkloclocations = VTag
t1.stklocind = 2
t1.stklocind2 = 1
DIM SHARED VTem2 AS c
VTem2 = topparent:Browse2:Stkinno.value
trace.WriteLn("Stkinno 1 = "+VTem1)
t1.enter_end(.T.)
t1.close()
end
else
' Record Does Not Exist. Entry is ok
If VB2No = "" then
ui_msg_box("NO RECORD FOUND","Invalid Assignment... Please select a Valid record.",UI_INFORMATION_SYMBOL+UI_OK)
END
end if
IF (VB2Qty - VB2Bal) <= 0 then
ui_msg_box("EMPTY RECORD","Stock empty or Dummy record... Please select a Valid Record.",UI_INFORMATION_SYMBOL+UI_OK)
END
end if
ui_msg_box("REcord does not exist","You may be allow to allocate",UI_INFORMATION_SYMBOL+UI_OK)
' end
end if
end if
If a_dlg_button = "CANCEL" then
END
end if
END
%code%)
Comment