Example #1
0
        protected virtual void BAccount_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            BAccount        acct   = e.Row as BAccount;
            CompanyBAccount header = CompanyHeader.Current;

            if (acct != null && header != null)
            {
                PXCache <BAccount> .RestoreCopy(header, acct);
            }
        }
Example #2
0
        public new IEnumerable SetDefault(PXAdapter adapter)
        {
            CompanyBAccount acct = this.CompanyHeader.Current;

            if (Locations.Current != null && acct != null && Locations.Current.LocationID != acct.DefLocationID)
            {
                acct.DefLocationID = Locations.Current.LocationID;
                this.CompanyHeader.Update(acct);
            }
            return(adapter.Get());
        }
Example #3
0
        protected virtual void CompanyBAccount_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            CompanyBAccount header = e.Row as CompanyBAccount;
            BAccount        acct   = BAccount.Select();

            if (acct != null && header != null)
            {
                PXCache <BAccount> .RestoreCopy(acct, header);

                BAccount.Cache.Normalize();
                if (BAccount.Cache.GetStatus(acct) == PXEntryStatus.Notchanged)
                {
                    BAccount.Cache.SetStatus(acct, PXEntryStatus.Updated);
                }
            }
        }
Example #4
0
        public override void Persist()
        {
            CompanyBAccount header = CompanyHeader.Current;

            if (header != null && CompanyHeader.Cache.GetStatus(header) == PXEntryStatus.Updated)
            {
                Company company = Company.Select();
                if (company != null)
                {
                    company.BAccountID = header.CompanyBAccountID;
                    company.CompanyCD  = header.AcctCD;
                    company.BaseCuryID = header.CompanyBaseCuryID;
                    company.CountryID  = header.CompanyCountryID;
                    company.PhoneMask  = header.CompanyPhoneMask;
                    Company.Update(company);
                }
            }
            base.Persist();
        }
Example #5
0
        protected virtual void CompanyBAccount_AcctCD_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            CompanyBAccount row = e.Row as CompanyBAccount;

            if (row != null)
            {
                if (row.BAccountID != null && row.BAccountID > 0)
                {
                    throw new PXSetPropertyException(Messages.FieldReadOnly);
                }
                else if (e.NewValue != null)
                {
                    BAccount acct = PXSelectReadonly <BAccount, Where <BAccount.acctCD, Equal <Required <BAccount.acctCD> > > > .Select(this, e.NewValue);

                    if (acct != null && acct.BAccountID != row.BAccountID)
                    {
                        throw new PXSetPropertyException(Messages.ItemExistsReenter);
                    }
                }
            }
        }
Example #6
0
        protected virtual void CompanyBAccount_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CompanyBAccount row = e.Row as CompanyBAccount;

            if (row != null)
            {
                if (row.BAccountID == null)
                {
                    BAccount acct = BAccount.Insert(row);
                    row.CompanyBAccountID = acct.BAccountID;
                    PXCache <BAccount> .RestoreCopy(row, acct);

                    CompanyHeader.Update(row);
                }
                else if (row.BAccountID > 0)
                {
                    BAccount.Current = PXCache <BAccount> .CreateCopy(row);

                    PXUIFieldAttribute.SetEnabled <CompanyBAccount.acctCD>(sender, row, false);
                }
                bool allowCurrencyChange = false;
                if (row.CompanyBaseCuryID == null)
                {
                    Currency b = new Currency();
                    b.CuryID = String.Empty;
                    b        = this.CompanyCurrency.Insert(b);
                    if (b != null)
                    {
                        row.CompanyBaseCuryID = b.CuryID;
                    }
                    allowCurrencyChange = true;
                }
                else
                {
                    allowCurrencyChange = AllowChangeCurrency();
                }
                PXUIFieldAttribute.SetEnabled <CompanyBAccount.companyBaseCuryID>(sender, row, allowCurrencyChange);
            }
        }