private async void Save() { SaveLabel.Focusable = true; SaveLabel.Focus(); SaveLabel.Focusable = false; var flag = true; if (Surname.Text.Equals("")) { BadSurname.BorderBrush = Brushes.Red; flag = false; } if (Name.Text.Equals("")) { BadName.BorderBrush = Brushes.Red; flag = false; } if (!flag) { BadLabel.Visibility = Visibility.Visible; return; } var _surname = Surname.Text; var _name = Name.Text; var _second_name = SecondName.Text; if (student != null) { if (_surname == student.Surname && _name == student.Name && _second_name == student.SecondName) { this.Close(); return; } } repository.SaveStudent(new Student { StudentID = _student, GroupID = _group, Name = _name, Surname = _surname, SecondName = _second_name }); await this.ShowMessageAsync(string.Empty, "Student saved."); GlobalVars.SaveFlag = true; this.Close(); }
private async void Save() { SaveLabel.Focus(); if (GroupNumber.Text.Equals(string.Empty)) { GroupNumber.Focus(); BadGroup.BorderBrush = Brushes.Red; BadLabel.Content = "Заполните обязательные поля"; BadLabel.Visibility = Visibility.Visible; return; } var group_number = GroupNumber.Text; if (_group != 0) { if (group_number == this.group_number) { this.Close(); return; } } if (repository.GetGroup(GroupNumber.Text) != null) { GroupNumber.Focus(); BadLabel.Content = "Группа с таким номером уже существует"; BadLabel.Visibility = Visibility.Visible; return; } repository.SaveGroup(new Group { GroupID = _group, GroupNumber = group_number }); await this.ShowMessageAsync(string.Empty, "Group saved."); GlobalVars.SaveFlag = true; this.Close(); }
private async void SaveNewPassword() { SaveLabel.Focusable = true; SaveLabel.Focus(); SaveLabel.Focusable = false; if (Password.IsEnabled) { this.Close(); } var flag = true; if (NewPassword.Password.Equals(string.Empty)) { flag = false; BadNewPassword.BorderBrush = Brushes.Red; } if (ConfirmPassword.Password.Equals(string.Empty)) { flag = false; BadConfirmPassword.BorderBrush = Brushes.Red; } if (!flag) { BadLabel.Content = "Заполните обязательные поля"; BadLabel.Visibility = Visibility.Visible; return; } if (NewPassword.Password != ConfirmPassword.Password) { NewPassword.Clear(); ConfirmPassword.Clear(); NewPassword.Focus(); BadLabel.Content = "Пароли не совпадают"; BadLabel.Visibility = Visibility.Visible; return; } if (NewPassword.Password == Password.Password) { NewPassword.Clear(); ConfirmPassword.Clear(); NewPassword.Focus(); BadLabel.Content = "Пароль уже используется"; BadLabel.Visibility = Visibility.Visible; return; } //rep.EditPass(NewPassword.Password); rep.GetPass = GlobalVars.GetHashCode(NewPassword.Password); // EncDecHelper.SetPassword(NewPassword.Password); await this.ShowMessageAsync(string.Empty, "Password has changed."); this.Close(); }