/// <summary>
 /// After Save
 /// </summary>
 /// <param name="newRecord">new</param>
 /// <param name="success">success</param>
 /// <returns>success</returns>
 protected override bool AfterSave(bool newRecord, bool success)
 {
     //	Default Value
     if (IsMandatory() && Is_ValueChanged("IsMandatory"))
     {
         if (ELEMENTTYPE_Activity.Equals(GetElementType()))
         {
             UpdateData("C_Activity_ID", GetC_Activity_ID());
         }
         else if (ELEMENTTYPE_BPartner.Equals(GetElementType()))
         {
             UpdateData("C_BPartner_ID", GetC_BPartner_ID());
         }
         else if (ELEMENTTYPE_Product.Equals(GetElementType()))
         {
             UpdateData("M_Product_ID", GetM_Product_ID());
         }
         else if (ELEMENTTYPE_Project.Equals(GetElementType()))
         {
             UpdateData("C_Project_ID", GetC_Project_ID());
         }
     }
     //	Resequence
     if (newRecord || Is_ValueChanged("SeqNo"))
     {
         MAccount.UpdateValueDescription(GetCtx(), "AD_Client_ID=" + GetAD_Client_ID(), Get_TrxName());
     }
     //	Clear Cache
     s_cache.Clear();
     return(success);
 }
        /// <summary>
        /// Before Save
        /// </summary>
        /// <param name="newRecord">new</param>
        /// <returns>true if it can be saved</returns>
        protected override bool BeforeSave(bool newRecord)
        {
            if (GetAD_Org_ID() != 0)
            {
                SetAD_Org_ID(0);
            }
            String et = GetElementType();

            if (IsMandatory() &&
                (ELEMENTTYPE_UserList1.Equals(et) || ELEMENTTYPE_UserList2.Equals(et) ||
                 ELEMENTTYPE_UserElement1.Equals(et) || ELEMENTTYPE_UserElement2.Equals(et) ||
                 ELEMENTTYPE_UserElement3.Equals(et) || ELEMENTTYPE_UserElement4.Equals(et) ||
                 ELEMENTTYPE_UserElement5.Equals(et) || ELEMENTTYPE_UserElement6.Equals(et) ||
                 ELEMENTTYPE_UserElement7.Equals(et) || ELEMENTTYPE_UserElement8.Equals(et) ||
                 ELEMENTTYPE_UserElement9.Equals(et)))
            {
                SetIsMandatory(false);
            }
            else if (IsMandatory())
            {
                String errorField = null;
                if (ELEMENTTYPE_Account.Equals(et) && GetC_ElementValue_ID() == 0)
                {
                    errorField = "C_ElementValue_ID";
                }
                else if (ELEMENTTYPE_Activity.Equals(et) && GetC_Activity_ID() == 0)
                {
                    errorField = "C_Activity_ID";
                }
                else if (ELEMENTTYPE_BPartner.Equals(et) && GetC_BPartner_ID() == 0)
                {
                    errorField = "C_BPartner_ID";
                }
                else if (ELEMENTTYPE_Campaign.Equals(et) && GetC_Campaign_ID() == 0)
                {
                    errorField = "C_Campaign_ID";
                }
                else if (ELEMENTTYPE_LocationFrom.Equals(et) && GetC_Location_ID() == 0)
                {
                    errorField = "C_Location_ID";
                }
                else if (ELEMENTTYPE_LocationTo.Equals(et) && GetC_Location_ID() == 0)
                {
                    errorField = "C_Location_ID";
                }
                else if (ELEMENTTYPE_Organization.Equals(et) && GetOrg_ID() == 0)
                {
                    errorField = "Org_ID";
                }
                else if (ELEMENTTYPE_OrgTrx.Equals(et) && GetOrg_ID() == 0)
                {
                    errorField = "Org_ID";
                }
                else if (ELEMENTTYPE_Product.Equals(et) && GetM_Product_ID() == 0)
                {
                    errorField = "M_Product_ID";
                }
                else if (ELEMENTTYPE_Project.Equals(et) && GetC_Project_ID() == 0)
                {
                    errorField = "C_Project_ID";
                }
                else if (ELEMENTTYPE_SalesRegion.Equals(et) && GetC_SalesRegion_ID() == 0)
                {
                    errorField = "C_SalesRegion_ID";
                }
                if (errorField != null)
                {
                    log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@IsMandatory@: @" + errorField + "@"));
                    return(false);
                }
            }
            //
            if (GetAD_Column_ID() == 0 &&
                (ELEMENTTYPE_UserElement1.Equals(et) || ELEMENTTYPE_UserElement2.Equals(et)))
            {
                log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@IsMandatory@: @AD_Column_ID@"));
                return(false);
            }
            return(true);
        }