protected virtual void EPRuleCondition_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { EPRuleCondition oldRow = e.OldRow as EPRuleCondition; EPRuleCondition newRow = e.Row as EPRuleCondition; if (oldRow != null && newRow != null) { if (!String.Equals(newRow.Entity, oldRow.Entity, StringComparison.OrdinalIgnoreCase)) { newRow.FieldName = newRow.Value = newRow.Value2 = null; } if (!String.Equals(newRow.FieldName, oldRow.FieldName, StringComparison.OrdinalIgnoreCase)) { newRow.Value = newRow.Value2 = null; } EPRuleCondition row = e.Row as EPRuleCondition; if (row.Condition == null || (PXCondition)row.Condition == PXCondition.ISNULL || (PXCondition)row.Condition == PXCondition.ISNOTNULL) { newRow.Value = newRow.Value2 = null; } if (newRow.Value == null) { PXFieldState state = sender.GetStateExt <EPRuleCondition.value>(newRow) as PXFieldState; newRow.Value = state != null && state.Value != null?state.Value.ToString() : null; } } }
protected virtual void EPRuleCondition_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { EPRuleCondition row = (EPRuleCondition)e.Row; if (row == null) { return; } if (AssigmentMap.Current == null) { return; } Type type = GraphHelper.GetType(AssigmentMap.Current.EntityType); if (type != null) { Type cachetype = GraphHelper.GetType(row.Entity); if (cachetype == null) { return; } PXFieldState state = GetPXFieldState(cachetype, row.FieldName); if (state == null) { throw new PXSetPropertyException <EPRuleCondition.fieldName>(Messages.FieldCannotBeFound, PXErrorLevel.Error); } } }
private void RestoreConditionValues(EPRuleCondition row, EPRuleCondition restoreFrom) { this.Rules.Cache.SetValue <EPRuleCondition.fieldName>(row, restoreFrom.FieldName); this.Rules.Cache.Update(row); this.Rules.Cache.SetValueExt <EPRuleCondition.value>(row, restoreFrom.Value); this.Rules.Cache.SetValue <EPRuleCondition.value2>(row, restoreFrom.Value2); this.Rules.Cache.Update(row); }
protected virtual void EPRuleCondition_FieldName_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { EPRuleCondition row = e.Row as EPRuleCondition; if (row != null && row.Entity != null) { e.ReturnState = CreateFieldStateForFieldName(e.ReturnState, AssigmentMap.Current.EntityType, AssigmentMap.Current.GraphType, row.Entity); } }
protected virtual void EPRuleCondition_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { EPRuleCondition row = e.Row as EPRuleCondition; if (row != null && !string.IsNullOrEmpty(row.FieldName) && row.Condition != null && (PXCondition)row.Condition != PXCondition.ISNULL && (PXCondition)row.Condition != PXCondition.ISNOTNULL) { var fieldState = CreateFieldStateForFieldValue(e.ReturnState, AssigmentMap.Current.EntityType, row.Entity, row.FieldName); if (fieldState != null) { e.ReturnState = fieldState; } } }
public virtual IEnumerable ConditionDown(PXAdapter adapter) { if (this.Rules.Current == null) { return(adapter.Get()); } EPRuleCondition next = PXSelect <EPRuleCondition, Where <EPRuleCondition.ruleID, Equal <Current <EPRule.ruleID> >, And <EPRuleCondition.rowNbr, Greater <Current <EPRuleCondition.rowNbr> > > >, OrderBy <Asc <EPRuleCondition.rowNbr> > > .Select(this); if (next != null) { var current = this.Rules.Current; var nextCopy = (EPRuleCondition)this.Rules.Cache.CreateCopy(next); var currentCopy = (EPRuleCondition)this.Rules.Cache.CreateCopy(this.Rules.Current); this.SwapItems(this.Rules.Cache, next, current); RestoreConditionValues(next, currentCopy); RestoreConditionValues(current, nextCopy); this.Rules.Cache.ActiveRow = next; } return(adapter.Get()); }
public virtual IEnumerable ConditionUp(PXAdapter adapter) { if (this.Rules.Current == null) { return(adapter.Get()); } EPRuleCondition prev = PXSelect <EPRuleCondition, Where <EPRuleCondition.ruleID, Equal <Current <EPRule.ruleID> >, And <EPRuleCondition.rowNbr, Less <Current <EPRuleCondition.rowNbr> > > >, OrderBy <Desc <EPRuleCondition.rowNbr> > > .Select(this); if (prev != null) { var current = this.Rules.Current; var prevCopy = (EPRuleCondition)this.Rules.Cache.CreateCopy(prev); var currentCopy = (EPRuleCondition)this.Rules.Cache.CreateCopy(this.Rules.Current); this.SwapItems(this.Rules.Cache, prev, current); RestoreConditionValues(prev, currentCopy); RestoreConditionValues(current, prevCopy); this.Rules.Cache.ActiveRow = prev; } return(adapter.Get()); }
protected virtual void EPRuleCondition_FieldName_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { EPRuleCondition condition = (EPRuleCondition)e.Row; Type type = GraphHelper.GetType(AssigmentMap.Current.EntityType); if (type != null) { Type cachetype = GraphHelper.GetType(condition.Entity); if (cachetype == null) { return; } PXCache cache = this.Caches[cachetype]; PXDBAttributeAttribute.Activate(cache); PXFieldState state = cache.GetStateExt(null, e.NewValue.ToString()) as PXFieldState; if (state == null) { throw new PXException(Messages.FieldCannotBeFound); } } }
protected virtual void EPRuleCondition_Entity_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { EPRuleCondition row = e.Row as EPRuleCondition; Rules.Cache.SetValue <EPRuleCondition.fieldName>(row, null); }