/// <summary> /// Событие при вводе текста в поле "AddressInput" /// </summary> private void AddressInput_TextChanged(object sender, TextChangedEventArgs e) { StringCheck check = new StringCheck(); bool trigger = check.CheckAddress(NewAddressInput.Text); string word = NewAddressInput.Text; foreach (var item in clientsController.ClientsLoginMatchUp(Settings.Default.login)) { if (trigger && word != item.address && 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 CheckAddress_isRusDashDelimiter_TrueReturned() { //Arrange string stringAddress = "Щорса-56"; //Act StringCheck isAddress = new StringCheck(); bool correctAddress = isAddress.CheckAddress(stringAddress); //Assert Assert.IsTrue(correctAddress); }
public void CheckAddress_isEngWithOutDilimiter_FalseReturned() { //Arrange string stringAddress = "Щорса56"; //Act StringCheck isAddress = new StringCheck(); bool correctAddress = isAddress.CheckAddress(stringAddress); //Assert Assert.IsFalse(correctAddress); }
public void CheckAddress_isEng_FalseReturned() { //Arrange string stringAddress = "Shorsa 56"; //Act StringCheck isAddress = new StringCheck(); bool correctAddress = isAddress.CheckAddress(stringAddress); //Assert Assert.IsFalse(correctAddress); }
public void CheckAddress_isRusWithOutNumbers_FalseReturned() { //Arrange string stringAddress = "Щорса"; //Act StringCheck isAddress = new StringCheck(); bool correctAddress = isAddress.CheckAddress(stringAddress); //Assert Assert.IsFalse(correctAddress); }
/// <summary> /// Событие при вводе текста в поле "AddressInput" /// </summary> private void AddressInput_TextChanged(object sender, TextChangedEventArgs e) { StringCheck check = new StringCheck(); bool trigger = check.CheckAddress(Convert.ToString(AddressInput.Text)); if (!trigger) { AddressWarningBtn.Visibility = Visibility.Visible; } else { AddressWarningBtn.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 AddressInput_TextChanged(object sender, TextChangedEventArgs e) { StringCheck check = new StringCheck(); bool trigger = check.CheckAddress(NewAddressInput.Text); string word = NewAddressInput.Text; foreach (var item in clientsController.ClientsInfoOutput()) { if (trigger && word != item.address) { 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(("); } } }