Example #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("نام رابطه مشخص نشده است");
                return;
            }
            if (optIsDisjoint.IsChecked == false && optIsOverlap.IsChecked == false)
            {
                MessageBox.Show("نوع " + "Disjoint/IsOverlap" + "مشخص نشده است");
                return;
            }
            if (optIsTolatParticipation.IsChecked == false && optIsPartialParticipation.IsChecked == false)
            {
                MessageBox.Show("نوع " + "TolatParticipation/PartialParticipation" + "مشخص نشده است");
                return;
            }
            BizISARelationship biz = new BizISARelationship();
            var item = new ISARelationshipDTO();

            item.Name                 = txtName.Text;
            item.IsDisjoint           = optIsDisjoint.IsChecked == true;
            item.IsTolatParticipation = optIsTolatParticipation.IsChecked == true;
            item.IsGeneralization     = optIsGeneralization.IsChecked == true;
            item.ID = biz.Save(item);
            if (ISARelationshipSelected != null)
            {
                ISARelationshipSelected(this, new ISARelationshipSelectedArg()
                {
                    ISARelationship = item
                });
            }
            MyProjectManager.GetMyProjectManager.CloseDialog(this);
        }
Example #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;
        }