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 Button_Click(object sender, RoutedEventArgs e) { if (SubjectField.Text.Length > 20 || TeacherField.Text.Length > 20) { MessageBox.Show("Subject name and Teacher's name must not contain more than 20 letters ", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (String.IsNullOrWhiteSpace(TeacherField.Text) || String.IsNullOrWhiteSpace(SubjectField.Text)) { MessageBox.Show("Please, fill all fields", "Error", MessageBoxButton.OK, MessageBoxImage.Error); TeacherField.Clear(); SubjectField.Clear(); return; } Group.struct_teachers res = new Group.struct_teachers { Name = TeacherField.Text, Subject = SubjectField.Text }; subject.teachers.Add(res); prevWindow.SubjectGrid.Items.Refresh(); Close(); }