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 Clear_Click(object sender, RoutedEventArgs e) { NameCustomerText.Clear(); SiteText.Clear(); RepresentativeText.Clear(); PhoneNumberText.Clear(); ClientsListBox.SelectedItem = -1; }
private void DeleteClient_Click(object sender, RoutedEventArgs e) { try { foreach (Customer cs in lc.Cust) { if (ClientsListBox.SelectedItem != null) { if (cs.Name == ClientsListBox.SelectedItem.ToString()) { NameCustomerText.Text = cs.Name; SiteText.Text = cs.Site; RepresentativeText.Text = cs.Representative; PhoneNumberText.Text = cs.RepPhone.ToString(); Log.logging("Удален клиент: " + cs.Name + " " + DateTime.Now); lc.Cust.Remove(cs); break; } } } Serialization.Serialize(lc); ClientsListBox.Items.Clear(); foreach (var item in lc.Cust) { ClientsListBox.Items.Add(item.Name); } NameCustomerText.Clear(); SiteText.Clear(); RepresentativeText.Clear(); PhoneNumberText.Clear(); MessageBox.Show("Удалено!"); } catch (Exception ex) { MessageBox.Show(ex.Message); Log.logging("Ошибка: " + ex); } }
private void AddClient_Click(object sender, RoutedEventArgs e) { try { if (ClientsListBox.SelectedItem.ToString() != NameCustomerText.Text) { Customer cust = new Customer(NameCustomerText.Text, SiteText.Text, RepresentativeText.Text, PhoneNumberText.Text); lc.Cust.Add(cust); Log.logging("Добавлен клиент: " + cust.Name + " " + DateTime.Now); Serialization.Serialize(lc); ClientsListBox.Items.Clear(); lc = Serialization.Deserialze(lc); NameCustomerText.Clear(); SiteText.Clear(); RepresentativeText.Clear(); PhoneNumberText.Clear(); foreach (var item in lc.Cust) { ClientsListBox.Items.Add(item.Name); } MessageBox.Show("Сохранено!"); } else { MessageBox.Show("Такой заказчик уже существует!"); NameCustomerText.Clear(); SiteText.Clear(); RepresentativeText.Clear(); PhoneNumberText.Clear(); ClientsListBox.SelectedItem = -1; } } catch (Exception ex) { MessageBox.Show(ex.Message); Log.logging("Ошибка" + ex); } }
private void Save_Click(object sender, EventArgs e) { Resturant rest = new Resturant(NameText.Text, AddressText.Text, PhoneNumberText.Text, ZipCodeText.Text, RatingText.Text, ReviewText.Text); if (!listOfRestruants.Contains(rest)) { listOfRestruants.Add(rest); } else { listOfRestruants.Add(rest); } NameText.Clear(); AddressText.Clear(); ZipCodeText.Clear(); PhoneNumberText.Clear(); RatingText.Clear(); ReviewText.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 != "" && 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"); } }