private bool ValidateDuplicates(PXCache sender, RQRequestClassItem row, RQRequestClassItem oldRow)
 {
     if (row.InventoryID != null)
     {
         foreach (RQRequestClassItem sibling in ClassItems.Select(row.ReqClassID))
         {
             if (String.Equals(sibling.ReqClassID, row.ReqClassID, StringComparison.OrdinalIgnoreCase) &&
                 sibling.InventoryID == row.InventoryID &&
                 row.LineID != sibling.LineID)
             {
                 if (oldRow == null || oldRow.ReqClassID != row.ReqClassID)
                 {
                     sender.RaiseExceptionHandling <RQRequestClassItem.reqClassID>(
                         row, row.ReqClassID, new PXSetPropertyException(ErrorMessages.DuplicateEntryAdded)
                         );
                 }
                 if (oldRow == null || oldRow.InventoryID != row.InventoryID)
                 {
                     sender.RaiseExceptionHandling <RQRequestClassItem.inventoryID>(
                         row, row.InventoryID, new PXSetPropertyException(ErrorMessages.DuplicateEntryAdded)
                         );
                 }
                 return(false);
             }
         }
     }
     PXUIFieldAttribute.SetError <RQRequestClassItem.reqClassID>(sender, row, null);
     PXUIFieldAttribute.SetError <RQRequestClassItem.inventoryID>(sender, row, null);
     return(true);
 }
Beispiel #2
0
        protected virtual void RQRequestClass_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            RQRequestClass row = (RQRequestClass)e.Row;

            PXDefaultAttribute.SetPersistingCheck <RQRequestClass.expenseAcctID>
                (sender, row,
                row.ExpenseAccountDefault == RQAccountSource.RequestClass ||
                row.ExpenseAccountDefault == RQAccountSource.PurchaseItem
                                        ? PXPersistingCheck.NullOrBlank
                                        : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <RQRequestClass.expenseSubID>(sender, row,
                                                                                row.ExpenseAccountDefault == RQAccountSource.RequestClass ||
                                                                                row.ExpenseAccountDefault == RQAccountSource.PurchaseItem ||
                                                                                row.ExpenseSubMask != null && (row.ExpenseSubMask.Contains(RQAcctSubDefault.MaskClass) || row.ExpenseSubMask.Contains(RQAcctSubDefault.MaskItem))
                                ? PXPersistingCheck.NullOrBlank
                                : PXPersistingCheck.Nothing);

            if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
            {
                if (row.RestrictItemList == true)
                {
                    RQRequestClassItem item = this.ClassItems.SelectWindowed(0, 1, row.ReqClassID);
                    if (item == null)
                    {
                        throw new PXRowPersistedException(typeof(RQRequestClass).Name, item, Messages.ItemListShouldBeDefined);
                    }
                }
            }
        }
Beispiel #3
0
        protected virtual void RQRequestClassItem_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            this.Classes.Cache.MarkUpdated(this.Classes.Cache.Current);
            RQRequestClassItem row = (RQRequestClassItem)e.Row;

            if (row != null)
            {
                e.Cancel = !ValidateDuplicates(sender, row, null);
            }
        }
        protected virtual void RQRequestClassItem_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            this.Classes.Cache.SetStatus(this.Classes.Cache.Current, PXEntryStatus.Updated);
            RQRequestClassItem row    = (RQRequestClassItem)e.Row;
            RQRequestClassItem newRow = (RQRequestClassItem)e.NewRow;

            if (row != null && newRow != null && row != newRow &&
                (row.ReqClassID != newRow.ReqClassID || row.InventoryID != newRow.InventoryID))
            {
                e.Cancel = !ValidateDuplicates(sender, newRow, row);
            }
        }
        protected virtual void RQRequestClassItem_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            if (this.Classes.Cache.GetStatus(this.Classes.Cache.Current) == PXEntryStatus.Notchanged)
            {
                this.Classes.Cache.SetStatus(this.Classes.Cache.Current, PXEntryStatus.Updated);
            }
            RQRequestClassItem row = (RQRequestClassItem)e.Row;

            if (row != null)
            {
                e.Cancel = !ValidateDuplicates(sender, row, null);
            }
        }
 protected virtual void RQRequestClass_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
 {
     if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
     {
         RQRequestClass row = (RQRequestClass)e.Row;
         if (row.RestrictItemList == true)
         {
             RQRequestClassItem item = this.ClassItems.SelectWindowed(0, 1, row.ReqClassID);
             if (item == null)
             {
                 throw new PXRowPersistedException(typeof(RQRequestClass).Name, item, Messages.ItemListShouldBeDefined);
             }
         }
     }
 }