private void Button_Click_1(object sender, RoutedEventArgs e) { var userinput = tbxUser.Text; var passwordinput = pbxPassword.Password; if (userinput.Trim() == "" || passwordinput.Trim() == "") { MessageBox.Show("Fyll i alla fälten"); } else { int value; if (int.TryParse(userinput, out value)) { var user = HandleItems.GetUser(value); if (user.userID.Equals(value) && user.password.Equals(passwordinput)) { Application.Current.Properties["currentUser"] = user; Application.Current.Properties["currentUser"] = UserHandling.GetUser(value); var rapport = new RapportHantering(); rapport.Show(); Close(); } else { MessageBox.Show("Inlogg eller lösenord fel"); } } else { MessageBox.Show("Fyll i alla fälten"); } } }
public static void FillUserInformation(int UserID, TextBox Tele, TextBox Email) { var user = UserHandling.GetUser(UserID); Tele.Text = user.phone; Email.Text = user.email; }
public static void ChangePassword(int user, PasswordBox newPasswordOne, PasswordBox newPasswordTwo, PasswordBox OldPassword) { if (Validering.CheckIf3Password(newPasswordOne, newPasswordTwo, OldPassword)) { var userNow = UserHandling.GetUser(user); if (userNow.password != OldPassword.Password) { MessageBox.Show("Du har angivit fel lösenord"); } else if (newPasswordOne.Password != newPasswordTwo.Password) { MessageBox.Show("Lösenorden stämmer inte överens"); } else { userNow.password = newPasswordOne.Password; UserHandling.UpdateUser(userNow); MessageBox.Show("Lösenordet har ändrats"); newPasswordOne.Password = ""; newPasswordTwo.Password = ""; OldPassword.Password = ""; } } }
public static void UpdateUser(int UserID, TextBox Tele, TextBox Email) { if (Validering.CheckIf2Empty(Tele, Email)) { var user = UserHandling.GetUser(UserID); user.phone = Tele.Text; user.email = Email.Text; UserHandling.UpdateUser(user); MessageBox.Show("Uppgifter sparade"); Tele.Text = ""; Email.Text = ""; } }
public static User GetUser(int id) { return(UserHandling.GetUser(id)); }