Пример #1
0
        private void btnNewEntity_Click_1(object sender, RoutedEventArgs e)
        {
            var newItem = new TableDrivedEntityDTO()
            {
                Name = "موجودیت جدید"
            };

            foreach (var item in Message.BaseEntity.Columns.Where(x => x.PrimaryKey))
            {
                newItem.Columns.Add(item);
            }

            SuperToSubRelationshipDTO superToSub = new SuperToSubRelationshipDTO();
            SubToSuperRelationshipDTO subToSuper = new SubToSuperRelationshipDTO();

            AddDrivedEntityTab(new Tuple <SuperToSubRelationshipDTO, SubToSuperRelationshipDTO, TableDrivedEntityDTO>(superToSub, subToSuper, newItem));
        }
Пример #2
0
        private void SetEntities()
        {
            Message.BaseEntity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), EntityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships);
            lblEntityName.Text = Message.BaseEntity.Name;

            BizISARelationship bizISARelationship = new BizISARelationship();

            Message.ISARelationship = bizISARelationship.GetInternalTableISARelationships(EntityID);
            if (Message.ISARelationship != null)
            {
                if (Message.ISARelationship.IsTolatParticipation)
                {
                    optIsTolatParticipation.IsChecked = true;
                }
                else
                {
                    optIsPartialParticipation.IsChecked = true;
                }
                if (Message.ISARelationship.IsDisjoint)
                {
                    optIsDisjoint.IsChecked = true;
                }
                else
                {
                    optIsOverlap.IsChecked = true;
                }
            }
            else
            {
                Message.ISARelationship = new ISARelationshipDTO();
            }

            if (Message.ISARelationship.ID != 0)
            {
                List <SuperToSubRelationshipDTO> listSuperToSubRels = new List <SuperToSubRelationshipDTO>();
                var drivedEntities = bizTableDrivedEntity.GetOtherDrivedEntityIDs(Message.ISARelationship);
                foreach (var id in drivedEntities)
                {
                    var entity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), id, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships);
                    List <RelationshipDTO>    removeRelationships    = new List <RelationshipDTO>();
                    SubToSuperRelationshipDTO subToSuperRelationship = null;
                    SuperToSubRelationshipDTO superToSubRelationship = null;

                    foreach (var item in entity.Relationships.Where(x => x.TypeEnum == Enum_RelationshipType.SubToSuper))
                    {
                        if (item is SubToSuperRelationshipDTO)
                        {
                            if ((item as SubToSuperRelationshipDTO).ISARelationship.ID == Message.ISARelationship.ID)
                            {
                                subToSuperRelationship = (item as SubToSuperRelationshipDTO);
                                superToSubRelationship = Message.BaseEntity.Relationships.FirstOrDefault(x => x.ID == (item as SubToSuperRelationshipDTO).PairRelationshipID) as SuperToSubRelationshipDTO;
                            }
                        }
                    }

                    if (subToSuperRelationship != null && superToSubRelationship != null)
                    {
                        entity.Relationships.Remove(subToSuperRelationship);
                        Message.BaseEntity.Relationships.Remove(superToSubRelationship);

                        AddDrivedEntityTab(new Tuple <SuperToSubRelationshipDTO, SubToSuperRelationshipDTO, TableDrivedEntityDTO>(superToSubRelationship, subToSuperRelationship, entity));
                    }
                }
            }
            dtgRelationships.ItemsSource = Message.BaseEntity.Relationships;
            dtgColumns.ItemsSource       = Message.BaseEntity.Columns;
        }