示例#1
0
        public virtual void VendorClass_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            VendorClass row = (VendorClass)e.Row;
            PXSelectBase <CashAccount> select = new PXSelect <CashAccount, Where <CashAccount.cashAccountID,
                                                                                  Equal <Required <VendorClass.cashAcctID> > > >(this);

            if (!String.IsNullOrEmpty(row.CuryID) && (row.AllowOverrideCury ?? false) != true)
            {
                CashAccount acct = select.Select(row.CashAcctID);
                if (acct != null)
                {
                    if (row.CuryID != acct.CuryID)
                    {
                        if (cache.RaiseExceptionHandling <VendorClass.cashAcctID>(e.Row, acct.CashAccountCD, new PXSetPropertyException(Messages.VendorCuryDifferentDefPayCury, typeof(VendorClass.cashAcctID).Name)))
                        {
                            throw new PXRowPersistingException(typeof(VendorClass.cashAcctID).Name, null, Messages.VendorCuryDifferentDefPayCury, typeof(VendorClass.cashAcctID).Name);
                        }
                    }
                }
            }
            if (VendorClassRecord.Cache.GetStatus(e.Row) == PXEntryStatus.Inserted)
            {
                EPEmployeeClass e1 = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.vendorClassID, Equal <Current <VendorClass.vendorClassID> > > > .SelectSingleBound(this, new object[] { e.Row });

                if (e1 != null)
                {
                    cache.IsDirty = false;
                    e.Cancel      = true;
                    throw new PXRowPersistingException(typeof(VendorClass.vendorClassID).Name, null, Messages.EmployeeClassExists);
                }
            }
        }
示例#2
0
        protected virtual System.Collections.IEnumerable Cancel(PXAdapter a)
        {
            foreach (PXResult <VendorClass, EPEmployeeClass> e in (new PXCancel <VendorClass>(this, "Cancel")).Press(a))
            {
                if (VendorClassRecord.Cache.GetStatus((VendorClass)e) == PXEntryStatus.Inserted)
                {
                    EPEmployeeClass e1 = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.vendorClassID, Equal <Required <EPEmployeeClass.vendorClassID> > > > .Select(this, ((VendorClass)e).VendorClassID);

                    if (e1 != null)
                    {
                        VendorClassRecord.Cache.RaiseExceptionHandling <VendorClass.vendorClassID>((VendorClass)e, ((VendorClass)e).VendorClassID, new PXSetPropertyException(Messages.EmployeeClassExists));
                    }
                }
                yield return(e);
            }
        }
        protected virtual void CSCalendar_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            CSCalendar row = e.Row as CSCalendar;

            if (row != null)
            {
                EPEmployeeClass refEmpClass = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refEmpClass != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByEmployeeClass, refEmpClass.VendorClassID);
                }

                Carrier refCarrier = PXSelect <Carrier, Where <Carrier.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refCarrier != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByCarrier, refCarrier.CarrierID);
                }

                Contract refContract = PXSelect <Contract, Where <Contract.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refContract != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByContract, refContract.ContractID);
                }

                EPEmployee refEmployee = PXSelect <EPEmployee, Where <EPEmployee.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refEmployee != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByEmployee, refEmployee.ClassID);
                }
            }
        }