예제 #1
0
 public FormStudent(EnrolmentSystemModel.University university, string id)
 {
     InitializeComponent();
     _university = university;
     _id         = id;
     LoadComponent();
 }
예제 #2
0
        private bool UniversityInitiate(string filename)
        {
            _university = new EnrolmentSystemModel.University();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(filename);

            if (streamReader.ReadLine() != "--university database--")
            {
                MessageBox.Show("Invalid file, please choose a university database file.");
                return(false);
            }

            string line = "";

            while (streamReader.Peek() >= 0)
            {
                line = streamReader.ReadLine();
                string[] temp = line.Split('_');

                //add paper or student to university object base on line header
                if (temp[0] == "paper")
                {
                    var      paper  = new EnrolmentSystemModel.Paper(temp[1], temp[2], temp[3]);
                    string[] member = streamReader.ReadLine().Split('_');
                    for (int i = 1; i < member.Length; i++)
                    {
                        if (member[i] != null && member[i] != "")
                        {
                            paper.AddStudent(member[i]);
                        }
                    }
                    _university.AddPaper(paper);
                }
                else if (temp[0] == "student")
                {
                    var student = new EnrolmentSystemModel.Student(temp[1], temp[2], temp[3], temp[4]);
                    _university.AddStudent(student);
                }
                else
                {
                    continue;
                }
            }

            streamReader.Close();
            return(true);
        }