private void InviteCodeButton_TextChanged(object sender, TextChangedEventArgs e) { if (string.IsNullOrWhiteSpace(((TextBox)sender).Text)) { return; } var person = _mockedData.FindPerson(Convert.ToInt32(((TextBox)sender).Text)); /* * -1 means the person was not located */ if (person.Id > -1) { // Enabling group enables child controls GroupGrid.IsEnabled = true; // This will automatically select the first control in the tab order MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); FirstNameTextBox.Text = person.FirstName; LastNameTextBox.Text = person.LastName; FirstNameTextBox.Select(person.FirstName.Length, 0); } else { GroupGrid.IsEnabled = false; } }
private void ModifyToggleButtonClick(object sender, RoutedEventArgs e) { ToggleButton currentModifyToggleButton = (ToggleButton)sender; if (currentModifyToggleButton != lastModifyToggleButton && lastModifyToggleButton != null) { lastModifyToggleButton.IsChecked = false; } lastModifyToggleButton = (bool)currentModifyToggleButton.IsChecked ? currentModifyToggleButton : null; if (lastModifyToggleButton != null) { authorToModify = (Author)AuthorsDataGrid.SelectedItem; AddButtonImage.Source = new BitmapImage(new Uri(@"Assets/Icons/modify.png", UriKind.Relative)); AddButtonTextBlock.Text = "Modyfikuj"; FirstNameTextBox.Text = authorToModify.FirstName; LastNameTextBox.Text = authorToModify.LastName; } else { authorToModify = null; AddButtonImage.Source = new BitmapImage(new Uri(@"Assets/Icons/add.png", UriKind.Relative)); AddButtonTextBlock.Text = "Dodaj"; FirstNameTextBox.Clear(); LastNameTextBox.Clear(); } }
public void UserRegistration(string firstName, string lastName, string email, string password, string gender, string country) { email = email.Replace("_random", Guid.NewGuid().ToString()); FirstNameTextBox.SendKeys(firstName); LastNameTextBox.SendKeys(lastName); EmailTextBox.SendKeys(email); PasswordTextBox.SendKeys(password); foreach (var genderBtn in GenderRadioButton) { var genderValue = genderBtn.GetAttribute("value"); if (genderValue == gender) { genderBtn.Click(); break; } } var countrySelect = new SelectElement(CountrySelectBox); countrySelect.SelectByText(country); DriverWait.Until(ExpectedConditions.ElementToBeClickable(SignupButton)).SendKeys(Keys.Enter); }
private void newWorkerSubmit_Click(object sender, EventArgs e) { string newUserBannerId = BannerTextBox.Text; string newUserFirstName = FirstNameTextBox.Text; string newUserLastName = LastNameTextBox.Text; string newUserPhoneNumber = PhoneNumberTextBox.Text; string newUserEmail = EmailTextBox.Text; string newUserUserType = UserTypeTextBox.Text; string newUserNotes = NotesTextBox.Text; string newUserStatus = StatusTextBox.Text; User newUser = new User(newUserBannerId, newUserFirstName, newUserLastName, newUserPhoneNumber, newUserEmail, newUserUserType, newUserNotes, newUserStatus); newUser.insert(); BannerTextBox.Clear(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); EmailTextBox.Clear(); UserTypeTextBox.Clear(); NotesTextBox.Clear(); StatusTextBox.Clear(); NewWorkerNotificationLabel.Text = "User added to database"; }
private void SaveButton_Click(object sender, EventArgs e) { try { DialogResult result = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { // create writer StreamWriter writer = new StreamWriter("Name2s.txt", true); writer.WriteLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text); // close connections writer.Close(); // reset the form fields FirstNameTextBox.Clear(); LastNameTextBox.Clear(); FirstNameTextBox.Focus(); } else { FirstNameTextBox.Focus(); FirstNameTextBox.SelectAll(); } } catch { Console.WriteLine("problems"); } }
private void AddContactButtonClick(object sender, RoutedEventArgs e) { try { var contact = new Contact { Email = EmailTextBox.Text, FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text }; MessageService.AddContact(contact); StatusBlock.Alert($"Contact {contact.Email} created successfully", StatusBlock.Success); EmailTextBox.Clear(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); } catch (ItemAllreadyExistsException ex) { StatusBlock.Alert(ex.Message, StatusBlock.Danger); } catch (FormatException ex) { StatusBlock.Alert(ex.Message, StatusBlock.Warning); } catch (DbEntityValidationException) { StatusBlock.Alert("Validation failed for one of the fields", StatusBlock.Danger); } catch (Exception) { StatusBlock.Alert("Error while saving to database", StatusBlock.Danger); } }
private void PerformSalutation() { _person.Salutation = String.Empty; // Reset personBindingSource.ResetBindings(false); if (_person.Name == String.Empty || _person.Firstname == String.Empty) { MessageBox.Show("Enter both the firstname and name of the person.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); FirstNameTextBox.Focus(); FirstNameTextBox.SelectAll(); return; } // Execute rules try { var ruleExecuter = new RuleSetInvoker(); if (_settings.Source == RuleSource.CodedDynamic) { ruleExecuter.PerformDynamicRules(_person, _settings.Rules); } else if (_settings.Source == RuleSource.CodedStatic) { ruleExecuter.PerformCodedRules(_person); } else { ruleExecuter.PerformDesignerRules(_person); } personBindingSource.ResetBindings(false); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void addStudentItem_Click(object sender, EventArgs e) { if (Text_boxes_empty()) { return; } if (students == null) { students = new StudentsCollection(); } if (students.GetEnumerator().Position + 1 >= students.students_list.Count) { students.AddStudent(new Student(FirstNameTextBox.Text, SecondNameTextBox.Text, FacultyTextBox.Text)); students.GetEnumerator().MoveEnd(); deleteStudent.Enabled = true; SetButtonEnable(TypeAction.Next, false); SetButtonEnable(TypeAction.Prev, true); need_updated = true; FirstNameTextBox.Focus(); MoveToAddForm(); toolStripLabelnfo.Text = "Студент добавлен"; } else { toolStripLabelnfo.Text = "Перейдите в поле для добавления"; } }
// New Customer button clicked private void NewCustomerButton_Click(object sender, EventArgs e) { // if text fields are filled, show messagebox if (FirstNameTextBox.Text != "" || LastNameTextBox.Text != "" || EmailTextBox.Text != "" || PhoneTextBox.Text != "" || AddressTextBox.Text != "" || CityTextBox.Text != "" || StateTextBox.Text != "" || ZipTextBox.Text != "") { DialogResult response = MessageBox.Show("Are you sure you want to discard all the changes?", "Discard Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (response == DialogResult.Yes) { ResetAll(); FirstNameTextBox.Focus(); SaveButton.Enabled = true; CustomerComboBox.Enabled = false; addNewCustomerMode = true; updateCustomerMode = false; } } else { ResetAll(); FirstNameTextBox.Focus(); SaveButton.Enabled = true; CustomerComboBox.Enabled = false; addNewCustomerMode = true; updateCustomerMode = false; } EnableTextFields(true); CustomerCancelButton.Enabled = true; }
private void ClearFormData() { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailAdrTextBox.Clear(); ContactNumberTextBox.Clear(); }
public void FillSupportForm() { //ComboBoxHelper.SelectElement(EnquiryReasonDropDown, value); var modelFaker = new Faker <DataModel>() .RuleFor(o => o.firstName, f => f.Name.FirstName()) .RuleFor(o => o.lastName, f => f.Name.LastName()) .RuleFor(o => o.emailAddress, f => f.Internet.Email()) .RuleFor(o => o.phoneNumber, f => f.Phone.PhoneNumber()) .RuleFor(o => o.websiteUrl, f => f.Internet.Url()) .RuleFor(o => o.company, f => f.Company.CompanyName()) .RuleFor(o => o.reason, f => f.PickRandom <Reason>()) .RuleFor(o => o.message, f => f.Lorem.Sentence()); var dataModel = modelFaker.Generate(); string firstName = dataModel.firstName; string lastName = dataModel.lastName; string emailAddress = dataModel.emailAddress; string phoneNumber = dataModel.phoneNumber; string websiteurl = dataModel.websiteUrl; string company = dataModel.company; string reason = dataModel.reason.ToString(); string message = dataModel.message; FirstNameTextBox.SendKeys(firstName); LastNameTextBox.SendKeys(lastName); EmailAddressTextBox.SendKeys(emailAddress); PhoneNumberTextBox.SendKeys(phoneNumber); WebsiteUrlTextBox.SendKeys(websiteurl); CompanyTextBox.SendKeys(company); EnquiryReasonDropDown.SendKeys(reason); MessageTextBox.SendKeys(message); }
private void SaveButton_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { // Step 1 - Open a stream StreamWriter writer = new StreamWriter("Names.txt", true); // Step 2 - Write to the buffer writer.WriteLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text); // Step 3 - Close the file writer.Close(); //Step 4 - Reset the Form FirstNameTextBox.Clear(); LastNameTextBox.Clear(); FirstNameTextBox.Focus(); } else { FirstNameTextBox.Focus(); FirstNameTextBox.SelectAll(); } }
private void addButton_Click(object sender, RoutedEventArgs e) { try { bl.AddPrayer(prayer); prayer = new BE.Prayer(); Grid1.DataContext = prayer; prayersWindow.PrayerDataGrid.ItemsSource = null; prayersWindow.PrayerDataGrid.ItemsSource = bl.GetAllPrayers(); prayersWindow.ChoosePrayerComboBox.ItemsSource = null; prayersWindow.ChoosePrayerComboBox.ItemsSource = bl.GetAllPrayers(); string message = prayer.FirstName + " " + prayer.LastName + "נוסף לרשימת המתפללים"; MessageBox.Show(message, "המתפלל נוסף לקהילה", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RightAlign); prayer = new BE.Prayer(); Grid1.DataContext = prayer; BMparashaComboBox.SelectedIndex = -1; LastAliyaParashaComboBox.SelectedIndex = -1; TribeComboBox.SelectedIndex = 2; FirstNameTextBox.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "אזהרה!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private bool ValidateForm() { if (!Regex.Match(FirstNameTextBox.Text, @"^\D{1,30}$").Success) { MessageBox.Show("First name must consist of at least 1 character and not exceed 30 characters!"); FirstNameTextBox.Focus(); return(false); } if (!Regex.Match(LastNameTextBox.Text, @"^\D{1,30}$").Success) { MessageBox.Show("Last name must consist of at least 1 character and not exceed 30 characters!"); LastNameTextBox.Focus(); return(false); } if (!Regex.Match(AddressTextBox.Text, @"^(Вул\.\s\D{1,40}\,\s\d{1,3})$").Success) { MessageBox.Show("Address must consist of at least 1 character and not exceed 50 characters!"); AddressTextBox.Focus(); return(false); } if (!Regex.Match(PhoneNumberTextBox.Text, @"^\d{10}$").Success) { MessageBox.Show("Phone number must consist of 10 digits!"); PhoneNumberTextBox.Focus(); return(false); } return(true); }
public void ClearLoginForm() { //Clear login form FirstNameTextBox.ClearTextBox(); LastNameTextBox.ClearTextBox(); PeselTextBox.ClearTextBox(); }
private void AcceptButton_Click(object sender, EventArgs e) { IsValidEmail(EmailText.Text); IsValidName(FirstNameTextBox.Text); IsValidName(SurnameText.Text); if (PhoneNumberText.Text.Length != 11) { MessageBox.Show("The length of your phone number must be 11 digits"); PhoneNumberText.Clear(); } if (FirstNameTextBox.Text != "" && SurnameText.Text != "" && EmailText.Text != "" && PhoneNumberText.Text != "") { if (CustomersSelectionFormcs.edit == false) { ReadInTextFile(); } ListofCustomers.Add(new SnippetsBackend.Customers((FirstNameTextBox.Text), SurnameText.Text, EmailText.Text, PhoneNumberText.Text)); //Add to textfile using (StreamWriter tw = new StreamWriter("ListofCustomers.txt", false)) { foreach (SnippetsBackend.Customers s in ListofCustomers) { tw.WriteLine(s.FirstName + "," + s.LastName + "," + s.Email + "," + s.PhoneNumber); } tw.Close(); } MessageBox.Show("Customer has been added/edited"); FirstNameTextBox.Clear(); SurnameText.Clear(); EmailText.Clear(); PhoneNumberText.Clear(); CustomerAppointments.Items.Clear(); } }
private void FirstNameTextBox_Leave(object sender, EventArgs e) { if (FirstNameTextBox.TextLength < 2) { FirstNameTextBox.Focus(); FirstNameTextBox.SelectAll(); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { FirstNameTextBox.Focus(FocusState.Programmatic); // Setup date picker. dateTimeOnPageCreation = DateTime.Now; DobDatePicker.MaxYear = dateTimeOnPageCreation; DobDatePicker.Date = dateTimeOnPageCreation; }
public void IsValidName(string name) { if (Regex.IsMatch(name, @"^[a-zA-Z]+$") == false) { MessageBox.Show("The First name and Last name must only contain letters"); FirstNameTextBox.Clear(); SurnameText.Clear(); } }
private void ClearButton_Click(object sender, System.EventArgs e) { //Calling ClearBoxes method to clear textboxes ClearTextBoxes(); //Setting focus back to SearchTextBox FirstNameTextBox.Focus(); //Setting ADD button to enabled AddButton.Enabled = true; }
/// <summary> /// Shows the message. /// </summary> /// <param name="message">The message.</param> /// <param name="controlName">Name of the control.</param> public void ShowMessage(string message, ControlNames controlName) { if (!string.IsNullOrEmpty(message)) { ErrorMessageTextBlock.Text = message; ErrorMessageTextBlock.Visibility = Visibility.Visible; switch (controlName) { case ControlNames.ConfirmPassword: { ConfirmPasswordBox.DelayedFocus(); break; } case ControlNames.Password: { PasswordBox.DelayedFocus(); break; } case ControlNames.ZipCode: { ZipCodeTextBox.DelayedFocus(); break; } case ControlNames.LastName: { LastNameTextBox.DelayedFocus(); break; } case ControlNames.FirstName: { FirstNameTextBox.DelayedFocus(); break; } case ControlNames.Email: { EmailTextBox.DelayedFocus(); break; } case ControlNames.GetEmail: { GetEmailCheckBox.DelayedFocus(); break; } } } else { ErrorMessageTextBlock.Visibility = Visibility.Collapsed; } }
public void ReadInTextFile() { string[] oneline; string RFirstName = ""; string RLastName = ""; string REmail = ""; string RPhoneNumber = ""; int i = 0; for (i = 0; i < ListofCustomers.Count; i++) { string customerstring = ListofCustomers[i].ToString(); oneline = customerstring.Split(','); for (int x = 0; x < oneline.Length; x++) { switch (x) { case 0: RFirstName = oneline[x]; break; case 1: RLastName = oneline[x]; break; case 2: REmail = oneline[x]; break; case 3: RPhoneNumber = oneline[x]; break; } } //If edit selected customer has been selected, check they do not have the same first name and last name if (RFirstName == FirstNameTextBox.Text && RLastName == SurnameText.Text) { MessageBox.Show("This person already exists please enter a different firstname and lastname"); FirstNameTextBox.Clear(); SurnameText.Clear(); } //If the edit customer button has been clicked if (CustomersSelectionFormcs.edit == true) { string SelectedCustomerFirstName = CustomersSelectionFormcs.CustomerFirstName; string SelectedCustomerLastName = CustomersSelectionFormcs.CustomerLastName; if (RFirstName == SelectedCustomerFirstName && RLastName == SelectedCustomerLastName) { FirstNameTextBox.Text = SelectedCustomerFirstName; SurnameText.Text = SelectedCustomerLastName; EmailText.Text = REmail; PhoneNumberText.Text = RPhoneNumber.ToString(); } } } }
private void ResetForm() { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailAddressTextBox.Clear(); ContactNumberTextBox.Clear(); // clear Contact ComboBox List Items ContactComboBox.Items.Clear(); }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { ErrorMessageTextBlock.Visibility = Visibility.Collapsed; FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); ZipCodeTextBox.Clear(); }
/// <summary> /// Handles the Click event of the NoButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void NoButton_Click(object sender, RoutedEventArgs e) { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); ZipCodeTextBox.Clear(); GetEmailCheckBox.IsChecked = null; this.NavigationService.GoBack(); }
private void NewContactButton_Click(object sender, RoutedEventArgs e) { string avata = ((Icon)AvataComboBox.SelectedValue).IconPath; Contacts.Add(new Contact { FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, AvataPath = avata }); FirstNameTextBox.Text = ""; LastNameTextBox.Text = ""; AvataComboBox.SelectedIndex = -1; FirstNameTextBox.Focus(FocusState.Programmatic); }
private void Add(object sender, RoutedEventArgs e) { string avatar = ((Icon)AvatarComboBox.SelectedValue).Icons; Contacts.Add(new Contact { FirstName = FirstNameTextBox.Text, LastName = LastnameTextBox.Text, Avatar = avatar }); FirstNameTextBox.Text = ""; LastnameTextBox.Text = ""; AvatarComboBox.SelectedIndex = -1; FirstNameTextBox.Focus(FocusState.Programmatic); }
// Checks imput fields. private bool CheckFields() { // First name. if (String.IsNullOrEmpty(FirstNameTextBox.Text)) { ErrorFirstNameTextBlock.Visibility = Visibility.Visible; FirstNameTextBox.Focus(FocusState.Programmatic); return(false); } else { ErrorFirstNameTextBlock.Visibility = Visibility.Collapsed; } // Last name. if (String.IsNullOrEmpty(LastNameTextBox.Text)) { ErrorLastNameTextBlock.Visibility = Visibility.Visible; LastNameTextBox.Focus(FocusState.Programmatic); return(false); } else { ErrorLastNameTextBlock.Visibility = Visibility.Collapsed; } // DOB. if (DobDatePicker.Date == null || DobDatePicker.Date >= dateTimeOnPageCreation) { ErrorDobDateTextBlock.Visibility = Visibility.Visible; DobDatePicker.Focus(FocusState.Programmatic); return(false); } else { ErrorDobDateTextBlock.Visibility = Visibility.Collapsed; } // Gender. if (GenderComboBox.SelectedItem == null) { ErrorGenderTextBlock.Visibility = Visibility.Visible; GenderComboBox.Focus(FocusState.Programmatic); return(false); } else { ErrorGenderTextBlock.Visibility = Visibility.Collapsed; } return(true); }
public LoginWindow(MainWindow mainWindow) { InitializeComponent(); _mainWindow = mainWindow; VoteButton.Clicked += VoteButton_Clicked; Loaded += (s, ea) => { //Focus on first name field in the login form FirstNameTextBox.FocusOnMe(); }; }
private const string BIO_TEXTBOX_DEFAULT = "(optional...)"; //default text to be displayed in BioTextBox /// <summary> /// Constructor for AddAuthorDialog /// Initializes fields and preps the Window for user interaction /// </summary> public AddAuthorDialog() { InitializeComponent(); FirstNameTextBox.Text = string.Empty; LastNameTextBox.Text = string.Empty; ErrorTextBlock.Text = string.Empty; ResetBioBox(); //ensure that FirstNameTextBox is focused FirstNameTextBox.Focus(); }