last commit before tests

This commit is contained in:
younes elhaddoury
2026-02-03 13:31:40 +01:00
parent 3ba5b10d05
commit 241ed4eb94
24 changed files with 1146 additions and 623 deletions

View File

@@ -1,23 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;
using BCrypt.Net;
namespace SkyTeam
{
/// <summary>
/// Interaction logic for Page1.xaml
/// </summary>
public partial class RegistrationPage : Page
{
public RegistrationPage()
@@ -25,20 +13,61 @@ namespace SkyTeam
InitializeComponent();
}
private void RegisterButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(PasswordBox.Password))
{
MessageBox.Show("Bitte geben Sie ein Passwort ein.");
return;
}
string hashedPassword = BCrypt.Net.BCrypt.HashPassword(PasswordBox.Password);
string query = "INSERT INTO users (Vorname, Nachname, Email, PasswortHash, Rolle, Stadt, Anrede, Geburtsdatum) " +
"VALUES (@vorname, @nachname, @email, @password, 'User', @stadt, @anrede, @geburtsdatum)";
try
{
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand(query, conn))
{
string selectedAnrede = (SalutationComboBox.SelectedItem as ComboBoxItem)?.Content.ToString();
DateTime? selectedDate = BirthDatePicker.SelectedDate;
cmd.Parameters.AddWithValue("@vorname", FirstNameTextBox.Text);
cmd.Parameters.AddWithValue("@nachname", LastNameTextBox.Text);
cmd.Parameters.AddWithValue("@email", EmailTextBox.Text);
cmd.Parameters.AddWithValue("@password", hashedPassword);
cmd.Parameters.AddWithValue("@stadt", CityTextBox.Text);
cmd.Parameters.AddWithValue("@anrede", selectedAnrede ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("@geburtsdatum", selectedDate.HasValue ? selectedDate.Value : (object)DBNull.Value);
cmd.ExecuteNonQuery();
}
}
MessageBox.Show("Dein Konto wurde erfolgreich angelegt!");
if (Application.Current.MainWindow is MainWindow mainWindow)
{
mainWindow.MainFrame.Navigate(new LogInPage());
}
}
catch (Exception ex)
{
MessageBox.Show("Etwas ist schief gelaufen: " + ex.Message);
}
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new LogInPage());
if (Application.Current.MainWindow is MainWindow mainWindow)
{
mainWindow.MainFrame.Navigate(new LogInPage());
}
}
}
}
}