예제 #1
0
        private void btn_addToHistory_Click(object sender, EventArgs e)
        {
            //Validate Data
            int credits;

            try
            {
                credits = int.Parse(txtBx_credits.Text);
            }
            catch
            {
                return;
            }
            string letterGrade = txtBx_grade.Text;

            Class        newClass = new Class(txtBx_className.Text, credits, letterGrade);
            List <Class> historicClasses;

            try
            {
                historicClasses = DataIO.LoadHistoricClasses();
            }
            catch
            {
                //Could not seralzie. New empty list
                historicClasses = new List <Class>();
            }
            historicClasses.Add(newClass);
            DataIO.SaveHistoricClasses(historicClasses);
            txtBx_credits.Text   = "0";
            txtBx_grade.Text     = "";
            txtBx_className.Text = "Class Name";
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     DataIO.SaveHistoricClasses(new List <Class>());
 }