protected virtual void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
        {
            EPEmployee employee = PXSelect <EPEmployee, Where <EPEmployee.acctCD, Equal <Required <EPEmployee.acctCD> > > >
                                  .SelectWindowed(sender.Graph, 0, 1, e.NewValue);

            if (employee != null)
            {
                e.NewValue = employee.BAccountID;
                e.Cancel   = true;
            }
            else
            {
                PXFieldUpdating fu = this.GetAttribute <PXDimensionAttribute>().FieldUpdating;
                fu(sender, e);
                e.Cancel = false;

                fu = this.GetAttribute <PXSelectorAttribute>().SubstituteKeyFieldUpdating;
                fu(sender, e);
            }
        }
Пример #2
0
            private void AddNewInjection(PXCache target, string specificModule)
            {
                var graph = target.Graph;

                foreach (PX.SM.RelationGroup group in PXSelect <PX.SM.RelationGroup,
                                                                Where <PX.SM.RelationGroup.specificModule, Equal <Required <Dimension.specificModule> >,
                                                                       And <PX.SM.RelationGroup.specificType, Equal <Required <PX.SM.RelationGroup.specificType> > > > >
                         .Select(graph, specificModule, typeof(SegmentValue).FullName))
                {
                    string name = @group.GroupName;
                    byte[] mask = @group.GroupMask;
                    if (!target.Fields.Contains(name) && mask != null)
                    {
                        PXFieldSelecting fieldSelectingHandler = delegate(PXCache cache, PXFieldSelectingEventArgs a)
                        {
                            a.ReturnState = PXFieldState.CreateInstance(a.ReturnState, typeof(Boolean), null, null, null, null, null, null, name, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Dynamic, null, null, null);
                            SegmentValue value = (SegmentValue)a.Row;
                            if (value != null)
                            {
                                a.ReturnValue = false;
                                if (value.GroupMask != null)
                                {
                                    for (int i = 0; i < value.GroupMask.Length && i < mask.Length; i++)
                                    {
                                        if (mask[i] != 0x00 && (mask[i] & value.GroupMask[i]) == mask[i])
                                        {
                                            a.ReturnValue = true;
                                            return;
                                        }
                                    }
                                }
                            }
                        };
                        PXFieldUpdating fieldUpdatingHandler = delegate(PXCache cache, PXFieldUpdatingEventArgs a)
                        {
                            SegmentValue value = (SegmentValue)a.Row;
                            if (value != null && a.NewValue != null)
                            {
                                bool included = false;
                                if (a.NewValue is string)
                                {
                                    bool.TryParse((string)a.NewValue, out included);
                                }
                                else
                                {
                                    included = (bool)a.NewValue;
                                }
                                if (value.GroupMask == null)
                                {
                                    value.GroupMask = new byte[mask.Length];
                                }
                                else if (value.GroupMask.Length < mask.Length)
                                {
                                    byte[] arr = value.GroupMask;
                                    Array.Resize <byte>(ref arr, mask.Length);
                                    value.GroupMask = arr;
                                }
                                for (int i = 0; i < mask.Length; i++)
                                {
                                    if (mask[i] != 0x00)
                                    {
                                        if (included)
                                        {
                                            value.GroupMask[i] = (byte)(value.GroupMask[i] | mask[i]);
                                        }
                                        else
                                        {
                                            value.GroupMask[i] = (byte)(value.GroupMask[i] & ~mask[i]);
                                        }
                                        if (target.Locate(value) != null && target.GetStatus(value) == PXEntryStatus.Notchanged)
                                        {
                                            target.SetStatus(value, PXEntryStatus.Updated);
                                        }
                                        return;
                                    }
                                }
                            }
                        };
                        _items.Add(new Box(name, fieldSelectingHandler, fieldUpdatingHandler));
                        target.Fields.Add(name);
                        graph.FieldSelecting.AddHandler(typeof(SegmentValue), name, fieldSelectingHandler);
                        graph.FieldUpdating.AddHandler(typeof(SegmentValue), name, fieldUpdatingHandler);
                    }
                }
            }
Пример #3
0
 public Box(string name, PXFieldSelecting selectingHandler, PXFieldUpdating updatingHandler)
 {
     _name             = name;
     _selectingHandler = selectingHandler;
     _updatingHandler  = updatingHandler;
 }