主单位与次单位

static Qty ConvertUnit(InventTable _inventTable,Qty _qtyFrom,UnitID _unitTo)
{
    qty         qtyTo;
    ;

    setprefix("Unit Conversion");

    if (_inventTable.inventTableModuleInvent().UnitId == "CT" ||
                                        _inventTable.inventTableModuleInvent().UnitId == "GM")
            {
                qtyTo  += UnitConvert::qty(_qtyFrom,
                                            _inventTable.inventTableModuleInvent().UnitId,
                                            _unitTo,
                                            _inventTable.ItemId);
            }
            else
            {
                if (_inventTable.ACT_SecUnitID == "CT" || _inventTable.ACT_SecUnitID == "GM")
                {
                    qtyTo += UnitConvert::qty(_qtyFrom,
                                               _inventTable.ACT_SecUnitID,
                                               _unitTo,
                                               _inventTable.ItemId);
                }
                else
                    Warning(strfmt("Units can not be converted to CT! ItemID:%1,Unit:%2,SecUnit:%3",
                                    _inventTable.ItemId,
                                    _inventTable.inventTableModuleInvent().UnitId,
                                    _inventTable.ACT_SecUnitID
                                    ));
            }

    return qtyTo;

}

posted @ 2012-03-01 12:14  perock  阅读(358)  评论(0编辑  收藏  举报