private void Button_Click_4(object sender, RoutedEventArgs e) //Записывает В NumberBox 5 { if (NumberBox.Text.Length < 13) { if ((NumberBox.Text[0] == '0') && (NumberBox.Text.Length == 1)) { NumberBox.Clear(); } NumberBox.Text = NumberBox.Text + 5; } }
private void Button_Click(object sender, RoutedEventArgs e) //Записывает В NumberBox 1 { if (NumberBox.Text.Length < 13) //Ограничивает кол-во записываемых символов { if ((NumberBox.Text[0] == '0') && (NumberBox.Text.Length == 1)) //Уберает первый символ, равный 0 { NumberBox.Clear(); } NumberBox.Text = NumberBox.Text + 1; } }
private void Button_Click_6(object sender, RoutedEventArgs e) { List.Items.Refresh(); NumberBox.Clear(); HeadCombo.SelectedIndex = -1; subject.teachers.Clear(); SubjectGrid.ItemsSource = subject.teachers; SubjectGrid.Items.Refresh(); CheckExisting.IsChecked = false; ChangeButton.IsEnabled = false; DeleteButton.IsEnabled = false; }
private void UpNumberclick(object sender, RoutedEventArgs e) { int s = Convert.ToInt32(NumberBox.Text); if (MixButton.IsChecked == true) { if (s < count) { s++; NumberBox.Text = s.ToString(); } else { MessageBox.Show("В базе данных всего " + count + " вопроса(ов) по теме " + ThemeBox.Text + "." + "\n" + "Дальнейшее увеличение числа вопросов невозможно!"); NumberBox.Clear(); NumberBox.Text = "1"; } } if (WithAnswersButton.IsChecked == true) { NumberBox.Clear(); NumberBox.Text = "1"; if (s < countWith) { s++; NumberBox.Text = s.ToString(); } else { MessageBox.Show("В базе данных всего " + countWith + " вопроса(ов) по теме " + ThemeBox.Text + " c вариантами ответов." + "\n" + "Дальнейшее увеличение числа вопросов невозможно!"); NumberBox.Clear(); NumberBox.Text = "1"; } } if (WithoutAnswersButton.IsChecked == true) { NumberBox.Clear(); NumberBox.Text = "1"; if (s < countWithout) { s++; NumberBox.Text = s.ToString(); } else { MessageBox.Show("В базе данных всего " + countWithout + " вопроса(ов) по теме " + ThemeBox.Text + " без вариантов вариантами ответов." + "\n" + "Дальнейшее увеличение числа вопросов невозможно!"); NumberBox.Clear(); NumberBox.Text = "1"; } } }
private void List_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { List.Items.Refresh(); 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; }
private void DownNumberclick(object sender, RoutedEventArgs e) { int s = Convert.ToInt32(NumberBox.Text); if (WithoutAnswersButton.IsChecked == true) { if (s > 1 && s < countWithout) { s--; NumberBox.Text = s.ToString(); } else { MessageBox.Show("Ошибка! Не менее 1 вопроса и не более " + countWithout + "."); NumberBox.Clear(); NumberBox.Text = "1"; } } if (WithAnswersButton.IsChecked == true) { if (s > 1 && s < countWith) { s--; NumberBox.Text = s.ToString(); } else { MessageBox.Show("Ошибка! Не менее 1 вопроса и не более " + countWith + "."); NumberBox.Clear(); NumberBox.Text = "1"; } } if (MixButton.IsChecked == true) { if (s > 1 && s < count) { s--; NumberBox.Text = s.ToString(); } else { MessageBox.Show("Ошибка! Не менее 1 вопроса и не более " + count + "."); NumberBox.Clear(); NumberBox.Text = "1"; } } }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { var selectedIndex = List.SelectedIndex; if (groups.groupList[selectedIndex].head != null) { var rez = groups.groupList[selectedIndex].head; rez.isHead = "-"; rez.groupHeading = "-"; } for (int i = 0; i < students.studentlist.Count(); i++) { if (students.studentlist[i].group == groups.groupList[selectedIndex]) { students.studentlist[i].group = null; students.studentlist[i].group_number = "-"; } if (students.studentlist[i].oldGroup == groups.groupList[selectedIndex]) { students.studentlist[i].oldGroup = null; students.studentlist[i].old_group_number = "-"; } } groups.groupList.Remove(groups.groupList[selectedIndex]); List.Items.Refresh(); NumberBox.Clear(); HeadCombo.SelectedIndex = -1; subject.teachers.Clear(); SubjectGrid.ItemsSource = subject.teachers; SubjectGrid.Items.Refresh(); CheckExisting.IsChecked = false; ChangeButton.IsEnabled = false; DeleteButton.IsEnabled = false; }
private void Button_Click_1(object sender, RoutedEventArgs e) { for (int i = 0; i < groups.groupList.Count(); i++) { if (NumberBox.Text == Convert.ToString(groups.groupList[i].Number)) { MessageBox.Show("Sorry, you can't create 2 similar groups", "Error", MessageBoxButton.OK, MessageBoxImage.Error); NumberBox.Clear(); return; } } if (String.IsNullOrWhiteSpace(NumberBox.Text)) { MessageBox.Show("Please, input the number of group", "Error", MessageBoxButton.OK, MessageBoxImage.Error); NumberBox.Clear(); return; } if (Convert.ToInt32(NumberBox.Text) > 999999) { MessageBox.Show("Please, input correct number", "Error", MessageBoxButton.OK, MessageBoxImage.Error); NumberBox.Clear(); return; } if (HeadCombo.SelectedItem != null) { var rez = (Student)HeadCombo.SelectedItem; if (rez.isHead == "+") { MessageBox.Show("This student is already a head", "Error", MessageBoxButton.OK, MessageBoxImage.Error); HeadCombo.SelectedItem = null; return; } } Group new_group = new Group(); new_group.Number = Convert.ToInt32(NumberBox.Text); if (CheckExisting.IsChecked == true) { new_group.Actual = "+"; } else { new_group.Actual = "-"; } if (HeadCombo.SelectedItem == null) { new_group.head = null; new_group.headName = "-"; } else { new_group.head = (Student)HeadCombo.SelectedItem; new_group.headName = new_group.head.Surname + " " + new_group.head.Name; var rez = new_group.head; rez.isHead = "+"; rez.group_number = Convert.ToString(new_group.Number); rez.groupHeading = rez.group_number; rez.group = new_group; } new_group.teachers = new List <Group.struct_teachers>(subject.teachers); groups.groupList.Add(new_group); List.Items.Refresh(); subject.teachers.Clear(); SubjectGrid.ItemsSource = subject.teachers; SubjectGrid.Items.Refresh(); NumberBox.Clear(); HeadCombo.SelectedIndex = -1; CheckExisting.IsChecked = false; ChangeButton.IsEnabled = false; DeleteButton.IsEnabled = false; }
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); }
private void Button_Click_3(object sender, RoutedEventArgs e) { for (int i = 0; i < groups.groupList.Count(); i++) { if (groups.groupList[List.SelectedIndex].Number == Convert.ToInt32(NumberBox.Text)) { continue; } if (groups.groupList[i].Number == Convert.ToInt32(NumberBox.Text)) { MessageBox.Show("Please, fill the number of group", "Error", MessageBoxButton.OK, MessageBoxImage.Error); NumberBox.Clear(); return; } } if (String.IsNullOrWhiteSpace(NumberBox.Text)) { MessageBox.Show("Please, input the number of group", "Error", MessageBoxButton.OK, MessageBoxImage.Error); NumberBox.Clear(); return; } if (HeadCombo.SelectedItem != null) { var rez = (Student)HeadCombo.SelectedItem; if (rez.isHead == "+") { MessageBox.Show("This student is already a head", "Error", MessageBoxButton.OK, MessageBoxImage.Error); HeadCombo.SelectedItem = null; return; } } var selectedIndex = List.SelectedIndex; for (int i = 0; i < students.studentlist.Count(); i++) { if (students.studentlist[i].group_number == Convert.ToString(groups.groupList[selectedIndex].Number)) { students.studentlist[i].group_number = NumberBox.Text; } } groups.groupList[selectedIndex].Number = Convert.ToInt32(NumberBox.Text); if (HeadCombo.SelectedItem == null) { groups.groupList[selectedIndex].head = null; groups.groupList[selectedIndex].headName = "-"; } else { var rez1 = groups.groupList[selectedIndex].head; rez1.groupHeading = "-"; rez1.isHead = "-"; groups.groupList[selectedIndex].head = (Student)HeadCombo.SelectedItem; groups.groupList[selectedIndex].headName = groups.groupList[selectedIndex].head.Surname + " " + groups.groupList[selectedIndex].head.Name; var rez = groups.groupList[selectedIndex].head; rez.isHead = "+"; rez.group_number = Convert.ToString(groups.groupList[selectedIndex].Number); rez.groupHeading = rez.group_number; rez.group = groups.groupList[selectedIndex]; } if (CheckExisting.IsChecked == false) { groups.groupList[selectedIndex].Actual = "-"; } else { groups.groupList[selectedIndex].Actual = "+"; } groups.groupList[selectedIndex].teachers = new List <Group.struct_teachers>(subject.teachers); List.Items.Refresh(); NumberBox.Clear(); HeadCombo.SelectedIndex = -1; subject.teachers.Clear(); SubjectGrid.ItemsSource = subject.teachers; SubjectGrid.Items.Refresh(); CheckExisting.IsChecked = false; ChangeButton.IsEnabled = false; DeleteButton.IsEnabled = false; }