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 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(); } }
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 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 ClearFormData() { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailAdrTextBox.Clear(); ContactNumberTextBox.Clear(); }
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(); } }
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(); } } } }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { ErrorMessageTextBlock.Visibility = Visibility.Collapsed; FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); ZipCodeTextBox.Clear(); }
private void ResetForm() { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailAddressTextBox.Clear(); ContactNumberTextBox.Clear(); // clear Contact ComboBox List Items ContactComboBox.Items.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(); }
//Method to sync textboxes with datagrid cells private void StudentOverviewDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { FirstNameTextBox.Text = StudentOverviewDataGrid[0, e.RowIndex].Value.ToString(); LastNameTextBox.Text = StudentOverviewDataGrid[1, e.RowIndex].Value.ToString(); StudyTextBox.Text = StudentOverviewDataGrid[2, e.RowIndex].Value.ToString(); } catch { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); StudyTextBox.Clear(); } }
// Clear UI infput fields private void ClearUI() { IDTextBox.Clear(); UserNameTextBox.Clear(); PasswordTextBox.Clear(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailTextBox.Clear(); var date = new DateTime(); date = DateTime.Today; StartDateDatePickerTextBox.Text = date.ToShortDateString(); UserTypeComboBox.Text = "Staff"; ProtectedUserCheckBox.IsChecked = false; UserInactiveCheckBox.IsChecked = false; }
//When called it will update the buttons private void UpdateButtons() { if (peopleList.Count == 0) { RemoveButton.Enabled = false; ClearAllButton.Enabled = false; MaleButton.Checked = false; FemaleButton.Checked = false; FirstNameTextBox.Clear(); LastNameTextBox.Clear(); SearchTextBox.Clear(); } else { RemoveButton.Enabled = true; ClearAllButton.Enabled = true; } }
private void SubmitButton_Click(object sender, EventArgs e) { myUserToModify.SetFirstName(FirstNameTextBox.Text); myUserToModify.SetLastName(LastNameTextBox.Text); myUserToModify.SetPhoneNumber(PhoneNumberTextBox.Text); myUserToModify.SetEmailAddress(EmailTextBox.Text); myUserToModify.SetUserType(UserTypeTextBox.Text); myUserToModify.SetNotes(NotesTextBox.Text); myUserToModify.SetStatus(StatusTextBox.Text); myUserToModify.update(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); EmailTextBox.Clear(); UserTypeTextBox.Clear(); NotesTextBox.Clear(); StatusTextBox.Clear(); NewWorkerNotificationLabel.Text = "User updated"; }
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 != "" && HourlyRateText.Text != "") { if (StylistSelectionForm.edit == false) { ReadInTextFile(); } ListofStylists.Add(new SnippetsBackend.Stylist((FirstNameTextBox.Text), SurnameText.Text, EmailText.Text, PhoneNumberText.Text, double.Parse(HourlyRateText.Text))); //Add to textfile using (StreamWriter tw = new StreamWriter("ListofStylists.txt", false)) { foreach (SnippetsBackend.Stylist s in ListofStylists) { tw.WriteLine(s.FirstName + "," + s.LastName + "," + s.Email + "," + s.PhoneNumber + "," + s.HourlyRate); } tw.Close(); } MessageBox.Show("Stylist has been added/edited"); FirstNameTextBox.Clear(); SurnameText.Clear(); EmailText.Clear(); PhoneNumberText.Clear(); HourlyRateText.Clear(); StylistTransactions.Items.Clear(); } else if (FirstNameTextBox.Text == "" || SurnameText.Text == "" || EmailText.Text == "" || PhoneNumberText.Text == "" || HourlyRateText.Text == "") { MessageBox.Show("Please fill in all the textboxes"); } }
private void AddButtonClick(object sender, RoutedEventArgs e) { AddButton.IsEnabled = false; FirstNameTextBox.IsEnabled = false; LastNameTextBox.IsEnabled = false; if (lastModifyToggleButton != null) { ModifyAction(); } else { AddAction(); } FirstNameTextBox.Clear(); LastNameTextBox.Clear(); AuthorsDataGrid.DataContext = dB.GetAuthors(); AddButton.IsEnabled = true; FirstNameTextBox.IsEnabled = true; LastNameTextBox.IsEnabled = true; }
private void SubmitButton_Click(object sender, EventArgs e) { try //throw this exception if this passenger already exists { string gender; if (FemaleradioButton1.Checked) { gender = FemaleradioButton1.Text; } else { gender = MaleradioButton2.Text; } Address addr = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text); TravelAgent trav1 = new TravelAgent(FirstNameTextBox.Text, LastNameTextBox.Text, gender, addr, PhoneNumberTextBox.Text, int.Parse(IDNumberTextBox.Text), double.Parse(EarningstextBox1.Text), SsnTextBox.Text); trav1.countofEmployees++; foreach (Person p in TravelAgency.people) { if (trav1.isEqual(p)) { throw new DuplicateDataExcception("Sorry! This Passenger already exists!"); } } string s = " "; if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s) { throw new InvalidName("Invalid Name"); } if (PhoneNumberTextBox.Text == s) { throw new InvalidPhoneNumber("Invalid PhoneNumber"); } if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s) { throw new InvalidAddress("Invalid Address"); } if (IDNumberTextBox.Text == s) { throw new InvalidDataException("Invalid ID"); } if (SsnTextBox.Text == s) { throw new InvalidDataException("Invalid Passport Number"); } if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked) { throw new InvalidDataException("Invalid Gender"); } TravelAgency.people.Add(trav1); MessageBox.Show("Travel Agent " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added"); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); StreetTextBox.Clear(); SsnTextBox.Clear(); CityTextBox.Clear(); StateTextBox.Clear(); ZipTextBox.Clear(); FemaleradioButton1.Checked = false; MaleradioButton2.Checked = false; IDNumberTextBox.Clear(); EarningstextBox1.Clear(); } catch (InvalidName) { MessageBox.Show("Invalid Name"); } catch (InvalidPhoneNumber) { MessageBox.Show("Invalid phone Number"); } catch (DuplicateDataExcception ex) { MessageBox.Show(ex.Message); } catch (OverflowException oe) { MessageBox.Show(oe.Message); } catch (FormatException f) { MessageBox.Show(f.Message); } catch (Exception q) { MessageBox.Show(q.Message); } }
public void SubmitButton_Click(object sender, EventArgs e) { try { string gender; if (FemaleradioButton1.Checked) { gender = FemaleradioButton1.Text; } else { gender = MaleradioButton2.Text; } Passport pass = new Passport(FirstNameTextBox.Text, LastNameTextBox.Text, CountryOfBirthTextBox.Text, NationalityTextBoox.Text); Address adr = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text); Person adam1 = new Passenger(int.Parse(IDNumberTextBox.Text), FirstNameTextBox.Text, LastNameTextBox.Text, gender, PhoneNumberTextBox.Text, adr, pass); foreach (Person p in TravelAgency.people) { if (adam1.isEqual(p)) { throw new DuplicateDataExcception("Sorry! This Passenger already exists"); } } string s = " "; if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s) { throw new InvalidName("Invalid Name"); } if (PhoneNumberTextBox.Text == s) { throw new InvalidPhoneNumber("Invalid PhoneNumber"); } if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s) { throw new InvalidAddress("Invalid Address"); } if (CountryOfBirthTextBox.Text == s) { throw new InvalidDataException("Invalid Country of Birth"); } if (NationalityTextBoox.Text == s) { throw new InvalidDataException("Invalid Nationality"); } if (IDNumberTextBox.Text == s) { throw new InvalidDataException("Invalid ID"); } if (PassportNumberTextBox.Text == s) { throw new InvalidDataException("Invalid Passport Number"); } if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked) { throw new InvalidDataException("Invalid Gender"); } TravelAgency.people.Add(adam1); MessageBox.Show("Passenger " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added"); IDNumberTextBox.Clear(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); StreetTextBox.Clear(); CityTextBox.Clear(); StateTextBox.Clear(); ZipTextBox.Clear(); CountryOfBirthTextBox.Clear(); NationalityTextBoox.Clear(); FemaleradioButton1.Checked = false; MaleradioButton2.Checked = false; PassportTextBox.Clear(); } catch (InvalidName) { MessageBox.Show("Invalid Name"); } catch (InvalidPhoneNumber) { MessageBox.Show("invalid Phone Number"); } catch (DuplicateDataExcception ex) { MessageBox.Show(ex.Message); } catch (OverflowException oe) { MessageBox.Show(oe.Message); } catch (Exception q) { MessageBox.Show(q.Message); } }
public void ReadInTextFile() { string[] oneline; string RFirstName = ""; string RLastName = ""; string REmail = ""; string RPhoneNumber = ""; double RHourlyRate = 0; int i = 0; for (i = 0; i < ListofStylists.Count; i++) { string splitstylist = ListofStylists[i].ToString(); oneline = splitstylist.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; case 4: RHourlyRate = double.Parse(oneline[x]); break; } } //If edit selected stylist 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 (StylistSelectionForm.edit == true) { string SelectedStylistFirstName = StylistSelectionForm.StylistFirstName; string SelectedStylistLastName = StylistSelectionForm.StylistLastName; if (RFirstName == SelectedStylistFirstName && RLastName == SelectedStylistLastName) { FirstNameTextBox.Text = SelectedStylistFirstName; SurnameText.Text = SelectedStylistLastName; EmailText.Text = REmail; PhoneNumberText.Text = RPhoneNumber.ToString(); HourlyRateText.Text = RHourlyRate.ToString(); } } } }
//lets discuss how these button clearing should work private void FirstNameTextBox_Click(object sender, EventArgs e) { FirstNameTextBox.Clear(); }
private void SubmitButton_Click(object sender, EventArgs e) { try { string gender; if (FemaleradioButton1.Checked) { gender = FemaleradioButton1.Text; } else { gender = MaleradioButton2.Text; } Address addr = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text); CreditCard cc = new CreditCard(int.Parse(CardNumbertextBox1.Text), int.Parse(PintextBox1.Text), DateTime.Parse(ExpirationDatedateTimePicker1.Text)); Customer cust1 = new Customer(FirstNameTextBox.Text, LastNameTextBox.Text, gender, addr, PhoneNumberTextBox.Text, int.Parse(IDNumberTextBox.Text), cc); foreach (Person p in TravelAgency.people) { if (cust1.isEqual(p)) { throw new DuplicateDataExcception("Sorry! This Customer already exists!"); } } string s = " "; if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s) { throw new InvalidName("Invalid Name"); } if (PhoneNumberTextBox.Text == s) { throw new InvalidPhoneNumber("Invalid PhoneNumber"); } if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s) { throw new InvalidAddress("Invalid Address"); } if (IDNumberTextBox.Text == s) { throw new InvalidDataException("Invalid ID"); } if (CardNumbertextBox1.Text == s || PintextBox1.Text == s) { throw new InvalidDataException("invalid card"); } if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked) { throw new InvalidDataException("Invalid Gender"); } TravelAgency.people.Add(cust1); MessageBox.Show("Customer " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added"); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); StreetTextBox.Clear(); CityTextBox.Clear(); StateTextBox.Clear(); ZipTextBox.Clear(); IDNumberTextBox.Clear(); FemaleradioButton1.Checked = false; MaleradioButton2.Checked = false; PintextBox1.Clear(); ExpirationDatedateTimePicker1.ResetText(); CardNumbertextBox1.Clear(); } catch (InvalidName) { MessageBox.Show("Invalid Name"); } catch (InvalidPhoneNumber) { MessageBox.Show("Invalid phone Number"); } catch (DuplicateDataExcception ex) { MessageBox.Show(ex.Message); } catch (OverflowException oe) { MessageBox.Show(oe.Message); } catch (Exception q) { MessageBox.Show(q.Message); } }
/// <summary> /// Enter a value into the 'First Name' field /// </summary> /// <param name="firstName">The value to enter</param> public void EnterFirstName(string firstName) { FirstNameTextBox.Clear(); FirstNameTextBox.SendKeys(firstName); }