Esempio n. 1
0
        private void SignIn()
        {
            string login;
            var    newUser = new UserForm(NewUsername.Text, NewPassword.Password);
            var    res     = SqlDataAccess.RegisterUser(newUser, out login);

            if (res == -1)
            {
                MessageBox.Show("Введенное имя пользователя уже существует", "Ошибка ввода логина", MessageBoxButton.OK, MessageBoxImage.Error);
                NewUsername.Clear();
                NewPassword.Clear();
            }
            else
            {
                RegPrivileges.ChangeElementsForUser(login,
                                                    (TextBlock)Owner.FindName("UserLogin"),
                                                    (Button)Owner.FindName("Autorization"),
                                                    (Button)Owner.FindName("SignOut"),
                                                    (Button)Owner.FindName("ExcelExport"),
                                                    (Grid)Owner.FindName("GridClothes"),
                                                    (Grid)Owner.FindName("GridCalendar"),
                                                    (Grid)Owner.FindName("GridPaint"));

                MessageBox.Show("Пользователь добавлен!", "", MessageBoxButton.OK, MessageBoxImage.Information);
                Owner.Activate();
                Close();
            }
        }
        public int ChangeUsername(NewUsername newUsername)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    command    = new SqlCommand("usp_changeUsername");

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@UserID", newUsername.UserID));
            command.Parameters.Add(new SqlParameter("@NewUsername", newUsername.NewUsernameString));
            command.Connection = connection;

            connection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            connection.Close();

            if (table.Rows[0][0].ToString() == newUsername.NewUsernameString)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 3
0
        public void ChangeUsernameTest()
        {
            NewUsername nu = new NewUsername();

            nu.UserID            = GetUserID();
            nu.NewUsernameString = "TESTUSERNAME2";

            int result = controller.ChangeUsername(nu);

            Assert.AreEqual(result, 1);
        }
Esempio n. 4
0
 private void NewPassword_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (NewPassword.Password == "")
         {
             MessageBox.Show("Введите пароль!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         else if (NewUsername.Text == "")
         {
             NewUsername.Focus();
         }
         else
         {
             SignIn();
         }
     }
 }