Example #1
0
        protected virtual void _(Events.FieldVerifying <THeaderBranchField> e)
        {
            var newBranchId = (int?)e.NewValue;

            if (newBranchId == null || PXAccess.FeatureInstalled <FeaturesSet.interBranch>())
            {
                return;
            }

            bool inappropriateSiteIsFound = false;

            foreach (var detail in GetDetails())
            {
                var detailSite = (INSite)PXSelectorAttribute.Select(DetailsCache, detail, typeof(TDetailSiteField).Name);
                if (detailSite == null || PXAccess.IsSameParentOrganization(newBranchId, detailSite.BranchID))
                {
                    continue;
                }

                inappropriateSiteIsFound = true;

                // In order to force validation in RowPersisting method.
                DetailsCache.MarkUpdated(detail);
            }

            if (inappropriateSiteIsFound)
            {
                RaiseBranchFieldWarning((int?)e.NewValue, Common.Messages.InappropriateSiteOnDetailsTab);
            }
        }
        protected virtual bool IsDestinationSiteValid(SOOrder row, int?newBranchId)
        {
            if (newBranchId == null || PXAccess.FeatureInstalled <FeaturesSet.interBranch>())
            {
                return(true);
            }

            var destSite = INSite.PK.Find(Base, row.DestinationSiteID);

            if (destSite == null || PXAccess.IsSameParentOrganization(newBranchId, destSite.BranchID))
            {
                return(true);
            }

            return(false);
        }
        protected virtual bool IsDestinationSiteValid(SOOrder row, int?newBranchId)
        {
            if (newBranchId == null || PXAccess.FeatureInstalled <FeaturesSet.interBranch>())
            {
                return(true);
            }

            var destSite = (INSite)PXSelectorAttribute.Select(HeaderCache, row, nameof(SOOrder.destinationSiteID));

            if (destSite == null || PXAccess.IsSameParentOrganization(newBranchId, destSite.BranchID))
            {
                return(true);
            }

            return(false);
        }
Example #4
0
        protected virtual void _(Events.RowPersisting <TDetail> e)
        {
            if (e.Operation.Command() == PXDBOperation.Delete)
            {
                return;
            }

            var headerBranchId = (int?)HeaderCache.GetValue <THeaderBranchField>(HeaderCache.Current);

            if (headerBranchId == null || PXAccess.FeatureInstalled <FeaturesSet.interBranch>())
            {
                return;
            }

            var detailSite = (INSite)PXSelectorAttribute.Select(DetailsCache, e.Row, typeof(TDetailSiteField).Name);

            if (detailSite == null || PXAccess.IsSameParentOrganization(headerBranchId, detailSite.BranchID))
            {
                return;
            }

            DetailsCache.RaiseExceptionHandling <INTran.siteID>(e.Row, detailSite.SiteCD, new PXSetPropertyException(Common.Messages.InterBranchFeatureIsDisabled));
        }
        protected virtual void SOOrder_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Operation.Command() == PXDBOperation.Delete || !Base.IsTransferOrder)
            {
                return;
            }

            var order = (SOOrder)e.Row;

            if (order?.BranchID == null || PXAccess.FeatureInstalled <FeaturesSet.interBranch>())
            {
                return;
            }

            var destSite = INSite.PK.Find(Base, order.DestinationSiteID);

            if (destSite == null || PXAccess.IsSameParentOrganization(order.BranchID, destSite.BranchID))
            {
                return;
            }

            cache.RaiseExceptionHandling <SOOrder.destinationSiteID>(e.Row, destSite.SiteCD, new PXSetPropertyException(Common.Messages.InterBranchFeatureIsDisabled));
        }