Esempio n. 1
0
        private void button10_Click(object sender, EventArgs e)
        {
            Form3 newForm3 = new Form3();

            newForm3.ShowDialog();
        }
Esempio n. 2
0
        private void button10_Click(object sender, EventArgs e)           //re used code from the School times planner for the graph
        {
            Form3 form3 = new Form3();

            int year = 0;

            bool result = false;

            using (Form2 form2 = new Form2())
            {
                if (form2.ShowDialog() == DialogResult.OK)
                {
                    if (form2.Year == null)
                    {
                        year = DateTime.Today.Year;
                    }
                    else
                    {
                        year = Convert.ToInt32(form2.Year);
                    }

                    result = true;
                }
            }

            if (result)
            {
                DateTime temp = new DateTime(year, 1, 1);
                foreach (Person p in listPerson)
                {
                    DateTime tempDate = new DateTime();
                    if (temp == DateTime.Today)
                    {
                        tempDate = (p.DOB.AddDays(temp.Day));
                        tempDate = (p.DOB.AddMonths(temp.Month));
                        tempDate = (p.DOB.AddYears(temp.Year));
                    }
                    tempDate = (p.DOB.AddYears(DateTime.Today.Year - temp.Year));
                    ListViewItem lvi = new ListViewItem(p.getName());

                    if (CalculateAge(tempDate) >= 1 && CalculateAge(tempDate) < 5)
                    {
                        pre++;
                    }
                    else if (CalculateAge(tempDate) >= 5 && CalculateAge(tempDate) <= 11)
                    {
                        prim++;
                    }
                    else if (CalculateAge(tempDate) >= 12 && CalculateAge(tempDate) <= 18)
                    {
                        sec++;
                    }
                    else if (CalculateAge(tempDate) >= 19 && CalculateAge(tempDate) <= 23)
                    {
                        college++;
                    }
                    else
                    {
                        finished++;
                    }
                }
            }

            form3.pre      = pre;       // Populate the Form 3 chart.
            form3.prim     = prim;
            form3.sec      = sec;
            form3.college  = college;
            form3.finished = finished;

            form3.ShowDialog();
        }