public static void ZipCode_LostFocus(object sender, RoutedEventArgs e) { TextBox x = sender as TextBox; if (App.isZipCodeValid(x.Text)) { x.BorderBrush = Brushes.Green; } else { x.BorderBrush = Brushes.Red; } }
private void NextButton_Click(object sender, RoutedEventArgs e) { try { int errorCount = 0; foreach (var child in this.MainGrid.Children) { if (child is TextBox) { TextBox textBox = child as TextBox; if ((!App.isWordValid(textBox.Text) && textBox != this.HouseNumberTextBox && textBox != this.ZipCodeTextBox && textBox != this.PhoneNumberTextBox) || (textBox == this.HouseNumberTextBox && !App.isHouseNoValid(textBox.Text)) || (textBox == this.ZipCodeTextBox && !App.isZipCodeValid(textBox.Text)) || (textBox == this.PhoneNumberTextBox && !App.isPhoneValid(textBox.Text))) { errorCount++; textBox.BorderBrush = Brushes.Red; } else { textBox.BorderBrush = Brushes.Black; } } else if (child is ComboBox) { ComboBox comboBox = child as ComboBox; if (comboBox.SelectedItem == null) { comboBox.BorderBrush = Brushes.Red; errorCount++; } else { comboBox.BorderBrush = Brushes.Black; } } } if (DifferntAddressCheckBox.IsChecked == true) { foreach (var child in DeliveryAddressGrid.Children) { if (child is TextBox) { TextBox textBox = child as TextBox; if ((textBox == DeliveryStretTextBox && !App.isWordValid(textBox.Text)) || (textBox == DeliveryHouseNoTextBox && !App.isHouseNoValid(textBox.Text)) || (textBox == DeliveryZipCodeTextBox && !App.isZipCodeValid(textBox.Text))) { textBox.BorderBrush = Brushes.Red; errorCount++; } else { textBox.BorderBrush = Brushes.Black; } } if (child is ComboBox) { ComboBox comboBox = child as ComboBox; if (comboBox.SelectedItem == null) { comboBox.BorderBrush = Brushes.Red; errorCount++; } else { comboBox.BorderBrush = Brushes.Black; } } } } if (errorCount != 0) { throw new Exception("Please fill all the fields correctly!"); } client.Add = Add; if (DifferntAddressCheckBox.IsChecked == true) { client.Location = Location; } Bl.addClient(client); AddOrderPage2 newOrder = new AddOrderPage2(); newOrder.order.ClientID = Bl.findClientByPhoneNumber(client.PhoneNumber).ClientID; this.NavigationService.Navigate(newOrder); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erorr", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void NextButton_Click(object sender, RoutedEventArgs e) { try { #region Data valid int errorCount = 0; foreach (var child in this.MainGrid.Children) { if (child is System.Windows.Controls.TextBox) { TextBox textBox = child as TextBox; if ((!App.isWordValid(textBox.Text) && textBox != this.HouseNumberTextBox && textBox != this.ZipCodeTextBox && textBox != this.PhoneNumberTextBox) || (textBox == this.HouseNumberTextBox && !App.isHouseNoValid(textBox.Text)) || (textBox == this.ZipCodeTextBox && !App.isZipCodeValid(textBox.Text)) || (textBox == this.PhoneNumberTextBox && !App.isPhoneValid(textBox.Text))) { errorCount++; textBox.BorderBrush = Brushes.Red; } else { textBox.BorderBrush = Brushes.Black; } } } if (errorCount != 0) { throw new Exception("Please fill all the fields correctly!"); } #endregion bl.updateBranch(branch.BranchID, branch); this.NavigationService.GoBack(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }