code

void OTOenable()
{
EAMOrderToClose eamOrderToClose;
EAMPermitIssue eamPermitIssue;
EAMParameters eamParameters;
int OTCCnt=0;
int cnt=0;
int permitcnt=0,permitclosecnt=0,permitcancelcnt=0;
if(EAMWorkRequest.IsolationFlag == NoYes::Yes)
{
if(EAMWorkRequest.PermitRequired==noyes::Yes)
{
select count(PermitNumber) from eamPermitIssue
where eamPermitIssue.WorkOrderNumber==EAMWorkRequest.WorkRequestNumber;
permitcnt=str2int(eamPermitIssue.PermitNumber);

if(str2int(eamPermitIssue.PermitNumber)<=0)
OrderToOperate.enabled(false);
else
{
select eamparameters;
if(eamparameters.PermitClosure==EAMPermitClosure::BeforeWorkOrderCompletion)
{
select count(PermitNumber) from eamPermitIssue
where eamPermitIssue.WorkOrderNumber==EAMWorkRequest.WorkRequestNumber
&& eamPermitIssue.PermitStatus==EAMPermitStatus::Close;
permitclosecnt=str2int(eamPermitIssue.PermitNumber);
select count(PermitNumber) from eamPermitIssue
where eamPermitIssue.WorkOrderNumber==EAMWorkRequest.WorkRequestNumber
&& eamPermitIssue.PermitStatus==EAMPermitStatus::Cancel;
permitcancelcnt=str2int(eamPermitIssue.PermitNumber);

if(permitcnt==(permitclosecnt+permitcancelcnt))
cnt=1;
else
OrderToOperate.enabled(false);
}
else
cnt=1;

}
}
else
cnt=1;

if(cnt==1)
{
select count(OTCNumber) from eamOrderToClose
where eamOrderToClose.WorkRequestNumber==EAMWorkRequest.WorkRequestNumber;
OTCCnt=str2int(eamOrderToClose.OTCNumber);

if (OTCCnt==0)
OrderToOperate.enabled(false);
else
select count(OTCNumber) from eamOrderToClose
where eamOrderToClose.WorkRequestNumber==EAMWorkRequest.WorkRequestNumber
&& eamOrderToClose.OrderToCloseStatus==EAMOTCStatus::Completed;

if (OTCCnt!=str2int(eamOrderToClose.OTCNumber))
OrderToOperate.enabled(false);
else
{
if (strltrim(strrtrim(EAMIsolationLevel::ReturnLevel(EAMWorkRequest.LevelID)))!=’’)
OrderToOperate.enabled(true);
else
OrderToOperate.enabled(false);
}
}
}
}

Yes this is code.

Hi,

Before posting your query, please take a minute and make sure the readers will be able to understand what you are asking.

The people who reply to your queries are providing free service for you. Please don’t abuse this.