/// <summary> /// Событие при вводе текста в поле "PhoneInput" /// </summary> private void PhoneInput_TextChanged(object sender, TextChangedEventArgs e) { StringCheck check = new StringCheck(); bool trigger = check.CheckPhone(NewPhoneInput.Text); string word = NewPhoneInput.Text; foreach (var item in clientsController.ClientsLoginMatchUp(Settings.Default.login)) { if (trigger && word != item.phone && word != "") { SaveBtn.IsEnabled = true; } else { SaveBtn.IsEnabled = false; } } if (NewFirstNameInput.Text == "" || NewLastNameInput.Text == "" || NewPatronymicInput.Text == "" || NewAddressInput.Text == "" || NewPhoneInput.Text == "" || NewLoginInput.Text == "" || NewPasswordInput.Password == "" || NewEmailInput.Text == "") { SaveBtn.IsEnabled = false; } }
public void CheckPhone_isNotEnoughChars_FalseReturned() { //Arrange string stringPhone = "8908963"; //Act StringCheck isPhone = new StringCheck(); bool correctPhone = isPhone.CheckPhone(stringPhone); //Assert Assert.IsFalse(correctPhone); }
public void CheckPhone_isDataWithLetters_FalseReturned() { //Arrange string stringPhone = "89089g15п"; //Act StringCheck isPhone = new StringCheck(); bool correctPhone = isPhone.CheckPhone(stringPhone); //Assert Assert.IsFalse(correctPhone); }
public void CheckPhone_isTooMuchChars_FalseReturned() { //Arrange string stringPhone = "89089150662265"; //Act StringCheck isPhone = new StringCheck(); bool correctPhone = isPhone.CheckPhone(stringPhone); //Assert Assert.IsFalse(correctPhone); }
public void CheckPhone_isEmpty_FalseReturned() { //Arrange string stringPhone = ""; //Act StringCheck isPhone = new StringCheck(); bool correctPhone = isPhone.CheckPhone(stringPhone); //Assert Assert.IsFalse(correctPhone); }
public void CheckPhone_isCorrectPhoneThatStartsWithNumber7_TrueReturned() { //Arrange string stringPhone = "79089150664"; //Act StringCheck isPhone = new StringCheck(); bool correctPhone = isPhone.CheckPhone(stringPhone); //Assert Assert.IsTrue(correctPhone); }
/// <summary> /// Событие при вводе текста в поле "PhoneInput" /// </summary> private void PhoneInput_TextChanged(object sender, TextChangedEventArgs e) { StringCheck check = new StringCheck(); bool trigger = check.CheckPhone(Convert.ToString(PhoneInput.Text)); if (!trigger) { PhoneWarningBtn.Visibility = Visibility.Visible; } else { PhoneWarningBtn.Visibility = Visibility.Collapsed; } }
/// <summary> /// Добавление нового пользователя /// </summary> /// <param name="userName" - имя></param> /// <param name="userSurname" - фамилия></param> /// <param name="userPatronymic" - отчество></param> /// <param name="userDate" - дата рождения></param> /// <param name="userAddress" - адрес></param> /// <param name="userWorkplace" - место работы></param> /// <param name="userStudyplace" - место учебы></param> /// <param name="userPhone" - телефон></param> /// <param name="userLogin" - логин></param> /// <param name="userPassword" - пароль></param> /// <param name="userEmail" - адрес электронной почты></param> /// <param name="userTicket" - читательский юилет></param> /// <returns> /// true - в случае выполнения метода /// false - в случае не выполения метода /// </returns> public bool AddNewUser(string userName, string userSurname, string userPatronymic, DateTime userDate, string userAddress, string userWorkplace, string userStudyplace, string userPhone, string userLogin, string userPassword, string userEmail, string userTicket) { try { StringCheck check = new StringCheck(); if (!check.CheckName(userName) || !check.CheckName(userSurname) || !check.CheckName(userPatronymic) || !check.CheckDate(Convert.ToString(userDate.Date.ToString("yyyy.MM.dd"))) || !check.CheckAddress(userAddress) || !check.CheckPhone(userPhone) || !check.CheckLogin(userLogin) || !check.CheckPassword(userPassword) || !check.CheckEmail(userEmail)) { return(false); } else { DateTime dateTime = Convert.ToDateTime(userDate.ToString("yyyy.MM.dd")); dbHelper.context.clients.Add(new clients { id_trading = null, id_role = 3, name = userName, surname = userSurname, patronymic = userPatronymic, birthday = dateTime, address = userAddress, workplace = userWorkplace, studyplace = userStudyplace, phone = userPhone, login = userLogin, password = userPassword, email = userEmail, ticket = userTicket }); dbHelper.context.SaveChanges(); return(true); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
private void PhoneInput_TextChanged(object sender, TextChangedEventArgs e) { StringCheck check = new StringCheck(); bool trigger = check.CheckPhone(NewPhoneInput.Text); string word = NewPhoneInput.Text; foreach (var item in clientsController.ClientsInfoOutput()) { if (trigger && word != item.phone) { SaveBtn.Background = Brushes.Green; SaveBtn.IsEnabled = true; } else { SaveBtn.Background = Brushes.Red; SaveBtn.IsEnabled = false; } } }
/// <summary> /// Обновление данных о пользователе /// </summary> /// <param name="newName" - новое имя></param> /// <param name="newSurname" - новоая фамилия></param> /// <param name="newPatronymic" - новое отчество></param> /// <param name="newBirthday" - новая дата рождения></param> /// <param name="newAddress" - новый адрес></param> /// <param name="newWorkplace" - новое место работы></param> /// <param name="newStudyplace" - новое место учебы></param> /// <param name="newPhone" - новый телефон></param> /// <param name="newLogin" - новый телефон></param> /// <param name="newPassword" - новый пароль></param> /// <param name="newEmail" - новый адрес электронной почты></param> /// <param name="oldUser" - лист со старыми данными пользователя></param> /// <returns> /// true - в случае выполнения метода /// false - в случае не выполения метода /// </returns> public bool UpdateClientInfo(string newName, string newSurname, string newPatronymic, DateTime newBirthday, string newAddress, string newWorkplace, string newStudyplace, string newPhone, string newLogin, string newPassword, string newEmail, List <clients> oldUser) { try { StringCheck check = new StringCheck(); if (!check.CheckName(newName) || !check.CheckName(newSurname) || !check.CheckName(newPatronymic) || !check.CheckDate(Convert.ToString(newBirthday.ToString("yyyy.MM.dd"))) || !check.CheckAddress(newAddress) || !check.CheckPhone(newPhone) || !check.CheckLogin(newLogin) || !check.CheckPassword(newPassword)) { return(false); } else { foreach (var item in oldUser) { item.name = newName; item.surname = newSurname; item.patronymic = newPatronymic; item.birthday = newBirthday.Date; item.address = newAddress; item.workplace = newWorkplace; item.studyplace = newStudyplace; item.phone = newPhone; item.login = newLogin; item.password = newPassword; item.email = newEmail; } dbHelper.context.SaveChanges(); return(true); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// Событие при клике на кнопку "Продолжить" /// </summary> private void StartBtnClick(object sender, RoutedEventArgs e) { Random rnd = new Random(); string generator = ""; string resultString = ""; StringCheck isName = new StringCheck(); bool resultName = isName.CheckName(FirstNameInput.Text); if (!resultName) { resultString += "Неправильно введено Имя\n"; } bool resultSurname = isName.CheckName(LastNameInput.Text); if (!resultSurname) { resultString += "Неправильно введена Фамилия\n"; } bool resultPatronymic = isName.CheckName(PatronymicInput.Text); if (!resultPatronymic) { resultString += "Неправильно введено Отчество\n"; } if (DateInput.SelectedDate == null) { resultString += "Неправильно введена Дата\n"; } else { bool resultDate = isName.CheckDate(DateInput.SelectedDate.Value.Date.ToString("yyyy.MM.dd")); bool resultDate2 = isName.CheckDate(Convert.ToString(Convert.ToDateTime(DateInput.Text).ToString("yyyy.MM.dd"))); if (!resultDate || !resultDate2) { resultString += "Неправильно введена Дата\n"; } } StringCheck isAddress = new StringCheck(); bool resultAddress = isAddress.CheckAddress(AddressInput.Text); if (!resultAddress) { resultString += "Неправильно введен Адрес\n"; } StringCheck isPhone = new StringCheck(); bool resultPhone = isPhone.CheckPhone(PhoneInput.Text); if (!resultPhone) { resultString += "Неправильно введен Телефон\n"; } StringCheck isLogin = new StringCheck(); bool resultLogin = isLogin.CheckLogin(LoginInput.Text); if (!resultLogin) { resultString += "Неправильно введен Логин\n"; } StringCheck isPassword = new StringCheck(); bool resultPassword = isPassword.CheckPassword(PasswordInput.Password); if (!resultPassword) { resultString += "Неправильно введен Пароль\n"; } StringCheck isEmail = new StringCheck(); bool resultEmail = isEmail.CheckEmail(EmailInput.Text); if (!resultEmail) { resultString += "Неправильно введен email\n"; } if (resultString == "") { if (clientsController.CheckForAnExistingkUser(LoginInput.Text)) { for (int i = 0; i < 4; i++) { generator += rnd.Next(0, 9); } FirstNameInput.IsReadOnly = true; LastNameInput.IsReadOnly = true; PatronymicInput.IsReadOnly = true; AddressInput.IsReadOnly = true; WorkplaceInput.IsReadOnly = true; StudyplaceInput.IsReadOnly = true; PhoneInput.IsReadOnly = true; LoginInput.IsReadOnly = true; EmailInput.IsReadOnly = true; string ticket = "X" + "-" + generator + "-" + DateTime.Now.ToString("yy"); DateTime word2 = Convert.ToDateTime(Convert.ToDateTime(DateInput.Text).ToString("yyyy.MM.dd")); if (clientsController.AddNewUser(FirstNameInput.Text, LastNameInput.Text, PatronymicInput.Text, word2, AddressInput.Text, WorkplaceInput.Text, StudyplaceInput.Text, PhoneInput.Text, LoginInput.Text, PasswordInput.Password, EmailInput.Text, ticket)) { MessageBox.Show("Регистрация прошла успешно."); if (clientsController.SendInfo(LoginInput.Text, PasswordInput.Password, EmailInput.Text)) { MessageBox.Show("Данные для авторизации были отправлены на вашу электронную почту. Если письмо не пришло, убедитесь, что оно не попало в папку Спам."); this.NavigationService.Navigate(new AuthorizationPage()); } else { MessageBox.Show("Данные для авторизации не были отправлены, повторная попытка будет произведена позже."); FirstNameInput.IsReadOnly = false; LastNameInput.IsReadOnly = false; PatronymicInput.IsReadOnly = false; AddressInput.IsReadOnly = false; WorkplaceInput.IsReadOnly = false; StudyplaceInput.IsReadOnly = false; PhoneInput.IsReadOnly = false; LoginInput.IsReadOnly = false; EmailInput.IsReadOnly = false; } } else { MessageBox.Show("Ошибка регистрации"); } } else { MessageBox.Show("Неккоректно введены данные"); } } else { MessageBox.Show(resultString); } }
private void StartBtnClick(object sender, RoutedEventArgs e) { string resultString = ""; StringCheck isName = new StringCheck(); bool resultName = isName.CheckName(FirstNameInput.Text); if (!resultName) { resultString += "Неправильно введено Имя"; } bool resultSurname = isName.CheckName(LastNameInput.Text); if (!resultSurname) { resultString += "Неправильно введена Фамилия"; } bool resultPatronymic = isName.CheckName(PatronymicInput.Text); if (!resultPatronymic) { resultString += "Неправильно введено Отчество"; } StringCheck isAddress = new StringCheck(); bool resultAddress = isAddress.CheckAddress(AddressInput.Text); if (!resultAddress) { resultString += "Неправильно введен Адрес"; } StringCheck isPhone = new StringCheck(); bool resultPhone = isPhone.CheckPhone(PhoneInput.Text); if (!resultPhone) { resultString += "Неправильно введен Телефон"; } StringCheck isLogin = new StringCheck(); bool resultLogin = isLogin.CheckLogin(LoginInput.Text); if (!resultLogin) { resultString += "Неправильно введен Логин"; } StringCheck isPassword = new StringCheck(); bool resultPassword = isPassword.CheckPassword(PasswordInput.Password); if (!resultPassword) { resultString += "Неправильно введен Пароль"; } StringCheck check = new StringCheck(); if (resultString == "") { if (clientsController.CheckForAnExistingkUser(LoginInput.Text, PasswordInput.Password)) { clientsController.AddNewUser(FirstNameInput.Text, LastNameInput.Text, PatronymicInput.Text, Convert.ToDateTime(DateInput.SelectedDate), AddressInput.Text, WorkplaceInput.Text, StudyplaceInput.Text, PhoneInput.Text, LoginInput.Text, PasswordInput.Password); } else { MessageBox.Show("sf-abuzer-zxc(("); } } }