private void ClearValidationErrors() { TbName.ClearValue(TextBox.BorderBrushProperty); TbAddress.ClearValue(TextBox.BorderBrushProperty); TbPhone.ClearValue(TextBox.BorderBrushProperty); RbDelivered.ClearValue(TextBox.BorderBrushProperty); RbPickup.ClearValue(TextBox.BorderBrushProperty); }
void ResetForm() { TbFirstName.Clear(); TbMiddleName.Clear(); TbLastName.Clear(); TbAddress.Clear(); TbInitail.Clear(); CbGender.SelectedIndex = 0; }
private bool IsValid(bool isEdit) { if (!isEdit) { TbUsername.GetBindingExpression(TextBox.TextProperty).UpdateSource(); PbPassword.GetBindingExpression(PasswordHelper.PasswordProperty).UpdateSource(); } CbGender.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); DpBirthDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource(); TbName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); TbEmail.GetBindingExpression(TextBox.TextProperty).UpdateSource(); TbPhoneNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); TbAddress.GetBindingExpression(TextBox.TextProperty).UpdateSource(); return(!Validation.GetHasError(CbGender) && !Validation.GetHasError(DpBirthDate) && !Validation.GetHasError(TbName) && !Validation.GetHasError(TbEmail) && !Validation.GetHasError(TbPhoneNumber) && !Validation.GetHasError(TbAddress) && (!isEdit || (!Validation.GetHasError(TbUsername) && !Validation.GetHasError(PbPassword)))); }
private void Add(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(TbAddress.Text)) { MB.MessageBoxInfo("Введите должность"); TbAddress.Focus(); } else { try { DataService.GetContext().Address.Add(new Data.Address() { Name = TbAddress.Text }); DataService.GetContext().SaveChanges(); MB.MessageBoxInfo("Вы успешно добавили адрес"); } catch { MB.MessageBoxError("Ошибка подключения к базе данных"); } } }