Tạo Data Entity cho bảng InventTrans


03/03/2020- duocnt    1825 Views    


Các bước thực hiện:

  1. Tạo Data Entity với table InventTransOrigin
  2. Add table InventTrans vào Data Entiy làm DataSource cho Data Source InventTransOrigin
  3. Tạo Relation giữa Data Source InventTransOrigin và  Data Source InventTrans trong Data Entity dựa vào Relation giữa 2 bảng.
  4. Kéo những field cần thiết của InventTransOrigin và InventTrans làm field cho Data Entity.
  5. Add table InventDim vào DataSource của InventTrans datasource.
  6. Tạo Relation giữa Data Source InventDim và Data Source InventTrans dựa vào Relation giữa 2 bảng.
  7. Chuyển Data Source field inventDimId của Data Entity từ InventTrans thành InventDim.
  8. Tạo 3 Unmapped field cho Data Entity.
  9. Chuyện thuộc tính "Is Computed Field" của 3 field vừa tạo từ "Yes" thành "No".
  10. Overide phương thức postLoad() của Data Entiy.
  11. Build project và kiểm tra dữ liệu với OData.
  12. Xem Video Clip.


THỰC HIỆN:

1 - Tạo Data Entity cho table InventTransOrigin.


2 - Add table InventTrans vào Data Entiy làm DataSource cho Data Source InventTransOrigin


3 - Tạo Relation giữa Data Source InventTransOrigin và  Data Source InventTrans trong Data Entity dựa vào Relation giữa 2 bảng.


4 - Kéo những field cần thiết của InventTransOrigin và InventTrans làm field cho Data Entity.


5 - Add table InventDim vào DataSource của InventTrans datasource.


6 - Tạo Relation giữa Data Source InventDim và Data Source InventTrans dựa vào Relation giữa 2 bảng.


7 - Chuyển Data Source field inventDimId của Data Entity từ InventTrans thành InventDim


8 - Tạo 3 Unmapped field cho Data Entity.


9 - Chuyện thuộc tính "Is Computed Field" của 3 field vừa tạo từ "Yes" thành "No".


 - Thực hiện với 2 field còn lại (ProductCBM và TotalCBM).


10 - Overide phương thức postLoad() của Data Entiy.

public class InventTransEntity extends common
{
    /// <summary>
    ///
    /// </summary>
    public void postLoad()
    {
        super();
        InventTrans                            _inventTrans;
        InventDim                              _inventDim;
        InventDimCombination                   _inventDimCombination;
        VtvEcoResProductVariantInformation      _producInformation;
 
        _inventTrans                =   InventTrans::findRecId(this.RecId1,false);
        _inventDim                  =   InventDim::find(_inventTrans.inventDimId,false);
        _inventDimCombination       =           InventDimCombination::findByInventDim(_inventTrans.ItemId,_inventDim,false);
        _producInformation          =           VtvEcoResProductVariantInformation::findByRetailVariantId(_inventDimCombination.RetailVariantId,false);
 
        this.CostValue          =   _inventTrans.costValue();
        this.ProductCBM         =   _producInformation.vtvBoxVolume();
        this.TotalCBM           =   _inventTrans.Qty *(_producInformation.vtvBoxVolume());
    }
}


11 - Build project và kiểm tra dữ liệu với OData.


12 - Xem Video Clip.




Góp ý kiến

;
;