/// <summary> ///Get Tree /// </summary> /// <returns>tree</returns> public X_AD_Tree GetTree() { if (_tree == null) { _tree = new X_AD_Tree(GetCtx(), GetAD_Tree_ID(), Get_TrxName()); } return(_tree); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord">newRecord new</param> /// <returns>true</returns> protected override bool BeforeSave(bool newRecord) { if (GetAD_Org_ID() != 0) { SetAD_Org_ID(0); } String elementType = GetElementType(); // Natural Account if (ELEMENTTYPE_UserDefined.Equals(elementType) && IsNaturalAccount()) { SetIsNaturalAccount(false); } // Tree validation X_AD_Tree tree = GetTree(); if (tree == null) { return(false); } String treeType = tree.GetTreeType(); if (ELEMENTTYPE_UserDefined.Equals(elementType)) { if (X_AD_Tree.TREETYPE_User1.Equals(treeType) || X_AD_Tree.TREETYPE_User2.Equals(treeType)) { ; } else { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@TreeType@ <> @ElementType@ (U)"), false); return(false); } } else { if (!X_AD_Tree.TREETYPE_ElementValue.Equals(treeType)) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@TreeType@ <> @ElementType@ (A)"), false); return(false); } } return(true); }