示例#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;
        }
示例#2
0
        private void Confirm_CreateGroup_Click(object sender, RoutedEventArgs e)
        {
            // Add a colour wheel or something
            if (Group_Name.Text == "")
            {
                MessageBox.Show("A group name is required");
            }
            else if (Group_Description.Text == "")
            {
                MessageBox.Show("A description is required");
            }
            else
            {
                GlobalGroupStorage.TOTAL_GROUPS++;
                GlobalGroupStorage.GroupNames.Add(Group_Name.Text);
                GlobalGroupStorage.GroupIDs.Add(Group_ID.Text);
                GlobalGroupStorage.GroupDescriptions.Add(Group_Description.Text);

                GlobalVariables.insertIntoGroup(Group_Name.Text, "#FFAA20", Group_Description.Text);

                int groupID = GlobalVariables.returnAmountOfGroups();

                foreach (string email in DisplayUsernamesData.NAMES_IN)
                {
                    GlobalVariables.insertPersonIntoGroup(GlobalVariables.emailToID(email), groupID);
                }

                NavigationService navService = NavigationService.GetNavigationService(this);
                Groups_Page       nextPage   = new Groups_Page();
                navService.Navigate(nextPage);
            }
        }