private void lstSelectedCol_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var col = ((FrameworkElement)e.OriginalSource).DataContext as Column;

            if (col != null)
            {
                _SelectedColCollection.Remove(col);
            }

            if (_SelectedColCollection.Count <= 11 && isExpanded == true)
            {
                SelectedColsStackPanel.Width -= 16;
                isExpanded = false;
            }
            /***********Validate Control***********/
            Validate();
            /**************************************/

            /*****Update Cross Tabulation**********/
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstSelectedCol);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.UpdateCrossTabulationTabCntrl(mainWindow);
                rvc.UpdateTabulationTabCntrl(mainWindow);
            }
            /**************************************/
        }
        private void RemoveAllBtn_Click(object sender, RoutedEventArgs e)
        {
            _SelectedColCollection.Clear();
            if (_SelectedColCollection.Count <= 11 && isExpanded == true)
            {
                SelectedColsStackPanel.Width -= 16;
                isExpanded = false;
            }
            /***********Validate Control***********/
            Validate();
            /**************************************/

            /*****Update Cross Tabulation and Tabulation**********/
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstSelectedCol);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.UpdateCrossTabulationTabCntrl(mainWindow);
                rvc.UpdateTabulationTabCntrl(mainWindow);
            }
            /**************************************/
        }
Beispiel #3
0
        private void UpdateXmlQuery()
        {
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbWhereTabLeftSideColumns);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWhereTabLeftSideColumns);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (mainWindow.ValidateAllTabCntrls(rvc))
                {
                    SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(rvc);
                    if (queryBuilder != null)
                    {
                        queryString = queryBuilder.BuildQuery();
                    }
                    XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                    StringWriter  writer        = new StringWriter();
                    SerializerObj.Serialize(writer, queryBuilder);
                }
                else
                {
                }
            }
        }
        private void AddRegularConditionRow()
        {
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWherTabCondition);
            ResultViewControl        rvc    = null;

            if (parent != null)
            {
                rvc = (ResultViewControl)parent;
            }

            WhereTabRegularConditionControl ws = new WhereTabRegularConditionControl();

            ws.Name = "Fs1";
            ws.cmbWhereTabQueryLevel.SelectedIndex = 0;
            ws.cmbWhereTabQueryAndOr.SelectedIndex = 0;
            ////** Check for AllDisabled
            if (isAllDisabled)
            {
                this.lblErrorMessage.Content        = "";
                ws.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                ws.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
            }
            ws.btnDelete.Visibility = System.Windows.Visibility.Visible;
            LoadColumnComboBox(ws);
            this.StackPanelWhereTab.Children.Add(ws);
        }
        private void UpdateXmlQuery()
        {
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbWhereTabInNotInColumns);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWhereTabInNotInColumns);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (mainWindow.ValidateAllTabCntrls(rvc))
                {
                    SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(rvc);
                    if (queryBuilder != null)
                    {
                        queryString = queryBuilder.BuildQuery();
                    }
                    XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                    StringWriter  writer        = new StringWriter();
                    SerializerObj.Serialize(writer, queryBuilder);
                    //rvc.txtQuery.Text = writer.ToString();
                    //rvc.lblActionTabErrorMessage.Content = "";
                }
                else
                {
                    //rvc.txtQuery.Text = "";
                    //rvc.lblActionTabErrorMessage.Content = "There is an error on one or more tab, please fix an error";
                }
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            whereborder.Visibility = System.Windows.Visibility.Visible;
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbWherTabCondition);

            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWherTabCondition);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (rvc.FromTabCntrl.isValidated)
                {
                    this.lblErrorMessage.Content = "";

                    //validate before adding stack panel row
                    Validate();
                    //** Check for AllDisabled
                    SetIsAllDisabled();
                    //***Add condition control
                    if (this.cmbWherTabCondition.SelectedIndex != -1)
                    {
                        switch (this.cmbWherTabCondition.Text)
                        {
                        case "Regular":
                            AddRegularConditionRow();
                            break;

                        case "Between":
                            AddBetweenConditionRow();
                            break;

                        case "In":
                            AddInNotInConditionRow();
                            break;

                        case "Not In":
                            AddInNotInConditionRow();
                            break;

                        case "Null":
                            AddNullNotNullConditionRow();
                            break;

                        case "Not Null":
                            AddNullNotNullConditionRow();
                            break;
                        }
                    }
                    Size size = new Size(1200, 500);
                }
                else
                {
                    this.lblErrorMessage.Content           = "********There is an error on From Tab**********";
                    rvc.lblXmlQueryTabErrorMessage.Content = "There is an error in one of Tabs";
                }
            }
        }
Beispiel #7
0
        private void txtCrossTabulationTabGroupByAlias_TextChanged(object sender, TextChangedEventArgs e)
        {
            this.txtCrossTabulationTabGroupByAlias.BorderBrush = TextBoxOriginalBorderBrush;
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbCrossTabulationTabGroupByColumnsName);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
            }
        }
        private void StackPanelWhereTab_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWherTabCondition);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.CustomQueryAccordion.LayoutChildren(true);
            }
        }
Beispiel #9
0
        private void txtFromAlias_LostFocus(object sender, RoutedEventArgs e)
        {
            FromTabStackPanelControl fromTabSPCntrl = new FromTabStackPanelControl();
            DependencyObject         parent         = fromTabSPCntrl.GetRVC(this.cmbFromTable);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                fromTabSPCntrl.UpdateAllControls(rvc);
                rvc.SelectTabCntrl.ColsToSelectAcc.LayoutChildren(true);
            }
        }
Beispiel #10
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            AddFromTabStackPanel();
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbFromTable);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.CustomQueryAccordion.LayoutChildren(true);
            }
        }
        private void cmbCrossTabulationTypeOfSummary_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // seting the style if style is changed due to Error it changes border of the combobox
            this.cmbCrossTabulationTypeOfSummary.Style = ComboboxOriginalStyle;
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbCrossTabulationTabSummaryColumnsName);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
            }
        }
        private void txtCrossTabulationTabSummaryAlias_TextChanged(object sender, TextChangedEventArgs e)
        {
            // seting the style if style is changed due to Error it changes border of the combobox
            this.txtCrossTabulationTabSummaryAlias.BorderBrush = TextBoxOriginalBorderBrush;
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbCrossTabulationTabSummaryColumnsName);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
            }
        }
Beispiel #13
0
        private void cmbFromTabJoinTable_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // seting the style if style is changed due to Error it changes border of the combobox
            this.cmbFromTabJoinTable.Style = ComboboxOriginalStyle;
            ComboBox   currentCmb = (ComboBox)sender;
            int        stkpanelNumberToCmbJoinColumClear = -1;
            MainWindow mainWindow = new MainWindow {
                WindowStartupLocation = WindowStartupLocation.CenterOwner, Owner = Window.GetWindow(this)
            };

            DependencyObject parent = GetRVC(this.cmbFromTabJoinTable);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (rvc.FromTabCntrl.StackPanelFromTab.Children.Count > 1)
                {
                    if (currentCmb.SelectedIndex > -1)
                    {
                        bool isSelectedTableThere = false;
                        for (int i = 0; i < rvc.FromTabCntrl.StackPanelFromTab.Children.Count; i++)
                        {
                            FromTabStackPanelControl fs = (FromTabStackPanelControl)rvc.FromTabCntrl.StackPanelFromTab.Children[i];
                            if (fs.cmbFromTabJoinTable != currentCmb)
                            {
                                if (fs.cmbFromTabJoinTable.SelectedIndex != currentCmb.SelectedIndex)
                                {
                                    isSelectedTableThere = false;
                                }
                                else
                                {
                                    isSelectedTableThere = true;
                                    stkpanelNumberToCmbJoinColumClear = i;
                                    currentCmb.SelectedIndex          = -1;
                                    break;
                                }
                            }
                        }
                        if (isSelectedTableThere == false)
                        {
                            LoadJoinTableColumnComboBox();
                        }
                    }
                }
                else
                {
                    UpdateAllControls(rvc);
                    LoadJoinTableColumnComboBox();
                }
            }
        }
Beispiel #14
0
        private void txtJoinTableAlias_LostFocus(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = new MainWindow {
                WindowStartupLocation = WindowStartupLocation.CenterOwner, Owner = Window.GetWindow(this)
            };
            DependencyObject parent = GetRVC(this.cmbFromTabJoinTable);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                UpdateAllControls(rvc);
            }
        }
Beispiel #15
0
        private void cmbFromTabJoinColumns_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // seting the style if style is changed due to Error it changes border of the combobox
            this.cmbFromTabJoinColumns.Style = ComboboxOriginalStyle;

            /********Validate********/
            DependencyObject parent = GetRVC(this.cmbFromTabJoinTable);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
            }
            /************************/
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbWhereTabNullNotNullColumns);

            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWhereTabNullNotNullColumns);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (rvc.WhereTabCntrl.StackPanelWhereTab.Children.Count > 0)
                {
                    DockPanel dkp = (DockPanel)btnDelete.Parent;
                    WhereTabNullNotNullConditionControl wsp = (WhereTabNullNotNullConditionControl)((Grid)((StackPanel)dkp.Parent).Parent).Parent;
                    rvc.WhereTabCntrl.StackPanelWhereTab.Children.Remove(wsp);

                    if (rvc.WhereTabCntrl.StackPanelWhereTab.Children.Count != 0)
                    {
                        string controlType = rvc.WhereTabCntrl.StackPanelWhereTab.Children[0].GetType().ToString();
                        switch (controlType)
                        {
                        case "FastDB.Control.WhereTabRegularConditionControl":
                            WhereTabRegularConditionControl wr = (WhereTabRegularConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wr.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wr.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;

                        case "FastDB.Control.WhereTabBetweenConditionControl":
                            WhereTabBetweenConditionControl wb = (WhereTabBetweenConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wb.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wb.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;

                        case "FastDB.Control.WhereTabInNotInConditionControl":
                            WhereTabInNotInConditionControl wInNotin = (WhereTabInNotInConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wInNotin.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wInNotin.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;

                        case "FastDB.Control.WhereTabNullNotNullConditionControl":
                            WhereTabNullNotNullConditionControl wNullNotNull = (WhereTabNullNotNullConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wNullNotNull.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wNullNotNull.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;
                        }
                    }
                }
            }
        }
        private void cmbCrossTabulationTabUserSelectSummaryColFormat_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.cmbCrossTabulationTabUserSelectSummaryColFormat.SelectedIndex != -1)
            {
                this.txtCrossTabulationTabSummaryColFormat.Text = this.cmbCrossTabulationTabUserSelectSummaryColFormat.SelectedValue.ToString();
            }
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbCrossTabulationTabSummaryColumnsName);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
            }
        }
Beispiel #18
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Button     btnDelete  = (Button)sender;
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbFromTabJoinTable);

            DependencyObject parent = GetRVC(this.cmbFromTabJoinTable);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (rvc.FromTabCntrl.StackPanelFromTab.Children.Count > 0)
                {
                    DockPanel dkp = (DockPanel)btnDelete.Parent;
                    FromTabStackPanelControl fsp = (FromTabStackPanelControl)((Grid)((StackPanel)dkp.Parent).Parent).Parent;
                    rvc.FromTabCntrl.StackPanelFromTab.Children.Remove(fsp);

                    if (rvc.FromTabCntrl.isValidated & (rvc.TabulationTabCntrl.isValidated & rvc.TabulationTabCntrl.isTabulation == false) & (rvc.CrossTabulationTabCntrl.isValidated & rvc.CrossTabulationTabCntrl.isCrossTabulation == false))
                    {
                        rvc.SelectTabCntrl.lstToSelecteColFrom.IsEnabled   = true;
                        rvc.SelectTabCntrl.lstToSelecteColFrom.ItemsSource = mainWindow.GenerateListOfSelectTabCntrlColumns(rvc);
                    }
                    rvc.CustomQueryAccordion.LayoutChildren(true);
                }
                if (rvc.FromTabCntrl.StackPanelFromTab.Children.Count == 0)
                {
                    rvc.FromTabCntrl.DockPanelFromTabRowHeader.Visibility = System.Windows.Visibility.Hidden;
                    UpdateAllControls(rvc);
                    rvc.CustomQueryAccordion.LayoutChildren(true);

                    /************Update query**************/
                    if (mainWindow.ValidateAllTabCntrls(rvc))
                    {
                        SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(rvc);
                        if (queryBuilder != null)
                        {
                            queryString = queryBuilder.BuildQuery();
                        }
                        XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                        StringWriter  writer        = new StringWriter();
                        SerializerObj.Serialize(writer, queryBuilder);
                    }
                    else
                    {
                    }
                    /**************************************/
                }
            }
        }
        private void lstToSelecteColFrom_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var col = ((FrameworkElement)e.OriginalSource).DataContext as Column;

            if (col != null)
            {
                IEnumerable <Column> columns = _SelectedColCollection.Where(x => x.Name == col.Name && x.AliasName == col.AliasName);
                if (columns.Count() == 0)
                {
                    IEnumerable <Column> columnsWithSameAlias = _SelectedColCollection.Where(x => x.AliasName == col.AliasName);
                    if (columnsWithSameAlias.Count() == 0)
                    {
                        _SelectedColCollection.Add(col);
                    }
                    else
                    {
                        MessageBox.Show("Duplicate Alias");
                    }
                }
                else
                {
                    MessageBox.Show("Duplicate Column");
                }
                this.lstToSelecteColFrom.SelectedIndex = -1;
            }

            if (_SelectedColCollection.Count > 11 && isExpanded == false)
            {
                SelectedColsStackPanel.Width += 16;
                isExpanded = true;
            }

            /***********Validate Control***********/
            Validate();
            /**************************************/

            /*****Update Cross Tabulation**********/
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstSelectedCol);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.UpdateCrossTabulationTabCntrl(mainWindow);
                rvc.UpdateTabulationTabCntrl(mainWindow);
            }
        }
