Exemplo n.º 1
0
        protected virtual void INTran_ReasonCode_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            INTran row = e.Row as INTran;

            if (row != null)
            {
                ReasonCode reasoncd = ReasonCode.PK.Find(this, (string)e.NewValue);

                if (reasoncd != null && row.ProjectID != null && !ProjectDefaultAttribute.IsNonProject(row.ProjectID))
                {
                    PX.Objects.GL.Account account = PXSelect <PX.Objects.GL.Account, Where <PX.Objects.GL.Account.accountID, Equal <Required <PX.Objects.GL.Account.accountID> > > > .Select(this, reasoncd.AccountID);

                    if (account != null && account.AccountGroupID == null)
                    {
                        sender.RaiseExceptionHandling <INTran.reasonCode>(e.Row, account.AccountCD, new PXSetPropertyException(PM.Messages.NoAccountGroup, PXErrorLevel.Warning, account.AccountCD));
                    }
                }

                e.Cancel = (reasoncd != null) &&
                           (row.TranType != INTranType.Issue && row.TranType != INTranType.Receipt && reasoncd.Usage == ReasonCodeUsages.Sales || reasoncd.Usage == row.DocType);
            }
        }
Exemplo n.º 2
0
        public virtual IEnumerable preload(PXAdapter adapter)
        {
            if (PreloadFilter.Current.FromAccount == null)
            {
                PreloadFilter.Cache.RaiseExceptionHandling <AccountsPreloadFilter.fromAccount>(PreloadFilter.Current, PreloadFilter.Current.FromAccount, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.RowError));
                PreloadFilter.Cache.RaiseExceptionHandling <AccountsPreloadFilter.toAccount>(PreloadFilter.Current, PreloadFilter.Current.ToAccount, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.RowError));
                return(adapter.Get());
            }
            GLBudgetTree currentItem = ((GLBudgetTree)PXSelect <GLBudgetTree,
                                                                Where <GLBudgetTree.groupID,
                                                                       Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group));

            PreloadFilter.Current.AccountCDWildcard = SubCDUtils.CreateSubCDWildcard(currentItem != null ? currentItem.AccountMask : string.Empty, AccountAttribute.DimensionName);

            GLBudgetTree LastItem = PXSelect <GLBudgetTree,
                                              Where <GLBudgetTree.parentGroupID,
                                                     Equal <Required <GLBudgetTree.parentGroupID> > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, this.CurrentSelected.Group);

            int  LastSortNum                  = LastItem == null ? 1 : LastItem.SortOrder.Value + 1;
            bool noLinesPreloaded             = true;
            List <GLBudgetTree> nodesToInsert = new List <GLBudgetTree>();

            foreach (PXResult <Account> account in PXSelect <Account, Where <Account.accountCD,
                                                                             GreaterEqual <Required <AccountsPreloadFilter.fromAccount> >,
                                                                             And <Account.active, Equal <True>,
                                                                                  And <Account.accountCD, LessEqual <Required <AccountsPreloadFilter.toAccount> > > > > > .Select(this,
                                                                                                                                                                                  PreloadFilter.Current.FromAccount != null ?
                                                                                                                                                                                  ((Account)PXSelect <Account, Where <Account.accountID, Equal <Current <AccountsPreloadFilter.fromAccount> > > > .Select(this)).AccountCD :
                                                                                                                                                                                  ((Account)PXSelect <Account> .Select(this).First()).AccountCD,
                                                                                                                                                                                  PreloadFilter.Current.ToAccount != null ?
                                                                                                                                                                                  ((Account)PXSelect <Account, Where <Account.accountID, Equal <Current <AccountsPreloadFilter.toAccount> > > > .Select(this)).AccountCD :
                                                                                                                                                                                  ((Account)PXSelect <Account> .Select(this).Last()).AccountCD))
            {
                foreach (PXResult <Sub> sub in PXSelect <Sub, Where <Sub.active, Equal <True>, And <Sub.subCD, Like <Current <AccountsPreloadFilter.subCDWildcard> > > > > .Select(this))
                {
                    Account      acct    = account;
                    Sub          subAcct = sub;
                    GLBudgetTree group   = new GLBudgetTree();
                    if (currentItem == null || acct.AccountID != currentItem.AccountID || subAcct.SubID != currentItem.SubID)
                    {
                        group.AccountID = acct.AccountID;
                        group.SubID     = subAcct.SubID;

                        group.SortOrder = LastSortNum++;

                        group.GroupMask = CurrentSelected.GroupMask;

                        nodesToInsert.Add(group);
                        noLinesPreloaded = false;
                    }
                }
            }
            if (noLinesPreloaded)
            {
                if (Details.Ask(Messages.BudgetTreePreloadArticlesTitle, Messages.BudgetTreePreloadArticlesNothingToPreload, MessageButtons.OK) == WebDialogResult.OK)
                {
                    return(adapter.Get());
                }
            }
            if (nodesToInsert.Count > 500)
            {
                if (Details.Ask(Messages.Confirmation, String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreePreloadArticlesTooManyMessage), nodesToInsert.Count), MessageButtons.OKCancel) == WebDialogResult.OK)
                {
                    foreach (GLBudgetTree node in nodesToInsert)
                    {
                        Details.Insert(node);
                    }
                }
            }
            else
            {
                foreach (GLBudgetTree node in nodesToInsert)
                {
                    Details.Insert(node);
                }
            }
            return(adapter.Get());
        }