private void Register() { String line; if (userType.Equals(Constants.UserTypeStudentText)) { line = String.Format("{0};{1};{2};{3};{4};{5};{6};{7}", Constants.UserTypeStudent, registerLoginNameTextBox.Text.ToLower(), registerFirstNameTextBox.Text, registerLastNameTextBox.Text, registerGroupTextBox.Text.ToUpper(), registerPasswordBox.Password, 0, 0); } else { line = String.Format("{0};{1};{2};{3};{4};{5};{6};{7}", Constants.UserTypeTeacher, registerLoginNameTextBox.Text.ToLower(), registerFirstNameTextBox.Text, registerLastNameTextBox.Text, registerGroupTextBox.Text.ToUpper(), registerPasswordBox.Password, 0, 0); } User temporaryUser = FileManager.CreateSubUserObject(line); userList.Add(temporaryUser); FileManager.WriteUserFiles(userList); loggedInUser = temporaryUser; mainInstance.SetLoggedInUser(loggedInUser); SetMainWindowLayout(); }
private void LogIn() { if (LookUpUser()) { if (PasswordCheck.ComparePasswords(loginPasswordBox.Password, tempUser.GetPassword)) { loggedInUser = tempUser; mainInstance.SetLoggedInUser(loggedInUser); SetMainWindowLayout(); tempUser = null; } else { loggedInUser = null; new CustomMessageBox(Constants.MessageIfPasswordIncorrect).Show(); loginPasswordBox.Clear(); } } else { new CustomMessageBox(Constants.MessageIfUserDoesNotExit).Show(); } }
private bool LookUpUser() { bool boolTemp = false; for (int i = 0; i < userList.Count; i++) { if (userList[i].GetLoginName.ToString().Equals(loginNameTextBox.Text.ToLower())) { tempUser = userList[i]; boolTemp = true; } } return boolTemp; }
private void SelectionChanged(object sender, SelectionChangedEventArgs e) { selectedUser = (User)userListBox.SelectedItem; PasswordTextBox.Text = selectedUser.GetPassword; userTypeLabel.Content = selectedUser.GetUserType(); }
public void SetLoggedInUser(User u) { loggedInUser = u; }
private void SetLayoutLoggedOff() { ResetButtonIndicators(); logOffButton.Opacity = Constants.OpacityPointOne; logOffButton.IsEnabled = false; manageQuestionsButton.Opacity = Constants.OpacityPointOne; manageQuestionsButton.IsEnabled = false; reportButton.Opacity = Constants.OpacityPointOne; reportButton.IsEnabled = false; mathQuizButton.Opacity = Constants.OpacityPointOne; mathQuizButton.IsEnabled = false; languageQuizButton.Opacity = Constants.OpacityPointOne; languageQuizButton.IsEnabled = false; knowledgeQuizButton.Opacity = Constants.OpacityPointOne; knowledgeQuizButton.IsEnabled = false; startGameButton.Opacity = Constants.OpacityPointOne; startGameButton.IsEnabled = false; mainContentControl.Content = new LoginRegisterUserControl(this, Constants.UserTypeStudentText); loggedInlabel.Content = string.Empty; loggedInUser = null; userPreferencesButton.Visibility = Visibility.Collapsed; userChangePrefsBorder.Visibility = Visibility.Collapsed; userPreferencesBorder.Visibility = Visibility.Collapsed; }