Ejemplo n.º 1
0
 private void Button_EditUser_Click(object sender, RoutedEventArgs e)
 {
     //Updates the values of the selected index to the info in the textboxes
     Index = ListBox_UserList.SelectedIndex;
     if (Index != -1)
     {
         int tempIndex = Index;
         Users[Index].UserName = TextBox_CreateUserName.Text;
         if (IsEmail(TextBox_CreateUserEmail.Text))
         {
             Users[Index].UserEmail = TextBox_CreateUserEmail.Text;
         }
         ListBox_UserList.Items.RemoveAt(Index);
         ListBox_UserList.Items.Insert(tempIndex, Users[tempIndex].UserName);
     }
     Index = ListBox_AdminList.SelectedIndex;
     if (Index != -1)
     {
         int tempIndex = Index;
         Admins[Index].UserName = TextBox_CreateUserName.Text;
         if (IsEmail(TextBox_CreateUserEmail.Text))
         {
             Admins[Index].UserEmail = TextBox_CreateUserEmail.Text;
         }
         ListBox_AdminList.Items.RemoveAt(Index);
         ListBox_AdminList.Items.Insert(tempIndex, Admins[tempIndex].UserName);
     }
     TextBox_CreateUserName.Clear();
     TextBox_CreateUserEmail.Clear();
     Lable_CreateUserNameWatermark.Visibility  = Visibility.Visible;
     Lable_CreateUserEmailWatermark.Visibility = Visibility.Visible;
     Button_EditUser.IsEnabled = false;
 }
Ejemplo n.º 2
0
        private void Button_CreateUser_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_CreateUserName != null && TextBox_CreateUserEmail != null && IsEmail(TextBox_CreateUserEmail.Text))
            {
                //remove users from Listbox_users
                ListBox_UserList.Items.Clear();

                //Add user to list users
                Users.Add(new UserClass(TextBox_CreateUserName.Text, TextBox_CreateUserEmail.Text));

                //Add the new users lst to listbox
                for (int i = 0; i < Users.Count; i++)
                {
                    ListBox_UserList.Items.Add(Users.ElementAt(i).UserName);
                }
                //Remove contest of textboxes
                TextBox_CreateUserName.Clear();
                TextBox_CreateUserEmail.Clear();
                Lable_CreateUserNameWatermark.Visibility  = Visibility.Visible;
                Lable_CreateUserEmailWatermark.Visibility = Visibility.Visible;
                Button_CreateUser.IsEnabled = false;
                Button_EditUser.IsEnabled   = false;
            }
        }