Refreshing Master Form Data Source from Child Form

//Example when modifying checkbox value and modify parent datasource,
// it will have an error unless if you refreshing parent datasource after you modify it,

public boolean modified()
{
//AIFD_ custom exchrate custtrans -> ledgerjournal trans
#Task
LedgerJournalTrans ledgerJournalTransLoc;
FormDataSource fds;

//END

boolean ret;

ret = super();

//AIFD_ custom exchrate custtrans -> ledgerjournal trans
ttsBegin;
if(this.checked())
{
select forUpdate LedgerJournalTransLoc where ledgerJournalTransLoc.RecId == originator.RecId;
LedgerJournalTransLoc.ExchRate = CustTrans.ExchRate;
ledgerJournalTransLoc.update();
}
else
{
select forUpdate LedgerJournalTransLoc where ledgerJournalTransLoc.RecId == originator.RecId;
LedgerJournalTransLoc.ExchRate = 100;
ledgerJournalTransLoc.update();

}

ttsCommit;

fds = element.args().record().dataSource();
fds.research(true);

fds.refresh();
//END

 

return ret;
}

Advertisements

Weight Detection PortComm

//Get PortComm number that already set from .txt file on local drive.
private str getPortComm()
{
    #file
    str getCOMport;
    boolean cekPortExist;
    AsciiIo file;
    Container data;
    int i;
    System.IO.FileInfo fileInfo;
    ;

    new InteropPermission(InteropKind::ClrInterop).assert();
    fileInfo = new System.IO.FileInfo(@”C:\portcomm.txt”);
    if(fileInfo.get_Exists())
    {
        file = new AsciiIo(@”C:\portcomm.txt”,#io_read);
        file.inFieldDelimiter(‘\t’);
        file.inRecordDelimiter(‘\n’);

        if(file)
        {
            while(file.status() == IO_Status::Ok)
            {  
                data = file.read();
                for(i = 1; i <= conlen(data); i++)
                {
                    getCOMport = any2str(conpeek(data, i));
                }
            }
        }

    }

    return strLTrim(getCOMport);
}

————————————

//Get Weight from PortComm
private real AI_getWeight()
{
    System.String netstring;
    System.String sample;

    int WeightInReal;
    int tryCount;
    str value;
    str value2;
    str portComm;
    System.IO.Ports.SerialPort port3;
    real weightFinal;

    tryCount = 0;

    portComm = this.getPortComm();
    if(portComm)
    {
        port3 = new System.IO.Ports.SerialPort();
        value = “0”;
        port3.set_PortName(portComm);
        port3.set_BaudRate(9600);
        port3.set_Parity(System.IO.Ports.Parity::None);
        port3.set_DataBits(8);
        port3.set_StopBits(System.IO.Ports.StopBits::One);
        port3.set_Handshake(System.IO.Ports.Handshake::None);

        try
        {
            port3.Open();
            while(tryCount<1)
            {
                WeightInReal = sleep(500);
                netstring = port3.ReadExisting();
                value = netstring;
                value2 = value;
                tryCount++;
            }
            port3.Close();
            port3.Dispose();
        }
        catch(Exception::CLRError)
        {
            info(“Wrong Port Comm Number”);
        }

        value2 = strReplace(value,”=”,””);
        value2 = strReplace(value2,”-“,””);
        value2 = strLTrim(value2);
        value2 = subStr(value2,1,6);
        weightFinal = str2num(value2);
    }
    else
    {
        info(“Check file portcomm.txt at C:\””);
    }

    if(!weightFinal)
    {
        info(“Please check your device, clarify it already turned on”);
    }
    return weightFinal;
}

—————————

on method button clicked, override.. some example here for you

void clicked()
{
    real _value;
    InventTable inventTableLoc;
    super();
    _value = this.AI_getWeight();
    
    Select * from inventTableLoc where inventTableLoc.ItemId == ProdJournalProd.ItemId;
    if(_value)
    {
        if(inventTableLoc.AISatuanPrimer!=”Kg”)
        {
            ProdJournalProd.AISatuanTertier = _value;
            ProdJournalProd_AISatuanTertier.enabled(False);
        }
        else
        {
            ProdJournalProd.AISatuanTertier =_value;
            ProdJournalProd_AISatuanTertier.enabled(True);
        }
    }
    ProdJournalProd_ds.executeQuery();
}

Location and Pallet Id Validation before posting form: ProdJournalTransBOM

void clicked()
{
    WMSPallet wmsPallet;

    select wmsPallet where wmsPallet.wMSPalletId==InventDimGrid_wMSPalletId.valueStr();
    if(wmsPallet.wMSLocationId != InventDimGrid_wMSLocationId.valueStr())
    {
        warning(strFmt(“Number of pallet %1 does not match in number of location %2″,InventDimGrid_wMSPalletId.valueStr(),InventDimGrid_wMSLocationId.valueStr()));
        error(“Posting has been canceled”);
    }
    else
    {
        super();
    }
}

Multi Print Report based on Selected Items on Grid

void clicked()
{
    //AIFD_PrintBarcode
    AI_PrintBarcodeController aiBarcode = new AI_PrintBarcodeController();
    AI_PrintBarcodeContract aiContract = new AI_PrintBarcodeContract();
    ProdJournalProd prodJournalProdLoc;

    super();

    prodJournalProdLoc = ProdJournalProd_ds.getFirst(true);

    while (prodJournalProdLoc)
    {
        aiBarcode.parmReportName(ssrsReportStr(AI_PrintBarcoderReport,Report));
        aiBarcode.parmShowDialog(false);
        aiContract.parmRecordId(prodJournalProdLoc.RecId);
        aiContract.parmDocumentTitle(“x”);
        aiBarcode.parmReportContract().parmRdpContract(aiContract);
        aiBarcode.startOperation();

        prodJournalProdLoc = ProdJournalProd_ds.getNext();
    }
    //END
}

Update Serial Inventory via SQL

select * from ECORESTRACKINGDIMENSIONGROUP

select * from ECORESTRACKINGDIMENSIONGROUPITEM where itemid = '000057610'
select * from ECORESTRACKINGDIMENSIONGROUPPRODUCT where PRODUCT = '5637294284'

select * from ECORESTRACKINGDIMENSIONGROUPFLDSETUP

update ECORESTRACKINGDIMENSIONGROUPITEM set TRACKINGDIMENSIONGROUP='5637144577' where itemid='000057610'
update ECORESTRACKINGDIMENSIONGROUPPRODUCT set TRACKINGDIMENSIONGROUP='5637144577' where product='5637294284'