Ejemplo n.º 1
0
 private void MainApp_Load(object sender, EventArgs e)
 {
     University myUniversity = new University();
     lablLogo.Text = myUniversity.Name; //Making a use of the required class (university) and passing the string name of the university and displaying it as a title for the main app interface
     windowToolStripMenuItem.Enabled = false; //disabling unused menu items
     openToolStripMenuItem.Enabled = false;
     viewToolStripMenuItem.Enabled = false;
 }
Ejemplo n.º 2
0
        private void ReadUniversityFromFile()
        {
            OpenFileDialog dialog;

            dialog        = new OpenFileDialog();
            dialog.Filter = "Uni Files|*.uni";
            DialogResult result;

            result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                FileStream fs;
                fs = (FileStream)dialog.OpenFile();
                StreamReader reader;
                reader = new StreamReader(fs);

                //Uni Name
                string uniName = reader.ReadLine();
                _uni = new University(uniName);

                //Students
                if (reader.ReadLine() == "<STUDENTS>")
                {
                    while (reader.ReadLine() != "</STUDENTS>")
                    {
                        int      id   = Convert.ToInt32(reader.ReadLine());
                        string   name = reader.ReadLine();
                        DateTime dob  = Convert.ToDateTime(reader.ReadLine());
                        Student  s    = new Student(name, id, dob);
                        _uni.Students.Add(s.ID, s);
                        reader.ReadLine();
                    }
                }

                //Papers
                if (reader.ReadLine() == "<PAPERS>")
                {
                    while (reader.ReadLine() != "</PAPERS>")
                    {
                        int    paperID          = Convert.ToInt32(reader.ReadLine());
                        string paperName        = reader.ReadLine();
                        string paperCoordinator = reader.ReadLine();
                        Paper  p = new Paper(paperName, paperID, paperCoordinator);
                        _uni.Papers.Add(p.PaperID, p);
                        if (reader.ReadLine() == "<ENROLLED>")
                        {
                            while (reader.ReadLine() != "</ENROLLED>")
                            {
                                int studentID = Convert.ToInt32(reader.ReadLine());
                                _uni.Papers[p.PaperID].AddStudentToPaper(_uni.Students[studentID]);
                                _uni.Students[studentID].AddPaperToStudent(_uni.Papers[p.PaperID]);
                                BindStudentData();
                                BindPaperData();
                                reader.ReadLine();
                            }
                        }
                    }
                }


                reader.Close();
                SetUpUI();
            }
        }