Exemplo n.º 1
0
 public журнал(teacher new_teacher)
 {
     InitializeComponent();
     current_teacher = new_teacher;
     this.label2.Text = new_teacher.name;
     XmlSerializer serializer_for_subjects = new XmlSerializer(typeof(List<subject>));
     FileStream stream_to_subjects = new FileStream(@"all_subjects\all_subjects.xml",
              FileMode.Open, FileAccess.Read);
     main_list_of_subjects = (List<subject>)serializer_for_subjects.
         Deserialize(stream_to_subjects);
     stream_to_subjects.Close();
     DirectoryInfo current_dir_info = new DirectoryInfo(@"all_groups");
     foreach (DirectoryInfo cur_dir_info in current_dir_info.GetDirectories())
     {
         this.list_of_groups.Items.Add(cur_dir_info.Name);
     }
 }
Exemplo n.º 2
0
 public form_for_lesson(group new_group, subject new_subject, int index_of_theme, DateTime date,
     teacher new_teacher)
 {
     InitializeComponent();
     current_teacher = new_teacher;
     this.date_label.Text = lesson_form.date_string + date.Day.ToString() + "." + date.Month.ToString() +
         "." + date.Year.ToString();
     current_group = new_group;
     current_subject = new_subject;
     current_index_of_theme = index_of_theme;
     this.current_name_of_group.Text = current_group.name_of_group;
     this.journal_table.ColumnCount = 2;
     this.journal_table.RowCount = current_group.all_students.Count + 1;
     Label buf_for_label = new Label();
     buf_for_label.Text = main_strings.students_string;
     this.journal_table.Controls.Add(buf_for_label,0,0);
     Label buf_for_label_2 = new Label();
     buf_for_label_2.Text = main_strings.marks_string;
     this.journal_table.Controls.Add(buf_for_label_2,1,0);
     int counter_of_students = 1;
     foreach (student current_student in current_group.all_students)
     {
         Label student_name_label = new Label();
         student_name_label.AutoSize = true;
         student_name_label.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, 
             System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
         student_name_label.Text = current_student.name;
         this.journal_table.Controls.Add(student_name_label, 0, counter_of_students);
         ++counter_of_students;
     }
     string [] list_of_marks = new string[] {"1","2","3","4","5","6","7","8","9","10","N","nothing"};
     for (int counter = 0; counter < current_group.all_students.Count; ++counter)
     {
         ComboBox buf_for_list_of_marks = new ComboBox();
         buf_for_list_of_marks.Items.AddRange(list_of_marks);
         all_marks.Add(buf_for_list_of_marks);
         this.journal_table.Controls.Add(buf_for_list_of_marks,1,counter + 1);
     }
     current_lesson = new lesson(current_group.name_of_group, current_subject.all_themes[current_index_of_theme],
         current_teacher.name, date);
     this.subject_label.Text = current_manager.GetString("subject_string") + current_subject.name;
     this.theme_label.Text = current_manager.GetString("theme_string") + current_subject.all_themes[current_index_of_theme];
 }
Exemplo n.º 3
0
 private void reg_button_Click(object sender, EventArgs e)
 {
     if (this.textBox4.Text != this.textBox3.Text)
     {
         MessageBox.Show(current_manager.GetString("incorrect_password_string"));
     }
     else
     {
         bool file_exist = false;
         DirectoryInfo current_dir_info = new DirectoryInfo(Environment.CurrentDirectory);
         foreach (DirectoryInfo cur_dir_info in current_dir_info.GetDirectories())
         {
             if (cur_dir_info.Name == "teaching_staff")
             {
                 file_exist = true;
             }
         }
         if (!file_exist)
         {
             Directory.CreateDirectory("teaching_staff");
             FileStream stream_to_teachers = new FileStream(@"teaching_staff\all_teachers.xml", FileMode.Create,
                 FileAccess.Write);
             XmlSerializer serializer_for_list_teachers = new XmlSerializer(typeof(List<teacher>));
             List<teacher> list_of_teachers = new List<teacher>();
             teacher new_teacher = new teacher(this.textBox1.Text, this.textBox2.Text,
                 this.textBox4.Text);
             list_of_teachers.Add(new_teacher);
             serializer_for_list_teachers.Serialize(stream_to_teachers, list_of_teachers);
             stream_to_teachers.Close();
             MessageBox.Show(current_manager.GetString("registration_success_string"));
             this.Close();
         }
         else
         {
             bool teacher_already_exist = false;
             FileStream stream_to_teachers = new FileStream(@"teaching_staff\all_teachers.xml", FileMode.OpenOrCreate,
                 FileAccess.ReadWrite);
             XmlSerializer serializer_for_list_teachers = new XmlSerializer(typeof(List<teacher>));
             List<teacher> list_of_teachers = (List<teacher>)serializer_for_list_teachers.
                 Deserialize(stream_to_teachers);
             stream_to_teachers.Close();
             File.Delete(@"teaching_staff\all_teachers.xml");
             FileStream stream_to_teachers_2 = new FileStream(@"teaching_staff\all_teachers.xml", FileMode.OpenOrCreate,
                 FileAccess.ReadWrite);
             foreach (teacher current_teacher in list_of_teachers)
             {
                 if (current_teacher.name == this.textBox1.Text && current_teacher.login == this.textBox2.Text
                     && current_teacher.hash_of_password == this.textBox4.Text.GetHashCode())
                 {
                     teacher_already_exist = true;
                 }
             }
             if (!teacher_already_exist)
             {
                 list_of_teachers.Add(new teacher(this.textBox1.Text, this.textBox2.Text,
                     this.textBox4.Text));
                 serializer_for_list_teachers.Serialize(stream_to_teachers_2, list_of_teachers);
                 MessageBox.Show(current_manager.GetString("registration_success_string"));
                 stream_to_teachers_2.Close();
                 this.Close();
             }
             else
             {
                 MessageBox.Show(current_manager.GetString("user_exist_string"));
                 stream_to_teachers_2.Close();
             }
         }
     }
 }