Ejemplo n.º 1
0
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);

            sender.Graph.FieldUpdating.AddHandler(
                sender.GetItemType(),
                nameof(POLandedCostDoc.hold),
                (cache, e) =>
            {
                PXBoolAttribute.ConvertValue(e);

                var item = e.Row as POLandedCostDoc;
                if (item != null)
                {
                    StatusSet(cache, item, (bool?)e.NewValue);
                }
            });

            sender.Graph.FieldVerifying.AddHandler(
                sender.GetItemType(),
                nameof(POLandedCostDoc.status),
                (cache, e) => { e.NewValue = cache.GetValue <POLandedCostDoc.status>(e.Row); });

            sender.Graph.RowSelected.AddHandler(
                sender.GetItemType(),
                (cache, e) =>
            {
                var document = e.Row as POLandedCostDoc;

                if (document != null)
                {
                    StatusSet(cache, document, document.Hold);
                }
            });
        }
 protected virtual void Dimension_Validate_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e)
 {
     PXBoolAttribute.ConvertValue(e);
     if (e.NewValue != null)
     {
         e.NewValue = !((bool)e.NewValue);
     }
 }
Ejemplo n.º 3
0
        protected virtual void _(Events.FieldUpdating <FeaturesSet, FeaturesSet.centralizedPeriodsManagement> e)
        {
            e.NewValue = PXBoolAttribute.ConvertValue(e.NewValue);
            if (e.Row == null)
            {
                return;
            }

            if (e.Row.CentralizedPeriodsManagement != null && e.Row.CentralizedPeriodsManagement != (bool)e.NewValue && (bool)e.NewValue == true)             // try to set
            {
                CheckMasterOrganizationCalendarDiscrepancy();
                CheckOrganizationCalendarFieldsDiscrepancy();
            }
        }
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);

            sender.Graph.FieldUpdating.AddHandler <CAAdj.hold>((cache, e) =>
            {
                PXBoolAttribute.ConvertValue(e);

                CAAdj item = e.Row as CAAdj;
                if (item != null)
                {
                    UpdateStatus(cache, item, (bool?)e.NewValue);
                }
            });

            sender.Graph.FieldVerifying.AddHandler <CAAdj.status>((cache, e) => { e.NewValue = cache.GetValue <CAAdj.status>(e.Row); });
        }
Ejemplo n.º 5
0
        protected virtual void _(Events.FieldUpdating <FeaturesSet.aSC606> e)
        {
            e.NewValue = PXBoolAttribute.ConvertValue(e.NewValue);

            FeaturesSet row = (FeaturesSet)e.Row;

            if (row == null)
            {
                return;
            }

            bool?oldValue = row.ASC606;

            if (row.ASC606 != null && oldValue != (bool)e.NewValue)
            {
                int?result = PXSelectGroupBy <
                    ARTranAlias,
                    Aggregate <Count> >
                             .SelectSingleBound(this, null)
                             .RowCount;

                if (result > 0)
                {
                    string          question = PXMessages.LocalizeFormatNoPrefixNLA(AR.Messages.UnreleasedDocsWithDRCodes, result);
                    WebDialogResult wdr      = Features.Ask(question, MessageButtons.YesNo);
                    if (wdr != WebDialogResult.Yes)
                    {
                        e.NewValue = oldValue;
                        e.Cancel   = true;
                        return;
                    }
                }

                //The system calculates the number of Stock and Non-Stock Inventories
                //in Active status which have MDA deferral code and empty field Allocation Method in Revenue Components.
                if ((bool)e.NewValue == false)
                {
                    //use AR.Messages.MDAInventoriesWithoutAllocationMethod
                }
            }
        }
