zoukankan      html  css  js  c++  java
  • When you are finished renamed the Item number Jobs

    When you are finished renamed the Item number, you must record original Item number, related configure  and so on!

     

    static void Jimmy_ItemRenamedAfterUpdate(Args _args)
    {
        InventTableCompany      ITCompany,delITCompany;
        InventTable             IT,ITUpdateOrg;
        ConfigTable             ConfigTable;
        InventDimCombination    Combination;
        Dialog                  dlg     = new Dialog("updated to comoany Items infomation");
        DialogField             dlgItem = dlg.addField(types::String,'after rename Items:',"Format such as :Items + ',' + Items + ','  + items");
        ListEnumerator          le;
        ItemId                  ItemConfig;
        InventTrans             InventTrans;
        int                     ITCompanys,Combinations,NoConfig;
    
        SysDataBaseLog          SysDataBaseLog;
        Container               Con;
        fieldId                 fieldId;
        List                    datalist;
        ListEnumerator          enumerator;
    ;
        dlgItem.displayHeight(20);
        dlgItem.displayLength(50);
        dlg.doInit();
        if(!dlg.run())
            return ;
    
        le = global::strSplit(dlgItem.value(),',').getEnumerator();
        while (le.moveNext())
        {
    
            ttsbegin;
            ITUpdateOrg = InventTable::find(le.current(),true);
            if(ITUpdateOrg)
            {
                select firstonly SysDataBaseLog
                        where SysDataBaseLog.table == tablenum(InventTable)
                        && SysDataBaseLog.LogType == DatabaseLogType::RenameKey
                        && SysDataBaseLog.Description like ITUpdateOrg.ItemId + '*';
                if(SysDataBaseLog)
                {
                    datalist = SysDataBaseLog.getDataAslist();
                    enumerator = datalist.getEnumerator();
                    while (enumerator.moveNext())
                    {
                        Con          = enumerator.current();
                        fieldId      = conpeek(Con, 1);
                        ITUpdateOrg.OrgItemId = sysdatabaselog.contents2Str(conpeek(Con, 3), fieldId);
                        break;
                    }
                }
                if(!ITUpdateOrg.OrgItemId)
                    ITUpdateOrg.OrgItemId = ITUpdateOrg.ItemId;
                ITUpdateOrg.Update();
            }
            ttscommit;
    
            select firstonly forupdate IT where IT.ItemId == le.current();
            if(IT)
            {
                /*
                select firstonly InventTrans where InventTrans.ItemId == le.current();
                if(InventTrans)
                    throw Error(StrFmt("The ItemId %1 Exists InventTrans,do not rename of Items!",le.current()));
                */
                select firstonly ConfigTable where ConfigTable.ItemId == IT.ItemId;
                //Have Configuration
                ItemConfig = '';
                if(ConfigTable)
                {
                    ConfigTable.clear();
    
                    while select ConfigTable where ConfigTable.ItemId == IT.ItemId
                    {
                        ItemConfig = IT.ItemId + '_' + ConfigTable.ConfigId;
    
                        ttsbegin;
                        select firstonly forupdate ITCompany where ITCompany.ItemId == ItemConfig;
                        if(!ITCompany)
                        {
                            ITCompany.initValue();
                            ITCompany.ItemId        = ItemConfig;
                            ITCompany.Name          = IT.itemName;
                            ITCompany.OrgItemId     = IT.OrgItemId;
                            ITCompany.NormalItemId  = IT.ItemId;
    
                            ITCompany.insert();
                            ITCompanys++;
                        }
                        else
                        {
                            ITCompany.ItemId        = ItemConfig;
                            ITCompany.Name          = IT.itemName;
                            ITCompany.OrgItemId     = IT.OrgItemId;
                            ITCompany.NormalItemId  = IT.ItemId;
                            ITCompany.update();
                        }
                        ttscommit;
    
                        ttsbegin;
                        delete_from delITCompany where delITCompany.ItemId == IT.OrgItemId + '_' + ConfigTable.ConfigId
                            && delITCompany.OrgItemId == '' && delITCompany.NormalItemId == '';
    
                        ttscommit;
    
                        ttsbegin;
                        select firstonly forupdate Combination
                            where Combination.ItemId == ConfigTable.ItemId
                            &&    Combination.ConfigId == ConfigTable.ConfigId;
                        if(Combination)
                        {
                            Combination.ItemIdCompany = ItemConfig;
                            Combination.update();
                            Combinations++;
                        }
                        ttscommit;
                    }
                }
                else //Have not Configuration
                {
                    ttsbegin;
                    select firstonly forupdate ITCompany where ITCompany.ItemId == IT.ItemId;
                    if(!ITCompany)
                    {
                        ITCompany.initValue();
                        ITCompany.ItemId        = IT.ItemId;
                        ITCompany.Name          = IT.itemName;
                        ITCompany.OrgItemId     = IT.OrgItemId;
                        ITCompany.NormalItemId  = IT.ItemId;
                        ITCompany.insert();
                    }
                    else
                    {
                        ITCompany.ItemId        = IT.ItemId;
                        ITCompany.Name          = IT.itemName;
                        ITCompany.OrgItemId     = IT.OrgItemId;
                        ITCompany.NormalItemId  = IT.ItemId;
                        ITCompany.update();
                    }
                    ttscommit;
                    ttsbegin;
                    IT.ItemIdCompany = it.ItemId;
                    IT.update();
                    ttscommit;
                    NoConfig ++;
                    info(IT.ItemId);
    
                }
            }
            ELSE
               info("Not exists Item detail " + le.current());
        }
        info(strfmt("NoConfig : %1,Combinations : %2,ITCompanys : %3",NoConfig,Combinations,ITCompanys));
    }
    
  • 相关阅读:
    2015 ACM/ICPC Asia Regional Changchun Online HDU 5444 Elven Postman【二叉排序树的建树和遍历查找】
    JDBC连接MySQL数据库
    MySQL实习训练1
    I Hate It
    Just a Hook
    Mayor's posters
    asd的甩锅计划
    程序员的恋情
    Radical and array
    Highways
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2105403.html
Copyright © 2011-2022 走看看