Exemplo n.º 1
0
        private void ClearAnalusisFilter_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            if (detailView == null)
            {
                return;
            }

            XafExtAnalysis currentObject = detailView.CurrentObject as XafExtAnalysis;

            if (currentObject == null)
            {
                return;
            }

            // Устанавливаем преднастроенный фильтр, если он определён
            currentObject.Criteria = currentObject.AdminCriteria;

            // Скрываем саму кнопку
            AnalysisCriterionListAction.Active[DO_NOT_ACTIVE] = true;

            // Разблокируем две кнопки
            AnalysisCriterionListAction.Enabled.Clear();
            AnalysisCriterionListAction.Enabled[DO_NOT_ENABLED] = true;


            AnalysisEditorWin         analysisEditor  = null;
            IList <AnalysisEditorWin> analysisEditors = detailView.GetItems <AnalysisEditorWin>();

            if (analysisEditors.Count == 1)
            {
                analysisEditor = analysisEditors[0];
            }

            // Скрытие панели с фильтром
            FilterPanelHide();
            currentFilterId = "";

            if (analysisDataBindController != null)
            {
                if (analysisEditor.IsDataSourceReady)
                {
                    ExecStandartAction(analysisDataBindController.UnbindDataAction);
                }
            }

            if (wp == null)
            {
                return;
            }
            wp.ClearFilter();
        }
Exemplo n.º 2
0
        private void FilteringCriterionListAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
        {
            // В зависимости от выбранного пункта вызывается та или иная форма
            if (detailView == null)
            {
                return;
            }
            DevExpress.ExpressApp.DC.ITypeInfo objectTypeInfo = detailView.ObjectTypeInfo;

            XafExtAnalysis currentObject = detailView.CurrentObject as XafExtAnalysis;

            if (currentObject == null)
            {
                return;
            }

            // Находим, если задан, фильтр из модели
            string           choiceActionItemFilterString = "";
            FilterController fc = Frame.GetController <FilterController>();
            ChoiceActionItem choiceActionItem = ((SingleChoiceAction)(fc.Actions["SetFilter"])).SelectedItem;

            if (choiceActionItem != null)
            {
                choiceActionItemFilterString = choiceActionItem.Data.ToString();
            }

            if (e.SelectedChoiceActionItem.Data != null)
            {
                IModelDetailView node = e.SelectedChoiceActionItem.Data as IModelDetailView;

                // Тип объекта-фильтра
                Type filterObjType = node.ModelClass.TypeInfo.Type;

                string strCriteria = this.criteriaBuilderString;

                IObjectSpace  objectSpace = frame.Application.CreateObjectSpace();
                ICustomFilter objFilter   = objectSpace.CreateObject(filterObjType) as ICustomFilter;
                if (objFilter == null)
                {
                    return;
                }
                objFilter.LV                 = null;
                objFilter.DV                 = detailView;
                objFilter.objectTypeInfo     = objectTypeInfo;
                objFilter.CriteriaController = this;

                objFilter.AdditionalCriterionString = choiceActionItemFilterString;

                //objFilter.Criterion = strCriteria;

                string DetailViewId = frame.Application.FindDetailViewId(objFilter.GetType());

                if (FilterIsShowihg & currentFilterId == DetailViewId)
                {
                    FilterPanelHide();
                    return;
                }

                currentFilterId = DetailViewId;
                FilterIsShowihg = true;

                wp = objFilter as ICustomFilter;
                if (wp == null)
                {
                    return;
                }
                wp.ClearFilter();

                DetailView newView = frame.Application.CreateDetailView(objectSpace, DetailViewId, false, objFilter);
                newView.CreateControls();

                filterPanel.Controls.Clear();
                DevExpress.ExpressApp.Win.Layout.XafLayoutControl ctrlFilter = ((DevExpress.ExpressApp.Win.Layout.XafLayoutControl)newView.Control);
                filterPanel.Controls.Add(ctrlFilter);

                AnalysisCriterionListAction.SelectedIndex = 0;

                //FilterPanelShow(100);
                //FilterPanelShow(GetFilterHight(newView) + 30);

                // Устанавливаем преднастроенный фильтр, если он определён
                currentObject.Criteria = currentObject.AdminCriteria;

                //AnalysisEditorWin analysisEditor = null;
                //IList<AnalysisEditorWin> analysisEditors = detailView.GetItems<AnalysisEditorWin>();
                //if (analysisEditors.Count == 1) {
                //    analysisEditor = analysisEditors[0];
                //}
                //if (analysisEditor != null) {
                //    ChartControl chartControl = ((AnalysisControlWin)analysisEditor.Control).ChartControl;
                //    PivotGridControl pivotGridControl = ((AnalysisControlWin)analysisEditor.Control).PivotGrid;
                //    // Do what you want with the chart and pivot grid controls
                //    pivotGridControl.RefreshData();
                //    chartControl.RefreshData();
                //    //pivotGridControl.Update();
                //}

                ExecStandartAction(analysisDataBindController.UnbindDataAction);

                FilterPanelShow(GetFilterHight(newView) + 30);

                return;
            }
        }
Exemplo n.º 3
0
        private void ApplyAnalysisFilter_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            //((XafExtAnalysis)View.CurrentObject).IsFilterVisible = true;   // !((XafExtAnalysis)View.CurrentObject).IsFilterVisible;

            XafExtAnalysis currentObject = detailView.CurrentObject as XafExtAnalysis;

            if (currentObject == null)
            {
                return;
            }

            // Добавляем преднастроенный фильтр, если он определён
            if (wp != null)
            {
                if (string.IsNullOrEmpty(currentObject.AdminCriteria))
                {
                    currentObject.Criteria = wp.CriterionString;
                }
                else
                {
                    currentObject.Criteria = "(" + currentObject.AdminCriteria + ")" + "(" + wp.CriterionString + ")";
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(currentObject.AdminCriteria))
                {
                    currentObject.Criteria = currentObject.AdminCriteria;
                }
            }

            // Подключаемся к ListViewProcessCurrentObjectController
            if (analysisDataBindController != null)
            {
                AnalysisEditorWin         analysisEditor  = null;
                IList <AnalysisEditorWin> analysisEditors = detailView.GetItems <AnalysisEditorWin>();
                if (analysisEditors.Count == 1)
                {
                    analysisEditor = analysisEditors[0];

                    if (analysisEditor.IsDataSourceReady)
                    {
                        ChartControl     chartControl     = ((AnalysisControlWin)analysisEditor.Control).ChartControl;
                        PivotGridControl pivotGridControl = ((AnalysisControlWin)analysisEditor.Control).PivotGrid;

                        //    Type currentType = currentObject.DataType.UnderlyingSystemType;
                        //    XPCollection xpDataSource = new XPCollection(currentObject.Session, currentType);
                        //    xpDataSource.CriteriaString = currentObject.Criteria;
                        //    if (!xpDataSource.IsLoaded) xpDataSource.Load();

                        //    pivotGridControl.DataSource = xpDataSource;
                        ////pivotGridControl.Fields.A
                        //    //(pivotGridControl.DataSource as XPCollection).CriteriaString = currentObject.Criteria.ToString();

                        pivotGridControl.RefreshData();
                        chartControl.RefreshData();
                        //pivotGridControl.Update();
                        //// Do what you want with the chart and pivot grid controls
                        //foreach (PivotGridField field in pivotGridControl.Fields) {
                        //    field.Visible = true;
                        //}
                    }
                    else
                    {
                        ExecStandartAction(analysisDataBindController.BindDataAction);
                    }
                }
            }
        }