zoukankan      html  css  js  c++  java
  • Object的使用技巧

    当对象转换为object之后可以调用任一方法,而且编译器不会报错。这样有利全用args.caller()传递对象到目标后,在目标方利用object转换后调用caller中的方法

    boolean useConvertableLookup(Object caller)

    {

        InventMovement          inventMovement;

        InventTableModule       inventTableModule;

        PriceDiscTable          priceDiscTable;

        SuppItemTable           suppItemTable;

        fieldId                 itemIdField;

        ;

        if (!element.args() || !element.args().caller())

            return false;

        if (caller.name() == formstr(UnitConversion))

        {

            otherUnit = caller.otherUnit();

            selectedItemId = caller.selectedItemId();

            if (selectedItemId && !otherUnit)

                this.buildConversionConvertable();

            else

                this.buildConvertable();

            return true;

        }

        if (caller.name() == formstr(InventOnHandMovement)      ||

            caller.name() == formstr(InventOnHandItem)          ||

            caller.name() == formstr(InventOnHandReserve)       ||

            caller.name() == formstr(WMSPickingLinePick))

        {

            otherUnit = caller.otherUnit();

            selectedItemId = caller.selectedItemId();

            this.buildConvertable();

            return true;

        }

        if (element.args().dataset())

        {

            switch(element.args().dataset())

            {

                case tablenum(InventTableModule):

                    inventTableModule = element.args().record();

                    switch(inventTableModule.ModuleType)

                    {

                        case ModuleInventPurchSales::Invent:

                            return false;

                        default:

                            selectedItemId = inventTableModule.ItemId;

                            otherUnit = InventTable::find(selectedItemId).inventUnitId();

                            this.buildConvertable();

                            return true;

                    }

                case tablenum(PriceDiscTable):

                    priceDiscTable = element.args().record();

                    if (priceDiscTable.ItemCode != TableGroupAll::Table)

                        return false;

                    selectedItemId = priceDiscTable.ItemRelation;

                    if (!selectedItemId)

                        return false;

                    otherUnit = InventTable::find(selectedItemId).inventUnitId();

                    this.buildConvertable();

                    return true;

                case tablenum(SuppItemTable):

                    suppItemTable = element.args().record();

                    if (suppItemTable.ItemCode != TableGroupAll::Table)

                        return false;

                    selectedItemId = suppItemTable.ItemRelation;

                    if (!selectedItemId)

                        return false;

                    otherUnit = InventTable::find(selectedItemId).inventUnitId();

                    this.buildConvertable();

                    return true;

                default:

                    itemIdField = fieldname2id(element.args().dataset(),fieldstr(InventTable,ItemId));

                    if (itemIdField)

                    {

                        selectedItemId = element.args().record().(itemIdField);

                        if (!selectedItemId)

                            return false;

                        otherUnit = InventTable::find(selectedItemId).inventUnitId();

                        this.buildConvertable();

                        return true;

                    }

                    break;

            }

        }

        if (element.args().dataset())

        {

            inventMovement = InventMovement::constructNoThrow(element.args().record());

            if (inventMovement)

            {

                selectedItemId = inventMovement.itemId();

                otherUnit = InventTable::find(selectedItemId).inventUnitId();

                this.buildConvertable();

                return true;

            }

        }

        return false;

    }

  • 相关阅读:
    CSS布局 ——从display,position, float属性谈起
    svchost.exe启动服务原理(如何查看系统服务究竟启动了哪个文件)
    简单模拟多线程Socket通信(java)
    把爱融入程序——程序,源自生活,高于生活
    SQL LIKE语句多条件贪婪匹配算法
    SQL多条件模糊查询解决方案(类似百度搜索)
    SQL LIKE语句多条件贪婪加权匹配算法(改进版)
    Foxmail添加微软最新outlook.com邮箱解决方案
    SQL LIKE语句多条件贪婪加权匹配(新增必要词指定)
    搜索的艺术——搜索引擎使用心得
  • 原文地址:https://www.cnblogs.com/perock/p/2120827.html
Copyright © 2011-2022 走看看