Exemplo n.º 1
0
 protected virtual void RelationGroup_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
 {
     PX.SM.RelationGroup group = e.Row as PX.SM.RelationGroup;
     if (itemclass.Current != null && group != null && Groups.Cache.GetStatus(group) == PXEntryStatus.Notchanged)
     {
         group.Included = PX.SM.UserAccess.IsIncluded(itemclass.Current.GroupMask, group);
     }
 }
 protected virtual void RelationGroup_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
 {
     PX.SM.RelationGroup group = (PX.SM.RelationGroup)e.Row;
     group.SpecificModule = null;
     group.SpecificType   = null;
     group.Active         = false;
     if (sender.GetStatus(group) != PXEntryStatus.InsertedDeleted)
     {
         sender.SetStatus(group, PXEntryStatus.Updated);
     }
 }
        protected virtual void RelationGroup_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            PX.SM.RelationGroup group = (PX.SM.RelationGroup)e.Row;
            if (group.SpecificModule != typeof(INSetup).Namespace || group.SpecificType != typeof(SegmentValue).FullName)
            {
                PX.SM.RelationGroup existing = PXSelectReadonly <PX.SM.RelationGroup,
                                                                 Where <PX.SM.RelationGroup.groupName, Equal <Required <PX.SM.RelationGroup.groupName> > > >
                                               .Select(this, group.GroupName);

                if (existing != null)
                {
                    sender.RestoreCopy(group, existing);
                }
                group.SpecificModule = typeof(INSetup).Namespace;
                group.SpecificType   = typeof(SegmentValue).FullName;
            }
        }
        protected virtual void RelationGroup_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            PX.SM.RelationGroup group = (PX.SM.RelationGroup)e.Row;
            group.SpecificModule = typeof(INSetup).Namespace;
            group.SpecificType   = typeof(SegmentValue).FullName;
            int count = GroupHelper.Count;

            foreach (PX.SM.RelationGroup inserted in sender.Inserted)
            {
                if (inserted.GroupMask != null && inserted.GroupMask.Length > 0)
                {
                    int cnt = 0;
                    for (int i = 0; i < inserted.GroupMask.Length; i++)
                    {
                        if (inserted.GroupMask[i] == 0x00)
                        {
                            cnt += 8;
                        }
                        else
                        {
                            for (int j = 1; j <= 8; j++)
                            {
                                if ((inserted.GroupMask[i] >> j) == 0x00)
                                {
                                    cnt += (9 - j);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    if (cnt > count)
                    {
                        count = cnt;
                    }
                }
            }
            byte[] mask;
            if (count == 0)
            {
                mask = new byte[] { (byte)128, (byte)0, (byte)0, (byte)0 };
            }
            else
            {
                if (count == 0 || count % 32 != 0)
                {
                    mask            = new byte[((count + 31) / 32) * 4];
                    mask[count / 8] = (byte)(128 >> (count % 8));
                }
                else
                {
                    mask = new byte[((count + 31) / 32) * 4 + 4];
                    mask[mask.Length - 4] = (byte)128;
                }
            }
            group.GroupMask = mask;
            if (GroupHelper.Count < mask.Length * 8)
            {
                if (!Views.Caches.Contains(typeof(PX.SM.Neighbour)))
                {
                    Views.Caches.Add(typeof(PX.SM.Neighbour));
                }
                PXCache c = Caches[typeof(PX.SM.Neighbour)];
                foreach (PX.SM.Neighbour n in PXSelect <PX.SM.Neighbour> .Select(this))
                {
                    byte[] ext = n.CoverageMask;
                    Array.Resize <byte>(ref ext, mask.Length);
                    n.CoverageMask = ext;
                    ext            = n.InverseMask;
                    Array.Resize <byte>(ref ext, mask.Length);
                    n.InverseMask = ext;
                    ext           = n.WinCoverageMask;
                    Array.Resize <byte>(ref ext, mask.Length);
                    n.WinCoverageMask = ext;
                    ext = n.WinInverseMask;
                    Array.Resize <byte>(ref ext, mask.Length);
                    n.WinInverseMask = ext;
                    c.Update(n);
                }
                c.IsDirty = false;
            }
        }