Hi
Im new to xbasic..
I wrote this event and everything works apart from it runs regardless whether i press Ok or Cancel.
COuld someone please advise on the if statement i have used and why id doesnt work.. the code with the if statement ive copied here actually does nothing now!!
FUNCTION Oid_ButtonClick AS V ( event AS C, data AS C , row AS N )
'DESCRIPTION: Fired when a button is clicked on a column.
'Arguments: event - the name of the event that is fired
' data - the data in the column cell
' row - the row number in the browse
'this.SetViewport_Row() sets the current row to the row with the button that was clicked.
this.Set_Viewport_row(row)
'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 SHARED vCodate as D
DIM SHARED vCoamount as N
DIM SHARED vPaid as L
DIM SHARED varC_result as C
DELETE expression_result
expression_result1 = eval("date()",form_name)
vCodate = convert_type(expression_result1,"D")
DELETE expression_result
expression_result2 = eval("Tbl_Orders->Ocommoutst",form_name)
vCoamount = convert_type(expression_result2,"N")
heading_string = "Please fill in the fields below"
ok_button_label = "&OK"
cancel_button_label = "&Cancel"
varC_result = ui_dlg_box("Pay Commission",<<%dlg%
{region}
{text=55,1:heading_string};
{endregion};
{region}
Date:| [%DATE;P=popup.calendar(dtoc(vCodate));I=popup.calendar%.40vCodate!vCodate_*];
Pay ammount:| [%Z;P=popup.calculator(vCoamount);I=popup.calculator%.40vCoamount];
Paid?:| (40vPaid);
{endregion};
{line=1,0};
{region}
<*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
{endregion};
%dlg%,<<%code%
if left(a_dlg_button,8) = "vCodate_" then
if a_dlg_button = "vCodate_killfocus" then
vCodate = ctod(dtoc(vCodate))
end if
a_dlg_button = ""
end if
%code%)
if (vCoamount <> 0 and var->varC_result="OK") then
dim tbl as p
tbl = table.open("tbl_commission",FILE_RW_SHARED)
tbl.enter_begin()
tbl.DID = a5_eval_expression("=Did",local_variables())
tbl.CODATE = convert_type(vCodate,"Date")
tbl.COAMOUNT = convert_type(vCoamount,"Numeric")
tbl.COPAID = convert_type(vPaid,"Logical")
tbl.OID = data
tbl.enter_end(.t.)
tbl.close()
end if
'topparent.Commit()
topparent.Resynch()
topparent.Refresh_Layout()
this.Set_Viewport_row(row)
END FUNCTION
Im new to xbasic..
I wrote this event and everything works apart from it runs regardless whether i press Ok or Cancel.
COuld someone please advise on the if statement i have used and why id doesnt work.. the code with the if statement ive copied here actually does nothing now!!
FUNCTION Oid_ButtonClick AS V ( event AS C, data AS C , row AS N )
'DESCRIPTION: Fired when a button is clicked on a column.
'Arguments: event - the name of the event that is fired
' data - the data in the column cell
' row - the row number in the browse
'this.SetViewport_Row() sets the current row to the row with the button that was clicked.
this.Set_Viewport_row(row)
'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 SHARED vCodate as D
DIM SHARED vCoamount as N
DIM SHARED vPaid as L
DIM SHARED varC_result as C
DELETE expression_result
expression_result1 = eval("date()",form_name)
vCodate = convert_type(expression_result1,"D")
DELETE expression_result
expression_result2 = eval("Tbl_Orders->Ocommoutst",form_name)
vCoamount = convert_type(expression_result2,"N")
heading_string = "Please fill in the fields below"
ok_button_label = "&OK"
cancel_button_label = "&Cancel"
varC_result = ui_dlg_box("Pay Commission",<<%dlg%
{region}
{text=55,1:heading_string};
{endregion};
{region}
Date:| [%DATE;P=popup.calendar(dtoc(vCodate));I=popup.calendar%.40vCodate!vCodate_*];
Pay ammount:| [%Z;P=popup.calculator(vCoamount);I=popup.calculator%.40vCoamount];
Paid?:| (40vPaid);
{endregion};
{line=1,0};
{region}
<*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
{endregion};
%dlg%,<<%code%
if left(a_dlg_button,8) = "vCodate_" then
if a_dlg_button = "vCodate_killfocus" then
vCodate = ctod(dtoc(vCodate))
end if
a_dlg_button = ""
end if
%code%)
if (vCoamount <> 0 and var->varC_result="OK") then
dim tbl as p
tbl = table.open("tbl_commission",FILE_RW_SHARED)
tbl.enter_begin()
tbl.DID = a5_eval_expression("=Did",local_variables())
tbl.CODATE = convert_type(vCodate,"Date")
tbl.COAMOUNT = convert_type(vCoamount,"Numeric")
tbl.COPAID = convert_type(vPaid,"Logical")
tbl.OID = data
tbl.enter_end(.t.)
tbl.close()
end if
'topparent.Commit()
topparent.Resynch()
topparent.Refresh_Layout()
this.Set_Viewport_row(row)
END FUNCTION
Comment