目标:要求可以选择多行订单,然后检查每个订单得每一个订单行的净金额是否为空。
用的是一个MenuItem,多选必须设定为Yes,然后重载clicked方法
Code/实现代码 :
FormDataSource fds ;
SalesTable _salesTable,_salesTable1,_salesTable2 ;
SalesLine _salesLine ;
Anytype salesidtemp[] ;
str salesidall,sqltemp ;
int a = 1 ;
int b = 1 ;
boolean WarningYes = false ;
;
//super();
fds = element.dataSource(1);
_salesTable1 = fds.getFirst(1) ;
_salesTable2 = fds.getNext() ;
// Judge single or multi SalesOrder
//Single SalesOrder process method: use SalesTable_SalesIdAdvanced.text() to get single SalesOrder SalesId.
if(_salesTable1.SalesId == _salesTable2.SalesId)
{
while select _salesLine where _salesLine.LineAmount == 0 && _salesLine.SalesId == SalesTable_SalesIdAdvanced.text()
{
box::warning('Sales Order ID '+ any2str(_salesLine.SalesId) + ' Sales Line '+ int2str(_salesline.HDSH_OrderLineNum) + ' Amount is Null, Please Check it!','Warning!!');
WarningYes = true ;
}
}
else
{
//It can't process single SalesOrder, only can process multi SalesOrder; use For sentence to get all SalesId
for( _salesTable=fds.getFirst(1)?fds.getFirst(1): _salesTable ;
_salesTable ;
_salesTable = fds.getNext())
{
salesidtemp[a] = _salesTable.SalesId ;
a=a+1 ;
}
a = a-1;
for (b=1 ; b <=a ; b++ )
{
while select _salesLine where _salesLine.LineAmount == 0 && _salesLine.SalesId == salesidtemp[b]
{
box::warning('Sales Order ID '+ any2str(_salesLine.SalesId) + ' Sales Line '+ int2str(_salesline.HDSH_OrderLineNum) + ' Amount is Null, Please Check it!','Warning!!');
WarningYes = true ;
}
}
}
if (WarningYes==false)
{
box::info('We do not found the record which the amount is null!','Info!!') ;
}
Question: For{} can't process once i selected only one record. So i judged it first and processed first if only selected one record. Then use For{} to process multi records selected. But Why????
问题:如果只选择单行的话,For{}是不能处理的。所有在For之前增加了一个判断是否只选择了单行的情况,单行单独处理,不知道这个是为什么?