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 EmailText_Enter(object sender, EventArgs e) { if (EmailText.Text.Equals("Email")) { EmailText.Clear(); } }
public bool IsValidEmail(string email) { try { int indexofat = EmailText.Text.IndexOf("@"); int indexofdot = EmailText.Text.IndexOf("."); { if (Regex.IsMatch(email, @"^[^0-9]+$") == false) { MessageBox.Show("An email should only contain numbers"); EmailText.Clear(); } if (indexofat > indexofdot) { return(false); } else { return(true); } } } catch { return(false); } }
private void ClearForm() { UserNameText.Clear(); EmailText.Clear(); NameText.Clear(); PasswordText.Clear(); ChangePasswordChk.Checked = false; ActiveChk.Checked = false; }
private void button1_Click(object sender, EventArgs e) { NameText.Clear(); PhoneText.Clear(); EmailText.Clear(); INNText.Clear(); ScoreText.Clear(); AddressText.Clear(); Close(); }
private void EditClientForm_FormClosing(object sender, FormClosingEventArgs e) { NameText.Clear(); PhoneText.Clear(); EmailText.Clear(); INNText.Clear(); ScoreText.Clear(); AddressText.Clear(); bsToShow = null; }
private void NovayRegistraciy_Click(object sender, RoutedEventArgs e) { try { string LoginPolzovately1 = LoginText.Text; //Создание переменных, в которые заносятся значения из TextBox/PasswordBox string Parol1 = ParolText.Password; string RetryParol1 = RetryParolText.Password; string Dolznost1 = DolznkstText.Text; string FIO1 = FIOText.Text; string DataRozdeniy1 = DenRozdeniyText.Text; string NomerTelephona1 = TelephonText.Text; string Email1 = EmailText.Text; string Pol1 = PolText.Text; if (LoginPolzovately1.Length > 3 && Parol1.Length > 8) // Проверка логина и пароля на допустимое кол-во символов { if (Parol1 == RetryParol1) //Проверка на совпадение паролей { RegistrPerson(LoginPolzovately1, Parol1, Dolznost1, FIO1, DataRozdeniy1, NomerTelephona1, Email1, Pol1); MessageBox.Show("Регистрация успешна", "Регистрация"); LoginText.Clear(); ParolText.Clear(); RetryParolText.Clear(); DolznkstText.Clear(); FIOText.Clear(); DenRozdeniyText.Clear(); TelephonText.Clear(); EmailText.Clear(); PolText.Clear(); PerehodNaAvtorizaciy(); } else { MessageBox.Show("Пароли не совпадают!", "Регистрация", MessageBoxButton.OK, MessageBoxImage.Information); ParolText.Clear(); RetryParolText.Clear(); } } else { MessageBox.Show("Логин должен быть больше трех символов.\nПароль должен быть больше восьми символов.", "Регистрация", MessageBoxButton.OK, MessageBoxImage.Information); } } catch { MessageBox.Show("Необходимо заполнить все поля", "Регистрация", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void UpdateBTN_Click(object sender, EventArgs e) { connect.Open(); SqlCommand command = new SqlCommand("update Customer set CustomerID='" + CustomerIDText.Text.ToString() + "',Name='" + NameText.Text.ToString() + "',Surname='" + SurnameText.Text.ToString() + "',Address='" + AddressText.Text.ToString() + "',Telephone='" + TelephoneText.Text.ToString() + "',Email='" + EmailText.Text.ToString() + "'where CustomerID=" + CustomerID + "", connect); command.ExecuteNonQuery(); connect.Close(); viewdetails(); CustomerIDText.Clear(); NameText.Clear(); SurnameText.Clear(); AddressText.Clear(); TelephoneText.Clear(); EmailText.Clear(); }
private void DeleteBTN_Click(object sender, EventArgs e) { connect.Open(); SqlCommand komut = new SqlCommand("Delete From Customer Where CustomerID=(" + sira + ")", connect); komut.ExecuteNonQuery(); connect.Close(); viewdetails(); viewdetails(); CustomerIDText.Clear(); NameText.Clear(); SurnameText.Clear(); AddressText.Clear(); TelephoneText.Clear(); EmailText.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"); } }
private void SaveStudentButton_Click(object sender, EventArgs e) { try { Person person = new Person(); try { person.fname = FirstNametext.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter correct first name!"); FirstNametext.Clear(); throw new ArgumentException(); } try { person.lname = LastNameText.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter correct last name!"); LastNameText.Clear(); throw new ArgumentException(); } try { person.Contact = ContactText.Text; } catch (ArgumentException) { MessageBox.Show("Please enter the correct 11 digit contact number"); ContactText.Clear(); throw new ArgumentException(); } try { person.Email = EmailText.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter the email address"); EmailText.Clear(); throw new ArgumentException(); } catch (FormatException) { MessageBox.Show("Please Enter the correct email address"); EmailText.Clear(); throw new ArgumentException(); } try { person.DOB = DOBdateTimePicker.Value; } catch (ArgumentException) { MessageBox.Show("Person Age Must Be Greater Than 18"); DOBdateTimePicker.Value = DateTime.Now; throw new ArgumentException(); } try { person.Gender = GenderComboBox.Text; } catch (ArgumentException) { MessageBox.Show("Please Select the gender From the dropdown list"); throw new ArgumentException(); } Student student = new Student(); try { student.regNo = RegistrationNoText.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter the Registration Number in the Format 1234-XY-567"); RegistrationNoText.Clear(); throw new ArgumentException(); } if (value1 == "add") { SqlConnection connection = new SqlConnection(connString); connection.Open(); string genderid = string.Format("SELECT Id FROM LookUp WHERE Value = '{0}' AND Category = 'GENDER'", person.Gender); SqlCommand cmd = new SqlCommand(genderid, connection); int id = (Int32)cmd.ExecuteScalar(); String cmdtext = String.Format("INSERT INTO Person(FirstName, LastName, Contact, Email, DateOfBirth, Gender) values('{0}','{1}', '{2}', '{3}', '{4}', '{5}' )", person.fname, person.lname, person.Contact, person.Email, person.DOB, id); cmd.CommandText = cmdtext; cmd.ExecuteNonQuery(); string getid = string.Format("SELECT id FROM Person WHERE Email = '{0}'", person.Email); cmd.CommandText = getid; id = (Int32)cmd.ExecuteScalar(); string addStudent = string.Format("INSERT INTO Student(Id, RegistrationNo) values('{0}' , '{1}')", id, student.regNo); cmd.CommandText = addStudent; cmd.ExecuteNonQuery(); MessageBox.Show("Student Added"); connection.Close(); } else if (value1 == "edit") { SqlConnection connection = new SqlConnection(connString); connection.Open(); string getGenderId = string.Format("SELECT Id FROM LookUp WHERE Value = '{0}' AND Category = 'GENDER'", GenderComboBox.Text); SqlCommand cmd = new SqlCommand(getGenderId, connection); int gender = (Int32)cmd.ExecuteScalar(); string update = string.Format("UPDATE Student SET RegistrationNo = '{0}' WHERE Id = '{1}'", RegistrationNoText.Text, IDStudent); cmd.CommandText = update; cmd.ExecuteNonQuery(); cmd.CommandText = string.Format("UPDATE Person SET FirstName = '{0}', LastName = '{1}', Contact = '{2}', Email = '{3}', " + "DateOfBirth = '{4}', Gender = '{5}' WHERE Id = '{6}'", FirstNametext.Text, LastNameText.Text, ContactText.Text, EmailText.Text, DOBdateTimePicker.Value, gender, IDStudent); cmd.ExecuteNonQuery(); MessageBox.Show("Student Updated!"); connection.Close(); } ManageStudentsForm form = new ManageStudentsForm(); this.Close(); form.Show(); } catch (Exception) { MessageBox.Show("Student not saved. Please try again!"); } }
private void EmailText_Click(object sender, EventArgs e) { EmailText.Clear(); }
private void AddAdvisor1_Click(object sender, EventArgs e) { try { Person person = new Person(); try { person.fname = FirstNametext.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter correct first name!"); FirstNametext.Clear(); throw new ArgumentException(); } try { person.lname = LastNameText.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter correct last name!"); LastNameText.Clear(); throw new ArgumentException(); } try { person.Contact = ContactText.Text; } catch (ArgumentException) { MessageBox.Show("Please enter the correct 11 digit contact number"); ContactText.Clear(); throw new ArgumentException(); } try { person.Email = EmailText.Text; } catch (ArgumentException) { MessageBox.Show("Please Enter the email address"); EmailText.Clear(); throw new ArgumentException(); } catch (FormatException) { MessageBox.Show("Please Enter the correct email address"); EmailText.Clear(); throw new ArgumentException(); } try { person.DOB = DOBdateTimePicker.Value; } catch (ArgumentException) { MessageBox.Show("Person Age Must Be Greater Than 18"); DOBdateTimePicker.Value = DateTime.Now; throw new ArgumentException(); } try { person.Gender = GenderComboBox.Text; } catch (ArgumentException) { MessageBox.Show("Please Select the gender From the dropdown list"); throw new ArgumentException(); } Advisor advisor = new Advisor(); try { advisor.designation = designationComboBox.Text; } catch (ArgumentException) { MessageBox.Show("Please select designation from the dropdown list"); designationComboBox.ResetText(); throw new ArgumentException(); } try { advisor.salary = SalaryTextBox.Text; } catch { MessageBox.Show("Please enter the salary in digits"); throw new ArgumentException(); } if (value1 == "add") { SqlConnection connection = new SqlConnection(connString); connection.Open(); string genderid = string.Format("SELECT Id FROM LookUp WHERE Value = '{0}' AND Category = 'GENDER'", GenderComboBox.Text); SqlCommand cmd = new SqlCommand(genderid, connection); int id = (Int32)cmd.ExecuteScalar(); String cmdtext = String.Format("INSERT INTO Person(FirstName, LastName, Contact, Email, DateOfBirth, Gender) values('{0}','{1}', '{2}', '{3}', '{4}', '{5}' )", FirstNametext.Text, LastNameText.Text, ContactText.Text, EmailText.Text, DOBdateTimePicker.Value, id); cmd.CommandText = cmdtext; cmd.ExecuteNonQuery(); string getid = string.Format("SELECT id FROM Person WHERE Email = '{0}'", EmailText.Text); cmd.CommandText = getid; id = (Int32)cmd.ExecuteScalar(); cmd.CommandText = string.Format("SELECT Id FROM Lookup WHERE Value = '{0}' AND Category = 'DESIGNATION'", designationComboBox.Text); int desig = (Int32)cmd.ExecuteScalar(); string addStudent = string.Format("INSERT INTO Advisor(Id, Designation, Salary) values('{0}' , '{1}', '{2}')", id, desig, SalaryTextBox.Text); cmd.CommandText = addStudent; cmd.ExecuteNonQuery(); MessageBox.Show("Advisor Added"); connection.Close(); } else if (value1 == "edit") { SqlConnection connection = new SqlConnection(connString); connection.Open(); string getGenderId = string.Format("SELECT Id FROM LookUp WHERE Value = '{0}' AND Category = 'GENDER'", GenderComboBox.Text); SqlCommand cmd = new SqlCommand(getGenderId, connection); int gender = (Int32)cmd.ExecuteScalar(); cmd.CommandText = String.Format("SELECT Id FROM Lookup WHERE Value = '{0}' AND Category = 'DESIGNATION'", designationComboBox.Text); int desig = (Int32)cmd.ExecuteScalar(); cmd.CommandText = string.Format("UPDATE Person SET FirstName = '{0}', LastName = '{1}', Contact = '{2}', Email = '{3}', " + "DateOfBirth = '{4}', Gender = '{5}' WHERE Id = '{6}'", FirstNametext.Text, LastNameText.Text, ContactText.Text, EmailText.Text, DOBdateTimePicker.Value, gender, IDadvisor); cmd.ExecuteNonQuery(); cmd.CommandText = string.Format("UPDATE Advisor SET Designation = '{0}', Salary = '{1}' " + "WHERE Id = '{2}'", desig, int.Parse(SalaryTextBox.Text), IDadvisor); cmd.ExecuteNonQuery(); MessageBox.Show("Advisor Updated!"); connection.Close(); } ManageAdvisors form = new ManageAdvisors(); this.Close(); form.Show(); } catch (Exception) { MessageBox.Show("Advisor not saved. Please try again!"); } }