private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     if (txtViewName.Text == "")
     {
         MessageBox.Show("عنوان مناسب تعریف نشده است");
         return;
     }
     foreach (var item in Message.EntitySearchAllColumns)
     {
         if (item.RelationshipTailID != 0)
         {
             var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
             BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
             var entity = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), EntityID);;
             var linkedServerMessage = bizEntityRelationshipTail.CheckLinkedServers(entity, relationshipTail);
             if (linkedServerMessage != "")
             {
                 var message = "اشکال در تعریف لینک سرور برای ستون" + " " + (string.IsNullOrEmpty(item.Alias) ? item.ColumnID.ToString() : item.Alias);
                 message += Environment.NewLine + linkedServerMessage;
                 MessageBox.Show(message);
                 return;
             }
         }
     }
     foreach (var item in Message.EntitySearchAllColumns)
     {
         if (item.RelationshipTailID != 0)
         {
             if (item.ColumnID == 0)
             {
                 BizTableDrivedEntity biz = new BizTableDrivedEntity();
                 var relationshipTail     = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                 var entity = biz.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), relationshipTail.TargetEntityID, EntityColumnInfoType.WithoutColumn, EntityRelationshipInfoType.WithoutRelationships);
                 if (entity.IsView)
                 {
                     MessageBox.Show("به منظور استفاده از رشته رابطه" + " " + relationshipTail.EntityPath + " " + "، به علت منتهی شدن با نما، انتخاب ستون هدف اجباری می باشد");
                     return;
                 }
             }
         }
     }
     Message.TableDrivedEntityID = EntityID;
     Message.Title = txtViewName.Text;
     Message.ID    = bizEntitySearch.UpdateEntitySearchs(Message);
     if (EntitySearchUpdated != null)
     {
         EntitySearchUpdated(this, new MyProject_WPF.EntitySearchUpdatedArg()
         {
             ID = Message.ID
         });
     }
     MessageBox.Show("اطلاعات ثبت شد");
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtViewName.Text == "")
            {
                MessageBox.Show("عنوان مناسب تعریف نشده است");
                return;
            }

            foreach (var item in Message.EntityListViewAllColumns)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
                    var entity = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), EntityID);
                    var linkedServerMessage = bizEntityRelationshipTail.CheckLinkedServers(entity, relationshipTail);
                    if (linkedServerMessage != "")
                    {
                        var message = "اشکال در تعریف لینک سرور برای ستون" + " " + (string.IsNullOrEmpty(item.Alias) ? item.ColumnID.ToString() : item.Alias);
                        message += Environment.NewLine + linkedServerMessage;
                        MessageBox.Show(message);
                        return;
                    }
                    if (relationshipTail.IsOneToManyTail)
                    {
                        var message = "رشته رابطه برای ستون" + " " + (string.IsNullOrEmpty(item.Alias) ? item.ColumnID.ToString() : item.Alias) + " " + "نمی تواند یک به چند باشد";
                        MessageBox.Show(message);
                        return;
                    }
                }
            }

            Message.TableDrivedEntityID = EntityID;
            Message.Title = txtViewName.Text;
            Message.ID    = bizEntityListView.UpdateEntityListViews(Message);
            if (EntityListViewUpdated != null)
            {
                EntityListViewUpdated(this, new MyProject_WPF.EntityListViewUpdatedArg()
                {
                    ID = Message.ID
                });
            }
            MessageBox.Show("اطلاعات ثبت شد");
        }
