1.extends runbase
class THK_DialogSelectiveLookup extends RunBase
{
FormStringControl custGroupCtrl, customerCtrl;
custGroupId _custGroupId;
custAccount _custAccount;
#define.CurrentVersion(1)
#define.Version1(1)
#localmacro.CurrentList
_custGroupId,_custAccount
#endmacro
}
2.Dialog
protected Object dialog(Dialog dialog, boolean forceOnClient)
{
DialogRunBase ret;
;
ret = super(dialog, forceOnClient);
ret.caption("Test lookup in Dialog");
custGroupCtrl = ret.formBuildDesign().addControl(FormControlType::String, 'CustGroup');
custGroupCtrl.extendedDataType(extendedTypeNum(custGroupId));
custGroupCtrl.text(_custGroupId);
customerCtrl = ret.formBuildDesign().addControl(FormControlType::String, 'Customer');
customerCtrl.extendedDataType(extendedTypeNum(custAccount));
customerCtrl.text(_custAccount);
return ret;
}
3.getFromDialog
public boolean getFromDialog()
{
boolean ret;
ret = super();
_custGroupId = custGroupCtrl.text();
_custAccount = customerCtrl.valueStr();
return ret;
}
4.pack
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
5.unpack
public boolean unpack(container _packedClass)
{
Version version = RunBase::getVersion(_packedClass);
boolean ret;
;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = _packedClass;
ret = true;
break;
default:
ret = false;
}
return ret;
}
6.dialogPostRun
public void dialogPostRun(DialogRunbase dialog)
{
;
super(dialog);
dialog.dialogForm().formRun().controlMethodOverload(true);
dialog.dialogForm().formRun().controlMethodOverloadObject(this);
custGroupCtrl = dialog.dialogForm().formRun().design().controlName('CustGroup');
customerCtrl = dialog.dialogForm().formRun().design().controlName('Customer');
}
7.validate
public boolean Customer_validate()
{
;
info(funcName());
return true;
// validation code goes here
}
//ote: The format of the event method name is as follows: fld<ID>_1_<event name>
8.lookup
void Customer_lookup()
{
Query q = new Query();
queryBuildRange qbr;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), customerCtrl);
;
//info(funcName());
sysTableLookup.addLookupField(fieldNum(custTable, accountNum));
sysTableLookup.addLookupField(fieldNum(custTable, name));
qbr = q.addDataSource(tableNum(custTable)).addRange(fieldNum(CustTable, CustGroup));
qbr.value(custGroupCtrl.text());
sysTableLookup.parmQuery(q);
sysTableLookup.performFormLookup();
}
9.modified
//We can add all the other methods as follows
public void Customer_modified()
{
;
info(funcName());
// modify code goes here
}
//ote: The format of the event method name is as follows: fld<ID>_1_<event name>
10.run
public void run()
{
;
info(strfmt("customer group id : %1 ; customer account : %2",_custGroupId,_custAccount));
}
11.main
static void main(Args _args)
{
THK_DialogSelectiveLookup test1 = new THK_DialogSelectiveLookup();
;
if (test1.prompt())
{
test1.run();
}
}
没有评论:
发表评论