private void Button_Search(object sender, MouseButtonEventArgs e) { key = int.Parse(Search.Text); if (StudentTeacherFunctions.KeyExistsStudent(key)) { tempStudent = StudentTeacherFunctions.ViewStudents(key); EnterName.Text = tempStudent.studentName; String facNum = Convert.ToString(tempStudent.facNum); EnterFacNum.Text = facNum; String egn = Convert.ToString(tempStudent.studentEGN); EnterEGN.Text = egn; EnterFaculty.Text = tempStudent.faculty; EnterSpecialty.Text = tempStudent.specialty; if (tempStudent.gender == "male") { Male.IsChecked = true; } else if (tempStudent.gender == "female") { Female.IsChecked = true; } } else { Search.Text = "No such key exists"; EnterName.Text = ""; EnterFacNum.Text = ""; EnterEGN.Text = ""; EnterFaculty.Text = ""; EnterSpecialty.Text = ""; } }
private void Button_SaveNew(object sender, MouseButtonEventArgs e) { String gender = null; if (Male.IsChecked == true) { gender = "male"; } else if (Female.IsChecked == true) { gender = "female"; } if (!StudentTeacherFunctions.CheckInput(EnterFacNum.Text)) { EnterFacNum.Text = "Invalid input: must contain 10 numbers"; } else if (!StudentTeacherFunctions.CheckInput(EnterEGN.Text)) { EnterEGN.Text = "Invalid input: must contain 10 numbers"; } else if (StudentTeacherFunctions.KeyExistsStudent(int.Parse(EnterEGN.Text))) { EnterEGN.Text = "EGN Already exists"; } else { StudentTeacherFunctions.AddNewStudent(EnterName.Text, int.Parse(EnterFacNum.Text), int.Parse(EnterEGN.Text), EnterFaculty.Text, EnterSpecialty.Text, gender); this.Close(); } }