private void Save_Button_Click(object sender, RoutedEventArgs e) { bool LoginExists = false; bool LoggedEdited = false; NullableError.Visibility = Visibility.Hidden; if (SurName_Field.Text.Length > 0 && Name_Field.Text.Length > 0 && MidleName_Field.Text.Length > 0 && Phone_Field.Text.Length > 0) { if (person.Account.Login != Login_Field.Text && person == dbl.LoggedPerson) { foreach (Account a in dbl.GiveAccounts()) { if (a.Login == Login_Field.Text) { LoginExists = true; LoginError.Visibility = Visibility.Visible; } } if (!LoginExists && Login_Field.Text.Length > 0 && Passwod_Field.Text.Length > 0) { person.Account.Login = Login_Field.Text; } else if (!LoginExists) { NullableError.Visibility = Visibility.Visible; } } if (!LoginExists && person == dbl.LoggedPerson) { if (Email_Field.Text.Length > 0 && EmailError.Visibility == Visibility.Hidden) { person.Account.Password = Passwod_Field.Text; person.Account.Email = Email_Field.Text; LoggedEdited = true; } else { EmailError.Visibility = Visibility.Visible; } } if (!LoginExists && EmailError.Visibility == Visibility.Hidden) { person.SurName = SurName_Field.Text; person.Name = Name_Field.Text; person.MidleName = MidleName_Field.Text; person.PhoneNumber = Phone_Field.Text; dbl.ChangeObject(person); if (LoggedEdited) { dbl.LoggedPerson = person; } if (person is Student) { EditeStudent(); } else if (person is Teacher) { EditeTeacher(); } else if (person is Dean) { EditeDean(); } } } else if (EmailError.Visibility != Visibility.Visible) { NullableError.Visibility = Visibility.Visible; } }