QueryBuildDataSource的应用

  void getDataFromJobTable()
{
    Query                       query;
    QueryRun                    qr;
    QueryBuildDataSource        qbdsJobTable;

    JaxJobTable                 curJobTable;
    EajProdMaterialCountLine    curCountLine;
    ;

    delete_from curCountLine where curCountLine.EajProdMaterialCountId == EajProdMaterialCountTable.EajProdMaterialCountId;

    frDateTime  = EajProdMaterialCountTable.FromDateTime;
    toDateTime  = EajProdMaterialCountTable.ToDateTime;

    //Inquiries the Job order
    query       = new Query();

    qbdsJobTable = query.addDataSource(tablenum(JaxJobTable));

    if(frDateTime && toDateTime)
    {
        sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,JobFromDate)).value(QueryRange(frDateTime,toDateTime));
    }
    else if(frDateTime && !toDateTime && frDateTime <= DateTimeUtil::utcNow())
    {
        sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,JobtoDate)).value(queryValue(frDateTime) + '..');
    }
    else if(!frDateTime && toDateTime)
    {
        sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,JobtoDate)).value('..'+ queryValue(toDateTime));
    }

    //if(emplIdStr)
    //    sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,EmplId)).value(queryValue(emplIdStr));

    if(EajProdMaterialCountTable.WrkCtrId)
        sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,WrkCtrId)).value(queryValue(EajProdMaterialCountTable.WrkCtrId));

    sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,JaxJobType)).value(queryValue(0));
    //sysQuery::findOrCreateRange(qbdsJobTable,fieldnum(JaxJobTable,Posted)).value(queryValue(0));

    qr = new QueryRun(query);
    while(qr.next())
    {
        curJobTable                             = qr.get(tablenum(JaxJobTable));
        if(!curJobTable.Posted)
        {
            curCountLine.EajSelected            = true;
        }
        curCountLine.EajProdMaterialCountId     = EajProdMaterialCountTable.EajProdMaterialCountId;
        curCountLine.JobId                      = curJobTable.JobId;
        curCountLine.Posted                     = curJobTable.Posted;
        curCountLine.ManualPosted               = curJobTable.Posted;
        curCountLine.ProdId                     = curJobTable.ProdId;
        curCountLine.GrossWeightOut             = curJobTable.dispOSGPW();
        curCountLine.GrossWeightIn              = curCountLine.GrossWeightOut;
        curCountLine.ProdQtyOut                 = curJobTable.dispOPOQ();
        curCountLine.GoldWeightOut              = curJobTable.dispOGW();

        curCountLine.insert();
    }

    //EajProdMaterialCountLine_ds.executeQuery();
}              

阅读更多
文章标签: query delete
个人分类: Microsoft Dynamics AX
想对作者说点什么? 我来说一句

pca应用应用应用

2015年04月22日 770B 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