Esempio n. 1
0
        private void RefreshResult()
        {
            string connectionString = null;
            if (!_getResultByTreeView)
            {
                connectionString = ConfigurationManager.AppSettings["DefaultDBConn"];
            }
            else
            {
                connectionString = "";
                if (_TableViewModel._ParentSchemaName == ConfigurationManager.AppSettings["DerivedTablesPath"])
                {
                    connectionString = ConfigurationManager.AppSettings["FastDBConn"];
                }
                else
                {
                    connectionString = ConfigurationManager.AppSettings["FastDBConn"];
                }

                _queryBuilder = new SQLBuilder.SelectQueryBuilder();
                //loading query builder for first time call we have to manulay populate query builder
                SQLBuilder.Clauses.Table fromTable = null;
                 if (_TableViewModel._table is MySQLData.DerivedTable)
                 {
                     fromTable = new SQLBuilder.Clauses.DerivedTable((MySQLData.DerivedTable)_TableViewModel._table, "X");
                 }
                 else if (_TableViewModel._table is MySQLData.Table)
                 {
                     fromTable = new SQLBuilder.Clauses.Table(_TableViewModel._table, "X");
                 }
                 _queryBuilder.SelectFromTable(fromTable);
            }
            bool isAddedColumnsManually = false;
            if (_queryBuilder.CrossTabClause.Col == null && (_queryBuilder.GroupByColumns== null || _queryBuilder.GroupByColumns.Count <= 0) 
                    && (_queryBuilder.SelectedColumns == null || _queryBuilder.SelectedColumns.Count <= 0))
            {
                isAddedColumnsManually = true;
                if (_TableViewModel != null && _TableViewModel._table != null)
                {
                    foreach (MySQLData.Column col in _TableViewModel._table.columns)
                    {
                        //load query builder select columns
                        SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                        column.Name = "X." + col.name;
                        _queryBuilder.SelectColumn(column);
                    }
                }
                else
                {
                    foreach (Table Tab in _queryBuilder.SelectedTables)
                    {
                        string tableName = Tab.Name;
                        List<MySQLData.Column> columns = MySQLData.DataAccess.ADODataBridge.getTableColumns(connectionString, ConfigurationManager.AppSettings["DefaultDatabase"], tableName);
                        foreach (MySQLData.Column col in columns)
                        {
                            //load query builder select columns
                            SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                            column.Name = "X." + col.name;
                            _queryBuilder.SelectColumn(column);
                        }
                        break;
                    }
                }
            }

            if (_queryBuilder.CrossTabClause.Col == null)
            {
                if (_getResultByQuery)
                {
                    Results = MySQLData.DataAccess.ADODataBridge.getData(connectionString, _queryBuilder, startRow, rowPageSize, startColumn, columnPageSize, sortColumn, ascending, out totalRows, out totalColumns).DefaultView;
                    _getResultByQuery = false;
                }
                else
                {
                    Results = MySQLData.DataAccess.ADODataBridge.getData(connectionString, _queryBuilder, startRow, rowPageSize, startColumn, columnPageSize, sortColumn, ascending, out totalColumns).DefaultView;
                }
            }
            else
            {
                Results = MySQLData.DataAccess.ADODataBridge.getCrossTabulationData(connectionString, _queryBuilder, out totalRows, out totalColumns).Results.DefaultView;
            }

            if (isAddedColumnsManually)
            {
                _queryBuilder.SelectedColumns.Clear();
            }
            // to determine to show scroll bar
            if (Results.Count == totalRows)
            {
                _ShowVertcalScrollBar = false;

            }
            if (Results.Table.Columns.Count == totalColumns)
            {
                _ShowHorizontalScrollBar = false;
            }
            
            NotifyPropertyChanged("Results");
            NotifyPropertyChanged("StartRow");
            NotifyPropertyChanged("EndRow");
            NotifyPropertyChanged("TotalIRows");

            NotifyPropertyChanged("StartColumn");
            NotifyPropertyChanged("EndColumn");
            NotifyPropertyChanged("TotalColumns");
            MainWindow.LatestQueryBuilder = _queryBuilder;
        }
