Пример #1
0
        private void AddUser_Click(object sender, RoutedEventArgs e)
        {
            bool isDigitsOnly = true;

            foreach (char c in AddedUsername.Text)
            {
                if (!(c < '0' || c > '9'))
                {
                    isDigitsOnly = false;
                }
            }
            if (isDigitsOnly)
            {
                UserAddedText.Text = "Error! Please enter number ID of user!";
            }
            else if (GlobalVariables.userInGroup(GlobalVariables.emailToID(AddedUsername.Text), GlobalVariables.selectedGroup))
            {
                UserAddedText.Text = "Error! User already in group!";
            }
            else if (GlobalVariables.userInDatabase(Convert.ToInt32(AddedUsername.Text)))
            {
                UserAddedText.Text = AddedUsername.Text + " Added!";
                GlobalVariables.insertPersonIntoGroup(Convert.ToInt32(AddedUsername.Text), GlobalVariables.selectedGroup);
            }
            else
            {
                UserAddedText.Text = AddedUsername.Text + " is not in database.";
            }

            AddedUsername.Text       = "";
            UserAddedText.Visibility = Visibility.Visible;
        }