the following code as about posted and unposted action
remark by Jimmy Jun 14th 2010
代码
void clicked()
{
Dialog dialog;
DialogField dlgGlueItem,dlgUserId,FieldMove;
UserId UserId;
Noyes ApproveMove;
QVS_GlueTraceability GlueTraceability;
boolean isRemove = false;
;
if(!QVS_GlueTraceability)
throw warning("@SYS36901");
dialog = new dialog("Post glue Traceability");
dlgGlueItem = dialog.addField(TypeId(ItemId),"Blue Item Number");
dlgGlueItem.active(false);
dlgGlueItem.value(QVS_GlueTraceability.ItemGlue);
dlgUserId = dialog.addfield(typeid(UserId),"@SYS16181");
UserId = curUserId();
if (UserId)
dlgUserId.active(false);
else
dlgUserId.active(true);
dlgUserId.value(UserId);
FieldMove = dialog.addField(Typeid(Noyes),"@SYS12778" + ' ' + '@SYS1711');
if(QVS_GlueTraceability.Posted)
{
if(!hasSecuritykeyAccess(securitykeynum(QVS_GlueTraceabilityUnPost),AccessType::Edit))
throw Error("@SYS57330");
isRemove = true;
Fieldmove.visible(true);
}
else
Fieldmove.visible(false);
if (dialog.run())
{
try
{
UserId = dlgUserId.value();
ApproveMove = FieldMove.value();
if(ApproveMove)
{
TTSBEGIN;
select firstonly forupdate GlueTraceability
where GlueTraceability.RecId == QVS_GlueTraceability.RecId;
if(GlueTraceability)
{
GlueTraceability.Posted = Noyes::No;
GlueTraceability.Postby = '';
GlueTraceability.Cancelby = UserId;
GlueTraceability.update();
}
TTSCOMMIT;
QVS_GlueTraceability_DS.reread();
QVS_GlueTraceability_ds.executeQuery();
QVS_GlueTraceability_ds.active();
info("@SYS21533");
}
else
{
if(isRemove && !ApproveMove)
return ;
TTSBEGIN;
select firstonly forupdate GlueTraceability
where GlueTraceability.RecId == QVS_GlueTraceability.RecId;
if(GlueTraceability)
{
GlueTraceability.Posted = Noyes::Yes;
GlueTraceability.Postby = UserId;
GlueTraceability.Cancelby = '';
GlueTraceability.update();
}
TTSCOMMIT;
QVS_GlueTraceability_DS.reread();
QVS_GlueTraceability_ds.executeQuery();
QVS_GlueTraceability_ds.active();
info("Posting successful!");
}//endif
}
catch (Exception::Deadlock)
retry;
}//endif
}