private void SignInBtn_Click(object sender, RoutedEventArgs e) { //TODO: Логика проверки Клиента try { CheckInputs(); var login = LoginTxt.Text; var password = PasswordTxt.Password; if ((UserData.User.UserGuid = DbClientWorker.SignIn(login, password)) != null) { if (AutorizationCompleted != null) { AutorizationCompleted(this, new AuthorizedEventArgs(true)); } } else { throw new Exception("Пользователя с таким логином и паролем не существует"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void TestUpdateClient() { var clientGuid = Guid.NewGuid(); var client = new Client { Guid = clientGuid, Login = "******", Password = "******" }; DbClientWorker.AddClient(client); var getClient = DbClientWorker.GetClient(clientGuid); Assert.IsNotNull(getClient); getClient.Login = "******"; getClient.Password = "******"; DbClientWorker.UpdateClient(getClient); var updatedClient = DbClientWorker.GetClient(clientGuid); Assert.IsNotNull(getClient); Assert.AreEqual(getClient.Login, "nigoLtseTtinU"); Assert.AreEqual(getClient.Password, "drowssaPtseTtinU"); DbClientWorker.DeleteClient(clientGuid); }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { //TODO: Сохранение новой инфы о клиенте try { CheckInputs(); var uri = new Uri(((BitmapFrame)EditImage.Source).Decoder.ToString()); var client = new Client { Guid = UserData.User.UserGuid.Value, Login = LoginTxt.Text, Password = Password.Password, FirstName = FirstNameTxt.Text, LastName = SecondNameTxt.Text, Patronymic = PatronymicTxt.Text, Birthday = Burthday.SelectedDate, Sex = SexCmb.SelectedIndex > -1 ? SexCmb.SelectedValue.ToString() : null, Email = EmailTxt.Text, Phone = PhoneTxt.Text, PassportNumber = PassportNumberTxt.Text, PassportSeries = PassportSeriaTxt.Text, BankCard = BankCard.Text, ImagePath = @"Users\" + System.IO.Path.GetFileName(uri.AbsolutePath) }; if (DbClientWorker.UpdateClient(client)) { var imagePath = System.IO.Path.Combine(Settings.AttachedFiles, client.ImagePath); if (!System.IO.File.Exists(imagePath)) { System.IO.File.Copy(uri.AbsolutePath, System.IO.Path.Combine(Settings.AttachedFiles, client.ImagePath)); } var model = (PersonnelCabinetWindowModel)DataContext; model.Login = client.Login; model.Password = client.Password; model.FirstName = client.FirstName; model.SecondName = client.LastName; model.Patronymic = client.Patronymic; model.Burthday = client.Birthday.ToString(); model.Sex = client.Sex; model.Email = client.Email; model.Phone = client.Phone; model.PassportNumber = client.PassportNumber; model.PassportSeria = client.PassportSeries; model.BankCard = client.BankCard; model.ImagePath = imagePath; Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void TestGetClient() { var clientGuid = Guid.NewGuid(); var client = new Client { Guid = clientGuid, Login = "******", Password = "******" }; DbClientWorker.AddClient(client); var getClient = DbClientWorker.GetClient(clientGuid); Assert.IsNotNull(getClient); DbClientWorker.DeleteClient(clientGuid); }
private void SignUpBtn_Click(object sender, RoutedEventArgs e) { //TODO: Создание нового клиента try { CheckInputs(); var login = LoginTxt.Text; var password = PasswordTxt.Password; var passwordRepeat = PasswordRepeatTxt.Password; var email = EmailTxt.Text; var phone = PhoneTxt.Text; if (DbClientWorker.CheckClient(login)) { throw new Exception("Логин \"" + login + "\" уже существует"); } var client = new Client { Guid = Guid.NewGuid(), Login = login, Password = password, Email = email, Phone = phone }; DbClientWorker.AddClient(client); if (RegisterEnded != null) { RegisterEnded(this, new EventArgs()); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { var client = DbClientWorker.GetClient(UserData.User.UserGuid.Value); var model = new PersonnelCabinetWindowModel { Login = client.Login, Password = client.Password, FirstName = client.FirstName, SecondName = client.LastName, Patronymic = client.Patronymic, Burthday = client.Birthday.ToString(), BankCard = client.BankCard, Email = client.Email, PassportNumber = client.PassportNumber, PassportSeria = client.PassportSeries, Phone = client.Phone, Sex = client.Sex, ImagePath = System.IO.Path.Combine(Settings.AttachedFiles, client.ImagePath) }; DataContext = model; SetPersonnelInfo(); }