//private bool PropertyHasValue(SearchProperty item)
        //{
        //    return !string.IsNullOrEmpty(item.Value)  && item.Value.ToLower() != "0";
        //}

        private bool SearchValueIsEmpty(SimpleSearchColumnControl typePropertyControl, string value)
        {
            if (typePropertyControl is NullColumnControl)
            {
                return(string.IsNullOrEmpty(value) || value == "false" || value == "0");
            }
            else if (typePropertyControl is RelationCheckColumnControl || typePropertyControl is RelationCountCheckColumnControl)
            {
                return(string.IsNullOrEmpty(value) || value == "false" || value == "0");
            }
            else
            {
                return(string.IsNullOrEmpty(value) || value == "0");
            }
        }
        //public bool ApplyPreDefinedSearch(EntityPreDefinedSearchDTO message)
        //{
        //    if (message.IsSimpleSearch)
        //    {
        //        if (message.EntitySearchID == SearchInitializer.SearchEntityID)
        //        {
        //            foreach (var item in message.SimpleColumns)
        //            {
        //                SimpleSearchColumnControl columnControl = null;
        //                if (item.EntitySearchColumnsID != 0)
        //                {
        //                    columnControl = SimpleColumnControls.FirstOrDefault(x => x.EntitySearchColumn != null && x.EntitySearchColumn.ID == item.EntitySearchColumnsID);
        //                }
        //                else if (item.ColumnID != 0)
        //                {
        //                    columnControl = SimpleColumnControls.FirstOrDefault(x => x.Column.ID == item.ColumnID);
        //                }
        //                if (columnControl != null)
        //                {
        //                    columnControl.ControlPackage.SetOperator(item.Operator);
        //                    columnControl.ControlPackage.SetValue(item.Value);
        //                }
        //                else
        //                    return false;
        //            }
        //            return true;
        //        }
        //    }
        //    return false;
        //}
        public bool ShowSearchRepository(DP_SearchRepository item)
        {
            firstRepository = item;
            List <SearchProperty> listProperties = GetSearchProperties(item.Phrases);

            foreach (SearchProperty prop in listProperties)
            {
                SimpleSearchColumnControl columnControl = null;
                if (prop.SearchColumnID != 0)
                {
                    columnControl = SimpleColumnControls.FirstOrDefault(x => x.Column.ID == prop.ColumnID && x.EntitySearchColumn != null && x.EntitySearchColumn.ID == prop.SearchColumnID);
                }
                else
                {
                    columnControl = SimpleColumnControls.FirstOrDefault(x => x.Column.ID == prop.ColumnID);
                }
                if (columnControl == null)
                {
                    return(false);
                }
            }
            foreach (SearchProperty prop in listProperties)
            {
                SimpleSearchColumnControl columnControl = null;
                if (prop.SearchColumnID != 0)
                {
                    columnControl = SimpleColumnControls.FirstOrDefault(x => x.Column.ID == prop.ColumnID && x.EntitySearchColumn != null && x.EntitySearchColumn.ID == prop.SearchColumnID);
                }
                else
                {
                    columnControl = SimpleColumnControls.FirstOrDefault(x => x.Column.ID == prop.ColumnID);
                }

                //برای عادی ها جواب میده اگر خودش کمنترل بود چی
                columnControl.ControlManager.SetValue(null, prop.Value);
                if (columnControl.ControlManager.HasOperator())
                {
                    columnControl.ControlManager.SetOperator(prop.Operator);
                }
            }
            return(true);
        }
        private void ManageSimpleSearchView()
        {
            foreach (var column in FullEntity.Columns.OrderBy(x => x.Position))
            {
                var propertyControl = new SimpleSearchColumnControl();
                propertyControl.Column = column;
                SimpleColumnControls.Add(propertyControl);
            }

            foreach (var columnControl in SimpleColumnControls)
            {
                columnControl.Operators = GetSimpleColumnOperators(columnControl.Column);
                //  columnControl.ControlPackage = new UIControlPackageForSimpleColumn();
                columnControl.ControlManager = AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GenerateSimpleControlManagerForOneDataForm(columnControl.Column, GetColumnUISetting(columnControl.Column), false, columnControl.Operators, true, columnControl.Column.Alias);
                var operator1 = columnControl.Operators.FirstOrDefault(x => x.Operator == GetDefaultOperator(columnControl.Column));
                if (operator1 != null)
                {
                    columnControl.ControlManager.SetOperator(operator1.Operator);
                }
                RawSearchView.AddUIControlPackage(columnControl.ControlManager, columnControl.ControlManager.LabelControlManager);
            }
        }
 private bool PropertyHasValue(SimpleSearchColumnControl property, object value)
 {
     return(value != null && !string.IsNullOrEmpty(value.ToString()) && value.ToString().ToLower() != "0");
 }
        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);
                }
            }
        }