protected virtual void _(Events.FieldUpdated <KCSiteAssociation, KCSiteAssociation.isCompanyLink> e)
        {
            KCSiteAssociation row = (KCSiteAssociation)e.Row;

            if (row != null)
            {
                if (row.IsCompanyLink == true)
                {
                    row.IsBranchLink = false;
                }
            }
        }
        protected virtual void _(Events.RowPersisting <KCSiteAssociation> e)
        {
            KCSiteAssociation row = (KCSiteAssociation)e.Row;

            if (row == null)
            {
                return;
            }

            if (row.IsCompanyLink != true && row.IsBranchLink != true)
            {
                ProjectionBranchWithSite.AllowSelect = false;
                string msg = KCMessages.SiteAssociationCheck;
                SiteAssociate.Cache.RaiseExceptionHandling <KCSiteAssociation.isCompanyLink>(row, row.IsCompanyLink, new PXSetPropertyException <KCSiteAssociation.isCompanyLink>(msg));
                throw new PXSetPropertyException <KCSiteAssociation.isCompanyLink>(msg);
            }
        }
        protected virtual void _(Events.FieldVerifying <KCSiteAssociation, KCSiteAssociation.siteMasterId> e)
        {
            KCSiteAssociation row = (KCSiteAssociation)e.Row;

            if (row == null)
            {
                return;
            }

            if (row != null)
            {
                if (row.IsCompanyLink == true && e.NewValue == null)
                {
                    string msg = KCMessages.ChannelAdvisorSiteRequired;
                    SiteAssociate.Cache.RaiseExceptionHandling <KCSiteAssociation.siteMasterId>(e.Row, row.SiteMasterId, new PXSetPropertyException <KCSiteAssociation.siteMasterId>(msg));
                    throw new PXSetPropertyException <KCSiteAssociation.siteMasterId>(msg);
                }
            }
        }
        protected virtual void _(Events.FieldSelecting <KCSiteAssociation, KCSiteAssociation.siteMasterId> e)
        {
            KCSiteAssociation row = (KCSiteAssociation)e.Row;

            if (row == null)
            {
                return;
            }

            if (row != null)
            {
                List <string> allowedText   = new List <string>();
                List <string> allowedValues = new List <string>();
                foreach (KCSiteMaster iSiteMaster in PXSelect <KCSiteMaster> .Select(this))
                {
                    allowedValues.Add(iSiteMaster.SiteMasterCD);
                    allowedText.Add(string.Format(KCConstants.DualParameters, iSiteMaster.SiteMasterCD, iSiteMaster.Descr));
                }

                e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(KCSiteMaster.siteMasterCD).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedText.ToArray(), false, null);
            }
        }
        protected virtual void _(Events.RowSelected <KCSiteAssociation> e)
        {
            if (e.Row == null)
            {
                return;
            }
            KCSiteAssociation row = (KCSiteAssociation)e.Row;

            if (row != null)
            {
                if (row.IsCompanyLink == true)
                {
                    ProjectionBranchWithSite.AllowSelect = false;
                    PXUIFieldAttribute.SetVisible <KCSiteAssociation.siteMasterId>(e.Cache, row, true);
                }

                if (row.IsBranchLink == true)
                {
                    ProjectionBranchWithSite.AllowSelect = true;
                    PXUIFieldAttribute.SetVisible <KCSiteAssociation.siteMasterId>(e.Cache, row, false);
                }
            }
        }