Beispiel #1
0
 private void btnCreateUser_Click(object sender, RoutedEventArgs e)
 {
     //TODO error check input
     try
     {
         string userName = this.userNameBox.Text;
         string password = this.passwordBox.Password;
         string confirm  = this.cpasswordBox.Password;
         string name     = this.nameBox.Text;
         bool   isAdmin  = (bool)this.isAdminCheck.IsChecked;
         if (userName != "" && password != "" && password == confirm && name != "")
         {
             new UserSyncer().WebCreateUser(userName, password, name, isAdmin);
             User user = new User(userName, password, name, isAdmin);
             UserPrefs.AddUser(user);
             this.Close();
         }
         else
         {
             MessageBox.Show("Cannot create user with empty fields");
         }
     } catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void btnCreateUser_Click(object sender, RoutedEventArgs e)
        {
            string userName = this.userNameBox.Text;
            string password = this.passwordBox.Password;
            string name     = this.nameBox.Text;
            bool   isAdmin  = (bool)this.isAdminCheck.IsChecked;

            UserSyncer userSyncer = new UserSyncer();
            User       user       = userSyncer.WebCreateUser(userName, password, name, isAdmin);

            if (user != null)
            {
                UserPrefs.AddUser(user);
                this.Close();
            }
            else
            {
                MessageBox.Show("User already exists!");
            }
        }