Beispiel #20
0
        public Window1(Control.ResultViewControl resultControl)
        {
            resultControlInit = resultControl;
            InitializeComponent();
            CenterWindowOnScreen();
            connectionString = ConfigurationManager.AppSettings["DefaultDBConn"]; //System.Configuration.ConfigurationSettings.AppSettings["FastDBConn"];
            CurrentDatabaseName = ConfigurationManager.AppSettings["DefaultDatabase"];

            connectionString = connectionString + "Database=" + CurrentDatabaseName + ";";
            MainWindow m = new MainWindow();
            try
            {
                List<Schema> schemas = MySQLData.DataAccess.ADODataBridge.getSchemaTree(connectionString, CurrentDatabaseName, ConfigurationManager.AppSettings["DerivedTablesPath"]);//DataAccess.GetDatabases();
                MainViewModel viewModel = new MainViewModel(schemas);
                
                m.MainTreeView.DataContext = viewModel;
                listOfTable = new List<MySQLData.Table>();
                foreach (Schema schema in schemas)
                {
                    listOfTable.AddRange(schema.tables);
                }
                if (listOfTable != null)
                {

                }

            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                if (isErrorLoggingOn)
                {
                    LogError.Log_Err("MainWindow Constructor", ex);
                    DisplayErrorMessage();
                }
            }
            catch (Exception ex)
            {
                if (isErrorLoggingOn)
                {
                    LogError.Log_Err("MainWindow Constructor", ex);
                    DisplayErrorMessage();
                }
            }
            var collView = CollectionViewSource.GetDefaultView(m.tabControlCustomQuery.Items);
            collView.CurrentChanging +=  this.OnTabItemSelecting;

        }
Beispiel #21
0
        public Window1(Control.ResultViewControl resultControl)
        {
            resultControlInit = resultControl;
            InitializeComponent();
            CenterWindowOnScreen();
            connectionString    = ConfigurationManager.AppSettings["DefaultDBConn"]; //System.Configuration.ConfigurationSettings.AppSettings["FastDBConn"];
            CurrentDatabaseName = ConfigurationManager.AppSettings["DefaultDatabase"];

            connectionString = connectionString + "Database=" + CurrentDatabaseName + ";";
            MainWindow m = new MainWindow();

            try
            {
                List <Schema> schemas   = MySQLData.DataAccess.ADODataBridge.getSchemaTree(connectionString, CurrentDatabaseName, ConfigurationManager.AppSettings["DerivedTablesPath"]);//DataAccess.GetDatabases();
                MainViewModel viewModel = new MainViewModel(schemas);

                m.MainTreeView.DataContext = viewModel;
                listOfTable = new List <MySQLData.Table>();
                foreach (Schema schema in schemas)
                {
                    listOfTable.AddRange(schema.tables);
                }
                if (listOfTable != null)
                {
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                if (isErrorLoggingOn)
                {
                    LogError.Log_Err("MainWindow Constructor", ex);
                    DisplayErrorMessage();
                }
            }
            catch (Exception ex)
            {
                if (isErrorLoggingOn)
                {
                    LogError.Log_Err("MainWindow Constructor", ex);
                    DisplayErrorMessage();
                }
            }
            var collView = CollectionViewSource.GetDefaultView(m.tabControlCustomQuery.Items);

            collView.CurrentChanging += this.OnTabItemSelecting;
        }
        private void cmbCrossTabulationTabSummaryColumnsName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.cmbCrossTabulationTabSummaryColumnsName.Style = ComboboxOriginalStyle;
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbCrossTabulationTabSummaryColumnsName);

            if (parent != null)
            {
                if (this.cmbCrossTabulationTabSummaryColumnsName.SelectedItem != null)
                {
                    this.txtCrossTabulationTabSummaryAlias.Text = this.cmbCrossTabulationTabSummaryColumnsName.SelectedItem.ToString();
                    this.txtCrossTabulationTabSummaryAlias.Text = this.txtCrossTabulationTabSummaryAlias.Text.Substring(txtCrossTabulationTabSummaryAlias.Text.IndexOf('.') + 1);
                    this.txtCrossTabulationTabSummaryAlias.Text = this.txtCrossTabulationTabSummaryAlias.Text.Replace("_", " ");
                    this.txtCrossTabulationTabSummaryAlias.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(this.txtCrossTabulationTabSummaryAlias.Text);
                }
                ResultViewControl rvc = (ResultViewControl)parent;
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Button     btnDelete  = (Button)sender;
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbFromTabFromANDOR);
            FromTabStackPanelControl FromTabStackPanelControl = (FromTabStackPanelControl)GetRVCFromStack(this.cmbFromTabFromANDOR);
            DependencyObject         parent = GetRVC(this.cmbFromTabFromANDOR);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (FromTabStackPanelControl.StackPanelFromTabMore.Children.Count > 0)
                {
                    DockPanel dkp = (DockPanel)btnDelete.Parent;
                    FromTabStackPanelControlMore fsp = (FromTabStackPanelControlMore)((Grid)((StackPanel)dkp.Parent).Parent).Parent;
                    FromTabStackPanelControl.StackPanelFromTabMore.Children.Remove(fsp);
                    rvc.CustomQueryAccordion.LayoutChildren(true);
                }
                if (rvc.FromTabCntrl.StackPanelFromTab.Children.Count == 0)
                {
                    rvc.FromTabCntrl.DockPanelFromTabRowHeader.Visibility = System.Windows.Visibility.Hidden;
                    UpdateAllControls(rvc);
                    rvc.CustomQueryAccordion.LayoutChildren(true);

                    /************Update query**************/
                    if (mainWindow.ValidateAllTabCntrls(rvc))
                    {
                        SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(rvc);
                        if (queryBuilder != null)
                        {
                            queryString = queryBuilder.BuildQuery();
                        }
                        XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                        StringWriter  writer        = new StringWriter();
                        SerializerObj.Serialize(writer, queryBuilder);
                    }
                    else
                    {
                    }
                    /**************************************/
                }
            }
        }
Beispiel #24
0
        private void cmbCrossTabulationTabGroupByColumnsName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((SQLBuilder.Clauses.Column) this.cmbCrossTabulationTabGroupByColumnsName.SelectedItem != null)
            {
                this.txtCrossTabulationTabGroupByColFormat.Text = ((SQLBuilder.Clauses.Column) this.cmbCrossTabulationTabGroupByColumnsName.SelectedItem).Format;
                this.txtCrossTabulationTabGroupByAlias.Text     = this.cmbCrossTabulationTabGroupByColumnsName.SelectedItem.ToString();
                this.txtCrossTabulationTabGroupByAlias.Text     = this.txtCrossTabulationTabGroupByAlias.Text.Substring(txtCrossTabulationTabGroupByAlias.Text.IndexOf('.') + 1);
                this.txtCrossTabulationTabGroupByAlias.Text     = this.txtCrossTabulationTabGroupByAlias.Text.Replace("_", " ");

                this.txtCrossTabulationTabGroupByAlias.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(this.txtCrossTabulationTabGroupByAlias.Text);
                this.cmbCrossTabulationSort.SelectedItem    = "Ascending";
            }

            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbCrossTabulationTabGroupByColumnsName);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
            }
        }
Beispiel #25
0
        private void cmbFromTable_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.cmbFromTable.SelectedIndex > -1)
            {
                FromTabStackPanelControl fromTabSPCntrl = new FromTabStackPanelControl();
                DependencyObject         parent         = fromTabSPCntrl.GetRVC(this.cmbFromTable);

                if (parent != null)
                {
                    ResultViewControl rvc = (ResultViewControl)parent;
                    fromTabSPCntrl.UpdateAllControls(rvc);
                    rvc.SelectTabCntrl._SelectedColCollection.Clear();
                }
                this.cmbFromTable.Style = ComboboxOriginalStyle;
                for (int i = 0; i < this.StackPanelFromTab.Children.Count; i++)
                {
                    FromTabStackPanelControl fs1 = (FromTabStackPanelControl)this.StackPanelFromTab.Children[i];
                    LoadFromTableColumnComboBox(fs1);
                }
            }
        }
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (this._SelectedColCollection.Count == 0)
            {
                this.lblErrorMessage.Content = "Please select column(s)";
            }

            int count = this.lstSelectedCol.SelectedItems.Count;

            for (int i = 0; i < count; i++)
            {
                Column col = (Column)this.lstSelectedCol.SelectedItems[0];
                _SelectedColCollection.Remove(col);
            }
            this.lstToSelecteColFrom.SelectedIndex = -1;
            this.lstSelectedCol.SelectedIndex      = -1;

            if (_SelectedColCollection.Count <= 11 && isExpanded == true)
            {
                SelectedColsStackPanel.Width -= 16;
                isExpanded = false;
            }
            /***********Validate Control***********/
            Validate();
            /**************************************/

            /*****Update Cross Tabulation**********/
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstSelectedCol);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.UpdateCrossTabulationTabCntrl(mainWindow);
                rvc.UpdateTabulationTabCntrl(mainWindow);
            }
            /**************************************/
        }
        private List <string> GetColumnsFromAllFromTabTable()
        {
            List <string>            list                   = new List <string>();
            MainWindow               mainWindow             = (MainWindow)GetTopLevelControl(this.cmbWherTabCondition);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent                 = fromTabStackPanelCntrl.GetRVC(this.cmbWherTabCondition); //get resultview control containing cmbWherTabCondition

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                //get the From table columns
                if (mainWindow.listOfTable != null & mainWindow.listOfTable.Count > 0)
                {
                    List <string> fc = GetFromTableColums(mainWindow.listOfTable[rvc.FromTabCntrl.cmbFromTable.SelectedIndex].columns, rvc.FromTabCntrl.txtFromAlias.Text);

                    if (fc != null)
                    {
                        list.AddRange(fc);
                    }
                }

                if (rvc.FromTabCntrl.StackPanelFromTab.Children.Count > 0)
                {
                    for (int i = 0; i < rvc.FromTabCntrl.StackPanelFromTab.Children.Count; i++)
                    {
                        FromTabStackPanelControl fs = (FromTabStackPanelControl)rvc.FromTabCntrl.StackPanelFromTab.Children[i];

                        List <string> jc = GetJoinTableColums((List <string>)fs.cmbFromTabJoinColumns.ItemsSource, fs.txtJoinTableAlias.Text);
                        if (jc != null)
                        {
                            list.AddRange(jc);
                        }
                    }
                }
            }
            return(list);
        }
        private List <string> GetColumnsFromAllFromTabTable()
        {
            List <string>            list                   = new List <string>();
            MainWindow               mainWindow             = (MainWindow)GetTopLevelControl(this.ComputedColFormatComboBox);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent                 = fromTabStackPanelCntrl.GetRVC(this.ComputedColFormatComboBox); //get resultview control containing cmbWherTabCondition

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                //get the From table columns
                if (mainWindow.listOfTable != null & mainWindow.listOfTable.Count > 0)
                {
                    List <string> fc = GetFromTableColums(mainWindow.listOfTable[rvc.FromTabCntrl.cmbFromTable.SelectedIndex].columns, rvc.FromTabCntrl.txtFromAlias.Text);

                    if (fc != null)
                    {
                        list.AddRange(fc);
                    }
                }
            }
            return(list);
        }
        private void AddAllBtn_Click(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstToSelecteColFrom);

            _SelectedColCollection.Clear();

            foreach (Column col in this.lstToSelecteColFrom.Items)
            {
                IEnumerable <Column> columns = _SelectedColCollection.Where(x => x.Name == col.Name & x.AliasName == col.AliasName);
                if (columns.Count() == 0)
                {
                    _SelectedColCollection.Add(col);
                }
            }

            if (_SelectedColCollection.Count > 11 && isExpanded == false)
            {
                SelectedColsStackPanel.Width += 16;
                isExpanded = true;
            }
            /***********Validate Control***********/
            Validate();
            /**************************************/

            /*****Update Cross Tabulation**********/

            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.UpdateCrossTabulationTabCntrl(mainWindow);
            }
            /**************************************/
        }
        public void UpdateAllControls(ResultViewControl rvc)
        {
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(rvc);

            rvc.SelectTabCntrl.lstToSelecteColFrom.IsEnabled = true;
            mainWindow.ColListForSelectTab = mainWindow.GenerateListOfSelectTabCntrlColumns(rvc);
            rvc.SelectTabCntrl.lstToSelecteColFrom.ItemsSource = mainWindow.ColListForSelectTab;

            rvc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.IsEnabled = true;
            rvc.TabulationTabCntrl.StackPanelTabuLationTabSummary.IsEnabled = true;

            List<SQLBuilder.Clauses.Column> listOfTabulationTabColumns = mainWindow.GenerateListOfTabulationTabCntrlColumns(rvc);

            if (((TabulationTabStackPanelGroupByControl)rvc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children[0]).cmbTabulationTabGroupByColumnsName.Items.Count == 0)
            {
                // loading groupby columns
                for (int i = 0; i < rvc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count; i++)
                {
                    TabulationTabStackPanelGroupByControl tg = (TabulationTabStackPanelGroupByControl)rvc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children[i];
                    tg.cmbTabulationTabGroupByColumnsName.ItemsSource = listOfTabulationTabColumns;
                }
                // loading summary columns
                for (int i = 0; i < rvc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Count; i++)
                {
                    TabulationTabStackPanelSummaryControl ts = (TabulationTabStackPanelSummaryControl)rvc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children[i];
                    ts.cmbTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                }
            }
            else
            {
                List<SQLBuilder.Clauses.Column> list1 = (List<SQLBuilder.Clauses.Column>)((TabulationTabStackPanelGroupByControl)rvc.TabulationTabCntrl.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 < rvc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count; i++)
                    {
                        TabulationTabStackPanelGroupByControl tg = (TabulationTabStackPanelGroupByControl)rvc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children[i];
                        tg.cmbTabulationTabGroupByColumnsName.ItemsSource = listOfTabulationTabColumns;
                    }
                    // Reloading summary columns
                    for (int i = 0; i < rvc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Count; i++)
                    {
                        TabulationTabStackPanelSummaryControl ts = (TabulationTabStackPanelSummaryControl)rvc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children[i];
                        ts.cmbTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                    }
                }
            }

            rvc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.IsEnabled = true;
            rvc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFirstRowColumnsName.IsEnabled = true;
            rvc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFristRowSort.IsEnabled = true;
            rvc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.IsEnabled = true;

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

                    // Reloading summary columns
                    for (int i = 0; i < rvc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children.Count; i++)
                    {
                        CrossTabulationTabStackPanelSummaryControl cts = (CrossTabulationTabStackPanelSummaryControl)rvc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children[i];
                        cts.cmbCrossTabulationTabSummaryColumnsName.ItemsSource = listOfTabulationTabColumns;
                    }
                }
            }

            List<string> Collist = (from x in (mainWindow.GenerateListOfTabulationTabCntrlColumns(rvc))
                                    select x.Name).ToList<string>();

            if (rvc.WhereTabCntrl.StackPanelWhereTab.Children.Count != 0)
            {
                for (int i = 0; i < rvc.WhereTabCntrl.StackPanelWhereTab.Children.Count; i++)
                {
                    if (rvc.WhereTabCntrl.StackPanelWhereTab.Children[i].GetType().Name == "WhereTabRegularConditionControl")
                    {
                        WhereTabRegularConditionControl regCondn = (WhereTabRegularConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[i]);
                        regCondn.cmbWhereTabLeftSideColumns.ItemsSource = Collist;
                        regCondn.cmbWhereTabRightSideColumns.ItemsSource = Collist;
                    }
                    else if (rvc.WhereTabCntrl.StackPanelWhereTab.Children[i].GetType().Name == "WhereTabBetweenConditionControl")
                    {
                        WhereTabBetweenConditionControl regCondn = (WhereTabBetweenConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[i]);
                        regCondn.cmbWhereTabBetweenColumns.ItemsSource = Collist;
                    }
                    else if (rvc.WhereTabCntrl.StackPanelWhereTab.Children[i].GetType().Name == "WhereTabInNotInConditionControl")
                    {
                        WhereTabInNotInConditionControl regCondn = (WhereTabInNotInConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[i]);
                        regCondn.cmbWhereTabInNotInColumns.ItemsSource = Collist;
                    }
                    else if (rvc.WhereTabCntrl.StackPanelWhereTab.Children[i].GetType().Name == "WhereTabNullNotNullConditionControl")
                    {
                        WhereTabNullNotNullConditionControl regCondn = (WhereTabNullNotNullConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[i]);
                        regCondn.cmbWhereTabNullNotNullColumns.ItemsSource = Collist;
                    }
                }
            }
        }
