Farseer

导航

实现Pick和Reigister

AX有个问题是很多功能都跟表现层窗体绑定在一起,要用代码直接实现某个功能就需要看窗体中的代码是如何处理的并将其剥离出来。
比如领料和登记功能,它都封装到了窗体InventTransPickInventTransRegister中,虽然也是通过类InventTransWMSInventTransWMS_PickInventTransWMS_Register实现相应的功能,但如果要通过代码直接实现Pick和Register功能就需要看一下它们的处理逻辑,并将其改造一下。
1.给InventTransWMS_Pick和InventTransWMS_Register分别增加movement方法,代码可以从相应的窗体上粘过来:
InventTransWMS_Pick:
static InventMovement  movement(Common _record)
{
    InventMovement          movement;
    InventQuarantineOrder   inventQuarantineOrder;
    ;

    
if (_record.TableId == tablenum(InventQuarantineOrder))
    
{
        inventQuarantineOrder 
= _record;

        
if (inventQuarantineOrder.Status == InventQuarantineStatus::Created)
        
{
            movement 
= InventMovement::construct(inventQuarantineOrder,InventMovSubType::TransferReceipt);
        }

    }


    
if (! movement)
    
{
        movement 
= InventMovement::construct(_record);
    }



    
return movement;
}
InventTransWMS_Resigter:
static InventMovement  movement(Common _record)
{
    InventMovement          movement;
    InventQuarantineOrder   inventQuarantineOrder;

    
if (_record.TableId == tablenum(InventQuarantineOrder))
    
{
        inventQuarantineOrder 
= _record;

        
if (inventQuarantineOrder.Status == InventQuarantineStatus::Created)
        
{
            movement 
= InventMovement::construct(inventQuarantineOrder,InventMovSubType::None);
        }

        
else
        
{
            movement 
= InventMovement::construct(inventQuarantineOrder,InventMovSubType::TransferReceipt);
        }

    }

    
else
    
{
        movement 
= InventMovement::construct(_record);
    }


    
if (movement.newMovement_TransferReceipt())
    
{
        movement 
= movement.newMovement_TransferReceipt();
        movement 
= movement.newMovement_TransferIssueReceive() ? movement.newMovement_TransferIssueReceive() : movement;
        movement 
= movement.newMovement_TransferReceipt() ? movement.newMovement_TransferReceipt() : movement;
    }



    
return movement;
}
2.给两个类分别增加Pick和Registe方法:
InventTransWMS_Pick:
static void pick(Common _cursor,TmpInventTransWMS _tmpInventTransWMS)
{
    InventTransWMS_Pick inventTransWMS_Pick 
= new InventTransWMS_Pick(InventTransWMS_Pick::movement(_cursor),_tmpInventTransWMS);
    ;
    InventTransWMS_Pick::updateInvent(inventTransWMS_Pick,_tmpInventTransWMS);

}
InventTransWMS_Register:
static void register(Common _cursor,TmpInventTransWMS _tmpInventTransWMS)
{
    InventTransWMS_Register inventTransWMS_register 
= new InventTransWMS_Register(InventTransWMS_Register::movement(_cursor),_tmpInventTransWMS);
    ;
    InventTransWMS_register::updateInvent(inventTransWMS_register,_tmpInventTransWMS);

}
3.调用示例:
将某行转移单明细做领料动作

    inventDim.InventLocationId          
= 'GW';
    tmpInventTransWMS.InventQty         
= 1;
    tmpInventTransWMS.InventDimId       
= InventDim::findOrCreate(inventDim).inventDimId;
    tmpInventTransWMS.insert();

    inventDim.InventLocationId          
= 'GW';
    tmpInventTransWMS.InventQty         
= 1;
    tmpInventTransWMS.InventDimId       
= InventDim::findOrCreate(inventDim).inventDimId;
    tmpInventTransWMS.insert();

    InventTransWMS_Pick::pick(inventTransferLine,tmpInventTransWMS);
将某行采购单明细做登记动作:
    tmpInventTransWMS.InventQty = 1;

    inventDim.InventLocationId  
= 'MW';
    inventDim.inventBatchId     
= '001';

    tmpInventTransWMS.InventDimId 
= InventDim::findOrCreate(inventDim).inventDimId;
    tmpInventTransWMS.insert();

    tmpInventTransWMS.InventQty 
= 1;
    inventDim.InventLocationId  
= 'MW';
    inventDim.inventBatchId     
= '002';
    tmpInventTransWMS.InventDimId 
= InventDim::findOrCreate(inventDim).inventDimId;
    tmpInventTransWMS.insert();
    
//Insert End

    InventTransWMS_Register::register(purchLine,tmpInventTransWMS);

posted on 2008-04-13 20:54  佛西亚  阅读(906)  评论(0编辑  收藏  举报