Beispiel #3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("نام");
                return;
            }
            if (lokFirstSideEntity.SelectedItem == null)
            {
                MessageBox.Show("موجودیت سمت اول انتخاب نشده است");
                return;
            }
            if (lokSecondSideEntity.SelectedItem == null)
            {
                MessageBox.Show("موجودیت سمت دوم انتخاب نشده است");
                return;
            }

            if (lokFirstDataMenu.SelectedItem != null)
            {
                Message.FirstSideDataMenuID = (int)lokFirstDataMenu.SelectedValue;
            }
            if (lokSecondDataMenu.SelectedItem != null)
            {
                Message.SecondSideDataMenuID = (int)lokSecondDataMenu.SelectedValue;
            }

            foreach (var item in Message.RelationshipsTails)
            {
                if (colRelationshipTail.ItemsSource != null && colRelationshipTail.ItemsSource is List <EntityRelationshipTailDTO> )
                {
                    var tail = (colRelationshipTail.ItemsSource as List <EntityRelationshipTailDTO>).FirstOrDefault(x => x.ID == item.RelationshipTailID);
                    if (tail != null)
                    {
                        TableDrivedEntityDTO sEntity = lokSecondSideEntity.SelectedItem as TableDrivedEntityDTO;
                        if (tail.TargetEntityID != sEntity.ID)
                        {
                            MessageBox.Show("رشته رابطه" + " " + tail.EntityPath + " " + "با موجودیت" + " " + sEntity.Alias + " " + "در ارتباط نمی باشد");
                            return;
                        }
                    }
                }
            }
            foreach (var item in Message.RelationshipsTails)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
                    var entity      = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), relationshipTail.TargetEntityID);
                    var viewMessage = bizEntityRelationshipTail.CheckTailHasRelationshipWithView(relationshipTail);
                    if (viewMessage != "")
                    {
                        var message = "اشکال در تعریف لینک داده با موجودیت" + " " + string.IsNullOrEmpty(relationshipTail.TargetEntityAlias);
                        message += Environment.NewLine + "در رشته رابطه ارتباط با نمای" + " " + viewMessage + " " + "امکان پذیر نمی باشد";
                        MessageBox.Show(message);
                        return;
                    }
                }
            }

            var firstEntity  = lokFirstSideEntity.SelectedItem as TableDrivedEntityDTO;
            var secondEntity = lokSecondSideEntity.SelectedItem as TableDrivedEntityDTO;

            if (firstEntity.ServerID != secondEntity.ServerID)
            {
                BizDatabase bizDatabase = new BizDatabase();
                if (!bizDatabase.LinkedServerExists(firstEntity.ServerID, secondEntity.ServerID))
                {
                    MessageBox.Show("ارتباط لینک سرور بین موجودیت طرف اول و دوم وجود ندارد");
                    return;
                }
            }
            foreach (var item in Message.RelationshipsTails)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail    = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    var linkedServerMessage = bizEntityRelationshipTail.CheckRelationshipsLinkedServers(relationshipTail);
                    if (linkedServerMessage != "")
                    {
                        var message = "اشکال در رشته رابطه" + " " + string.IsNullOrEmpty(relationshipTail.EntityPath);
                        message += Environment.NewLine + linkedServerMessage;
                        MessageBox.Show(message);
                        return;
                    }
                }
            }
            Message.NotJointEntities = chkNotJoint.IsChecked == true;
            Message.ReportTitle      = txtName.Text;
            if (Message.ID == 0)
            {
                Message.TableDrivedEntityID = (int)lokFirstSideEntity.SelectedValue;
                Message.SecondSideEntityID  = (int)lokSecondSideEntity.SelectedValue;
            }

            Message.ID = bizDataLink.UpdateDataLink(Message);
            MessageBox.Show("اطلاعات ثبت شد");
            if (Updated != null)
            {
                Updated(this, new MyProject_WPF.UpdatedEventArg()
                {
                    ID = Message.ID
                });
            }
        }
        //private void AddFile_Click(object sender, RoutedEventArgs e)
        //{
        //    OpenFileDialog openFileDialog = new OpenFileDialog();
        //    openFileDialog.Filter = "Icons (*.png,*.ico)|*.png;*.ico|All files (*.*)|*.*";
        //    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        //    //if (openFileDialog.ShowDialog() == true)
        //    //{
        //    //    txtFilePath.Text = openFileDialog.FileName;
        //    //}
        //}

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            foreach (var item in Message.DataViewRelationships)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
                    var entity = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), relationshipTail.TargetEntityID);
                    var linkedServerMessage = bizEntityRelationshipTail.CheckLinkedServers(entity, relationshipTail.ReverseRelationshipTail);
                    if (linkedServerMessage != "")
                    {
                        var message = "اشکال در تعریف نمایش داده و لینک سرور برای موجودیت" + " " + string.IsNullOrEmpty(relationshipTail.TargetEntityAlias);
                        message += Environment.NewLine + linkedServerMessage;
                        MessageBox.Show(message);
                        return;
                    }
                }
            }
            foreach (var item in Message.GridViewRelationships)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
                    var entity = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), relationshipTail.TargetEntityID);
                    var linkedServerMessage = bizEntityRelationshipTail.CheckLinkedServers(entity, relationshipTail.ReverseRelationshipTail);
                    if (linkedServerMessage != "")
                    {
                        var message = "اشکال در تعریف گرید داده و لینک سرور برای موجودیت" + " " + string.IsNullOrEmpty(relationshipTail.TargetEntityAlias);
                        message += Environment.NewLine + linkedServerMessage;
                        MessageBox.Show(message);
                        return;
                    }
                }
            }
            foreach (var item in Message.SearchableReportRelationships)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
                    var entity = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), relationshipTail.TargetEntityID);
                    var linkedServerMessage = bizEntityRelationshipTail.CheckLinkedServers(entity, relationshipTail.ReverseRelationshipTail);
                    if (linkedServerMessage != "")
                    {
                        var message = "اشکال در تعریف گزارشات مرتبط و لینک سرور برای موجودیت" + " " + string.IsNullOrEmpty(relationshipTail.TargetEntityAlias);
                        message += Environment.NewLine + linkedServerMessage;
                        MessageBox.Show(message);
                        return;
                    }
                }
                if (item.EntitySearchableReportID == 0)
                {
                    var message = "اشکال در تعریف گزارشات مرتبط";
                    message += Environment.NewLine + "گزارش مرتبط اجباری می باشد";
                    MessageBox.Show(message);
                    return;
                }
            }
            if (Entity.IsView)
            {
                if (lokRelationship.SelectedItem != null)
                {
                    if (lokDataMenuSetting.SelectedItem == null)
                    {
                        MessageBox.Show("تنظیمات منوی رابطه مشخص نشده است");
                        return;
                    }
                }
            }
            if (Message.SearchableReportRelationships.Any(x => x.RelationshipTailID == 0))
            {
                MessageBox.Show("انتخاب رابطه و گزارش برای لیست گزارشات اجباری می باشد");
                return;
            }
            if (txtFilePath.Text != "")
            {
                Message.IconContent = File.ReadAllBytes(txtFilePath.Text);
            }
            if (lokEntityDataView.SelectedItem != null)
            {
                Message.EntityListViewID = (int)lokEntityDataView.SelectedValue;
            }
            else
            {
                Message.EntityListViewID = 0;
            }
            Message.EntityID = EntityID;
            Message.Name     = txtName.Text;

            if (lokRelationship.SelectedItem != null)
            {
                Message.RelationshipID = (int)lokRelationship.SelectedValue;
            }
            if (lokDataMenuSetting.SelectedItem != null)
            {
                Message.TargetDataMenuSettingID = (int)lokDataMenuSetting.SelectedValue;
            }


            bizDataMenuSetting.UpdateEntityReportDataMenuSettings(Message);
            MessageBox.Show("اطلاعات ثبت شد");
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("نام");
                return;
            }
            if (lokFirstSideEntity.SelectedItem == null)
            {
                MessageBox.Show("موجودیت سمت اول انتخاب نشده است");
                return;
            }


            foreach (var item in Message.RelationshipsTails)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    BizTableDrivedEntity bizTableDrivedEntity = new MyModelManager.BizTableDrivedEntity();
                    var entity      = bizTableDrivedEntity.GetSimpleEntity(MyProjectManager.GetMyProjectManager.GetRequester(), relationshipTail.TargetEntityID);
                    var viewMessage = bizEntityRelationshipTail.CheckTailHasRelationshipWithView(relationshipTail);
                    if (viewMessage != "")
                    {
                        var message = "اشکال در تعریف لینک داده با موجودیت" + " " + string.IsNullOrEmpty(relationshipTail.TargetEntityAlias);
                        message += Environment.NewLine + "در رشته رابطه ارتباط با نمای" + " " + viewMessage + " " + "امکان پذیر نمی باشد";
                        MessageBox.Show(message);
                        return;
                    }
                }
            }

            foreach (var item in Message.RelationshipsTails)
            {
                if (item.RelationshipTailID != 0)
                {
                    var relationshipTail    = bizEntityRelationshipTail.GetEntityRelationshipTail(MyProjectManager.GetMyProjectManager.GetRequester(), item.RelationshipTailID);
                    var linkedServerMessage = bizEntityRelationshipTail.CheckRelationshipsLinkedServers(relationshipTail);
                    if (linkedServerMessage != "")
                    {
                        var message = "اشکال در رشته رابطه" + " " + string.IsNullOrEmpty(relationshipTail.EntityPath);
                        message += Environment.NewLine + linkedServerMessage;
                        MessageBox.Show(message);
                        return;
                    }
                }
            }

            Message.ReportTitle = txtName.Text;
            if (lokFirstDataMenu.SelectedItem != null)
            {
                Message.FirstSideDataMenuID = (int)lokFirstDataMenu.SelectedValue;
            }
            Message.TableDrivedEntityID = (int)lokFirstSideEntity.SelectedValue;
            Message.NotJointEntities    = chkNotJoint.IsChecked == true;
            Message.ID = bizGraph.UpdateGraph(Message);
            MessageBox.Show("اطلاعات ثبت شد");
            if (Updated != null)
            {
                Updated(this, new MyProject_WPF.UpdatedEventArg()
                {
                    ID = Message.ID
                });
            }
        }