예제 #1
0
        public FormFilterWijk(window form, PostgresSQL conn)
        {
            db       = conn;
            mainForm = form;
            InitializeComponent();
            DataTable dt = new DataTable();

            dt.Load(db.QueryDataReader("SELECT DISTINCT stadsdeel FROM wijken"));
            cBoxStadsdeel.DataSource    = dt;
            cBoxStadsdeel.DisplayMember = "stadsdeel"; cBoxStadsdeel.ValueMember = "stadsdeel";
        }
        //private PostgresSQL db;
        public FormFilter(window form, PostgresSQL db, string lastPostcode)
        {
            DataTable dt = new DataTable();

            InitializeComponent();
            mainWindow = form;
            dt.Load(db.QueryDataReader("SELECT DISTINCT voorzieningen FROM voorzieningen"));
            cBoxVoorziening.DropDownStyle = ComboBoxStyle.DropDownList;
            cBoxVoorziening.DataSource    = dt;
            cBoxVoorziening.DisplayMember = "voorzieningen";
            cBoxVoorziening.ValueMember   = "voorzieningen";

            if (lastPostcode != null)
            {
                txtPostcode.Text = lastPostcode;
            }
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            menuStrip1.Items.Clear();

            DataTable dt     = new DataTable();
            var       reader = db.QueryDataReader("SELECT DISTINCT voorzieningen FROM voorzieningen");

            int count = reader.FieldCount;

            while (reader.Read())
            {
                for (int i = 0; i < count; i++)
                {
                    series.Add(reader.GetValue(i).ToString());
                }
            }

            reader.Dispose();

            var readerWijken = db.QueryDataReader("SELECT id, wijk FROM wijken");

            int countWijken = readerWijken.FieldCount;

            while (readerWijken.Read())
            {
                Wijken wijk = new Wijken();
                wijk.Id   = int.Parse(readerWijken[0].ToString());
                wijk.Wijk = readerWijken[1].ToString();
                wijken.Add(wijk);
            }

            readerWijken.Dispose();

            ToolStripMenuItem menuItem = new ToolStripMenuItem("Filter");

            barChart.ChartAreas[0].AxisX.Interval = 1;
            foreach (string serieName in series)
            {
                Series serie = new Series(serieName);
                serie.ChartType = SeriesChartType.StackedBar;
                barChart.Series.Add(serie);
                // menuStrip1.Items.Add(serieName, null, myContextMenuStrip_ItemClicked);


                ToolStripMenuItem foo = new ToolStripMenuItem(serieName);
                foo.Click += new EventHandler(myContextMenuStrip_ItemClicked);
                menuItem.DropDownItems.Add(foo);

                int i = 0;

                foreach (Wijken wijk in wijken)
                {
                    var readerCountFilter =
                        db.queryScalar("SELECT COUNT(*) FROM voorzieningen WHERE voorzieningen = '" +
                                       serieName + "' AND wijk_id = " + wijk.Id + "");
                    barChart.Series[serieName].Points.AddY(readerCountFilter);
                    barChart.Series[serieName].Points[i].AxisLabel = wijk.Wijk;

                    i++;
                }
            }

            ToolStripMenuItem last = new ToolStripMenuItem("None");

            last.Click += new EventHandler(myContextMenuStrip_ItemClicked);
            menuItem.DropDownItems.Add(last);

            menuStrip1.Items.Add(menuItem);
        }