Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            Console.WriteLine("Building query....");
            var factory = new SimpleSQLFactory(this.visualQueryBuilder1.SelectedTableName, new List<string>()
            {
                this.visualQueryBuilder1.SelectedFieldName,
                this.visualQueryBuilder1.SelectedRowGroupingFieldName,
                this.visualQueryBuilder1.SelectedColGroupingFieldName
            });

            var db = new AccessDatabase(this.textboxWithOpenFileDialog1.Text);
            var builder = new StandardQueryBuilder(factory);
            Console.WriteLine("Retrieving data from access...");
            DataTable results = db.ExecuteQuery(builder.BuildSQL());

            try
            {
                Console.WriteLine("Calculating aggregate statistics");
                var statistics = new BasicStatistics(results, 0);
                var visualiser = new DataVisualisation.BasicStatisticsVisualiser(statistics);
                this.explorationPanel1.SetAggregateResults(visualiser);

            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message +
                        " Please make sure you have selected quantitative variables for the analysis", "Error analysing query dataset",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidCastException ex)
            {
                MessageBox.Show(ex.Message +
                            " Please make sure you have selected quantitative variables for the analysis", "Error analysing query dataset",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            var adapter = new DataTableToCrossTabAdapter(results, new DataTableToCrossTabAdapterArgs()
            {
                RowFieldNames = new List<string>(){this.visualQueryBuilder1.SelectedRowGroupingFieldName},
                ColFieldNames = new List<string>(){this.visualQueryBuilder1.SelectedColGroupingFieldName}
            });

            Console.WriteLine("Building crosstab...");

            var ctDataTable = new CrossTabDataTable(adapter, this.visualQueryBuilder1.SelectedRowGroupingFieldName);
            this.explorationPanel1.SetCrossTab(ctDataTable);
            this.extendedTabControl1.SelectedTab = this.tabPage4;

            Console.WriteLine("Complete.");
        }
        protected DataTable GetData(string locality)
        {
            var db = new AccessDatabase(querySetup.DatabasePath);

            var factory = new VisitsByLocalityQuerySQLFactory(querySetup, locality);

            var builder = new StandardQueryBuilder(factory);
            Console.WriteLine("Retrieving data for {0}", locality);
            var data = db.ExecuteQuery(builder.BuildSQL());
            return data;
        }
        /// <summary>
        /// Queries the database for all hub data
        /// </summary>
        /// <returns></returns>
        private DataTable GetHubData()
        {
            var db = new AccessDatabase(this.querySetup.DatabasePath);

            var factory = new LocalityHubsQuerySQLFactory(this.querySetup);

            var builder = new StandardQueryBuilder(factory);

            var data = db.ExecuteQuery(builder.BuildSQL());

            return data;
        }
        /// <summary>
        /// Querys the database
        /// </summary>
        /// <param name="locality"></param>
        /// <returns></returns>
        private DataTable GetData(string locality)
        {
            var db = new AccessDatabase(this.querySetup.DatabasePath);

            var factory = new VisitsByLocalityQuerySQLFactory(this.querySetup, locality);

            var builder = new StandardQueryBuilder(factory);

            DataTable data = null;

            try
            {

                data = db.ExecuteQuery(builder.BuildSQL());
            }
            catch (System.Data.OleDb.OleDbException ex)
            {
                throw new ArgumentException("Cannot open database.  Please check that path is correct", ex);
            }

            return data;
        }
Exemplo n.º 5
0
        private DataTable GetDistinct(string fieldName)
        {
            this.Cursor = Cursors.WaitCursor;
            var factory = new SimpleDistinctSQLFactory(this.visualQueryBuilder1.SelectedTableName, new List<string>() { fieldName });
            var db = new AccessDatabase(this.textboxWithOpenFileDialog1.Text);
            var builder = new StandardQueryBuilder(factory);
            DataTable results = db.ExecuteQuery(builder.BuildSQL());

            this.Cursor = Cursors.Default;

            return results;
        }
        /// <summary>
        /// Querys the database
        /// </summary>
        /// <param name="locality"></param>
        /// <returns></returns>
        private DataTable GetData(string locality)
        {
            var db = new AccessDatabase(this.querySetup.DatabasePath);

            var factory = new VisitsByLocalityQuerySQLFactory(this.querySetup, locality);

            var builder = new StandardQueryBuilder(factory);

            var data = db.ExecuteQuery(builder.BuildSQL());

            return data;
        }