/// <summary> /// Author: Ramesh Adhikari /// Created On: 01/30/2019 /// Create new member and check for the validation /// </summary> private void CreateMember() { string firstName = txtFirstName.Text.Trim(); string lastName = txtLastName.Text.Trim(); string phoneNumber = txtPhoneNumber.Text.Trim(); string email = txtEmail.Text.Trim(); string password = txtPassword.Password.Trim(); string active = txtActive.IsEnabled.ToString(); if (txtFirstName.Text == "" || txtLastName.Text == "" || txtEmail.Text == "" || txtPhoneNumber.Text == "" ) { MessageBox.Show("Please Fill Out the Form"); } // Validate the phone number else if (!Regex.IsMatch(txtPhoneNumber.Text, @"^\(?\d{3}\)?[\s\-]?\d{3}\-?\d{4}$")) { MessageBox.Show("Please Enter Valid Phone Number"); txtPhoneNumber.Select(0, txtPhoneNumber.Text.Length); txtPhoneNumber.Focus(); } else if (!ValidateEmailAddress()) { MessageBox.Show("Please Enter Valid Email"); txtEmail.Select(0, txtEmail.Text.Length); txtEmail.Focus(); } else { MemberValidator.ValidateEmail(new Member() { Email = email }); MemberValidator.ValidatePhoneNumber(new Member() { PhoneNumber = phoneNumber }); // New member try { _newMember = new Member { FirstName = firstName, LastName = lastName, PhoneNumber = phoneNumber, Email = email, Password = password, //Active = active, }; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }