private bool ValidateDuplicates(PXCache sender, POSetupApproval row, POSetupApproval oldRow) { foreach (POSetupApproval sibling in SetupApproval.Select()) { if (String.Equals(sibling.OrderType, row.OrderType, StringComparison.OrdinalIgnoreCase) && sibling.AssignmentMapID == row.AssignmentMapID && row.ApprovalID != sibling.ApprovalID) { if (oldRow == null || oldRow.OrderType != row.OrderType) { sender.RaiseExceptionHandling <POSetupApproval.orderType>( row, row.OrderType, new PXSetPropertyException(ErrorMessages.DuplicateEntryAdded) ); } if (oldRow == null || oldRow.AssignmentMapID != row.AssignmentMapID) { sender.RaiseExceptionHandling <POSetupApproval.assignmentMapID>( row, row.AssignmentMapID, new PXSetPropertyException(ErrorMessages.DuplicateEntryAdded) ); } return(false); } } PXUIFieldAttribute.SetError <POSetupApproval.orderType>(sender, row, null); PXUIFieldAttribute.SetError <POSetupApproval.assignmentMapID>(sender, row, null); return(true); }
protected virtual void POSetupApproval_RowInserting(PXCache sender, PXRowInsertingEventArgs e) { POSetupApproval row = (POSetupApproval)e.Row; if (row != null) { e.Cancel = !ValidateDuplicates(sender, row, null); } }
protected virtual void POSetupApproval_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e) { POSetupApproval row = (POSetupApproval)e.Row; POSetupApproval newRow = (POSetupApproval)e.NewRow; if (row != null && newRow != null && row != newRow && (row.OrderType != newRow.OrderType || row.AssignmentMapID != newRow.AssignmentMapID)) { e.Cancel = !ValidateDuplicates(sender, newRow, row); } }