Esempio n. 1
0
        private void viewGraphic_Click(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(country.Text))
                {
                    viewGraphic.Enabled = false;
                    country.Enabled     = false;
                    clearBtn.Enabled    = true;
                    string[] series = { "Silent Generation", "G.I. Generation", "Boomers", "Millenials", "Generation  X" };
                    int[]    puntos = { mc.DeathsCountByGeneration("Silent",    country.Text), mc.DeathsCountByGeneration("G.I. Generation", country.Text),
                                        mc.DeathsCountByGeneration("Boomers",      country.Text), mc.DeathsCountByGeneration("Millenials",      country.Text),
                                        mc.DeathsCountByGeneration("Generation X", country.Text) };

                    chart1.Titles.Add("Suicides of generations in the country " + country.Text);

                    for (int i = 0; i < series.Length; i++)
                    {
                        Series sr = chart1.Series.Add(series[i]);

                        sr.Label = puntos[i].ToString();

                        sr.Points.Add(puntos[i]);
                    }
                }
                else
                {
                    MessageBox.Show("Please fill the field!");
                }
            }catch (Exception)
            {
                clearBtn.Enabled    = false;
                viewGraphic.Enabled = true;
                country.Enabled     = true;

                MessageBox.Show("The country you have wrote is not in the data base, make  sure you it is well written.");
            }
        }