Tuesday, 17 November 2015

ui builder class lookup in one parameter depends on other parameters(passing range in parameters)

lookup in one parameter depends on other parameters:

here in we selected production id in parameter
that production having 4 Opr no parameter
here in i selected one opr no. parameter
for that production having 3 job identfication parameters
selected one job identification parameter
having 2 route card journal parameters

passing the range depends on above parameter we are showing lookup in other parametes





public class MSTravelCardUIBuilder extends SysOperationAutomaticUIBuilder
{
    DialogField          dialogProdId,dialogOprNum;
    DialogField          dialogProdJobId,dialogProdJournalRoute;
    MSTravelCardContract contract;
}



public void build()
{
    Dialog               dialogLocal = this.dialog();
    MSTravelCardContract contractLocal = this.dataContractObject();

    //dialogLocal.addGroup(“Parameters”);
    this.addDialogField(methodStr(MSTravelCardContract,parmProdId), contractLocal);
    this.addDialogField(methodStr(MSTravelCardContract,parmOprNum), contractLocal);
    this.addDialogField(methodStr(MSTravelCardContract,parmProdJobId), contractLocal);
    this.addDialogField(methodStr(MSTravelCardContract,parmProdJournalIdRoute), contractLocal);

}


public void getFromDialog()
{
    contract = this.dataContractObject();
    super();
}

public void initializeFields()
{
    contract = this.dataContractObject();
}

public void lookupOprNum(FormStringControl _control)
{

    Query          query = new Query();
    SysTableLookup sysTablelookup;

    sysTablelookup =SysTableLookup::newParameters(tableNum(ProdJournalRoute),_control);
    sysTablelookup.addLookupfield(fieldNum(ProdJournalRoute,OprNum));
    sysTablelookup.addLookupfield(fieldnum(ProdJournalRoute,ProdId));

    query.addDataSource(tableNum(ProdJournalRoute));
    query.dataSourceTable(tableNum(ProdJournalRoute)).addRange(fieldNum(ProdJournalRoute, ProdId)).value(queryValue(dialogProdId.value()));

    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();
}



public void lookupProdJobId(FormStringControl _control)
{
    Query                   query = new Query();
    QueryBuildDataSource    qbdsJournalRoute,qbdsRouteTrans;
    SysTableLookup          sysTablelookup;

    sysTablelookup =SysTableLookup::newParameters(tableNum(ProdJournalRoute),_control);
    sysTablelookup.addLookupfield(fieldNum(ProdJournalRoute,JobId));
    sysTablelookup.addLookupfield(fieldNum(ProdJournalRoute,OprNum));
    sysTablelookup.addLookupfield(fieldnum(ProdJournalRoute,ProdId));

    qbdsJournalRoute = query.addDataSource(tableNum(ProdJournalRoute));
    qbdsJournalRoute.addRange(fieldNum(ProdJournalRoute, ProdId)).value(queryValue(dialogProdId.value()));
    qbdsJournalRoute.addRange(fieldNum(ProdJournalRoute, OprNum)).value(queryValue(dialogOprNum.value()));
    qbdsJournalRoute.addRange(fieldNum(ProdJournalRoute, QtyGood)).value(queryValue('>0'));

    qbdsRouteTrans = qbdsJournalRoute.addDataSource(tableNum(ProdRouteTrans));
    qbdsRouteTrans.addLink(fieldNum(ProdJournalRoute,ProdId),fieldNum(ProdRouteTrans,TransRefId));
    qbdsRouteTrans.addLink(fieldNum(ProdJournalRoute,JobId),fieldNum(ProdRouteTrans,JobId));
    qbdsRouteTrans.joinMode(joinmode::ExistsJoin);
    qbdsRouteTrans.addRange(fieldNum(ProdRouteTrans,TransType)).value(queryValue(ProdRouteTransType::Qty));
    qbdsRouteTrans.addRange(fieldNum(ProdRouteTrans,QtyGood)).value(queryValue('>0'));

    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();

}


public void lookupProdJournalRoute(FormStringControl _control)
{

    Query                   query = new Query();
    QueryBuildDataSource    qbdsJournalRoute,qbdsRouteTrans;
    SysTableLookup sysTablelookup;

    sysTablelookup =SysTableLookup::newParameters(tableNum(ProdJournalRoute),_control);
    sysTablelookup.addLookupfield(fieldNum(ProdJournalRoute,JournalId),true);
    sysTablelookup.addLookupfield(fieldNum(ProdJournalRoute,JobId));
    sysTablelookup.addLookupfield(fieldNum(ProdJournalRoute,OprNum));
    sysTablelookup.addLookupfield(fieldnum(ProdJournalRoute,ProdId));

    qbdsJournalRoute = query.addDataSource(tableNum(ProdJournalRoute));
    qbdsJournalRoute.addRange(fieldNum(ProdJournalRoute, ProdId)).value(queryValue(dialogProdId.value()));
    qbdsJournalRoute.addRange(fieldNum(ProdJournalRoute, OprNum)).value(queryValue(dialogOprNum.value()));
    qbdsJournalRoute.addRange(fieldNum(ProdJournalRoute, QtyGood)).value(queryValue('>0'));

    qbdsRouteTrans = qbdsJournalRoute.addDataSource(tableNum(ProdRouteTrans));
    qbdsRouteTrans.addLink(fieldNum(ProdJournalRoute,ProdId),fieldNum(ProdRouteTrans,TransRefId));
    qbdsRouteTrans.addLink(fieldNum(ProdJournalRoute,JobId),fieldNum(ProdRouteTrans,JobId));
    qbdsRouteTrans.joinMode(joinmode::ExistsJoin);
    qbdsRouteTrans.addRange(fieldNum(ProdRouteTrans,TransType)).value(queryValue(ProdRouteTransType::Qty));
    qbdsRouteTrans.addRange(fieldNum(ProdRouteTrans,QtyGood)).value(queryValue('>0'));
    qbdsRouteTrans.addRange(fieldNum(ProdRouteTrans,JobId)).value(queryValue(dialogProdJobId.value()));

    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();
}




public void postBuild()
{
    ;
    super();

    dialogProdId = this.bindInfo().getDialogField(
                         this.dataContractObject(),
                         methodStr(MSTravelCardContract,parmProdId));

    dialogOprNum = this.bindInfo().getDialogField(
                         this.dataContractObject(),
                         methodStr(MSTravelCardContract,parmOprNum));

    dialogOprNum.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(MSTravelCardUIBuilder, lookupOprNum), this);
    if (dialogOprNum)
    {
        dialogOprNum.lookupButton(2);
    }

    dialogProdJobId = this.bindInfo().getDialogField(
                         this.dataContractObject(),
                         methodStr(MSTravelCardContract,parmProdJobId));

    dialogProdJobId.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(MSTravelCardUIBuilder, lookupProdJobId), this);
    if (dialogProdJobId)
    {
        dialogProdJobId.lookupButton(2);
    }


    dialogProdJournalRoute = this.bindInfo().getDialogField(
                         this.dataContractObject(),
                         methodStr(MSTravelCardContract,parmProdJournalIdRoute));

    dialogProdJournalRoute.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(MSTravelCardUIBuilder, lookupProdJournalRoute), this);
    if (dialogProdJournalRoute)
    {
        dialogProdJournalRoute.lookupButton(2);
    }


}




public void postRun()
{
    super();
}


public boolean transTypeModified(FormStringControl _control)
{
    dialogProdId.value(_control.valueStr());
    dialogOprNum.value("");
    dialogProdJobId.value("");
    dialogProdJournalRoute.value("");
    return true;
}




No comments:

Post a Comment