Exemplo n.º 1
0
        protected virtual void AccountPtr_AccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            AccountAttribute.VerifyAccountIsNotControl <AccountPtr.accountID>(sender, e);

            AccountPtr row = e.Row as AccountPtr;

            if (row != null)
            {
                Account account = PXSelect <Account> .Search <Account.accountID>(this, e.NewValue);

                if (account != null && account.IsCashAccount == true)
                {
                    sender.RaiseExceptionHandling <AccountPtr.accountID>(row, e.NewValue,
                                                                         new PXSetPropertyException(GL.Messages.CashAccountIsNotForProjectPurposes, PXErrorLevel.Warning, account.AccountCD));
                }

                if (account != null && AccountGroup.Current != null && account.AccountGroupID != null && account.AccountGroupID != AccountGroup.Current.GroupID)
                {
                    PMAccountGroup ag = PXSelect <PMAccountGroup, Where <PMAccountGroup.groupID, Equal <Required <PMAccountGroup.groupID> > > > .Select(this, account.AccountGroupID);

                    sender.RaiseExceptionHandling <AccountPtr.accountID>(row, e.NewValue,
                                                                         new PXSetPropertyException(Warnings.AccountIsUsed, PXErrorLevel.Warning, ag.GroupCD));
                }
            }
        }
Exemplo n.º 2
0
        protected virtual void FATran_DebitAccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            var tran = (FATran)e.Row;

            if (tran != null &&
                e.ExternalCall &&
                (tran.TranType == FATran.tranType.DepreciationMinus ||
                 tran.TranType == FATran.tranType.DepreciationPlus))
            {
                AccountAttribute.VerifyAccountIsNotControl <FATran.debitAccountID>(sender, e);
            }
        }
Exemplo n.º 3
0
        protected virtual void FATran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            var tran = (FATran)e.Row;

            if (tran != null &&
                tran.Origin != FARegister.origin.Reversal &&
                (tran.TranType == FATran.tranType.DepreciationMinus ||
                 tran.TranType == FATran.tranType.DepreciationPlus))
            {
                AccountAttribute.VerifyAccountIsNotControl <FATran.debitAccountID>(sender, e);
            }
        }
Exemplo n.º 4
0
        private void ValidateAccountGroupID(PXCache sender, Account account)
        {
            if (account.AccountGroupID == null)
            {
                return;
            }

            if (account.IsCashAccount == true)
            {
                throw new PXSetPropertyException(Messages.CashAccountIsNotForProjectPurposes, PXErrorLevel.Warning, account.AccountCD);
            }
            else
            {
                AccountAttribute.VerifyAccountIsNotControl(account);
            }
        }
Exemplo n.º 5
0
        private void VerifyAccountIDToBeNoControl <T, A>(PXCache cache, EventArgs e, object accountID, int?ledgerID) where T : IBqlField where A : IBqlField
        {
            if (accountID == null)
            {
                return;
            }

            var ledger = (Ledger)PXSelect <Ledger> .Search <Ledger.ledgerID>(this, ledgerID);

            if (ledger?.BalanceType != LedgerBalanceType.Actual)
            {
                return;
            }

            var account = (Account)PXSelect <Account> .Search <A>(this, accountID);

            AccountAttribute.VerifyAccountIsNotControl <T>(cache, e, account);
        }
Exemplo n.º 6
0
        protected virtual void AccountPtr_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            AccountAttribute.VerifyAccountIsNotControl <AccountPtr.accountID>(sender, e);

            AccountPtr row = e.Row as AccountPtr;

            if (row != null)
            {
                switch (e.Operation)
                {
                case PXDBOperation.Delete:
                    RemoveAccount(row);
                    break;

                case PXDBOperation.Insert:
                case PXDBOperation.Update:
                    AddAccount(row);
                    break;
                }

                e.Cancel = true;
            }
        }