private void btnTeachersSerialize_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "JSON | *.json";
            saveFileDialog.Title  = "Save Teachers as JSON file";
            List <Teacher> teachers = new List <Teacher>();

            try
            {
                interpretor.LoadTeachers(out teachers);

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(saveFileDialog.FileName, JsonConvert.SerializeObject(teachers));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            saveFileDialog        = new SaveFileDialog();
            saveFileDialog.Filter = "JSON | *.json";
            saveFileDialog.Title  = "Save Lectures as JSON file";
            List <Lecture> lectures = new List <Lecture>();

            try
            {
                interpretor.LoadLectures(out lectures);

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(saveFileDialog.FileName, JsonConvert.SerializeObject(lectures));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
 public void Reload()
 {
     interpretor.LoadTeachers(out teachers);
     interpretor.LoadLectures(out lectures);
 }