Bài viết liên quan

Tạo class BOMStructureExplodingUIBuilder


01/10/2020- duocnt    844 Views    

NỘI DUNG

 - Tạo class BOMLinesExplodeUIBuilder extends SrsReportDataContractUIBuilder.

 - Khai báo các biến dùng chung class kiểu đối tượng DialogField.

    DialogField     dlgField_ListItemId;
    DialogField     dlgField_Collapse;
    DialogField     dlgField_ByBOMId;
    DialogField     dlgField_BOMId;


 - Tạo mới hoặc Override phương thức:

void setDistincData() (New Method).
private void lookupListItem(FormStringControl _control) (New Method).
private boolean ByBOMId(FormCheckBoxControl   _formCheckBoxControl) (New Method).
private void toggle() (New Method).
public void postBuild() (Override).
public void postRun() (Override).


CODE X++

 - Code chi tiết của class BOMLinesExplodeUIBuilder.

class BOMStructureExplodingUIBuilder extends SrsReportDataContractUIBuilder
{
    DialogField dlgField_ListItemId;
    DialogField     dlgField_Collapse;
    DialogField     dlgField_ByBOMId;
    DialogField     dlgField_BOMId;
 
    void setDistincData()
    {
        InventDim          _InventDim;
        InventItemPrice    _InventItemPrice;
        DistinctItemIdTmp  _distinctItemIdTmp;
        delete_from  _distinctItemIdTmp;
        while select ItemId
            from _InventItemPrice
            join configId from  _InventDim
            group by _InventDim.configId, _InventItemPrice.ItemId
            where _InventItemPrice.InventDimId  ==     _InventDim.inventDimId
                && _InventDim.configId!=""
                &&  _InventItemPrice.PriceCalcId!=""
        {
            InventTable           _inventTable;
            _inventTable   =      InventTable::find(_InventItemPrice.ItemId);
            _distinctItemIdTmp.ItemId       =  _InventItemPrice.ItemId;
            _distinctItemIdTmp.ConfigId     =  _InventDim.configId;
            _distinctItemIdTmp.ProductName  =  _inventTable.defaultProductName();
            _distinctItemIdTmp.insert();
        }
    }
 
    private void lookupListItem(FormStringControl _control)
    {
        Query       _query;
        QueryBuildDataSource      _querybuildDataSource;
        container   _cont;
        _query      =      new Query();
        _querybuildDataSource     =       _query.addDataSource(tableNum(DistinctItemIdTmp));
 
        _querybuildDataSource.addSelectionField(fieldNum(DistinctItemIdTmp,ItemId));
        _querybuildDataSource.addSelectionField(fieldNum(DistinctItemIdTmp,ProductName));
 
        _querybuildDataSource.addGroupByField(fieldNum(DistinctItemIdTmp,ItemId));
        _querybuildDataSource.addGroupByField(fieldNum(DistinctItemIdTmp,ProductName));
        _querybuildDataSource.addOrderByField(fieldNum(DistinctItemIdTmp,ItemId));
        SysLookupMultiSelectGrid::lookup(_query,_control,_Control,_control,_cont);
    }
 

 
    /// <summary>
    ///
    /// </summary>
    public void postBuild()
    {
        BOMStructureExplodingContract    _contract;
        super();
        _contract            = this.dataContractObject() as BOMStructureExplodingContract;
        dlgField_ListItemId  = this.bindInfo().getDialogField(this.dataContractObject(),                                                 methodStr(BOMStructureExplodingContract,parmListItemId));
        dlgField_Collapse    = this.bindInfo().getDialogField(this.dataContractObject(),                                                 methodStr(BOMStructureExplodingContract,parmCollapse));
        dlgField_ByBOMId     = this.bindInfo().getDialogField(this.dataContractObject(),                                                 methodStr(BOMStructureExplodingContract,parmByBOMId));
        dlgField_BOMId       = this.bindInfo().getDialogField(this.dataContractObject(),                                                 methodStr(BOMStructureExplodingContract,parmBOMId));
       

        this.setDistincData();

        this.toggle();
       
        /*REGISTER METHOD*/
        dlgField_ListItemId.registerOverrideMethod(methodStr(FormStringControl,Lookup),                                            methodStr(BOMStructureExplodingUIBuilder,lookupListItem),this);
        if(dlgField_ListItemId)
        {
            dlgField_ListItemId.lookupButton(2);
        }
       dlgField_ByBOMId.registerOverrideMethod(methodStr(FormCheckBoxControl,modified),                                               methodStr(BOMStructureExplodingUIBuilder,ByBOMId),this);
 
    }
 
    /// <summary>
    /// Hide or unhide parameter when select ByBOMId parameter
    /// </summary>
    /// <param name = "_formCheckBoxControl"></param>
    /// <returns></returns>
    private boolean ByBOMId(FormCheckBoxControl    _formCheckBoxControl)
    {
        NoYes   _ByBOMid = dlgField_ByBOMId.value();
        if(_ByBOMid ==  NoYes::Yes)
        {
            dlgField_BOMId.visible(true);
            dlgField_Collapse.visible(true);
            dlgField_ListItemId.visible(false);
        }
        else
        {
            dlgField_BOMId.visible(false);
            dlgField_Collapse.visible(true);
            dlgField_ListItemId.visible(true);
           
        }
        return true;
    }
 
    /// <summary>
    /// Hide or unhide parameter
    /// </summary>
    private void toggle()
    {
        NoYes   _ByBOMid = dlgField_ByBOMId.value();
        if(_ByBOMid ==  NoYes::Yes)
        {
            dlgField_BOMId.visible(true);
            dlgField_Collapse.visible(true);
            dlgField_ListItemId.visible(false);
        }
        else
        {
            dlgField_BOMId.visible(false);
            dlgField_Collapse.visible(true);
            dlgField_ListItemId.visible(true);
        }
    }
 
    /// <summary>
    ///
    ///</summary>
    public void postRun()
    {
        //super();
    }
}

Góp ý kiến

;
;