Beispiel #31
0
        //zahed
        public bool ValidateAllTabCntrls(ResultViewControl rc)
        {
            int numberOfInvalidTab = 0;
            isAllTabValidated = rc.FromTabCntrl.Validate();
            //this jus temp code untill i figure out how to handle this
            if (isAllTabValidated == false)
            {
                numberOfInvalidTab = numberOfInvalidTab + 1;
            }
            isAllTabValidated = rc.WhereTabCntrl.Validate();
            //this jus tem code untill i figure out how to handle this
            if (isAllTabValidated == false)
            {
                numberOfInvalidTab = numberOfInvalidTab + 1;
            }
            //we have to validate both Tabulation Tab & Cross Tabulation
            bool isTabaulationTabValid = rc.TabulationTabCntrl.Validate();
            bool isCrossTabulationTabValid = rc.CrossTabulationTabCntrl.Validate();
            if (isTabaulationTabValid)
            {
                isAllTabValidated = true;
            }
            else
            {
                isAllTabValidated = false;
                numberOfInvalidTab = numberOfInvalidTab + 1;
            }
            if (isCrossTabulationTabValid)
            {
                isAllTabValidated = true;
            }
            else
            {
                isAllTabValidated = false;
                numberOfInvalidTab = numberOfInvalidTab + 1;
            }
            //this jus temp code untill i figure out how to handle this
            if (isAllTabValidated)
            {

                //Tabulation Tab is valid
                //check do we have Tabulation on both
                //bool isBothHasTabulation = false;
                if (rc.TabulationTabCntrl.isTabulation & rc.CrossTabulationTabCntrl.isCrossTabulation)
                {
                    rc.TabulationTabCntrl.lblErrorMessage.Content = "You can do only one Tabulation, either do Tabulation Tab or Cross Tabulation Tab, please Clear one of Tabaulation ";
                    rc.CrossTabulationTabCntrl.lblErrorMessage.Content = "You can do only one Tabulation, either do Tabulation Tab or Cross Tabulation Tab, please Clear one of Tabaulation ";
                    // we have tabulation then we don't need select tab
                    rc.SelectTabCntrl.lblErrorMessage.Content = "";
                    //rc.SelectTabCntrl._SelectedColCollection.Clear();
                    isAllTabValidated = false;
                    numberOfInvalidTab = numberOfInvalidTab + 1;
                }
                else
                {
                    if (rc.TabulationTabCntrl.isTabulation)
                    {
                        // we have tabulation then we don't need select tab
                        rc.SelectTabCntrl.lblErrorMessage.Content = "";
                        //rc.SelectTabCntrl._SelectedColCollection.Clear();
                    }
                    else if (rc.CrossTabulationTabCntrl.isCrossTabulation)
                    {
                        // we have tabulation then we don't need select tab
                        rc.SelectTabCntrl.lblErrorMessage.Content = "";
                        //rc.SelectTabCntrl._SelectedColCollection.Clear();
                    }
                    else
                    {
                        isAllTabValidated = rc.SelectTabCntrl.Validate();
                        //if all other tab validated  select  tab datagrid is null
                        // that is user did not visit the select tab and datagrid on select tab is null
                        if (rc.SelectTabCntrl.lstToSelecteColFrom.ItemsSource == null)
                        {
                            isAllTabValidated = false;
                        }
                        if (isAllTabValidated == false)
                        {
                            numberOfInvalidTab = numberOfInvalidTab + 1;
                        }
                    }
                }

            }

            if (numberOfInvalidTab > 0)
            {
                isAllTabValidated = false;
                return false;
            }
            return true;
        }