Esempio n. 2
0
        private void RefreshResult()
        {
            string connectionString = null;

            if (!_getResultByTreeView)
            {
                connectionString = ConfigurationManager.AppSettings["DefaultDBConn"];
            }
            else
            {
                connectionString = "";
                if (_TableViewModel._ParentSchemaName == ConfigurationManager.AppSettings["DerivedTablesPath"])
                {
                    connectionString = ConfigurationManager.AppSettings["FastDBConn"];
                }
                else
                {
                    connectionString = ConfigurationManager.AppSettings["FastDBConn"];
                }

                _queryBuilder = new SQLBuilder.SelectQueryBuilder();
                //loading query builder for first time call we have to manulay populate query builder
                SQLBuilder.Clauses.Table fromTable = null;
                if (_TableViewModel._table is MySQLData.DerivedTable)
                {
                    fromTable = new SQLBuilder.Clauses.DerivedTable((MySQLData.DerivedTable)_TableViewModel._table, "X");
                }
                else if (_TableViewModel._table is MySQLData.Table)
                {
                    fromTable = new SQLBuilder.Clauses.Table(_TableViewModel._table, "X");
                }
                _queryBuilder.SelectFromTable(fromTable);
            }
            bool isAddedColumnsManually = false;

            if (_queryBuilder.CrossTabClause.Col == null && (_queryBuilder.GroupByColumns == null || _queryBuilder.GroupByColumns.Count <= 0) &&
                (_queryBuilder.SelectedColumns == null || _queryBuilder.SelectedColumns.Count <= 0))
            {
                isAddedColumnsManually = true;
                if (_TableViewModel != null && _TableViewModel._table != null)
                {
                    foreach (MySQLData.Column col in _TableViewModel._table.columns)
                    {
                        //load query builder select columns
                        SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                        column.Name = "X." + col.name;
                        _queryBuilder.SelectColumn(column);
                    }
                }
                else
                {
                    foreach (Table Tab in _queryBuilder.SelectedTables)
                    {
                        string tableName = Tab.Name;
                        List <MySQLData.Column> columns = MySQLData.DataAccess.ADODataBridge.getTableColumns(connectionString, ConfigurationManager.AppSettings["DefaultDatabase"], tableName);
                        foreach (MySQLData.Column col in columns)
                        {
                            //load query builder select columns
                            SQLBuilder.Clauses.Column column = new SQLBuilder.Clauses.Column();
                            column.Name = "X." + col.name;
                            _queryBuilder.SelectColumn(column);
                        }
                        break;
                    }
                }
            }

            if (_queryBuilder.CrossTabClause.Col == null)
            {
                if (_getResultByQuery)
                {
                    Results           = MySQLData.DataAccess.ADODataBridge.getData(connectionString, _queryBuilder, startRow, rowPageSize, startColumn, columnPageSize, sortColumn, ascending, out totalRows, out totalColumns).DefaultView;
                    _getResultByQuery = false;
                }
                else
                {
                    Results = MySQLData.DataAccess.ADODataBridge.getData(connectionString, _queryBuilder, startRow, rowPageSize, startColumn, columnPageSize, sortColumn, ascending, out totalColumns).DefaultView;
                }
            }
            else
            {
                Results = MySQLData.DataAccess.ADODataBridge.getCrossTabulationData(connectionString, _queryBuilder, out totalRows, out totalColumns).Results.DefaultView;
            }

            if (isAddedColumnsManually)
            {
                _queryBuilder.SelectedColumns.Clear();
            }
            // to determine to show scroll bar
            if (Results.Count == totalRows)
            {
                _ShowVertcalScrollBar = false;
            }
            if (Results.Table.Columns.Count == totalColumns)
            {
                _ShowHorizontalScrollBar = false;
            }

            NotifyPropertyChanged("Results");
            NotifyPropertyChanged("StartRow");
            NotifyPropertyChanged("EndRow");
            NotifyPropertyChanged("TotalIRows");

            NotifyPropertyChanged("StartColumn");
            NotifyPropertyChanged("EndColumn");
            NotifyPropertyChanged("TotalColumns");
            MainWindow.LatestQueryBuilder = _queryBuilder;
        }