private void button1_Click(object sender, EventArgs e) { resetchart(sender, e); DateTime begin = new DateTime(); DateTime end = new DateTime(); string result = comboBox1.Text; //sets a filter range dependend on the month given in the dropdown menu if (result == "December") { begin = new DateTime(2011, 11, 30); end = new DateTime(2012, 1, 1); } else if (result == "Februari") { begin = new DateTime(2011, 1, 31); end = new DateTime(2011, 3, 1); } else if (result == "March") { begin = new DateTime(2011, 2, 28); end = new DateTime(2011, 4, 1); } else if (result == "April") { begin = new DateTime(2011, 3, 31); end = new DateTime(2011, 5, 1); } else if (result == "May") { begin = new DateTime(2011, 4, 30); end = new DateTime(2011, 6, 1); } else if (result == "June") { begin = new DateTime(2011, 5, 31); end = new DateTime(2011, 7, 1); } else if (result == "July") { begin = new DateTime(2011, 6, 30); end = new DateTime(2011, 8, 1); } else if (result == "August") { begin = new DateTime(2011, 7, 31); end = new DateTime(2011, 9, 1); } else if (result == "September") { begin = new DateTime(2011, 8, 31); end = new DateTime(2011, 10, 1); } else if (result == "Oktober") { begin = new DateTime(2011, 9, 30); end = new DateTime(2011, 11, 1); } else if (result == "November") { begin = new DateTime(2011, 10, 31); end = new DateTime(2011, 12, 1); } else { begin = new DateTime(2010, 12, 31); end = new DateTime(2011, 2, 1); } DataFilter filter = new DataFilter(begin, end); BarChart.DataManipulator.Filter(filter, BarChart.Series[0]); BarChart.DataManipulator.Filter(filter, BarChart.Series[1]); }
//redraws the table in its entirety and removes the points that are outside the given range private void FilterButton_Click(object sender, EventArgs e) { resetchart(sender, e); //checks if the filter is filled in if (BegDay.Text.Length > 0 && BegMonth.Text.Length > 0) { bool text = true; //chekcs if the filter consists out of digits foreach (char letter in BegDay.Text) { if (!char.IsDigit(letter)) { text = false; } } foreach (char letter in BegMonth.Text) { if (!char.IsDigit(letter)) { text = false; } } foreach (char letter in EndDay.Text) { if (!char.IsDigit(letter)) { text = false; } } foreach (char letter in EndMonth.Text) { if (!char.IsDigit(letter)) { text = false; } } //gets the values from the textboxes and puts them into interger variables int BeginningMonth = Int32.Parse(BegMonth.Text); int BeginningDay = Int32.Parse(BegDay.Text); int EndingMonth = Int32.Parse(EndMonth.Text); int EndingDay = Int32.Parse(EndDay.Text); //checks if the values are in bounds if ((1 >= BeginningDay) && (BeginningDay <= 31) && (1 >= EndingDay) && (EndingDay <= 31)) { text = false; } if ((1 >= BeginningMonth) && (BeginningDay <= 12) && (1 >= EndingMonth) && (EndingMonth <= 12)) { text = false; } //when all the checks above pass, it creates two date times using the values and calls the filter function if (text == true) { DateTime begin = new DateTime(2011, BeginningMonth, BeginningDay); DateTime end = new DateTime(2011, EndingMonth, EndingDay); DataFilter filter = new DataFilter(begin, end); BarChart.DataManipulator.Filter(filter, BarChart.Series[0]); BarChart.DataManipulator.Filter(filter, BarChart.Series[1]); } else { //displays a error message if one of the tests fails MessageBox.Show("The given filter is not correct"); } } }