Ejemplo n.º 6
0
        protected virtual void _(Events.FieldUpdating <FeaturesSet.centralizedPeriodsManagement> e)
        {
            e.NewValue = PXBoolAttribute.ConvertValue(e.NewValue);
            FeaturesSet row = (FeaturesSet)e.Row;

            if (row == null)
            {
                return;
            }

            int  messageCount = 0;
            bool isError      = false;

            if (row.CentralizedPeriodsManagement != null && row.CentralizedPeriodsManagement != (bool)e.NewValue && (bool)e.NewValue == true)
            {
                foreach (Organization organization in PXSelect <Organization> .Select(this))
                {
                    foreach (MasterFinPeriod problemPeriod in PXSelectJoin <
                                 MasterFinPeriod,
                                 LeftJoin <OrganizationFinPeriod,
                                           On <MasterFinPeriod.finPeriodID, Equal <OrganizationFinPeriod.masterFinPeriodID>,
                                               And <OrganizationFinPeriod.organizationID, Equal <Required <OrganizationFinPeriod.organizationID> > > > >,
                                 Where <OrganizationFinPeriod.finPeriodID, IsNull> >
                             .Select(this, organization.OrganizationID))
                    {
                        isError = true;
                        if (messageCount <= MAX_FINPERIOD_DISCREPANCY_MESSAGE_COUNT)
                        {
                            PXTrace.WriteError(GL.Messages.DiscrepancyPeriod, organization.OrganizationCD, problemPeriod.FinPeriodID);

                            messageCount++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                if (isError)
                {
                    e.Cancel = true;
                    throw new PXSetPropertyException(GL.Messages.DiscrepancyPeriodError);
                }

                Organization etalonOrganization = PXSelect <Organization> .Select(this).First();

                if (etalonOrganization != null)
                {
                    foreach (Organization organization in PXSelect <Organization> .Select(this))
                    {
                        if (organization.OrganizationID == etalonOrganization.OrganizationID)
                        {
                            continue;
                        }

                        foreach (OrganizationFinPeriod problemPeriod in PXSelectJoin <
                                     OrganizationFinPeriod,
                                     LeftJoin <OrganizationFinPeriodStatus,
                                               On <OrganizationFinPeriodStatus.organizationID, Equal <Required <OrganizationFinPeriodStatus.organizationID> >,
                                                   And <OrganizationFinPeriod.finPeriodID, Equal <OrganizationFinPeriodStatus.finPeriodID>,
                                                        And <OrganizationFinPeriod.dateLocked, Equal <OrganizationFinPeriodStatus.dateLocked>,
                                                             And <OrganizationFinPeriod.status, Equal <OrganizationFinPeriodStatus.status>,
                                                                  And <OrganizationFinPeriod.aPClosed, Equal <OrganizationFinPeriodStatus.aPClosed>,
                                                                       And <OrganizationFinPeriod.aRClosed, Equal <OrganizationFinPeriodStatus.aRClosed>,
                                                                            And <OrganizationFinPeriod.iNClosed, Equal <OrganizationFinPeriodStatus.iNClosed>,
                                                                                 And <OrganizationFinPeriod.cAClosed, Equal <OrganizationFinPeriodStatus.cAClosed>,
                                                                                      And <OrganizationFinPeriod.fAClosed, Equal <OrganizationFinPeriodStatus.fAClosed> > > > > > > > > > >,
                                     Where <OrganizationFinPeriodStatus.finPeriodID, IsNull,
                                            And <OrganizationFinPeriod.organizationID, Equal <Required <OrganizationFinPeriod.organizationID> > > > >
                                 .Select(this, organization.OrganizationID, etalonOrganization.OrganizationID))
                        {
                            isError = true;
                            if (messageCount <= MAX_FINPERIOD_DISCREPANCY_MESSAGE_COUNT)
                            {
                                string problemFields = GetProblemFields(organization, problemPeriod);

                                PXTrace.WriteError(GL.Messages.DiscrepancyField,
                                                   etalonOrganization.OrganizationCD,
                                                   organization.OrganizationCD,
                                                   problemFields,
                                                   problemPeriod.FinPeriodID);

                                messageCount++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    if (isError)
                    {
                        e.Cancel = true;
                        throw new PXSetPropertyException(GL.Messages.DiscrepancyFieldError);
                    }
                }

                foreach (PXResult <MasterFinPeriod, OrganizationFinPeriod> res in MasterFinPeriods.Select(etalonOrganization.OrganizationID))
                {
                    MasterFinPeriod       masterFinPeriod       = res;
                    OrganizationFinPeriod organizationFinPeriod = res;

                    masterFinPeriod.DateLocked = organizationFinPeriod.DateLocked;
                    masterFinPeriod.Status     = organizationFinPeriod.Status;
                    masterFinPeriod.APClosed   = organizationFinPeriod.APClosed;
                    masterFinPeriod.ARClosed   = organizationFinPeriod.ARClosed;
                    masterFinPeriod.INClosed   = organizationFinPeriod.INClosed;
                    masterFinPeriod.CAClosed   = organizationFinPeriod.CAClosed;
                    masterFinPeriod.FAClosed   = organizationFinPeriod.FAClosed;

                    this.MasterFinPeriods.Cache.Update(masterFinPeriod);
                }
            }
        }