コード例 #1
0
        private void OnTabItemSelecting(Object sender, CurrentChangingEventArgs e)        //uncomment
        {
            ItemCollection tbc = (ItemCollection)sender;
            //validate all tabs before we go to next tab
            ValidateAllTabs();
            TabItem ti = tabControlCustomQuery.SelectedItem as TabItem;
            switch (ti.Name)
            {
                case "FromTabItem":
                    //this.CustomQueryTxTBlk.Text = "From";
                    break;
                case "WhereTabItem":
                    //this.CustomQueryTxTBlk.Text = "Where";
                    break;
                case "SelectTabItem":
                    //this.CustomQueryTxTBlk.Text = "Select";
                    // check to see From tab validated
                    if (this.FromTabUC.isValidated & (this.TabulationTabUC.isValidated & this.TabulationTabUC.isTabulation == false) & (this.CrossTabulationTabUC.isValidated & this.CrossTabulationTabUC.isCrossTabulation == false))
                    {
                        this.SelectTabUC.lstToSelecteColFrom.IsEnabled = true;
                        this.SelectTabUC.lstToSelecteColFrom.ItemsSource = GenerateListOfSelectTabColumns();
                    }
                    break;
                case "TabulationTabItem":

                    if (this.FromTabUC.isValidated)
                    {
                        this.TabulationTabUC.StackPanelTabuLationTabGroupBy.IsEnabled = true;
                        this.TabulationTabUC.StackPanelTabuLationTabSummary.IsEnabled = true;

                        List<SQLBuilder.Clauses.Column> listOfTabulationTabColumns = GenerateListOfTabulationTabColumns();

                        //if first drop down is null on Tabulation means all dropdown item source is null
                        if (((TabulationTabStackPanelGroupByControl)this.TabulationTabUC.StackPanelTabuLationTabGroupBy.Children[0]).cmbTabulationTabGroupByColumnsName.Items.Count == 0)
                        {
                            // loading groupby columns
                            for (int i = 0; i < this.TabulationTabUC.StackPanelTabuLationTabGroupBy.Children.Count; i++)
                            {
                                TabulationTabStackPanelGroupByControl tg = (TabulationTabStackPanelGroupByControl)this.TabulationTabUC.StackPanelTabuLationTabGroupBy.Children[i];
                                tg.cmbTabulationTabGroupByColumnsName.ItemsSource = listOfTabulationTabColumns;
                            }
                            // loading summary columns
                            for (int i = 0; i < this.TabulationTabUC.StackPanelTabuLationTabSummary.Children.Count; i++)
                            {
                                TabulationTabStackPanelSummaryControl ts = (TabulationTabStackPanelSummaryControl)this.TabulationTabUC.StackPanelTabuLationTabSummary.Children[i];
                                ts.cmbTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                            }
                        }
                        else
                        {
                            List<SQLBuilder.Clauses.Column> list1 = (List<SQLBuilder.Clauses.Column>)((TabulationTabStackPanelGroupByControl)this.TabulationTabUC.StackPanelTabuLationTabGroupBy.Children[0]).cmbTabulationTabGroupByColumnsName.ItemsSource;

                            IEnumerable<SQLBuilder.Clauses.Column> difference = list1.Except(listOfTabulationTabColumns);

                            if (list1.SequenceEqual(listOfTabulationTabColumns) == false)
                            {
                                // Reloading groupby columns
                                for (int i = 0; i < this.TabulationTabUC.StackPanelTabuLationTabGroupBy.Children.Count; i++)
                                {
                                    TabulationTabStackPanelGroupByControl tg = (TabulationTabStackPanelGroupByControl)this.TabulationTabUC.StackPanelTabuLationTabGroupBy.Children[i];
                                    tg.cmbTabulationTabGroupByColumnsName.ItemsSource = listOfTabulationTabColumns;
                                }
                                // Reloading summary columns
                                for (int i = 0; i < this.TabulationTabUC.StackPanelTabuLationTabSummary.Children.Count; i++)
                                {
                                    TabulationTabStackPanelSummaryControl ts = (TabulationTabStackPanelSummaryControl)this.TabulationTabUC.StackPanelTabuLationTabSummary.Children[i];
                                    ts.cmbTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                                }
                            }
                        }
                    }
                    break;
                case "CrossTabulationTabItem":
                    if (this.FromTabUC.isValidated)
                    {
                        this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.IsEnabled = true;
                        this.CrossTabulationTabUC.cmbCrossTabulationTabSummaryFirstRowColumnsName.IsEnabled = true;
                        this.CrossTabulationTabUC.cmbCrossTabulationTabSummaryFristRowSort.IsEnabled = true;
                        this.CrossTabulationTabUC.StackPanelCrossTabuLationTabSummary.IsEnabled = true;
                        List<SQLBuilder.Clauses.Column> listOfTabulationTabColumns = GenerateListOfTabulationTabColumns();

                        //if first drop down is null on Cross Tabulation means all dropdown item source is null
                        if (((CrossTabulationTabStackPanelGroupByControl)this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.Children[0]).cmbCrossTabulationTabGroupByColumnsName.Items.Count == 0)
                        {
                            // loading groupby columns
                            for (int i = 0; i < this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.Children.Count; i++)
                            {
                                CrossTabulationTabStackPanelGroupByControl ctg = (CrossTabulationTabStackPanelGroupByControl)this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.Children[i];
                                ctg.cmbCrossTabulationTabGroupByColumnsName.ItemsSource = listOfTabulationTabColumns;
                            }
                            //loading summary first row means (column Name and sort) row
                            this.CrossTabulationTabUC.cmbCrossTabulationTabSummaryFirstRowColumnsName.ItemsSource = listOfTabulationTabColumns;
                            // loading summary columns
                            for (int i = 0; i < this.CrossTabulationTabUC.StackPanelCrossTabuLationTabSummary.Children.Count; i++)
                            {
                                CrossTabulationTabStackPanelSummaryControl cts = (CrossTabulationTabStackPanelSummaryControl)this.CrossTabulationTabUC.StackPanelCrossTabuLationTabSummary.Children[i];
                                cts.cmbCrossTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                            }
                        }
                        else
                        {
                            List<SQLBuilder.Clauses.Column> list1 = (List<SQLBuilder.Clauses.Column>)((CrossTabulationTabStackPanelGroupByControl)this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.Children[0]).cmbCrossTabulationTabGroupByColumnsName.ItemsSource;

                            IEnumerable<SQLBuilder.Clauses.Column> difference = list1.Except(listOfTabulationTabColumns);

                            if (list1.SequenceEqual(listOfTabulationTabColumns) == false)
                            {
                                // Reloading groupby columns
                                for (int i = 0; i < this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.Children.Count; i++)
                                {
                                    CrossTabulationTabStackPanelGroupByControl ctg = (CrossTabulationTabStackPanelGroupByControl)this.CrossTabulationTabUC.StackPanelCrossTabuLationTabGroupBy.Children[i];
                                    ctg.cmbCrossTabulationTabGroupByColumnsName.ItemsSource = listOfTabulationTabColumns;
                                }
                                // Reloading summary first row means (column Name and sort) row
                                this.CrossTabulationTabUC.cmbCrossTabulationTabSummaryFirstRowColumnsName.ItemsSource = listOfTabulationTabColumns;

                                // Reloading summary columns
                                for (int i = 0; i < this.CrossTabulationTabUC.StackPanelCrossTabuLationTabSummary.Children.Count; i++)
                                {
                                    CrossTabulationTabStackPanelSummaryControl cts = (CrossTabulationTabStackPanelSummaryControl)this.CrossTabulationTabUC.StackPanelCrossTabuLationTabSummary.Children[i];
                                    cts.cmbCrossTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                                }
                            }
                        }
                    }
                    break;
                case "ActionsTabItem":
                    if (isAllTabValidated)
                    {
                        queryBuilder = LoadSelectQueryBuilder();
                        if (queryBuilder != null)
                        {
                            queryString = queryBuilder.BuildQuery();
                        }
                        XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                        StringWriter writer = new StringWriter();
                        SerializerObj.Serialize(writer, queryBuilder);
                        this.txtQuery.Text = writer.ToString();
                        this.lblActionTabErrorMessage.Content = "";
                    }
                    else
                    {
                        this.txtQuery.Text = "";
                        this.lblActionTabErrorMessage.Content = "There is an error on one or more tab, please fix an error";
                    }
                    break;
            }

        }