Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <XMark> exms = new List <XMark>();

            if (comboBox5.SelectedItem + "" != "")
            {
                XMark mark = new XMark(0, Int32.Parse(comboBox5.SelectedItem + ""),
                                       DateTime.Parse(dateTimePicker1.Text));
                exms.Add(mark);
            }
            if (comboBox6.SelectedItem + "" != "")
            {
                XMark mark = new XMark(1, Int32.Parse(comboBox6.SelectedItem + ""),
                                       DateTime.Parse(dateTimePicker2.Text));
                exms.Add(mark);
            }
            if (comboBox8.SelectedItem + "" != "")
            {
                XMark mark = new XMark(2, Int32.Parse(comboBox8.SelectedItem + ""),
                                       DateTime.Parse(dateTimePicker3.Text));
                exms.Add(mark);
            }
            if (textBox1.Text != "" && textBox2.Text != "" && (comboBox1.SelectedItem + "") != "" &&
                (comboBox2.SelectedItem + "") != "" && (comboBox3.SelectedItem + "") != "" &&
                ((comboBox5.SelectedItem + "") != "" || (comboBox6.SelectedItem + "") != "" ||
                 (comboBox8.SelectedItem + "") != ""))
            {
                Student stud = new Student(textBox2.Text, textBox1.Text, exms, Form1.facs.Where(f => f.name == comboBox1.SelectedItem + "").First(),
                                           Form1.groups.Where(g => g.name == comboBox3.SelectedItem + "").First(), Int32.Parse(comboBox2.SelectedItem + ""));
                Form1.students.Add(stud);
                Hide();
            }
        }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem + "" != "")
     {
         foreach (Student stud in Form1.students)
         {
             if (stud.studentID == Int32.Parse((comboBox1.SelectedItem + "").Split(' ')[0]))
             {
                 List <XMark> exms = new List <XMark>();
                 if (comboBox5.SelectedItem + "" != "")
                 {
                     XMark mark = new XMark(0, Int32.Parse(comboBox5.SelectedItem + ""),
                                            DateTime.Parse(dateTimePicker1.Text));
                     exms.Add(mark);
                 }
                 if (comboBox6.SelectedItem + "" != "")
                 {
                     XMark mark = new XMark(1, Int32.Parse(comboBox6.SelectedItem + ""),
                                            DateTime.Parse(dateTimePicker2.Text));
                     exms.Add(mark);
                 }
                 if (comboBox8.SelectedItem + "" != "")
                 {
                     XMark mark = new XMark(2, Int32.Parse(comboBox8.SelectedItem + ""),
                                            DateTime.Parse(dateTimePicker3.Text));
                     exms.Add(mark);
                 }
                 if (textBox1.Text != "" && textBox2.Text != "" && (comboBox4.SelectedItem + "") != "" &&
                     (comboBox2.SelectedItem + "") != "" && (comboBox3.SelectedItem + "") != "" &&
                     ((comboBox5.SelectedItem + "") != "" || (comboBox6.SelectedItem + "") != "" ||
                      (comboBox8.SelectedItem + "") != ""))
                 {
                     stud.firstName = textBox1.Text;
                     stud.surName   = textBox2.Text;
                     stud.group     = Form1.groups.Where(g => g.name == comboBox3.SelectedItem + "").First();
                     stud.fac       = Form1.facs.Where(f => f.name == comboBox4.SelectedItem + "").First();
                     stud.course    = Int32.Parse(comboBox2.SelectedItem + "");
                     stud.exams     = exms;
                     Hide();
                 }
             }
         }
     }
 }
Пример #3
0
        public void readFromFile()
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load("xmltext.xml");
            XmlElement xRoot = xDoc.DocumentElement;

            if (xRoot.HasChildNodes)
            {
                //находим все факультеты, которые есть в xml файле
                foreach (XmlElement facult in xDoc.GetElementsByTagName("faculty"))
                {
                    try
                    {
                        if (facs.Contains(facs.Where(f => f.name == facult.InnerText).First()))
                        {
                            continue; //если факультет уже есть в списке, пропускаем, если нет - ловим ошибку и добавляем его
                        }
                    } catch
                    {
                        Faculty fac = new Faculty(facult.InnerText);
                        facs.Add(fac);
                    }
                }
                foreach (XmlElement gr in xDoc.GetElementsByTagName("group"))
                {
                    try
                    {
                        if (groups.Contains(groups.Where(g => g.name == gr.InnerText).First()))
                        {
                            continue; //если группа уже есть в списке, пропускаем, если нет -
                                      //ловим ошибку и добавляем еe
                        }
                    }
                    catch
                    {
                        Group group = new Group(gr.InnerText);
                        groups.Add(group);
                    }
                }
                foreach (XmlElement s in xDoc.GetElementsByTagName("student"))
                {
                    try
                    {
                        if (students.Contains(students.Where(st => st.studentID == int.Parse(s.GetElementsByTagName("ID")[0].InnerText)).First()))
                        {
                            continue;
                        }
                    } catch
                    {
                        List <XMark> exams = new List <XMark>();
                        foreach (XmlElement mrk in s.GetElementsByTagName("predmet"))
                        {
                            XMark mark = new XMark(int.Parse(mrk.GetElementsByTagName("code")[0].InnerText),
                                                   int.Parse(mrk.GetElementsByTagName("mark")[0].InnerText),
                                                   DateTime.Parse(mrk.GetElementsByTagName("examDate")[0].InnerText));
                            exams.Add(mark);
                        }
                        Student stud = new Student(s.GetElementsByTagName("firstName")[0].InnerText,
                                                   s.GetElementsByTagName("surName")[0].InnerText, exams,
                                                   facs.Where(f => f.name == s.GetElementsByTagName("faculty")[0].InnerText).First(),
                                                   groups.Where(g => g.name == s.GetElementsByTagName("group")[0].InnerText).First(),
                                                   int.Parse(s.GetElementsByTagName("course")[0].InnerText));
                        students.Add(stud);
                    }
                }
            }
        }