Beispiel #32
0
        private void btnRunQuery_Click(object sender, RoutedEventArgs e)
        {
            DateTime startTime = DateTime.Now;
            if (isAllTabValidated)
            {

                if (queryString != System.String.Empty)
                {
                    if (queryBuilder != null)
                    {
                        CloseableTabItem tabItem = (CloseableTabItem)this.tabControl1.SelectedItem;
                        if (tabItem.Content == null)
                        {
                            //it is new
                            Mouse.OverrideCursor = Cursors.Wait;
                            try
                            {
                                Control.ResultViewControl resultControl = new Control.ResultViewControl(queryBuilder, CurrentDatabaseName);
                                ResultViewModel rv = (ResultViewModel)resultControl.DataContext;
                                //set isNew and isModified 
                                rv.isNew = true;
                                rv.isModified = true;
                                tabItem.labelStar.Content = "*";
                                tabItem.Content = resultControl;
                            }
                            catch (MySql.Data.MySqlClient.MySqlException ex)
                            {
                                if (isErrorLoggingOn)
                                {
                                    LogError.Log_Err("btnRunQuery_Click", ex);
                                    DisplayErrorMessage();
                                }
                            }
                            catch (Exception ex)
                            {
                                if (isErrorLoggingOn)
                                {
                                    LogError.Log_Err("btnRunQuery_Click", ex);
                                    DisplayErrorMessage();
                                }
                            }
                            Mouse.OverrideCursor = null;
                        }
                        else
                        {
                            //it canbe old or it can be new
                            Control.ResultViewControl oldResultControl = (Control.ResultViewControl)tabItem.Content;
                            ResultViewModel rv = (ResultViewModel)oldResultControl.DataContext;
                            if (rv.isNew)
                            {
                                // we still let user run the query, query still new and modified= true
                                Mouse.OverrideCursor = Cursors.Wait;
                                try
                                {
                                    Control.ResultViewControl resultControl = new Control.ResultViewControl(queryBuilder, CurrentDatabaseName);
                                    ResultViewModel rv2 = (ResultViewModel)resultControl.DataContext;
                                    rv2.isNew = true;
                                    rv2.isModified = true;
                                    tabItem.Content = resultControl;
                                    tabItem.labelStar.Content = "*";
                                }
                                catch (MySql.Data.MySqlClient.MySqlException ex)
                                {
                                    if (isErrorLoggingOn)
                                    {
                                        LogError.Log_Err("btnRunQuery_Click", ex);
                                        DisplayErrorMessage();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    if (isErrorLoggingOn)
                                    {
                                        LogError.Log_Err("btnRunQuery_Click", ex);
                                        DisplayErrorMessage();
                                    }
                                }
                                Mouse.OverrideCursor = null;
                            }
                            else
                            {
                                // it is old
                                //check to see if old querybuilder and new querybuilder is same, if different CompairQueryBuilder retuns true
                                if (CompairQueryBuilder(rv.QueryBulder, queryBuilder))
                                {
                                    Mouse.OverrideCursor = Cursors.Wait;
                                    try
                                    {
                                        Control.ResultViewControl resultControl = new Control.ResultViewControl(queryBuilder, CurrentDatabaseName);
                                        ResultViewModel rv1 = (ResultViewModel)resultControl.DataContext;
                                        //set isModified 
                                        rv1.isModified = true;
                                        //assign orignial directory path
                                        rv1.directoryPath = rv.directoryPath;
                                        tabItem.Content = resultControl;
                                        tabItem.labelStar.Content = "*";
                                    }
                                    catch (MySql.Data.MySqlClient.MySqlException ex)
                                    {
                                        if (isErrorLoggingOn)
                                        {
                                            LogError.Log_Err("btnRunQuery_Click", ex);
                                            DisplayErrorMessage();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        if (isErrorLoggingOn)
                                        {
                                            LogError.Log_Err("btnRunQuery_Click", ex);
                                            DisplayErrorMessage();
                                        }
                                    }
                                    Mouse.OverrideCursor = null;
                                }
                                //else it is same we don't need do anything
                            }

                        }

                        if (DocPanelCustomQuery.HorizontalAlignment != HorizontalAlignment.Right)
                        {
                            MiniMizeCustomeQyeryWindow();
                        }
                    }
                }
            }
            Console.WriteLine("Cross Tabulation View Control execution time: " + (DateTime.Now - startTime));
        }
Beispiel #33
0
        //private List<MySQLData.Column> GenerateListOfSelectTabColumns()
        //{
        //    List<MySQLData.Column> list = new List<MySQLData.Column>();

        //    //get the From table columns 
        //    if (this.listOfTable != null & this.listOfTable.Count > 0)
        //    {
        //        if (this.FromTabUC.cmbFromTable.SelectedIndex != -1)
        //        {
        //            foreach (Column col in this.listOfTable[this.FromTabUC.cmbFromTable.SelectedIndex].columns)
        //            {
        //                MySQLData.Column sc = new MySQLData.Column(this.FromTabUC.txtFromAlias.Text + "." + col.name, col.type);
        //                list.Add(sc);
        //            }
        //        }
        //    }
        //    // get join table columns
        //    if (this.FromTabUC.StackPanelFromTab.Children.Count > 0)
        //    {
        //        for (int i = 0; i < this.FromTabUC.StackPanelFromTab.Children.Count; i++)
        //        {
        //            FromTabStackPanelControl fs = (FromTabStackPanelControl)this.FromTabUC.StackPanelFromTab.Children[i];
        //            foreach (Column col in this.listOfTable[fs.cmbFromTabJoinTable.SelectedIndex].columns)
        //            {
        //                MySQLData.Column sc = new MySQLData.Column(fs.txtJoinTableAlias.Text + "." + col.name, col.type);
        //                list.Add(sc);
        //            }
        //            //foreach (string name in ((List<string>)fs.cmbFromTabJoinColumns.ItemsSource))
        //            //{
        //            //    MySQLData.Column sc = new MySQLData.Column(fs.txtJoinTableAlias.Text + "." + name, );
        //            //      list.Add(sc);
        //            //}
        //        }
        //    }
        //    return list;
        //}            

        //zahed code start

        public List<SQLBuilder.Clauses.Column> GenerateListOfTabulationTabCntrlColumns_old(ResultViewControl rc)
        {
            List<SQLBuilder.Clauses.Column> list = new List<SQLBuilder.Clauses.Column>();

            //get the From table columns 
            if (this.listOfTable != null & this.listOfTable.Count > 0)
            {
                if (rc.FromTabCntrl.cmbFromTable.SelectedIndex != -1)
                {
                    foreach (Column col in this.listOfTable[rc.FromTabCntrl.cmbFromTable.SelectedIndex].columns)
                    {
                        SQLBuilder.Clauses.Column sc = new SQLBuilder.Clauses.Column();//false, this.FromTabUC.txtFromAlias.Text + "." + col.name, "");
                        sc.Name = rc.FromTabCntrl.txtFromAlias.Text + "." + col.name;
                        sc.Format = col.format;
                        sc.DataType = col.type;
                        list.Add(sc);
                    }
                }
            }
            // get join table columns
            if (rc.FromTabCntrl.StackPanelFromTab.Children.Count > 0)
            {
                for (int i = 0; i < rc.FromTabCntrl.StackPanelFromTab.Children.Count; i++)
                {
                    FromTabStackPanelControl fs = (FromTabStackPanelControl)rc.FromTabCntrl.StackPanelFromTab.Children[i];
                    foreach (Column col in this.listOfTable[fs.cmbFromTabJoinTable.SelectedIndex].columns)
                    {
                        SQLBuilder.Clauses.Column sc = new SQLBuilder.Clauses.Column();
                        sc.Name = fs.txtJoinTableAlias.Text + "." + col.name;
                        sc.Format = col.format;
                        sc.DataType = col.type;
                        list.Add(sc);
                    }
                }
            }
            return list;

        }
Beispiel #34
0
 public List<SQLBuilder.Clauses.Column> GenerateListOfTabulationTabCntrlColumns(ResultViewControl rc)
 {
     if (rc.SelectTabCntrl._SelectedColCollection.Count > 0)
     {
         List<SQLBuilder.Clauses.Column> list = new List<SQLBuilder.Clauses.Column>();
         foreach (SQLBuilder.Clauses.Column column in rc.SelectTabCntrl._SelectedColCollection)
         {
             SQLBuilder.Clauses.Column sc = new SQLBuilder.Clauses.Column();
             sc.Name = column.AliasName;//column.Name;
             sc.Format = column.Format;
             sc.DataType = column.DataType;
             list.Add(sc);
         }
         return list;
     }
     else
     {
         return GenerateListOfSelectTabCntrlColumns(rc);
     }
 }
Beispiel #35
0
        private void New_Click()
        {
            /******************************/
            this.Logo.Visibility = Visibility.Hidden;
            this.LogoTxt.Visibility = Visibility.Hidden;
            this.tabControl1.Visibility = Visibility.Visible;
            /******************************/

            count = 0;
            //addd new tab
            CloseableTabItem tabItem = new CloseableTabItem();
            tabItem.Name = "CustomQuery" + (this.tabControl1.Items.Count + 1).ToString();
            tabItem.Header = "SQLQuery" + (this.tabControl1.Items.Count + 1).ToString();
            tabItem.Part_Label_Content = "";
            //tableViewModel tvm = null;
            currentTableViewModel = null;
            Control.ResultViewControl rvCntrl = new ResultViewControl(currentTableViewModel, false);
            tabItem.Content = rvCntrl;

            //add tab to tabcontrol
            this.tabControl1.Items.Add(tabItem);
            //Clear Custom QueryTabs

            //ClearAllCustomeQueryTabs();

            //Get focus on new tab
            ((TabItem)(this.tabControl1.Items[this.tabControl1.Items.Count - 1])).Focus();

            //this.adornedControl.IsAdornerVisible = true;

            //Display Custom query window
            //DocPanelCustomQuery.HorizontalAlignment = HorizontalAlignment.Right;
            //DocPanelCustomQuery.HorizontalAlignment = HorizontalAlignment.Stretch;
            //DocPanelCustomQuery.Margin = new Thickness(0, 60, 0, 0);
            //DocPanelCustomQuery.Width = Double.NaN;
            //this.BtnHideCustomQueryWindow.Visibility = System.Windows.Visibility.Hidden;
            //Hide if tree view window open
            //if (this.TreeViewDocPanel.Width != 0)
            //{
            //    this.TreeViewDocPanel.Width = 0;
            //    TreeViewHideStackPanel.Width = 20;
            //}
        }
Beispiel #36
0
        private void Open_Click()
        {
            string FileName = OpenFileDialog();
            if (FileName != System.String.Empty)
            {
                XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                SelectQueryBuilder loadedQuery = (SelectQueryBuilder)SerializerObj.Deserialize(new StreamReader(FileName));
                string[] splitedArray = FileName.Split('\\');
                string tabItemName = splitedArray[splitedArray.Length - 1].Remove((splitedArray[splitedArray.Length - 1]).Length - 4, 4);
                if (loadedQuery != null)
                {
                    //addd new tab
                    CloseableTabItem tabItem = new CloseableTabItem();
                    tabItem.Name = "CustomQuery" + (this.tabControl1.Items.Count + 1).ToString();
                    tabItem.Header = tabItemName;

                    /******************************/
                    this.Logo.Visibility = Visibility.Hidden;
                    this.LogoTxt.Visibility = Visibility.Hidden;
                    this.tabControl1.Visibility = Visibility.Visible;
                    /******************************/

                    //add tab to tabcontrol
                    this.tabControl1.Items.Add(tabItem);
                    //Clear Custom QueryTabs

                    //Modified 11/10/11 clearing tab with common method ClearAllCustomeQueryTabs
                    //ClearAllCustomeQueryTabs();
                    ////Clear from tab
                    //this.FromTabUC.cmbFromTable.SelectedIndex = -1;
                    //this.FromTabUC.txtFromAlias.Text = System.String.Empty;
                    //this.FromTabUC.StackPanelFromTab.Children.Clear();

                    //////Clear where tab
                    //this.WhereTabUC.StackPanelWhereTab.Children.Clear();

                    ////clear Select Tab
                    //this.SelectTabUC.dgSelectTab.ItemsSource = null;

                    //Get focus on new tab
                    ((TabItem)(this.tabControl1.Items[this.tabControl1.Items.Count - 1])).Focus();
                    string queryString = loadedQuery.BuildQuery();
                    if (queryString != System.String.Empty)
                    {
                        CloseableTabItem tbItem = (CloseableTabItem)this.tabControl1.SelectedItem;
                        Mouse.OverrideCursor = Cursors.Wait;
                        Control.ResultViewControl resultControl = new Control.ResultViewControl(loadedQuery, CurrentDatabaseName);

                        //*****
                        directoryPath = FileName.Replace(splitedArray[splitedArray.Length - 1], "");//Directory.GetCurrentDirectory();
                        ResultViewModel rv = (ResultViewModel)resultControl.result;//DataContext;
                        rv.directoryPath = directoryPath;
                        //*********

                        tabItem.Content = resultControl;
                        //LoadAllCustomQueryTabs(loadedQuery, rv._getResultByTreeView);
                        LoadAllCustomQueryCntrls(rv.QueryBulder, rv._getResultByTreeView, resultControl);
                        Mouse.OverrideCursor = null;
                        //if (DocPanelCustomQuery.HorizontalAlignment != HorizontalAlignment.Right)
                        //{
                        //    MiniMizeCustomeQyeryWindow();
                        //}
                    }
                }
            }
        }
Beispiel #37
0
        private void MainTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeView tv = (TreeView)sender;
            count = 0;                      //zahed          

            if (tv.SelectedItem.GetType().Name == "tableViewModel")
            {

                tableViewModel tvm = (tableViewModel)tv.SelectedItem;

                currentTableViewModel = tvm;
                CurrentDatabaseName = tvm._ParentSchemaName;
                // display path at the top of the screen
                //txtBlockDisplayPath.Text = "All Databases/" + ((schemaViewModel)tvm.Parent).schemaName + "/" + tvm.tableName;
                int tabNumber = this.tabControl1.Items.Count + 1;
                CloseableTabItem tabItem = new CloseableTabItem();
                tabItem.Name = tvm.tableName + tabNumber;
                nameOfTabitemAssoWithCustomQuery = tabItem.Name;                
                tabItem.Header = GetTabHeaderName(tvm.tableName, tabNumber);                                

                //add ResultViewerControl
                Mouse.OverrideCursor = Cursors.Wait;
                try
                {
                    Control.ResultViewControl resultControl = new Control.ResultViewControl(tvm, true);

                    ResultViewModel rv = (ResultViewModel)resultControl.DataContext;
                    if (rv.Results.Count != 0)
                    {
                        rv.isNew = true;
                        rv.isModified = true;
                        tabItem.Part_Label_Content = "*";
                    }

                    tabItem.Content = resultControl;
                    /******************************/
                    this.Logo.Visibility = Visibility.Hidden;
                    this.LogoTxt.Visibility = Visibility.Hidden;
                    this.tabControl1.Visibility = Visibility.Visible;
                    /******************************/
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    if (isErrorLoggingOn)
                    {
                        LogError.Log_Err("MainTreeView_SelectedItemChanged", ex);
                        DisplayErrorMessage();
                    }
                }
                catch (Exception ex)
                {
                    if (isErrorLoggingOn)
                    {
                        LogError.Log_Err("MainTreeView_SelectedItemChanged", ex);
                        DisplayErrorMessage();
                    }
                }
                Mouse.OverrideCursor = null;
                //add tab to tabcontrol
                this.tabControl1.Items.Add(tabItem);
                //Get focus on new tab
                ((TabItem)(this.tabControl1.Items[tabNumber - 1])).Focus();


                this.adornedControl.IsAdornerVisible = false;
                //this.BtnHideCustomQueryWindow.Visibility = System.Windows.Visibility.Visible;



            }

        }
Beispiel #38
0
        /************************************************zahed************************/

        private void ClearAllCustomQueryTabCntrls(ResultViewControl rc)
        {
            //Clear from tab
            rc.FromTabCntrl.cmbFromTable.SelectedIndex = -1;
            rc.FromTabCntrl.txtFromAlias.Text = System.String.Empty;
            rc.FromTabCntrl.StackPanelFromTab.Children.Clear();
            rc.FromTabCntrl.DockPanelFromTabRowHeader.Visibility = System.Windows.Visibility.Hidden;

            ////Clear where tab
            rc.WhereTabCntrl.StackPanelWhereTab.Children.Clear();

            //clear Select Tab
            rc.SelectTabCntrl.lstToSelecteColFrom.ItemsSource = null;
            rc.SelectTabCntrl._SelectedColCollection.Clear();

            rc.SelectTabCntrl.lstSelectedCol.ItemsSource = rc.SelectTabCntrl._SelectedColCollection;
            //clear old regular tabulation
            //clear group by rows
            for (int i = 0; i < rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count; i++)
            {
                TabulationTabStackPanelGroupByControl tg = (TabulationTabStackPanelGroupByControl)rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children[i];
                //tg.cmbTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                tg.cmbTabulationTabGroupByColumnsName.SelectedIndex = -1;
                tg.cmbTabulationSort.SelectedIndex = -1;
                tg.txtTabulationTabGroupByAlias.Text = System.String.Empty;
            }
            //clear summary rows
            for (int i = 0; i < rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Count; i++)
            {
                TabulationTabStackPanelSummaryControl ts = (TabulationTabStackPanelSummaryControl)rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children[i];
                //ts.cmbTabulationTabSummaryColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                ts.cmbTabulationTabSummaryColumnsName.SelectedIndex = -1;
                ts.cmbTabulationTypeOfSummary.SelectedIndex = -1;
                ts.cmbTabulationTabUserSelectSummaryColFormat.SelectedIndex = -1;
                ts.txtTabulationTabSummaryAlias.Text = System.String.Empty;
                ts.txtTabulationTabSummaryColFormat.Text = System.String.Empty;

            }
            //clear old Cross tabulation
            //clear group by rows
            for (int i = 0; i < rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Count; i++)
            {
                CrossTabulationTabStackPanelGroupByControl ctg = (CrossTabulationTabStackPanelGroupByControl)rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children[i];
                //ctg.cmbCrossTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabColumns();
                ctg.cmbCrossTabulationTabGroupByColumnsName.SelectedIndex = -1;
                ctg.cmbCrossTabulationSort.SelectedIndex = -1;
                ctg.txtCrossTabulationTabGroupByAlias.Text = System.String.Empty;
            }
            //clear summary rows
            for (int i = 0; i < rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children.Count; i++)
            {
                CrossTabulationTabStackPanelSummaryControl cts = (CrossTabulationTabStackPanelSummaryControl)rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children[i];
                //cts.cmbCrossTabulationTabSummaryColumnsName.ItemsSource = GenerateListOfTabulationTabColumns();
                cts.cmbCrossTabulationTabSummaryColumnsName.SelectedIndex = -1;
                cts.cmbCrossTabulationTypeOfSummary.SelectedIndex = -1;
                cts.cmbCrossTabulationTabUserSelectSummaryColFormat.SelectedIndex = -1;
                cts.txtCrossTabulationTabSummaryColFormat.Text = System.String.Empty;
                cts.txtCrossTabulationTabSummaryAlias.Text = System.String.Empty;

            }
            // clear summary frist row
            rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFirstRowColumnsName.ItemsSource = GenerateListOfTabulationTabColumns();
            rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFirstRowColumnsName.SelectedIndex = -1;
            rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFristRowSort.SelectedIndex = -1;
            //clear action tab txtquery
            this.txtQuery.Text = "";
            this.CustomQueryTxTBlk.Text = "";
        }
Beispiel #39
0
        private void LoadAllCustomQueryCntrls(SQLBuilder.SelectQueryBuilder queryBuilder, bool isGetResultByTreeView, ResultViewControl rc)
        {
            Mouse.OverrideCursor = Cursors.Wait;

            string db = ConfigurationManager.AppSettings["DefaultDatabase"].ToString();
            List<Schema> schemas1 = MySQLData.DataAccess.ADODataBridge.getSchemaTree(connectionString, db, ConfigurationManager.AppSettings["DerivedTablesPath"]);//DataAccess.GetDatabases();

            listOfTable = new List<MySQLData.Table>();
            foreach (Schema schema in schemas1)
            {
                listOfTable.AddRange(schema.tables);
            }

            if (listOfTable != null)
            {
                rc.FromTabCntrl.cmbFromTable.ItemsSource = Common.ConvertTablesToStringList(listOfTable);
            }
            rc.FromTabCntrl.cmbFromTable.SelectedIndex = Common.getIndex((List<string>)rc.FromTabCntrl.cmbFromTable.ItemsSource, queryBuilder.SelectedTables[0].Name);
            rc.FromTabCntrl.txtFromAlias.Text = queryBuilder.SelectedTables[0].AliasName;

            int loopCount = 0;
            foreach (SQLBuilder.Clauses.JoinClause JoinClasue in queryBuilder.Joins)
            {
                // create join row control
                int numberOfStackPanel = loopCount++;
                FromTabStackPanelControl fc = new FromTabStackPanelControl();
                fc.Name = "Fs2";
                fc.Margin = new Thickness(0, 5, 0, 5);
                fc.btnDelete.Visibility = System.Windows.Visibility.Visible;
                fc.btnDelete.Uid = (numberOfStackPanel + 1).ToString();
                fc.btnDelete.Width = 25.0;

                if (this.listOfTable != null & this.listOfTable.Count > 0)
                {
                    fc.cmbFromTabJoinTable.ItemsSource = Common.ConvertTablesToStringList(this.listOfTable);
                    fc.cmbFromTabFromColumns.ItemsSource = Common.ConvertColumsToStringList(this.listOfTable[rc.FromTabCntrl.cmbFromTable.SelectedIndex].columns);
                }
                fc.cmbFromTabJoinType.SelectedIndex = Common.getIndex((List<string>)fc.cmbFromTabJoinType.ItemsSource, JoinClasue.JoinType.ToString());
                fc.cmbFromTabJoinTable.SelectedIndex = Common.getIndex((List<string>)fc.cmbFromTabJoinTable.ItemsSource, JoinClasue.ToTable.Name);
                fc.txtJoinTableAlias.Text = JoinClasue.ToTable.AliasName;
                fc.cmbFromTabFromColumns.Text = JoinClasue.FromColumn.ToString();
                fc.cmbFromTabQueryOpretor.SelectedIndex = Common.getIndex((List<string>)fc.cmbFromTabQueryOpretor.ItemsSource, JoinClasue.ComparisonOperator.ToString());
                fc.cmbFromTabJoinColumns.ItemsSource = Common.ConvertColumsToStringList(this.listOfTable[fc.cmbFromTabJoinTable.SelectedIndex].columns);
                fc.cmbFromTabJoinColumns.Text = JoinClasue.ToColumn.ToString();
                rc.FromTabCntrl.StackPanelFromTab.Children.Add(fc);
                rc.FromTabCntrl.DockPanelFromTabRowHeader.Visibility = System.Windows.Visibility.Visible;
                rc.FromTabCntrl.borderJoinDock.Visibility = System.Windows.Visibility.Visible;


                SQLBuilder.Clauses.WhereClause[] joinConditions = queryBuilder.Joins[loopCount - 1].JoinCondition.ToArray<SQLBuilder.Clauses.WhereClause>();
                for (int index = 1; index < joinConditions.Length; index++)
                {
                    FromTabStackPanelControlMore fcm = new FromTabStackPanelControlMore();
                    fcm.Name = "Fs2";
                    fcm.Margin = new Thickness(0, 5, 0, 5);
                    fcm.btndeletemore.Visibility = System.Windows.Visibility.Visible;
                    fcm.btndeletemore.Uid = (numberOfStackPanel + 1).ToString();
                    fcm.btndeletemore.Width = 25.0;

                    List<string> Collist = (from x in (GenerateListOfSelectTabCntrlColumns(rc))
                                            select x.Name).ToList<string>();

                    //List<string> Collist1 = (from x in (GenerateListOfSelectTabColumns(rc))
                    //                        select x.Name).ToList<string>();

                    SQLBuilder.Clauses.GeneralWhereClause generalClause = (SQLBuilder.Clauses.GeneralWhereClause)joinConditions[index];
                    fcm.cmbFromTabFromColumns.ItemsSource = Collist;
                    fcm.cmbFromTabJoinColumns.ItemsSource = Collist;
                    //if (this.listOfTable != null & this.listOfTable.Count > 0)
                    //{
                    //    fcm.cmbFromTabFromColumns.ItemsSource = Common.ConvertColumsToStringList(this.listOfTable[fc.cmbFromTabFromColumns.SelectedIndex].columns);
                    //    fcm.cmbFromTabJoinColumns.ItemsSource = Common.ConvertColumsToStringList(this.listOfTable[fc.cmbFromTabJoinColumns.SelectedIndex].columns);
                    //}
                    fcm.cmbFromTabFromANDOR.Visibility = System.Windows.Visibility.Visible;
                    List<string> ListOfLogicalOpreator = new List<string> { "And", "Or" };
                    fcm.cmbFromTabFromANDOR.ItemsSource = ListOfLogicalOpreator;
                    fcm.cmbFromTabFromANDOR.SelectedIndex = Common.getIndex((List<string>)fcm.cmbFromTabFromANDOR.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));


                    fcm.cmbFromTabFromColumns.Text = generalClause.FieldName;
                    fcm.cmbFromTabQueryOpretor.SelectedIndex = Common.getIndex((List<string>)fcm.cmbFromTabQueryOpretor.ItemsSource, Common.GetStringValueForEnum("Comparison", generalClause.ComparisonOperator));

                    fcm.cmbFromTabJoinColumns.Text = generalClause.Value.ToString();
                    fc.StackPanelFromTabMore.Children.Add(fcm);




                }

                //int RowNumber1 = 0;
                //foreach (SQLBuilder.Clauses.JoinClause whereClause in queryBuilder.Joins)
                //{
                //    int i = 1;
                //    FromTabStackPanelControlMore fcm = new FromTabStackPanelControlMore();
                //    int innerJoinCount = queryBuilder.Joins[loopCount - 1].JoinCondition.Count;
                //    for (i = 1; i < innerJoinCount;i++)
                //    {
                //        fcm.Name = "Fs2";
                //        fcm.Margin = new Thickness(0, 5, 0, 5);
                //        fcm.btndeletemore.Visibility = System.Windows.Visibility.Visible;
                //        fcm.btndeletemore.Uid = (numberOfStackPanel + 1).ToString();
                //        fcm.btndeletemore.Width = 25.0;
                //    }
                //    string controlType = whereClause.GetType().FullName;
                //    List<string> Collist = (from x in (GenerateListOfSelectTabCntrlColumns(rc))
                //                            select x.Name).ToList<string>();
                //    RowNumber1 = RowNumber1 + 1;
                //    SQLBuilder.Clauses.JoinClause generalClause = (SQLBuilder.Clauses.JoinClause)whereClause;

                //    //FromTabStackPanelControlMore fcm = new FromTabStackPanelControlMore();
                //    //if (RowNumber1 != 1)
                //    //{
                //    //    if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                //    //    {
                //    //        generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                //    //    }
                //    //}
                //    //fcm.cmbFromTabFromANDOR.SelectedIndex = Common.getIndex((List<string>)fcm.cmbFromTabFromANDOR.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                //    if (RowNumber1 == 1)
                //    {
                //        fcm.cmbFromTabFromANDOR.Visibility = System.Windows.Visibility.Hidden;
                //    }
                //    fcm.cmbFromTabFromColumns.ItemsSource = Collist;
                //    fcm.cmbFromTabFromColumns.Text = generalClause.FromColumn.ToString();
                //    fcm.cmbFromTabQueryOpretor.SelectedIndex = Common.getIndex((List<string>)fcm.cmbFromTabQueryOpretor.ItemsSource, Common.GetStringValueForEnum("Comparison", generalClause.ComparisonOperator));
                //    fcm.cmbFromTabJoinColumns.ItemsSource = Collist;
                //    fcm.cmbFromTabJoinColumns.Text = generalClause.ToColumn.ToString();
                //    fc.StackPanelFromTabMore.Children.Add(fcm);
                //    i++;
                //}



                //int RowNumber1 = 0;
                //foreach (SQLBuilder.Clauses.WhereClause whereClause in queryBuilder.Where)
                //{
                //    string controlType = whereClause.GetType().FullName;
                //    List<string> Collist = (from x in (GenerateListOfSelectTabCntrlColumns(rc))
                //                            select x.Name).ToList<string>();
                //    RowNumber1 = RowNumber1 + 1;
                //    SQLBuilder.Clauses.GeneralWhereClause generalClause = (SQLBuilder.Clauses.GeneralWhereClause)whereClause;
                //    FromTabStackPanelControlMore fcm = new FromTabStackPanelControlMore();
                //    if (RowNumber1 != 1)
                //    {
                //        if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                //        {
                //            generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                //        }
                //    }
                //    fcm.cmbFromTabFromANDOR.SelectedIndex = Common.getIndex((List<string>)fcm.cmbFromTabFromANDOR.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                //    if (RowNumber1 == 1)
                //    {
                //        fcm.cmbFromTabFromANDOR.Visibility = System.Windows.Visibility.Hidden;
                //    }
                //    fcm.cmbFromTabFromColumns.ItemsSource = Collist;
                //    fcm.cmbFromTabFromColumns.Text = generalClause.FieldName;
                //    fcm.cmbFromTabQueryOpretor.SelectedIndex = Common.getIndex((List<string>)fcm.cmbFromTabQueryOpretor.ItemsSource, Common.GetStringValueForEnum("Comparison", generalClause.ComparisonOperator));
                //    fcm.cmbFromTabJoinColumns.ItemsSource = Collist;
                //    fcm.cmbFromTabJoinColumns.Text = generalClause.Value.ToString();
                //    fc.StackPanelFromTabMore.Children.Add(fcm);
                //}
            }

            //load select tab
            ColListForSelectTab = GenerateListOfSelectTabCntrlColumns(rc);
            // seting up select Tab's observabla collection _FromSelectedColToCollection
            //ColListForSelectTab.ForEach(x => this.SelectTabUC._FromSelectedColToCollection.Add(x));
            rc.SelectTabCntrl.lstToSelecteColFrom.ItemsSource = ColListForSelectTab;
            //clear old selected columns
            rc.SelectTabCntrl._SelectedColCollection.Clear();
            //load selected Column List and set  _SelectedColCollection observable collection from queryBuilder.SelectedColumns
            //Regex regex = new Regex("(?<X>[.]+).(?<Z>)");// this to check if queryBuilder is not generated from custome query, so if user selects table from Tree view we don't need to show selected columns
            if (queryBuilder.SelectedColumns.Count != 0)
            {
                if (!isGetResultByTreeView)
                {
                    //first we copy  queryBuilder.SelectedColumns from generic list to observable collection
                    queryBuilder.SelectedColumns.ForEach(x => rc.SelectTabCntrl._SelectedColCollection.Add(x));
                    //this.SelectTabUC.lstSelectedCol.ItemsSource = this.SelectTabUC._SelectedColCollection;//queryBuilder.SelectedColumns;
                }
            }

            if (queryBuilder.GroupByColumns.Count > 0)
            {

                //we have Tabluation but we need to find out what type of tabulation we have
                //***
                if (queryBuilder.CrossTabClause._col == null)
                {
                    //we have regular tabulation
                    //clear tabulation
                    rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Clear();
                    rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Clear();
                    //loading groupby
                    List<string> GroupByColumnNameList = new List<string>();
                    foreach (SQLBuilder.Clauses.Column groupByColumn in queryBuilder.GroupByColumns)
                    {
                        if (queryBuilder.OrderByStatement.Count == 0)
                        {
                            //we don't have oreder by
                            TabulationTabStackPanelGroupByControl tg = new TabulationTabStackPanelGroupByControl();
                            tg.cmbTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                            //modified on 11-18-11

                            tg.cmbTabulationTabGroupByColumnsName.Text = groupByColumn.Name;
                            tg.txtTabulationTabGroupByColFormat.Text = groupByColumn.Format;
                            //tg.cmbTabulationTabGroupByColumnsName.SelectedIndex = 1;// groupByColumn;
                            // tg.cmbTabulationTabGroupByColumnsName.SelectedItem= groupByColumn;
                            tg.txtTabulationTabGroupByAlias.Text = groupByColumn.AliasName;
                            //add Grupby row
                            rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Add(tg);
                            GroupByColumnNameList.Add(groupByColumn.Name);
                        }
                        else
                        {
                            //we have orderby
                            foreach (SQLBuilder.Clauses.OrderByClause orderByClause in ((List<SQLBuilder.Clauses.OrderByClause>)queryBuilder.OrderByStatement))
                            {
                                if (groupByColumn.Name == orderByClause.FieldName)
                                {
                                    TabulationTabStackPanelGroupByControl tg = new TabulationTabStackPanelGroupByControl();
                                    tg.cmbTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                                    tg.cmbTabulationTabGroupByColumnsName.Text = groupByColumn.Name;
                                    tg.txtTabulationTabGroupByColFormat.Text = groupByColumn.Format;
                                    tg.cmbTabulationSort.Text = Common.GetStringValueForEnum("Sorting", orderByClause.SortOrder);
                                    tg.txtTabulationTabGroupByAlias.Text = groupByColumn.AliasName;
                                    //add Grupby row
                                    rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Add(tg);
                                    GroupByColumnNameList.Add(groupByColumn.Name);
                                }
                            }
                        }
                    }
                    //we display total 3 rows in Group by secction,  we are going to add missing row
                    int numberOfMissingGroupByRow = 3 - rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count;
                    if (rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count != 0)
                    {
                        for (int i = 0; i < numberOfMissingGroupByRow; i++)
                        {
                            rc.TabulationTabCntrl.AddGroupByRow();
                            //loading group by drop down columns to just added group by row
                            ((TabulationTabStackPanelGroupByControl)rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children[rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count - 1]).cmbTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc); ;
                        }

                    }
                    //load summary
                    foreach (SQLBuilder.Clauses.Column summaryColumn in queryBuilder.SummarizeColumns)
                    {
                        //foreach (string colName in GroupByColumnNameList)
                        //{
                        //    if (summaryColumn.Name != colName)
                        //    {
                        if (summaryColumn.Name.Contains("(") & summaryColumn.Name.Contains(")"))
                        {
                            TabulationTabStackPanelSummaryControl ts = new TabulationTabStackPanelSummaryControl();
                            ts.cmbTabulationTabSummaryColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                            // first remove ')' from column name then spilt the string by'('
                            string[] summaryArr = summaryColumn.Name.Remove(summaryColumn.Name.Length - 1, 1).Split('(');
                            ts.cmbTabulationTabSummaryColumnsName.Text = summaryArr[1];
                            ts.cmbTabulationTypeOfSummary.SelectedIndex = Common.getIndex((List<string>)ts.cmbTabulationTypeOfSummary.ItemsSource, summaryArr[0]);
                            ts.cmbTabulationTabUserSelectSummaryColFormat.SelectedIndex = Common.getIndex((List<string>)ts.cmbTabulationTabUserSelectSummaryColFormat.ItemsSource, summaryColumn.Format);
                            ts.txtTabulationTabSummaryColFormat.Text = summaryColumn.Format;
                            ts.txtTabulationTabSummaryAlias.Text = summaryColumn.AliasName;
                            rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Add(ts);
                        }
                        //    }
                        //}
                    }
                    //we display total 6 rows in summary secction, we are going to add missing row
                    int numberOfMissingSummaryRow = 6 - rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count;
                    if (rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Count != 0)
                    {
                        for (int i = 0; i < numberOfMissingSummaryRow; i++)
                        {
                            rc.TabulationTabCntrl.AddSummaryRow();
                            //loading group by drop down columns to just added group by row
                            ((TabulationTabStackPanelSummaryControl)rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children[rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Count - 1]).cmbTabulationTabSummaryColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc); ;
                        }

                    }
                }
                else
                {
                    //we have cross tabulation
                    //clear cross tabulation tab
                    rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Clear();    //here
                    rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children.Clear();
                    //loading groupby
                    List<string> GroupByColumnNameList = new List<string>();
                    foreach (SQLBuilder.Clauses.Column groupByColumn in queryBuilder.GroupByColumns)
                    {
                        if (queryBuilder.OrderByStatement.Count == 0)
                        {
                            //we don't have oreder by
                            CrossTabulationTabStackPanelGroupByControl ctg = new CrossTabulationTabStackPanelGroupByControl();
                            ctg.cmbCrossTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                            ctg.cmbCrossTabulationTabGroupByColumnsName.Text = groupByColumn.Name;
                            ctg.txtCrossTabulationTabGroupByColFormat.Text = groupByColumn.Format;
                            ctg.txtCrossTabulationTabGroupByAlias.Text = groupByColumn.AliasName;
                            //add Grupby row
                            rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Add(ctg);
                            GroupByColumnNameList.Add(groupByColumn.Name);
                        }
                        else
                        {
                            //we have orderby
                            foreach (SQLBuilder.Clauses.OrderByClause orderByClause in ((List<SQLBuilder.Clauses.OrderByClause>)queryBuilder.OrderByStatement))
                            {
                                if (groupByColumn.Name == orderByClause.FieldName)
                                {
                                    CrossTabulationTabStackPanelGroupByControl ctg = new CrossTabulationTabStackPanelGroupByControl();
                                    ctg.cmbCrossTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                                    ctg.cmbCrossTabulationTabGroupByColumnsName.Text = groupByColumn.Name;
                                    ctg.txtCrossTabulationTabGroupByColFormat.Text = groupByColumn.Format;
                                    ctg.cmbCrossTabulationSort.Text = Common.GetStringValueForEnum("Sorting", orderByClause.SortOrder);
                                    ctg.txtCrossTabulationTabGroupByAlias.Text = groupByColumn.AliasName;
                                    //add Grupby row
                                    rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Add(ctg);
                                    GroupByColumnNameList.Add(groupByColumn.Name);
                                }
                            }
                        }
                    }
                    //we display total 3 rows in Group by secction,  we are going to add missing row
                    int numberOfMissingGroupByRow = 3 - rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Count;
                    if (rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Count != 0)
                    {
                        for (int i = 0; i < numberOfMissingGroupByRow; i++)
                        {
                            rc.CrossTabulationTabCntrl.AddGroupByRow();
                            //loading group by drop down columns to just added group by row
                            ((CrossTabulationTabStackPanelGroupByControl)rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children[rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Count - 1]).cmbCrossTabulationTabGroupByColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc); ;
                        }

                    }
                    //load summary
                    foreach (SQLBuilder.Clauses.Column summaryColumn in queryBuilder.SummarizeColumns)
                    {
                        //foreach (string colName in GroupByColumnNameList)
                        //{
                        //    if (summaryColumn.Name != colName)
                        //    {
                        if (summaryColumn.Name.Contains("(") & summaryColumn.Name.Contains(")"))
                        {
                            CrossTabulationTabStackPanelSummaryControl cts = new CrossTabulationTabStackPanelSummaryControl();
                            cts.cmbCrossTabulationTabSummaryColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                            // first remove ')' from column name then spilt the string by'('
                            string[] summaryArr = summaryColumn.Name.Remove(summaryColumn.Name.Length - 1, 1).Split('(');
                            cts.cmbCrossTabulationTabSummaryColumnsName.Text = summaryArr[1];
                            cts.txtCrossTabulationTabSummaryColFormat.Text = summaryColumn.Format;
                            cts.cmbCrossTabulationTypeOfSummary.SelectedIndex = Common.getIndex((List<string>)cts.cmbCrossTabulationTypeOfSummary.ItemsSource, summaryArr[0]);
                            cts.cmbCrossTabulationTabUserSelectSummaryColFormat.SelectedIndex = Common.getIndex((List<string>)cts.cmbCrossTabulationTabUserSelectSummaryColFormat.ItemsSource, summaryColumn.Format);
                            cts.txtCrossTabulationTabSummaryColFormat.Text = summaryColumn.Format;
                            cts.txtCrossTabulationTabSummaryAlias.Text = summaryColumn.AliasName;
                            rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children.Add(cts);
                        }
                        //    }
                        //}
                    }
                    //we display total 6 rows in summary secction, we are going to add missing row
                    int numberOfMissingSummaryRow = 6 - rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Count;
                    if (this.CrossTabulationTabUC.StackPanelCrossTabuLationTabSummary.Children.Count != 0)
                    {
                        for (int i = 0; i < numberOfMissingSummaryRow; i++)
                        {
                            rc.CrossTabulationTabCntrl.AddSummaryRow();
                            //loading group by drop down columns to just added group by row
                            ((CrossTabulationTabStackPanelSummaryControl)rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children[rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children.Count - 1]).cmbCrossTabulationTabSummaryColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc); ;
                        }

                    }

                    //load summary frist row
                    rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFirstRowColumnsName.ItemsSource = GenerateListOfTabulationTabCntrlColumns(rc);
                    rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFirstRowColumnsName.Text = queryBuilder.CrossTabClause.Col.Name;
                    if (queryBuilder.CrossTabClause.SortSet)
                    {
                        rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFristRowSort.Text = Common.GetStringValueForEnum("Sorting", queryBuilder.CrossTabClause.SortOrder);
                    }

                }
                //********
            }


            int RowNumber = 0;
            //rc.WhereTabCntrl.StackPanelWhereTab.Children.Clear();
            rc.WhereTabCntrl.IsAllDisabled = false;
            rc.WhereTabCntrl.whereborder.Visibility = System.Windows.Visibility.Visible;
            foreach (SQLBuilder.Clauses.WhereClause whereClause in queryBuilder.Where)
            {
                RowNumber = RowNumber + 1;
                // create where Tab row control

                string controlType = whereClause.GetType().FullName;
                //List<string> Collist = (from x in (GenerateListOfTabulationTabCntrlColumns(rc))
                //                        select x.Name).ToList<string>();
                List<string> Collist = (from x in (GenerateListOfSelectTabCntrlColumns(rc))
                                        select x.Name).ToList<string>();
                if (controlType == "SQLBuilder.Clauses.BetweenWhereClause")
                {
                    //between where clause
                    SQLBuilder.Clauses.BetweenWhereClause Betweenclause = (SQLBuilder.Clauses.BetweenWhereClause)whereClause;
                    WhereTabBetweenConditionControl wsb = new WhereTabBetweenConditionControl();
                    if (RowNumber != 1)
                    {
                        if (Common.GetStringValueForEnum("LogicOperator", Betweenclause.LogicalOperator) == "None")
                        {
                            Betweenclause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                        }
                    }
                    wsb.cmbWhereTabQueryAndOr.SelectedIndex = Common.getIndex((List<string>)wsb.cmbWhereTabQueryAndOr.ItemsSource, Common.GetStringValueForEnum("LogicOperator", Betweenclause.LogicalOperator));
                    if (RowNumber == 1)
                    {
                        wsb.lblLogicalOpreator.Visibility = System.Windows.Visibility.Hidden;
                        wsb.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                    }
                    wsb.cmbWhereTabBetweenColumns.ItemsSource = Collist;// GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns( (List<SelectTabColumn>) this.SelectTabUC.dgSelectTab.ItemsSource);
                    wsb.cmbWhereTabBetweenColumns.Text = Betweenclause.FieldName;
                    //wsb.cmbWhereTabBetweenColumns.SelectedIndex = Common.getIndex((List<string>)wsb.cmbWhereTabBetweenColumns.ItemsSource, Betweenclause.FieldName);
                    wsb.txtBetweenLeftValue.Text = Betweenclause.FromValue;
                    wsb.txtBetweenRightValue.Text = Betweenclause.ToValue;
                    wsb.cmbWhereTabQueryLevel.SelectedIndex = (Betweenclause.Level - 1);
                    rc.WhereTabCntrl.StackPanelWhereTab.Children.Add(wsb);
                }

                else
                {
                    SQLBuilder.Clauses.GeneralWhereClause generalClause = (SQLBuilder.Clauses.GeneralWhereClause)whereClause;

                    if (generalClause.ComparisonOperator == SQLBuilder.Enums.Comparison.In)
                    {
                        //in where clause
                        WhereTabInNotInConditionControl wInNotIn = new WhereTabInNotInConditionControl();
                        if (RowNumber != 1)
                        {
                            if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                            {
                                generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                            }
                        }
                        wInNotIn.cmbWhereTabQueryAndOr.SelectedIndex = Common.getIndex((List<string>)wInNotIn.cmbWhereTabQueryAndOr.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                        if (RowNumber == 1)
                        {
                            wInNotIn.lblLogicalOpreator.Visibility = System.Windows.Visibility.Hidden;
                            wInNotIn.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                        }
                        wInNotIn.cmbWhereTabInNotInColumns.ItemsSource = Collist;//GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns( (List<SelectTabColumn>) this.SelectTabUC.dgSelectTab.ItemsSource);
                        wInNotIn.cmbWhereTabInNotInColumns.Text = generalClause.FieldName;
                        wInNotIn.lblInNotIn.Content = "    in"; ;
                        wInNotIn.txtInNotInValue.Text = generalClause.Value.ToString();
                        wInNotIn.cmbWhereTabQueryLevel.SelectedIndex = (generalClause.Level - 1);
                        rc.WhereTabCntrl.StackPanelWhereTab.Children.Add(wInNotIn);
                    }

                    else if (generalClause.ComparisonOperator == SQLBuilder.Enums.Comparison.NotIn)
                    {
                        //not in where clause
                        WhereTabInNotInConditionControl wInNotIn2 = new WhereTabInNotInConditionControl();
                        if (RowNumber != 1)
                        {
                            if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                            {
                                generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                            }
                        }
                        wInNotIn2.cmbWhereTabQueryAndOr.SelectedIndex = Common.getIndex((List<string>)wInNotIn2.cmbWhereTabQueryAndOr.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                        if (RowNumber == 1)
                        {
                            wInNotIn2.lblLogicalOpreator.Visibility = System.Windows.Visibility.Hidden;
                            wInNotIn2.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                        }
                        wInNotIn2.cmbWhereTabInNotInColumns.ItemsSource = Collist;//GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns((List<SelectTabColumn>)this.SelectTabUC.dgSelectTab.ItemsSource);
                        wInNotIn2.cmbWhereTabInNotInColumns.Text = generalClause.FieldName;
                        wInNotIn2.lblInNotIn.Content = "not in";
                        wInNotIn2.txtInNotInValue.Text = generalClause.Value.ToString();
                        wInNotIn2.cmbWhereTabQueryLevel.SelectedIndex = (generalClause.Level - 1);
                        rc.WhereTabCntrl.StackPanelWhereTab.Children.Add(wInNotIn2);
                    }

                    else if (generalClause.Value == null)
                    {

                        if (generalClause.ComparisonOperator == SQLBuilder.Enums.Comparison.Equals)
                        {
                            // is null where clause
                            WhereTabNullNotNullConditionControl wNullNotNull = new WhereTabNullNotNullConditionControl();
                            if (RowNumber != 1)
                            {
                                if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                                {
                                    generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                                }
                            }
                            wNullNotNull.cmbWhereTabQueryAndOr.SelectedIndex = Common.getIndex((List<string>)wNullNotNull.cmbWhereTabQueryAndOr.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                            if (RowNumber == 1)
                            {
                                wNullNotNull.lblLogicalOpreator.Visibility = System.Windows.Visibility.Hidden;
                                wNullNotNull.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            }
                            wNullNotNull.cmbWhereTabNullNotNullColumns.ItemsSource = Collist;//GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns((List<SelectTabColumn>)this.SelectTabUC.dgSelectTab.ItemsSource);
                            wNullNotNull.cmbWhereTabNullNotNullColumns.Text = generalClause.FieldName;
                            wNullNotNull.lblNullNotNull.Content = "null";
                            wNullNotNull.cmbWhereTabQueryLevel.SelectedIndex = (generalClause.Level - 1);
                            rc.WhereTabCntrl.StackPanelWhereTab.Children.Add(wNullNotNull);
                        }

                        else if (generalClause.ComparisonOperator == SQLBuilder.Enums.Comparison.NotEquals)
                        {
                            // is not null where clause
                            WhereTabNullNotNullConditionControl wNullNotNull2 = new WhereTabNullNotNullConditionControl();
                            if (RowNumber != 1)
                            {
                                if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                                {
                                    generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                                }
                            }
                            wNullNotNull2.cmbWhereTabQueryAndOr.SelectedIndex = Common.getIndex((List<string>)wNullNotNull2.cmbWhereTabQueryAndOr.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                            if (RowNumber == 1)
                            {
                                wNullNotNull2.lblLogicalOpreator.Visibility = System.Windows.Visibility.Hidden;
                                wNullNotNull2.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            }

                            //IEnumerable<Column> columnsWithSameAlias = _SelectedColCollection.Where(x => x.AliasName == compuatedCol.AliasName)

                            wNullNotNull2.cmbWhereTabNullNotNullColumns.ItemsSource = Collist; //GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns((List<SelectTabColumn>)this.SelectTabUC.dgSelectTab.ItemsSource);
                            wNullNotNull2.cmbWhereTabNullNotNullColumns.Text = generalClause.FieldName;
                            wNullNotNull2.lblNullNotNull.Content = "not null";
                            wNullNotNull2.cmbWhereTabQueryLevel.SelectedIndex = (generalClause.Level - 1);
                            rc.WhereTabCntrl.StackPanelWhereTab.Children.Add(wNullNotNull2);
                        }
                    }
                    else
                    {
                        //Regular where clause
                        WhereTabRegularConditionControl ws = new WhereTabRegularConditionControl();
                        if (RowNumber != 1)
                        {
                            if (Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator) == "None")
                            {
                                generalClause.LogicalOperator = SQLBuilder.Enums.LogicOperator.And;
                            }
                        }
                        ws.cmbWhereTabQueryAndOr.SelectedIndex = Common.getIndex((List<string>)ws.cmbWhereTabQueryAndOr.ItemsSource, Common.GetStringValueForEnum("LogicOperator", generalClause.LogicalOperator));
                        if (RowNumber == 1)
                        {
                            ws.lblLogicalOpreator.Visibility = System.Windows.Visibility.Hidden;
                            ws.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                        }
                        ws.cmbWhereTabLeftSideColumns.ItemsSource = Collist;// GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns((List<SelectTabColumn>)this.SelectTabUC.dgSelectTab.ItemsSource);
                        ws.cmbWhereTabLeftSideColumns.Text = generalClause.FieldName;
                        ///ws.cmbWhereTabLeftSideColumns.SelectedIndex = Common.getIndex((List<string>)ws.cmbWhereTabLeftSideColumns.ItemsSource, generalClause.FieldName);
                        ws.cmbWhereTabQueryOpretor.SelectedIndex = Common.getIndex((List<string>)ws.cmbWhereTabQueryOpretor.ItemsSource, Common.GetStringValueForEnum("Comparison", generalClause.ComparisonOperator));
                        ws.cmbWhereTabRightSideColumns.ItemsSource = Collist;//GenerateListOfTabulationTabColumns();//Common.GetWhereClauseDropDownColumns((List<SelectTabColumn>)this.SelectTabUC.dgSelectTab.ItemsSource);
                        ws.cmbWhereTabRightSideColumns.Text = generalClause.Value.ToString();
                        //ws.cmbWhereTabRightSideColumns.SelectedIndex = Common.getIndex((List<string>)ws.cmbWhereTabRightSideColumns.ItemsSource, generalClause.Value.ToString());
                        ws.cmbWhereTabQueryLevel.SelectedIndex = (generalClause.Level - 1);
                        rc.WhereTabCntrl.StackPanelWhereTab.Children.Add(ws);
                    }
                }
            }
            rc.WhereTabCntrl.cmbWherTabCondition.SelectedIndex = 0;
            //make all tab validated
            rc.FromTabCntrl.isValidated = true;
            rc.FromTabCntrl.lblErrorMessage.Content = "";
            rc.WhereTabCntrl.isValidated = true;
            rc.WhereTabCntrl.lblErrorMessage.Content = "";
            rc.SelectTabCntrl.isValidated = true;
            rc.SelectTabCntrl.lblErrorMessage.Content = "";
            rc.SelectTabCntrl.lstToSelecteColFrom.IsEnabled = true;
            rc.TabulationTabCntrl.lblErrorMessage.Content = "";
            rc.TabulationTabCntrl.isValidated = true;
            rc.CrossTabulationTabCntrl.lblErrorMessage.Content = "";
            rc.CrossTabulationTabCntrl.isValidated = true;
            Mouse.OverrideCursor = null;
            //Clear Action Tab
            this.txtQuery.Text = System.String.Empty;
            count = count + 1;
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < this.lstToSelecteColFrom.SelectedItems.Count; i++)
            {
                Column col = (Column)this.lstToSelecteColFrom.SelectedItems[i];
                //check if alias already exist
                IEnumerable <Column> columnsWithSameAlias = _SelectedColCollection.Where(x => x.AliasName == col.AliasName);
                if (columnsWithSameAlias.Count() == 0)
                {
                    //check if column alreadyexist
                    IEnumerable <Column> columns = _SelectedColCollection.Where(x => x.Name == col.Name & x.AliasName == col.AliasName);
                    if (columns.Count() == 0)
                    {
                        _SelectedColCollection.Add(col);
                    }
                    else
                    {
                        System.Media.SystemSounds.Beep.Play();
                    }
                }
                else
                {
                    System.Media.SystemSounds.Beep.Play();
                }
            }

            if (this.lstToSelecteColFrom.SelectedIndex == -1)
            {
                Column computedCol = new Column();
                computedCol.Name      = ComputedColExpTxtBox.Text;
                computedCol.AliasName = "";
                if (ComputedColFormatComboBox.SelectedValue.ToString() != "Select One")
                {
                    computedCol.Format = ComputedColFormatComboBox.SelectedValue.ToString();
                }
                else
                {
                    computedCol.Format = "NO";
                }

                if (computedCol != null)
                {
                    if (computedCol.Name != System.String.Empty & computedCol.AliasName != System.String.Empty)
                    {
                        IEnumerable <Column> columnsWithSameAlias = _SelectedColCollection.Where(x => x.AliasName == computedCol.AliasName);
                        if (columnsWithSameAlias.Count() == 0)
                        {
                            IEnumerable <Column> columns = _SelectedColCollection.Where(x => x.Name == computedCol.Name & x.AliasName == computedCol.AliasName);
                            if (columns.Count() == 0)
                            {
                                _SelectedColCollection.Add(computedCol);
                            }
                            else
                            {
                                System.Media.SystemSounds.Beep.Play();
                            }
                        }
                        else
                        {
                            System.Media.SystemSounds.Beep.Play();
                        }
                    }
                }
            }

            if (_SelectedColCollection.Count > 11 && isExpanded == false)
            {
                SelectedColsStackPanel.Width += 16;
                isExpanded = true;
            }

            this.lstToSelecteColFrom.SelectedIndex = -1;
            this.lstSelectedCol.SelectedIndex      = -1;
            if (this._SelectedColCollection.Count > 0)
            {
                this.lblErrorMessage.Content = "";
            }
            /***********Validate Control***********/
            Validate();
            /**************************************/

            /************Update query**************/
            //UpdateXmlQuery();
            /**************************************/

            /*****Update Cross Tabulation**********/
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstSelectedCol);
            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;
                rvc.UpdateCrossTabulationTabCntrl(mainWindow);
                rvc.UpdateTabulationTabCntrl(mainWindow);
            }
            /**************************************/

            /*****************To Enable Save***********/
            //FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            //DependencyObject parent = fromTabStackPanelCntrl.GetRVC(this.lstSelectedCol);

            //if (parent != null)
            //{
            //    ResultViewControl rvc = (ResultViewControl)parent;
            //    string directoryPath = rvc.result.directoryPath;

            //    //MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.lstSelectedCol);
            //    //SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(rvc);

            //    //MainGirdViewControl mainGridView1 = new MainGirdViewControl(queryBuilder, mainWindow.CurrentDatabaseName);
            //    //rvc.result = mainGridView1.result;
            //    rvc.result.isModified = true;
            //    rvc.result.isNew = false;
            //    rvc.result.directoryPath = directoryPath;
            //}
            /********************************************/
        }
