-
Notifications
You must be signed in to change notification settings - Fork 1
/
Module_Nine_Solution.xaml.cs
79 lines (72 loc) · 2.7 KB
/
Module_Nine_Solution.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GUI_Application9
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private List<Student> listOfStudents = new List<Student>();
int currentListIndx;
private void btnCreateStudent_Click(object sender, RoutedEventArgs e)
{
Student studnt = new Student();
if (txtFirstName.Text == null || txtFirstName.Text == "" || txtLastName.Text == null || txtLastName.Text == "" || txtCity.Text == null || txtCity.Text == "")
{
MessageBox.Show("Could not create new student due to empty fields");
txtFirstName.Clear();
txtLastName.Clear();
txtCity.Clear();
}
else
{
studnt.FirstName = txtFirstName.Text;
studnt.LastName = txtLastName.Text;
studnt.City = txtCity.Text;
listOfStudents.Add(studnt);
MessageBox.Show("New student created");
currentListIndx = listOfStudents.Count;
txtFirstName.Clear();
txtLastName.Clear();
txtCity.Clear();
}
}
private void btnNext_Click(object sender, RoutedEventArgs e)
{
if (currentListIndx < listOfStudents.Count - 1)
{
txtFirstName.Text = listOfStudents[currentListIndx + 1].FirstName;
txtLastName.Text = listOfStudents[currentListIndx + 1].LastName.ToString();
txtCity.Text = listOfStudents[currentListIndx + 1].City.ToString();
currentListIndx += 1;
}
}
private void btnPrevious_Click(object sender, RoutedEventArgs e)
{
if (currentListIndx > 0 && listOfStudents.Count != 1)
{
txtFirstName.Text = listOfStudents[currentListIndx - 1].FirstName;
txtLastName.Text = listOfStudents[currentListIndx - 1].LastName.ToString();
txtCity.Text = listOfStudents[currentListIndx - 1].City.ToString();
currentListIndx -= 1;
}
}
}
}