public static Tuple <I_EditEntityArea, string> GetEditEntityArea(EditEntityAreaInitializer initializer)
        {
            I_EditEntityArea result = null;
            var simpleEntity        = AgentUICoreMediator.GetAgentUICoreMediator.tableDrivedEntityManagerService.GetSimpleEntity(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), initializer.EntityID);

            if (simpleEntity == null)
            {
                return(new Tuple <I_EditEntityArea, string>(null, "عدم دسترسی به موجودیت به شناسه" + " " + initializer.EntityID));
            }
            var _Permission = AgentUICoreMediator.GetAgentUICoreMediator.tableDrivedEntityManagerService.GetEntityAssignedPermissions(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), initializer.EntityID, false);

            if (!_Permission.GrantedActions.Any(x => x == SecurityAction.ReadOnly ||
                                                x == SecurityAction.Edit || x == SecurityAction.EditAndDelete))
            {
                return(new Tuple <I_EditEntityArea, string>(null, "عدم دسترسی فرمی به موجودیت به شناسه" + " " + initializer.EntityID));
            }
            if (initializer.DataMode == DataMode.None)
            {
                if (simpleEntity.BatchDataEntry == false)
                {
                    initializer.DataMode = DataMode.One;
                }
                else
                {
                    initializer.DataMode = DataMode.Multiple;
                }
            }
            if (initializer.DataMode == DataMode.One)
            {
                result = new EditEntityAreaOneData(simpleEntity);
            }
            else if (initializer.DataMode == DataMode.Multiple)
            {
                result = new EditEntityAreaMultipleData(simpleEntity);
            }
            if (result != null)
            {
                initializer.EditAreaDataManager       = new EditAreaDataManager();
                initializer.ActionActivityManager     = new UIActionActivityManager(result);
                initializer.RelationshipFilterManager = new RelationshipFilterManager(result);
                initializer.EntityAreaLogManager      = new EntityAreaLogManager();
                initializer.UIFomulaManager           = new UIFomulaManager(result as BaseEditEntityArea);
                initializer.UIValidationManager       = new UIValidationManager(result as BaseEditEntityArea);
            }
            return(new Tuple <I_EditEntityArea, string>(result, ""));
        }
 private void EntitySearchLookup_SelectionChanged(object sender, SelectionChangedArg e)
 {
     if (e.SelectedItem != null)
     {
         var entity = e.SelectedItem as TableDrivedEntityDTO;
         EditEntityAreaInitializer editEntityAreaInitializer1 = new EditEntityAreaInitializer();
         editEntityAreaInitializer1.EntityID      = entity.ID;
         editEntityAreaInitializer1.IntracionMode = CommonDefinitions.UISettings.IntracionMode.Select;
         editEntityAreaInitializer1.DataMode      = CommonDefinitions.UISettings.DataMode.One;
         var FirstSideEditEntityAreaResult = EditEntityAreaConstructor.GetEditEntityArea(editEntityAreaInitializer1);
         if (FirstSideEditEntityAreaResult.Item1 != null && FirstSideEditEntityAreaResult.Item1 is I_EditEntityAreaOneData)
         {
             EditEntityArea = FirstSideEditEntityAreaResult.Item1 as I_EditEntityAreaOneData;
             EditEntityArea.SetAreaInitializer(editEntityAreaInitializer1);
             View.AddDataSelector(EditEntityArea.TemporaryDisplayView);
         }
     }
     else
     {
         View.RemoveDataSelector();
     }
 }
        private void ManageSimpleSearchView()
        {
            foreach (var searchcolumn in EntitySearch.EntitySearchAllColumns.OrderBy(x => x.OrderID))
            {
                if (searchcolumn.Column == null)
                {
                    if (searchcolumn.RelationshipTail != null)
                    {
                        var propertyControl = new RelationshipSearchColumnControl();
                        propertyControl.RelationshipTail   = searchcolumn.RelationshipTail;
                        propertyControl.EntitySearchColumn = searchcolumn;

                        EditEntityAreaInitializer editEntityAreaInitializer1 = new EditEntityAreaInitializer();
                        editEntityAreaInitializer1.EntityID      = searchcolumn.RelationshipTail.TargetEntityID;
                        editEntityAreaInitializer1.IntracionMode = CommonDefinitions.UISettings.IntracionMode.Select;

                        editEntityAreaInitializer1.DataMode = CommonDefinitions.UISettings.DataMode.One;
                        var FirstSideEditEntityAreaResult = EditEntityAreaConstructor.GetEditEntityArea(editEntityAreaInitializer1);
                        if (FirstSideEditEntityAreaResult.Item1 != null)
                        {
                            propertyControl.EditNdTypeArea = FirstSideEditEntityAreaResult.Item1 as I_EditEntityAreaOneData;
                            propertyControl.EditNdTypeArea.SetAreaInitializer(editEntityAreaInitializer1);
                            //         propertyControl.ControlPackage = new UIControlPackageForRelationshipColumn();
                            propertyControl.ControlManager = AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GenerateRelationshipControlManagerForOneDataForm(propertyControl.EditNdTypeArea.TemporaryDisplayView, GetRelationshipUISetting(), true, propertyControl.EntitySearchColumn.Alias);
                            if (!string.IsNullOrEmpty(propertyControl.EntitySearchColumn.Tooltip))
                            {
                                propertyControl.ControlManager.LabelControlManager.SetTooltip(null, propertyControl.EntitySearchColumn.Tooltip);
                            }
                        }
                        RelationshipColumnControls.Add(propertyControl);

                        ////اینجا چیه بررسی شود چرا اینجا؟
                        //if (propertyControl.EditNdTypeArea.SimpleEntity.SearchInitially == true)
                        //    propertyControl.EditNdTypeArea.SearchViewEntityArea.SearchInitialy();
                    }
                }
                else
                {
                    var propertyControl = new SimpleSearchColumnControl();
                    propertyControl.Column             = searchcolumn.Column;
                    propertyControl.EntitySearchColumn = searchcolumn;
                    propertyControl.Operators          = GetSimpleColumnOperators(propertyControl.Column);
                    //        propertyControl.ControlPackage = new UIControlPackageForSimpleColumn();
                    propertyControl.ControlManager = AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GenerateSimpleControlManagerForOneDataForm(propertyControl.Column, GetColumnUISetting(propertyControl.Column), false, propertyControl.Operators, true, propertyControl.EntitySearchColumn.Alias);
                    if (!string.IsNullOrEmpty(propertyControl.EntitySearchColumn.Tooltip))
                    {
                        propertyControl.ControlManager.LabelControlManager.SetTooltip(null, propertyControl.EntitySearchColumn.Tooltip);
                    }

                    if (propertyControl.Operators.Any())
                    {
                        propertyControl.ControlManager.SetOperator(propertyControl.Operators.First(x => x.Operator == GetDefaultOperator(propertyControl.Column)).Operator);
                    }
                    SimpleColumnControls.Add(propertyControl);
                }
            }

            foreach (var searchcolumn in EntitySearch.EntitySearchAllColumns.OrderBy(x => x.OrderID))
            {
                if (searchcolumn.Column == null)
                {
                    if (searchcolumn.RelationshipTail != null)
                    {
                        var relControl = RelationshipColumnControls.First(x => x.EntitySearchColumn == searchcolumn);
                        SimpleSearchView.AddView(relControl.ControlManager, relControl.ControlManager.LabelControlManager);
                    }
                }
                else
                {
                    var simpleControl = SimpleColumnControls.First(x => x.EntitySearchColumn == searchcolumn);
                    SimpleSearchView.AddUIControlPackage(simpleControl.ControlManager, simpleControl.ControlManager.LabelControlManager);
                }
            }
        }