Beispiel #41
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Button     btnDelete  = (Button)sender;
            MainWindow mainWindow = (MainWindow)GetTopLevelControl(this.cmbWhereTabLeftSideColumns);

            FromTabStackPanelControl fromTabStackPanelCntrl = new FromTabStackPanelControl();
            DependencyObject         parent = fromTabStackPanelCntrl.GetRVC(this.cmbWhereTabLeftSideColumns);

            if (parent != null)
            {
                ResultViewControl rvc = (ResultViewControl)parent;

                if (rvc.WhereTabCntrl.StackPanelWhereTab.Children.Count > 0)
                {
                    DockPanel dkp = (DockPanel)btnDelete.Parent;
                    WhereTabRegularConditionControl fsp = (WhereTabRegularConditionControl)((Grid)((StackPanel)dkp.Parent).Parent).Parent;
                    rvc.WhereTabCntrl.StackPanelWhereTab.Children.Remove(fsp);

                    if (rvc.WhereTabCntrl.StackPanelWhereTab.Children.Count != 0)
                    {
                        string controlType = rvc.WhereTabCntrl.StackPanelWhereTab.Children[0].GetType().ToString();
                        switch (controlType)
                        {
                        case "FastDB.Control.WhereTabRegularConditionControl":
                            WhereTabRegularConditionControl wr = (WhereTabRegularConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wr.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wr.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;

                        case "FastDB.Control.WhereTabBetweenConditionControl":
                            WhereTabBetweenConditionControl wb = (WhereTabBetweenConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wb.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wb.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;

                        case "FastDB.Control.WhereTabInNotInConditionControl":
                            WhereTabInNotInConditionControl wInNotin = (WhereTabInNotInConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wInNotin.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wInNotin.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;

                        case "FastDB.Control.WhereTabNullNotNullConditionControl":
                            WhereTabNullNotNullConditionControl wNullNotNull = (WhereTabNullNotNullConditionControl)(rvc.WhereTabCntrl.StackPanelWhereTab.Children[0]);
                            wNullNotNull.lblLogicalOpreator.Visibility    = System.Windows.Visibility.Hidden;
                            wNullNotNull.cmbWhereTabQueryAndOr.Visibility = System.Windows.Visibility.Hidden;
                            break;
                        }
                    }
                }
                /**********Update Xml Query*********/
                if (mainWindow.ValidateAllTabCntrls(rvc))
                {
                    SelectQueryBuilder queryBuilder = mainWindow.LoadSelectQueryBuilderNew(rvc);
                    if (queryBuilder != null)
                    {
                        queryString = queryBuilder.BuildQuery();
                    }
                    XmlSerializer SerializerObj = new XmlSerializer(typeof(SelectQueryBuilder));
                    StringWriter  writer        = new StringWriter();
                    SerializerObj.Serialize(writer, queryBuilder);
                }
                else
                {
                }
                /************************************/
            }
        }
Beispiel #42
0
        //zahed
        public SelectQueryBuilder LoadSelectQueryBuilderNew(ResultViewControl rc)     //made public zahed 
        {
            SelectQueryBuilder query = new SelectQueryBuilder();

            bool isSelecteTabColumnsOrGroupbyColumns = false;
            if (rc.SelectTabCntrl.lstSelectedCol.ItemsSource != null)
            {
                //****Geting select columns*****
                ObservableCollection<SQLBuilder.Clauses.Column> ListOfSelectColumn = ((ObservableCollection<SQLBuilder.Clauses.Column>)rc.SelectTabCntrl.lstSelectedCol.ItemsSource);
                query.SelectedColumns = ListOfSelectColumn.ToList();
                //foreach (SQLBuilder.Clauses.Column Col in ListOfSelectColumn)
                //{
                //    SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                //    column.Name = Col.Name;
                //    column.AliasName = Col.AliasName;
                //    column.Format = Col.Format;
                //    query.SelectColumn(column);
                //}
                isSelecteTabColumnsOrGroupbyColumns = true;
            }
            if (rc.TabulationTabCntrl.isTabulation)
            {
                //group by column
                for (int i = 0; i < rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children.Count; i++)
                {
                    TabulationTabStackPanelGroupByControl tg = (TabulationTabStackPanelGroupByControl)rc.TabulationTabCntrl.StackPanelTabuLationTabGroupBy.Children[i];
                    if (tg.cmbTabulationTabGroupByColumnsName.SelectedIndex != -1)
                    {
                        SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();

                        column.Name = tg.cmbTabulationTabGroupByColumnsName.Text;
                        column.Format = tg.txtTabulationTabGroupByColFormat.Text;
                        column.AliasName = tg.txtTabulationTabGroupByAlias.Text;

                        query.AddGroupBy(column);
                        if (tg.cmbTabulationSort.SelectedIndex != -1)
                        {
                            query.AddOrderBy(tg.cmbTabulationTabGroupByColumnsName.Text, GetSortingEnum(tg.cmbTabulationSort.Text));
                        }
                    }
                }
                //summarize column
                for (int i = 0; i < rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children.Count; i++)
                {
                    TabulationTabStackPanelSummaryControl ts = (TabulationTabStackPanelSummaryControl)rc.TabulationTabCntrl.StackPanelTabuLationTabSummary.Children[i];
                    if (ts.cmbTabulationTabSummaryColumnsName.SelectedIndex != -1)
                    {
                        SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                        column.Name = ts.cmbTabulationTypeOfSummary.Text + "(" + ts.cmbTabulationTabSummaryColumnsName.Text + ")";
                        column.Format = ts.txtTabulationTabSummaryColFormat.Text;
                        column.AliasName = ts.txtTabulationTabSummaryAlias.Text;
                        query.AddSummarize(column);
                    }
                }

                isSelecteTabColumnsOrGroupbyColumns = true;
            }
            else if (rc.CrossTabulationTabCntrl.isCrossTabulation)
            {
                //group by column
                for (int i = 0; i < rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children.Count; i++)
                {
                    CrossTabulationTabStackPanelGroupByControl ctg = (CrossTabulationTabStackPanelGroupByControl)rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabGroupBy.Children[i];
                    if (ctg.cmbCrossTabulationTabGroupByColumnsName.SelectedIndex != -1)
                    {
                        SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                        //modified on  11/18/11
                        //column.Name = ctg.cmbCrossTabulationTabGroupByColumnsName.Text;
                        column.Name = ctg.cmbCrossTabulationTabGroupByColumnsName.Text;//((SQLBuilder.Clauses.Column)ctg.cmbCrossTabulationTabGroupByColumnsName.SelectionBoxItem).Name;
                        column.Format = ctg.txtCrossTabulationTabGroupByColFormat.Text; //((SQLBuilder.Clauses.Column)ctg.cmbCrossTabulationTabGroupByColumnsName.SelectionBoxItem).Format;
                        column.AliasName = ctg.txtCrossTabulationTabGroupByAlias.Text;
                        //query.SelectColumn(column);
                        query.AddGroupBy(column);
                        if (ctg.cmbCrossTabulationSort.SelectedIndex != -1)
                        {
                            // SQLBuilder.Clauses.OrderByClause orderBy = new  SQLBuilder.Clauses.OrderByClause(tg.cmbTabulationTabGroupByColumnsName.Text,GetSortingEnum(tg.cmbTabulationSort.Text));
                            // modified on 11/18/11
                            query.AddOrderBy(ctg.cmbCrossTabulationTabGroupByColumnsName.Text, GetSortingEnum(ctg.cmbCrossTabulationSort.Text));
                            //query.AddOrderBy(((SQLBuilder.Clauses.Column)ctg.cmbCrossTabulationTabGroupByColumnsName.SelectionBoxItem).Name, GetSortingEnum(ctg.cmbCrossTabulationSort.Text));
                        }
                    }
                }
                //summarize column
                for (int i = 0; i < rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children.Count; i++)
                {
                    CrossTabulationTabStackPanelSummaryControl ts = (CrossTabulationTabStackPanelSummaryControl)rc.CrossTabulationTabCntrl.StackPanelCrossTabuLationTabSummary.Children[i];
                    if (ts.cmbCrossTabulationTabSummaryColumnsName.SelectedIndex != -1)
                    {
                        SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                        //modified on 11/18/11
                        column.Name = ts.cmbCrossTabulationTypeOfSummary.Text + "(" + ts.cmbCrossTabulationTabSummaryColumnsName.Text + ")";
                        column.Format = ts.txtCrossTabulationTabSummaryColFormat.Text;
                        //column.Name = ts.cmbCrossTabulationTypeOfSummary.Text + "(" + ((SQLBuilder.Clauses.Column)ts.cmbCrossTabulationTabSummaryColumnsName.SelectionBoxItem).Name + ")";
                        //column.Format = ((SQLBuilder.Clauses.Column)ts.cmbCrossTabulationTabSummaryColumnsName.SelectionBoxItem).Format;
                        column.AliasName = ts.txtCrossTabulationTabSummaryAlias.Text;
                        //query.SelectColumn(column);
                        query.AddSummarize(column);
                    }
                }
                //summary first row
                SQLBuilder.Clauses.Column column1 = new SQLBuilder.Clauses.Column();
                //modified on 11/18/11
                column1.Name = rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFirstRowColumnsName.Text;
                //column1.Name =  ((SQLBuilder.Clauses.Column)this.CrossTabulationTabUC.cmbCrossTabulationTabSummaryFirstRowColumnsName.SelectionBoxItem).Name;
                if (rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFristRowSort.SelectedIndex == -1)
                {
                    query.CrossTabClause = new SQLBuilder.Clauses.CrossTabulationClause(column1);
                    isSelecteTabColumnsOrGroupbyColumns = true;
                }
                else
                {
                    query.CrossTabClause = new SQLBuilder.Clauses.CrossTabulationClause(column1, GetSortingEnum(rc.CrossTabulationTabCntrl.cmbCrossTabulationTabSummaryFristRowSort.Text));
                    isSelecteTabColumnsOrGroupbyColumns = true;
                }
            }

            if (isSelecteTabColumnsOrGroupbyColumns)
            {
                //Geting from table
                SQLBuilder.Clauses.Table fromTable = null;
                MySQLData.Table table = this.listOfTable[rc.FromTabCntrl.cmbFromTable.SelectedIndex];
                if (table is MySQLData.DerivedTable)
                {
                    fromTable = new SQLBuilder.Clauses.DerivedTable((MySQLData.DerivedTable)table, rc.FromTabCntrl.txtFromAlias.Text);
                }
                else if (table is MySQLData.Table)
                {
                    fromTable = new SQLBuilder.Clauses.Table(table, rc.FromTabCntrl.txtFromAlias.Text);
                }

                //fromTable.Name = rc.FromTabCntrl.cmbFromTable.Text;
                //fromTable.AliasName = rc.FromTabCntrl.txtFromAlias.Text;
                query.SelectFromTable(fromTable);

                //Geting join table and join colums
                for (int i = 0; i < rc.FromTabCntrl.StackPanelFromTab.Children.Count; i++)
                {
                    FromTabStackPanelControl fs = (FromTabStackPanelControl)rc.FromTabCntrl.StackPanelFromTab.Children[i];
                    SQLBuilder.Clauses.Table joinTable = null;

                    MySQLData.Table jTable = null;
                    if (fs.cmbFromTabJoinTable.SelectedIndex != -1)
                    {
                        jTable = this.listOfTable[fs.cmbFromTabJoinTable.SelectedIndex];

                        if (jTable is MySQLData.DerivedTable)
                        {
                            joinTable = new SQLBuilder.Clauses.DerivedTable((MySQLData.DerivedTable)jTable, fs.txtJoinTableAlias.Text);
                        }
                        else if (jTable is MySQLData.Table)
                        {
                            joinTable = new SQLBuilder.Clauses.Table(jTable, fs.txtJoinTableAlias.Text);
                        }

                        //joinTable.Name = fs.cmbFromTabJoinTable.Text;
                        //joinTable.AliasName = fs.txtJoinTableAlias.Text;
                        SQLBuilder.Clauses.JoinClause joinClause = query.AddJoin(GetJoinType(fs.cmbFromTabJoinType.Text), fromTable, fs.cmbFromTabFromColumns.Text, GetComparisonOpreator(fs.cmbFromTabQueryOpretor.Text), joinTable, fs.cmbFromTabJoinColumns.Text);
                        for (int condIndex = 0; condIndex < fs.StackPanelFromTabMore.Children.Count; condIndex++)
                        {
                            FromTabStackPanelControlMore fsCondition = (FromTabStackPanelControlMore)fs.StackPanelFromTabMore.Children[condIndex];

                            joinClause.addJoinCondition(GetLogicalOpreator(fsCondition.cmbFromTabFromANDOR.Text), fromTable, fsCondition.cmbFromTabFromColumns.Text, GetComparisonOpreator(fsCondition.cmbFromTabQueryOpretor.Text), joinTable, fsCondition.cmbFromTabJoinColumns.Text);
                        }
                    }
                }
                //******Geting Wheree Clause********
                for (int i = 0; i < rc.WhereTabCntrl.StackPanelWhereTab.Children.Count; i++)
                {
                    string controlType = rc.WhereTabCntrl.StackPanelWhereTab.Children[i].GetType().ToString();
                    switch (controlType)
                    {
                        case "FastDB.Control.WhereTabRegularConditionControl":
                            WhereTabRegularConditionControl ws = (WhereTabRegularConditionControl)rc.WhereTabCntrl.StackPanelWhereTab.Children[i];
                            if (i == 0)
                            {
                                query.AddWhere(SQLBuilder.Enums.LogicOperator.None, ws.cmbWhereTabLeftSideColumns.Text, GetComparisonOpreator(ws.cmbWhereTabQueryOpretor.Text), ws.cmbWhereTabRightSideColumns.Text, Convert.ToInt32(ws.cmbWhereTabQueryLevel.Text));
                            }
                            else
                            {
                                query.AddWhere(GetLogicalOpreator(ws.cmbWhereTabQueryAndOr.Text), ws.cmbWhereTabLeftSideColumns.Text, GetComparisonOpreator(ws.cmbWhereTabQueryOpretor.Text), ws.cmbWhereTabRightSideColumns.Text, Convert.ToInt32(ws.cmbWhereTabQueryLevel.Text));
                            }
                            break;
                        case "FastDB.Control.WhereTabBetweenConditionControl":
                            WhereTabBetweenConditionControl wsb = (WhereTabBetweenConditionControl)rc.WhereTabCntrl.StackPanelWhereTab.Children[i];
                            if (i == 0)
                            {
                                query.AddWhere(SQLBuilder.Enums.LogicOperator.None, wsb.cmbWhereTabBetweenColumns.Text, wsb.txtBetweenLeftValue.Text, wsb.txtBetweenRightValue.Text, Convert.ToInt32(wsb.cmbWhereTabQueryLevel.Text));
                            }
                            else
                            {
                                query.AddWhere(GetLogicalOpreator(wsb.cmbWhereTabQueryAndOr.Text), wsb.cmbWhereTabBetweenColumns.Text, wsb.txtBetweenLeftValue.Text, wsb.txtBetweenRightValue.Text, Convert.ToInt32(wsb.cmbWhereTabQueryLevel.Text));
                            }
                            break;
                        case "FastDB.Control.WhereTabInNotInConditionControl":
                            WhereTabInNotInConditionControl wInNotIn = (WhereTabInNotInConditionControl)rc.WhereTabCntrl.StackPanelWhereTab.Children[i];
                            if (i == 0)
                            {
                                query.AddWhere(SQLBuilder.Enums.LogicOperator.None, wInNotIn.cmbWhereTabInNotInColumns.Text, GetComparisonOpreator(wInNotIn.lblInNotIn.Content.ToString()), wInNotIn.txtInNotInValue.Text, Convert.ToInt32(wInNotIn.cmbWhereTabQueryLevel.Text));
                            }
                            else
                            {
                                query.AddWhere(GetLogicalOpreator(wInNotIn.cmbWhereTabQueryAndOr.Text), wInNotIn.cmbWhereTabInNotInColumns.Text, GetComparisonOpreator(wInNotIn.lblInNotIn.Content.ToString()), wInNotIn.txtInNotInValue.Text, Convert.ToInt32(wInNotIn.cmbWhereTabQueryLevel.Text));
                            }
                            break;
                        case "FastDB.Control.WhereTabNullNotNullConditionControl":
                            WhereTabNullNotNullConditionControl wNullNotNull = (WhereTabNullNotNullConditionControl)rc.WhereTabCntrl.StackPanelWhereTab.Children[i];
                            if (i == 0)
                            {
                                query.AddWhere(SQLBuilder.Enums.LogicOperator.None, wNullNotNull.cmbWhereTabNullNotNullColumns.Text, GetComparisonOpreator(wNullNotNull.lblNullNotNull.Content.ToString()), null, Convert.ToInt32(wNullNotNull.cmbWhereTabQueryLevel.Text));
                            }
                            else
                            {
                                query.AddWhere(GetLogicalOpreator(wNullNotNull.cmbWhereTabQueryAndOr.Text), wNullNotNull.cmbWhereTabNullNotNullColumns.Text, GetComparisonOpreator(wNullNotNull.lblNullNotNull.Content.ToString()), null, Convert.ToInt32(wNullNotNull.cmbWhereTabQueryLevel.Text));
                            }
                            break;
                    }
                }
            }
            return query;
        }