private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (SubjectField.Text.Length > 16)
            {
                MessageBox.Show("Subject name must not contain more than 16 letters ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrWhiteSpace(MarkField.Text) || String.IsNullOrWhiteSpace(SubjectField.Text))
            {
                MessageBox.Show("Please, fill all fields", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                MarkField.Clear();
                SubjectField.Clear();
                return;
            }

            if (Convert.ToInt32(MarkField.Text) > 10 || Convert.ToInt32(MarkField.Text) < 0)
            {
                MessageBox.Show("In the mark field number should be between 0 to 10", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                MarkField.Clear();
                return;
            }

            Student.struct_marks res = new Student.struct_marks
            {
                Mark    = Convert.ToInt32(MarkField.Text),
                Subject = SubjectField.Text
            };
            marks.marks.Add(res);

            prevWindow.Table.Items.Refresh();
            Close();
        }
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            GroupEnum   new_groups   = new GroupEnum();
            StudentEnum new_students = new StudentEnum();


            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt = ".zip";
            dialog.Filter     = "zip|*.zip";

            string selectedArchive = "";
            bool?  result          = dialog.ShowDialog();

            if (result == true)
            {
                selectedArchive = dialog.FileName;
            }
            else
            {
                return;
            }
            try
            {
                if (!Directory.Exists(Directory.GetCurrentDirectory() + @"\Buffer") && selectedArchive != "")
                {
                    ZipFile.ExtractToDirectory(selectedArchive, Directory.GetCurrentDirectory());
                }
                else
                {
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please, select another folder ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            FileStream   connector = new FileStream(Directory.GetCurrentDirectory() + @"\Buffer\Temp.txt", FileMode.Open);;
            StreamReader reader    = new StreamReader(connector);

            int groupsNumber = Convert.ToInt32(reader.ReadLine());

            reader.ReadLine();
            for (int i = 0; i < groupsNumber; i++)
            {
                reader.ReadLine();
                Group new_group = new Group();

                new_group.Number   = Convert.ToInt32(reader.ReadLine());
                new_group.Actual   = reader.ReadLine();
                new_group.headName = reader.ReadLine();
                int teachersNumber = Convert.ToInt32(reader.ReadLine());

                Group subject = new Group();
                if (teachersNumber != 0)
                {
                    reader.ReadLine();
                    for (int j = 0; j < teachersNumber; j++)
                    {
                        Group.struct_teachers new_teacher = new Group.struct_teachers();
                        new_teacher.Name    = reader.ReadLine();
                        new_teacher.Subject = reader.ReadLine();
                        subject.teachers.Add(new_teacher);
                    }
                    reader.ReadLine();
                    new_group.teachers = new List <Group.struct_teachers>(subject.teachers);
                }
                else
                {
                    reader.ReadLine();
                }

                reader.ReadLine();
                new_groups.groupList.Add(new_group);
            }
            reader.ReadLine();

            int studentsNumber = Convert.ToInt32(reader.ReadLine());

            reader.ReadLine();
            for (int i = 0; i < studentsNumber; i++)
            {
                reader.ReadLine();
                Student new_student = new Student();

                new_student.Name             = reader.ReadLine();
                new_student.Surname          = reader.ReadLine();
                new_student.Middlename       = reader.ReadLine();
                new_student.Year             = Convert.ToInt32(reader.ReadLine());
                new_student.isHead           = reader.ReadLine();
                new_student.groupHeading     = reader.ReadLine();
                new_student.group_number     = reader.ReadLine();
                new_student.old_group_number = reader.ReadLine();

                new_student.photoPath = reader.ReadLine();
                if (new_student.photoPath != "")
                {
                    BitmapImage StudentPhoto = new BitmapImage();
                    StudentPhoto.BeginInit();
                    StudentPhoto.UriSource   = new Uri(new_student.photoPath, UriKind.Absolute);
                    StudentPhoto.CacheOption = BitmapCacheOption.OnLoad;
                    StudentPhoto.EndInit();
                    new_student.studentPhoto = StudentPhoto;
                }

                int     marksNumber = Convert.ToInt32(reader.ReadLine());
                Student mark        = new Student();
                if (marksNumber != 0)
                {
                    reader.ReadLine();
                    for (int j = 0; j < marksNumber; j++)
                    {
                        Student.struct_marks new_mark = new Student.struct_marks();
                        new_mark.Mark    = Convert.ToInt32(reader.ReadLine());
                        new_mark.Subject = reader.ReadLine();
                        mark.marks.Add(new_mark);
                    }
                    reader.ReadLine();
                    new_student.marks = new List <Student.struct_marks>(mark.marks);
                }
                else
                {
                    reader.ReadLine();
                }

                reader.ReadLine();
                new_students.studentlist.Add(new_student);
            }

            for (int i = 0; i < new_groups.groupList.Count(); i++)
            {
                for (int j = 0; j < new_students.studentlist.Count(); j++)
                {
                    if (new_students.studentlist[j].group_number == Convert.ToString(new_groups.groupList[i].Number))
                    {
                        new_students.studentlist[j].group = new_groups.groupList[i];
                        if (new_students.studentlist[j].groupHeading == Convert.ToString(new_groups.groupList[i].Number))
                        {
                            new_groups.groupList[i].head = new_students.studentlist[j];
                        }
                    }
                    if (new_students.studentlist[j].old_group_number == Convert.ToString(new_groups.groupList[i].Number))
                    {
                        new_students.studentlist[j].oldGroup = new_groups.groupList[i];
                    }
                }
            }
            reader.Close();
            connector.Close();

            groups.groupList     = new_groups.groupList;
            students.studentlist = new_students.studentlist;

            List.ItemsSource = groups.groupList;
            List.Items.Refresh();
            SubjectGrid.ItemsSource = subject.teachers;

            List.SelectedIndex = -1;
            NumberBox.Clear();
            HeadCombo.SelectedIndex = -1;
            subject.teachers.Clear();
            SubjectGrid.ItemsSource = subject.teachers;
            SubjectGrid.Items.Refresh();

            CheckExisting.IsChecked = false;
            ChangeButton.IsEnabled  = false;
            DeleteButton.IsEnabled  = false;

            if (Directory.Exists(Directory.GetCurrentDirectory() + @"\Buffer"))
            {
                Directory.Delete(Directory.GetCurrentDirectory() + @"\Buffer", true);
            }

            MessageBox.Show("File loaded", "", MessageBoxButton.OK, MessageBoxImage.Information);
        }