private void Add_Button_Click(object sender, RoutedEventArgs e) { bool LoginExists = false; NullableError.Visibility = Visibility.Hidden; LoginError.Visibility = Visibility.Hidden; FacultyNullableError.Visibility = Visibility.Hidden; CardNumberError.Visibility = Visibility.Hidden; GroupNullableError.Visibility = Visibility.Hidden; foreach (Account a in dbl.GiveAccounts()) { if (a.Login == Login_Field.Text) { LoginExists = true; } } if (!LoginExists && Login_Field.Text.Length > 0 && SurName_Field.Text.Length > 0 && Name_Field.Text.Length > 0 && MidleName_Field.Text.Length > 0 && Phone_Field.Text.Length > 0 && Passwod_Field.Text.Length > 0 && Email_Field.Text.Length > 0 && EmailError.Visibility != Visibility.Visible) { if (person is Student) { Student student = new Student(); student = AddStudent(); if (student != null) { student.Account = new Account { Login = Login_Field.Text, Password = Passwod_Field.Text, Email = Email_Field.Text }; student.SurName = SurName_Field.Text; student.Name = Name_Field.Text; student.MidleName = MidleName_Field.Text; student.PhoneNumber = Phone_Field.Text; student.University = dbl.LoggedPerson.University; dbl.AddPerson(student); Added_Event(); } } else if (person is Teacher) { Teacher teacher = new Teacher(); teacher = AddTeacher(); if (teacher != null) { teacher.Account = new Account { Login = Login_Field.Text, Password = Passwod_Field.Text, Email = Email_Field.Text }; teacher.SurName = SurName_Field.Text; teacher.Name = Name_Field.Text; teacher.MidleName = MidleName_Field.Text; teacher.PhoneNumber = Phone_Field.Text; teacher.University = dbl.LoggedPerson.University; dbl.AddPerson(teacher); Added_Event(); } } else if (person is Dean) { Dean dean = new Dean(); dean = AddDean(); if (dean != null) { dean.Account = new Account { Login = Login_Field.Text, Password = Passwod_Field.Text, Email = Email_Field.Text }; dean.SurName = SurName_Field.Text; dean.Name = Name_Field.Text; dean.MidleName = MidleName_Field.Text; dean.PhoneNumber = Phone_Field.Text; dean.University = dbl.LoggedPerson.University; dbl.AddPerson(dean); Added_Event(); } } else { Rector rector = new Rector(); rector.Account = new Account { Login = Login_Field.Text, Password = Passwod_Field.Text, Email = Email_Field.Text }; rector.SurName = SurName_Field.Text; rector.Name = Name_Field.Text; rector.MidleName = MidleName_Field.Text; rector.PhoneNumber = Phone_Field.Text; rector.University = person.University; dbl.AddPerson(rector); RectorAdded_Event(rector); } } else if (LoginExists) { LoginError.Visibility = Visibility.Visible; } else { NullableError.Visibility = Visibility.Visible; } }