last commit before tests
This commit is contained in:
159
SkyTeam/AdminDashBoard.xaml
Normal file
159
SkyTeam/AdminDashBoard.xaml
Normal file
@@ -0,0 +1,159 @@
|
||||
<Page x:Class="SkyTeam.AdminDashboard"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
Title="AdminDashboard"
|
||||
Background="{DynamicResource PageBackground}">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Row="0" Grid.ColumnSpan="2" Background="#D32F2F" Padding="15">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="ShieldAccount" Width="36" Height="36" Foreground="White" Margin="0,0,10,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Sky Team ADMIN" FontSize="20" FontWeight="Bold" Foreground="White"/>
|
||||
<TextBlock Text="Management Console" FontSize="12" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Background="{DynamicResource SidebarBackground}">
|
||||
<Button Height="50" Margin="5" Click="ShowUsers_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="AccountGroup" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Benutzer verwalten"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Height="50" Margin="5" Click="ShowFlights_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Flüge verwalten"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Height="50" Margin="5" Background="#FFEBEB" BorderBrush="#FFB71C1C" Foreground="#D32F2F" FontWeight="Bold" Click="Logout_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Logout" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Abmelden"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1" Margin="20">
|
||||
|
||||
<Grid x:Name="UserManagementGrid" Visibility="Visible">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="Alle Benutzer" FontSize="24" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
|
||||
|
||||
<DataGrid x:Name="AllUsersGrid" Grid.Row="1" Margin="0,10,0,20" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" SelectionChanged="AllUsersGrid_SelectionChanged">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="50"/>
|
||||
<DataGridTextColumn Header="Vorname" Binding="{Binding Vorname}" Width="*"/>
|
||||
<DataGridTextColumn Header="Nachname" Binding="{Binding Nachname}" Width="*"/>
|
||||
<DataGridTextColumn Header="Email" Binding="{Binding Email}" Width="150"/>
|
||||
<DataGridTextColumn Header="Rolle" Binding="{Binding Rolle}" Width="80"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,0,0,10">
|
||||
<TextBlock Text="Buchungen des ausgewählten Benutzers" FontSize="18" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" VerticalAlignment="Center"/>
|
||||
<Button Content="Benutzer Löschen" Background="#D32F2F" Foreground="White" FontWeight="Bold" Margin="20,0,0,0" Padding="10,5" Click="DeleteUser_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid x:Name="UserBookingsGrid" Grid.Row="3" AutoGenerateColumns="False" IsReadOnly="True" Background="{DynamicResource CardBackground}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Buchung ID" Binding="{Binding BuchungId}"/>
|
||||
<DataGridTextColumn Header="Flug Nr." Binding="{Binding Flugnummer}"/>
|
||||
<DataGridTextColumn Header="Von" Binding="{Binding Abflugort}"/>
|
||||
<DataGridTextColumn Header="Nach" Binding="{Binding Zielort}"/>
|
||||
<DataGridTextColumn Header="Datum" Binding="{Binding Abflugdatum}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="FlightManagementGrid" Visibility="Collapsed">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="Flugplan & Management" FontSize="24" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" Margin="0,0,0,10"/>
|
||||
|
||||
<DataGrid x:Name="AllFlightsGrid" Grid.Row="1" Margin="0,0,0,20" AutoGenerateColumns="False" IsReadOnly="True">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="40"/>
|
||||
<DataGridTextColumn Header="Nummer" Binding="{Binding Flugnummer}" FontWeight="Bold" Width="80"/>
|
||||
<DataGridTextColumn Header="Von" Binding="{Binding Abflugort}" Width="*"/>
|
||||
<DataGridTextColumn Header="Nach" Binding="{Binding Zielort}" Width="*"/>
|
||||
<DataGridTextColumn Header="Datum" Binding="{Binding Abflugdatum}" Width="120"/>
|
||||
<DataGridTextColumn Header="Preis" Binding="{Binding Preis}" Width="60"/>
|
||||
<DataGridTextColumn Header="Flugzeug" Binding="{Binding Plane}" Width="100"/>
|
||||
<DataGridTextColumn Header="Pilot" Binding="{Binding Pilot}" Width="100"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Button Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Right" Content="Flug Löschen" Background="#D32F2F" Foreground="White" Margin="0,-40,0,0" Padding="10,5" Click="DeleteFlight_Click"/>
|
||||
|
||||
<Border Grid.Row="2" Background="{DynamicResource CardBackground}" CornerRadius="8" Padding="15" BorderBrush="#DDD" BorderThickness="1">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Neuen Flug hinzufügen (ID wird generiert: SYJ-XXX)" FontWeight="Bold" Margin="0,0,0,10"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Margin="5">
|
||||
<Label Content="Von:"/>
|
||||
<TextBox x:Name="AddFromTxt"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="5">
|
||||
<Label Content="Nach:"/>
|
||||
<TextBox x:Name="AddToTxt"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Margin="5">
|
||||
<Label Content="Datum:"/>
|
||||
<DatePicker x:Name="AddDatePick"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="3" Margin="5">
|
||||
<Label Content="Preis (€):"/>
|
||||
<TextBox x:Name="AddPriceTxt"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="5">
|
||||
<Label Content="Flugzeug:"/>
|
||||
<ComboBox x:Name="PlaneCombo" DisplayMemberPath="Modell" SelectedValuePath="Id"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Margin="5">
|
||||
<Label Content="Pilot:"/>
|
||||
<ComboBox x:Name="PilotCombo" DisplayMemberPath="FullName" SelectedValuePath="Id"/>
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Row="1" Grid.Column="3" Content="Flug Erstellen" Background="#1E88E5" Foreground="White" FontWeight="Bold" VerticalAlignment="Bottom" Height="30" Margin="5" Click="AddFlight_Click"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
130
SkyTeam/AdminDashBoard.xaml.cs
Normal file
130
SkyTeam/AdminDashBoard.xaml.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
public partial class AdminDashboard : Page
|
||||
{
|
||||
public AdminDashboard()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadUsers();
|
||||
LoadFlights();
|
||||
LoadCombos();
|
||||
}
|
||||
|
||||
private void LoadUsers()
|
||||
{
|
||||
BindGrid("SELECT Id, Vorname, Nachname, Email, Rolle FROM users", AllUsersGrid);
|
||||
}
|
||||
|
||||
private void AllUsersGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (AllUsersGrid.SelectedItem == null) return;
|
||||
DataRowView row = (DataRowView)AllUsersGrid.SelectedItem;
|
||||
int userId = Convert.ToInt32(row["Id"]);
|
||||
BindGrid($"SELECT b.Id AS BuchungId, f.Flugnummer, f.Abflugort, f.Zielort, f.Abflugdatum FROM buchungen b JOIN fluege f ON b.FlugId = f.Id WHERE b.UserId = {userId}", UserBookingsGrid);
|
||||
}
|
||||
|
||||
private void DeleteUser_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AllUsersGrid.SelectedItem == null) { MessageBox.Show("Bitte User wählen"); return; }
|
||||
DataRowView row = (DataRowView)AllUsersGrid.SelectedItem;
|
||||
int uid = Convert.ToInt32(row["Id"]);
|
||||
|
||||
if (MessageBox.Show($"User {uid} löschen?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
|
||||
ExecuteSql($"DELETE FROM users WHERE Id={uid}");
|
||||
LoadUsers();
|
||||
UserBookingsGrid.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadFlights()
|
||||
{
|
||||
string q = @"SELECT f.Id, f.Flugnummer, f.Abflugort, f.Zielort, f.Abflugdatum, f.Preis, z.Modell AS Plane, CONCAT(p.Vorname, ' ', p.Nachname) AS Pilot
|
||||
FROM fluege f JOIN flugzeuge z ON f.FlugzeugId = z.Id JOIN piloten p ON f.PilotId = p.Id ORDER BY f.Abflugdatum DESC";
|
||||
BindGrid(q, AllFlightsGrid);
|
||||
}
|
||||
|
||||
private void DeleteFlight_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AllFlightsGrid.SelectedItem == null) return;
|
||||
DataRowView row = (DataRowView)AllFlightsGrid.SelectedItem;
|
||||
if (MessageBox.Show("Flug löschen?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
ExecuteSql($"DELETE FROM fluege WHERE Id={row["Id"]}");
|
||||
LoadFlights();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddFlight_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(AddFromTxt.Text) || string.IsNullOrWhiteSpace(AddToTxt.Text) || AddDatePick.SelectedDate == null || PlaneCombo.SelectedValue == null || PilotCombo.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Bitte alle Felder ausfüllen.");
|
||||
return;
|
||||
}
|
||||
|
||||
int creatorId = SessionManager.CurrentUserId;
|
||||
if (creatorId == 0)
|
||||
{
|
||||
creatorId = 1;
|
||||
}
|
||||
|
||||
string flightNum = "SYJ-" + new Random().Next(100, 999);
|
||||
string query = @"INSERT INTO fluege (Abflugort, Zielort, Abflugdatum, Ankunftsdatum, Flugnummer, Preis, FlugzeugId, PilotId, ErstelltVon)
|
||||
VALUES (@from, @to, @date, @arr, @fnum, @price, @plane, @pilot, @admin)";
|
||||
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@from", AddFromTxt.Text);
|
||||
cmd.Parameters.AddWithValue("@to", AddToTxt.Text);
|
||||
cmd.Parameters.AddWithValue("@date", AddDatePick.SelectedDate.Value);
|
||||
cmd.Parameters.AddWithValue("@arr", AddDatePick.SelectedDate.Value.AddHours(4));
|
||||
cmd.Parameters.AddWithValue("@fnum", flightNum);
|
||||
cmd.Parameters.AddWithValue("@price", AddPriceTxt.Text);
|
||||
cmd.Parameters.AddWithValue("@plane", PlaneCombo.SelectedValue);
|
||||
cmd.Parameters.AddWithValue("@pilot", PilotCombo.SelectedValue);
|
||||
|
||||
cmd.Parameters.AddWithValue("@admin", creatorId);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
MessageBox.Show($"Flug {flightNum} erstellt!");
|
||||
LoadFlights();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); }
|
||||
}
|
||||
|
||||
private void LoadCombos()
|
||||
{
|
||||
BindComboBox("SELECT Id, Modell FROM flugzeuge WHERE IstDefekt=0", PlaneCombo, "Modell", "Id");
|
||||
BindComboBox("SELECT Id, CONCAT(Vorname, ' ', Nachname) AS FullName FROM piloten WHERE IstVerfuegbar=1", PilotCombo, "FullName", "Id");
|
||||
}
|
||||
private void BindGrid(string q, DataGrid g)
|
||||
{
|
||||
try { using (var c = new MySqlConnection(DatenbankServices.GetConnection())) { c.Open(); var a = new MySqlDataAdapter(q, c); var t = new DataTable(); a.Fill(t); g.ItemsSource = t.DefaultView; } } catch { }
|
||||
}
|
||||
private void BindComboBox(string q, ComboBox b, string d, string v)
|
||||
{
|
||||
try { using (var c = new MySqlConnection(DatenbankServices.GetConnection())) { c.Open(); var a = new MySqlDataAdapter(q, c); var t = new DataTable(); a.Fill(t); b.ItemsSource = t.DefaultView; b.DisplayMemberPath = d; b.SelectedValuePath = v; } } catch { }
|
||||
}
|
||||
private void ExecuteSql(string s)
|
||||
{
|
||||
try { using (var c = new MySqlConnection(DatenbankServices.GetConnection())) { c.Open(); new MySqlCommand(s, c).ExecuteNonQuery(); } } catch (Exception ex) { MessageBox.Show(ex.Message); }
|
||||
}
|
||||
|
||||
private void ShowUsers_Click(object sender, RoutedEventArgs e) { UserManagementGrid.Visibility = Visibility.Visible; FlightManagementGrid.Visibility = Visibility.Collapsed; }
|
||||
private void ShowFlights_Click(object sender, RoutedEventArgs e) { UserManagementGrid.Visibility = Visibility.Collapsed; FlightManagementGrid.Visibility = Visibility.Visible; }
|
||||
private void Logout_Click(object sender, RoutedEventArgs e) { SessionManager.CurrentUserId = 0; NavigationService.Navigate(new LogInPage()); }
|
||||
}
|
||||
}
|
||||
39
SkyTeam/AdminLoginPage.xaml
Normal file
39
SkyTeam/AdminLoginPage.xaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<Page x:Class="SkyTeam.AdminLoginPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
Title="Admin Login">
|
||||
|
||||
<Grid Margin="40,20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,30">
|
||||
<iconPacks:PackIconMaterial Kind="ShieldAccount" Width="40" Height="40" Foreground="#D32F2F" Margin="0,0,15,0"/>
|
||||
<TextBlock Text="Admin Login" FontSize="36" FontWeight="Bold" Foreground="#D32F2F"/>
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.Row="1" Background="White" CornerRadius="16" Padding="40" BorderBrush="#D32F2F" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<StackPanel Width="300">
|
||||
<TextBlock Text="Sicherheits-Check" FontWeight="Bold" Margin="0,0,0,15" HorizontalAlignment="Center"/>
|
||||
|
||||
<Label Content="Vorname (Username):"/>
|
||||
<TextBox x:Name="AdminUserBox" Height="35" Margin="0,0,0,10"/>
|
||||
|
||||
<Label Content="E-Mail:"/>
|
||||
<TextBox x:Name="AdminEmailBox" Height="35" Margin="0,0,0,10"/>
|
||||
|
||||
<Label Content="Rolle (z.B. Admin):"/>
|
||||
<TextBox x:Name="AdminRoleBox" Height="35" Margin="0,0,0,10"/>
|
||||
|
||||
<Label Content="Passwort:"/>
|
||||
<PasswordBox x:Name="AdminPassBox" Height="35" Margin="0,0,0,20"/>
|
||||
|
||||
<Button Content="Admin Anmelden" Height="40" Background="#D32F2F" Foreground="White" FontWeight="Bold" Click="AdminLogin_Click"/>
|
||||
<Button Content="Abbrechen" Margin="0,10,0,0" Background="Transparent" BorderThickness="0" Click="Back_Click"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Page>
|
||||
65
SkyTeam/AdminLoginPage.xaml.cs
Normal file
65
SkyTeam/AdminLoginPage.xaml.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using MySql.Data.MySqlClient;
|
||||
using BCrypt.Net;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
public partial class AdminLoginPage : Page
|
||||
{
|
||||
public AdminLoginPage() => InitializeComponent();
|
||||
|
||||
private void AdminLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string query = "SELECT Id, PasswortHash FROM users WHERE Email = @email AND Vorname = @user AND Rolle = @role";
|
||||
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand(query, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@email", AdminEmailBox.Text);
|
||||
cmd.Parameters.AddWithValue("@user", AdminUserBox.Text);
|
||||
cmd.Parameters.AddWithValue("@role", AdminRoleBox.Text);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
string storedHash = reader.GetString("PasswortHash");
|
||||
int dbId = reader.GetInt32("Id");
|
||||
|
||||
if (BCrypt.Net.BCrypt.Verify(AdminPassBox.Password, storedHash))
|
||||
{
|
||||
SessionManager.CurrentUserId = dbId;
|
||||
SessionManager.CurrentUserName = AdminUserBox.Text;
|
||||
|
||||
MessageBox.Show("Admin-Zugriff gewährt!");
|
||||
NavigationService.Navigate(new AdminDashboard());
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ungültiges Passwort.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Kein Admin mit diesen Daten gefunden.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void Back_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new LogInPage());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
<Application x:Class="SkyTeam.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:SkyTeam"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
<SolidColorBrush x:Key="PageBackground" Color="White"/>
|
||||
<SolidColorBrush x:Key="CardBackground" Color="#F5F7FA"/>
|
||||
<SolidColorBrush x:Key="SidebarBackground" Color="#FFE3F2FD"/>
|
||||
<SolidColorBrush x:Key="PrimaryText" Color="Black"/>
|
||||
<SolidColorBrush x:Key="SecondaryText" Color="#666666"/>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
</Application>
|
||||
@@ -1,14 +1,54 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using MySql.Data.MySqlClient;
|
||||
using BCrypt.Net;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
// Beim Start der Anwendung einen Standard Admin-Benutzer erstellen, falls keiner existiert , selbGedacht.
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
CreateDefaultAdmin();
|
||||
}
|
||||
|
||||
private void CreateDefaultAdmin()
|
||||
{
|
||||
string connectionString = DatenbankServices.GetConnection();
|
||||
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
string checkQuery = "SELECT COUNT(*) FROM users WHERE Rolle = 'Admin'";
|
||||
MySqlCommand checkCmd = new MySqlCommand(checkQuery, conn);
|
||||
long count = (long)checkCmd.ExecuteScalar();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
string hashedPassword = BCrypt.Net.BCrypt.HashPassword("admin");
|
||||
|
||||
string insertQuery = @"
|
||||
INSERT INTO users (Vorname, Nachname, Email, PasswortHash, Rolle, Stadt, CreatedAt)
|
||||
VALUES ('System', 'Root', 'admin@skyteam.com', @hash, 'Admin', 'HQ', NOW())";
|
||||
|
||||
MySqlCommand insertCmd = new MySqlCommand(insertQuery, conn);
|
||||
insertCmd.Parameters.AddWithValue("@hash", hashedPassword);
|
||||
insertCmd.ExecuteNonQuery();
|
||||
|
||||
MessageBox.Show("Ein Standard-Admin wurde erstellt!\nEmail: admin@skyteam.com\nPasswort: admin");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
||||
MessageBox.Show("Fehler beim Erstellen des Standard Admins: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,125 +2,82 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
Title="BuchungenPage">
|
||||
Title="BuchungenPage"
|
||||
Background="{DynamicResource PageBackground}">
|
||||
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Background="#FF1E88E5"
|
||||
Padding="15">
|
||||
<Border Grid.Row="0" Grid.ColumnSpan="2" Background="#FF1E88E5" Padding="15">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Ellipse Width="36" Height="36" Fill="White" Margin="0,0,10,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Sky Team Airlines"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"/>
|
||||
<TextBlock Text="Sichere und komfortable Flüge weltweit"
|
||||
FontSize="12"
|
||||
Foreground="White"/>
|
||||
<TextBlock Text="Sky Team Airlines" FontSize="20" FontWeight="Bold" Foreground="White"/>
|
||||
<TextBlock Text="Sichere und komfortable Flüge weltweit" FontSize="12" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Background="#FFE3F2FD">
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Background="{DynamicResource SidebarBackground}">
|
||||
<Button Height="50" Margin="5" Click="HomeButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Home" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Home"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
|
||||
<Button Height="50"
|
||||
Margin="5"
|
||||
Background="#FFBBDEFB"
|
||||
Click="BookingsButton_Click">
|
||||
<Button Height="50" Margin="5" Background="#FFBBDEFB" Click="BookingsButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Meine Buchungen"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button Height="50" Margin="5" Click="SettingsButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Einstellungen"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button Height="50"
|
||||
Margin="5"
|
||||
Background="#FFEBEB"
|
||||
BorderBrush="#FFB71C1C"
|
||||
Foreground="#D32F2F"
|
||||
FontWeight="Bold"
|
||||
Click="LogoutButton_Click">
|
||||
<Button Height="50" Margin="5" Background="#FFEBEB" BorderBrush="#FFB71C1C" Foreground="#D32F2F" FontWeight="Bold" Click="LogoutButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Logout" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Abmelden"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1" Margin="30">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Meine Buchungen" FontSize="28" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<TextBlock Text="Ihre reservierten Flüge im Überblick" FontSize="16" Foreground="{DynamicResource SecondaryText}" Margin="0,0,0,20"/>
|
||||
|
||||
<StackPanel Margin="0,0,0,25">
|
||||
<TextBlock Text="Meine Buchungen"
|
||||
FontSize="28"
|
||||
FontWeight="Bold"/>
|
||||
<TextBlock Text="Ihre reservierten Flüge im Überblick"
|
||||
FontSize="16"
|
||||
Foreground="#666"/>
|
||||
<Border x:Name="NoBookingsView" Visibility="Visible" Background="{DynamicResource CardBackground}" CornerRadius="12" Padding="40">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="AirplaneOff" Width="50" Height="50" Foreground="#888"/>
|
||||
<TextBlock Text="Sie haben noch keinen Flug reserviert." FontSize="18" Margin="0,15,0,5" TextAlignment="Center" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<Button Content="Jetzt reservieren" Width="180" Height="45" Background="#FF1E88E5" Foreground="White" FontWeight="Bold" Margin="0,20,0,0" Click="OpenReservierungSuche_Click"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<DataGrid x:Name="BookingsGrid" Visibility="Collapsed" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="True" Height="400" Background="{DynamicResource CardBackground}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Buchungs ID" Binding="{Binding BuchungId}" Width="80"/>
|
||||
<DataGridTextColumn Header="Flug Nr." Binding="{Binding Flugnummer}" Width="*"/>
|
||||
<DataGridTextColumn Header="Von" Binding="{Binding Abflugort}" Width="*"/>
|
||||
<DataGridTextColumn Header="Nach" Binding="{Binding Zielort}" Width="*"/>
|
||||
<DataGridTextColumn Header="Datum" Binding="{Binding Abflugdatum}" Width="*"/>
|
||||
<DataGridTextColumn Header="Status" Binding="{Binding Status}" Width="100"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Button x:Name="CancelBtn" Visibility="Collapsed" Content="Flug Stornieren" Background="#D32F2F" Foreground="White" FontWeight="Bold" Width="150" Height="40" HorizontalAlignment="Right" Margin="0,15,0,0" Click="CancelBooking_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<Border Background="#F5F7FA"
|
||||
CornerRadius="12"
|
||||
Padding="40">
|
||||
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="AirplaneOff"
|
||||
Width="50"
|
||||
Height="50"
|
||||
Foreground="#888"/>
|
||||
|
||||
<TextBlock Text="Sie haben noch keinen Flug reserviert."
|
||||
FontSize="18"
|
||||
Margin="0,15,0,5"
|
||||
TextAlignment="Center"/>
|
||||
|
||||
<TextBlock Text="Reservieren Sie jetzt Ihren ersten Flug!"
|
||||
FontSize="14"
|
||||
Foreground="#666"
|
||||
Margin="0,0,0,20"
|
||||
TextAlignment="Center"/>
|
||||
|
||||
<Button Content="Jetzt reservieren"
|
||||
Width="180"
|
||||
Height="45"
|
||||
Click="OpenReservierungSuche_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
</Page>
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Collections.ObjectModel;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
@@ -8,56 +10,75 @@ namespace SkyTeam
|
||||
{
|
||||
public BuchungenPage()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
LoadBookings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void SearchBookingsButton_Click(object sender, RoutedEventArgs e)
|
||||
private void LoadBookings()
|
||||
{
|
||||
|
||||
}
|
||||
if (SessionManager.CurrentUserId == 0) return;
|
||||
|
||||
private void HomeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new NavigationPage());
|
||||
}
|
||||
string query = @"SELECT b.Id AS BuchungId, f.Flugnummer, f.Abflugort, f.Zielort, f.Abflugdatum, b.Status
|
||||
FROM buchungen b
|
||||
JOIN fluege f ON b.FlugId = f.Id
|
||||
WHERE b.UserId = @uid";
|
||||
|
||||
private void BookingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new SettingsPage());
|
||||
}
|
||||
|
||||
private void BookFlightButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"Möchten Sie sich wirklich abmelden?",
|
||||
"Abmelden",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
try
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new LogInPage());
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@uid", SessionManager.CurrentUserId);
|
||||
|
||||
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
|
||||
DataTable dt = new DataTable();
|
||||
adapter.Fill(dt);
|
||||
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
BookingsGrid.ItemsSource = dt.DefaultView;
|
||||
NoBookingsView.Visibility = Visibility.Collapsed;
|
||||
BookingsGrid.Visibility = Visibility.Visible;
|
||||
CancelBtn.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
NoBookingsView.Visibility = Visibility.Visible;
|
||||
BookingsGrid.Visibility = Visibility.Collapsed;
|
||||
CancelBtn.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show(ex.Message); }
|
||||
}
|
||||
|
||||
private void CancelBooking_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (BookingsGrid.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Bitte wählen Sie einen Flug aus.");
|
||||
return;
|
||||
}
|
||||
|
||||
DataRowView row = (DataRowView)BookingsGrid.SelectedItem;
|
||||
int bid = Convert.ToInt32(row["BuchungId"]);
|
||||
|
||||
|
||||
if (MessageBox.Show("Stornieren?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
new MySqlCommand($"DELETE FROM buchungen WHERE Id={bid}", conn).ExecuteNonQuery();
|
||||
}
|
||||
LoadBookings();
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenReservierungSuche_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new ReservierungssuchePage());
|
||||
}
|
||||
private void HomeButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new NavigationPage());
|
||||
private void BookingsButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new BuchungenPage());
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new SettingsPage());
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new LogInPage());
|
||||
private void OpenReservierungSuche_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new ReservierungssuchePage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
class DatenbankServices
|
||||
static class DatenbankServices
|
||||
{
|
||||
private string ConnectionString = "server=localhost;uid=root;pwd=root;database=hci";
|
||||
//private string ConnectionString ="Server=mysql.pb.bib.de;uid=pbt3h24akh;pwd=Dd3dwQgPeNxW;database=pbt3h24akh_SkyTeam;";
|
||||
// private static readonly string connectionString = "server=localhost;uid=root;pwd=root;database=hci";
|
||||
private static readonly string connectionString ="Server=mysql.pb.bib.de;uid=pbt3h24akh;pwd=Dd3dwQgPeNxW;database=pbt3h24akh_SkyTeam;";
|
||||
|
||||
protected virtual string connectionString
|
||||
public static string GetConnection()
|
||||
{
|
||||
get { return ConnectionString; }
|
||||
private set { ConnectionString = value; }
|
||||
return connectionString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
class FlugeRepo : DatenbankServices
|
||||
class FlugeRepo
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
class FlugzeugRepo : DatenbankServices
|
||||
class FlugzeugRepo
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,43 +5,21 @@
|
||||
Title="LogInPage">
|
||||
|
||||
<Grid Margin="40,20">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,0,50">
|
||||
<iconPacks:PackIconMaterial Kind="Account"
|
||||
Width="36"
|
||||
Height="36"
|
||||
Margin="0,0,15,0"/>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,50">
|
||||
<iconPacks:PackIconMaterial Kind="Account" Width="36" Height="36" Margin="0,0,15,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Sky Team"
|
||||
FontSize="36"
|
||||
FontWeight="Bold"/>
|
||||
<TextBlock Text="Melden Sie sich an um zu starten"
|
||||
FontSize="14"
|
||||
Foreground="#666"
|
||||
Margin="0,5,0,0"/>
|
||||
<TextBlock Text="Sky Team" FontSize="36" FontWeight="Bold"/>
|
||||
<TextBlock Text="Melden Sie sich an um zu starten" FontSize="14" Foreground="#666" Margin="0,5,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Form Container -->
|
||||
<Border Grid.Row="1"
|
||||
Background="White"
|
||||
CornerRadius="16"
|
||||
Padding="50"
|
||||
BorderBrush="#E0E0E0"
|
||||
BorderThickness="1"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center">
|
||||
<Border Grid.Row="1" Background="White" CornerRadius="16" Padding="50" BorderBrush="#E0E0E0" BorderThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -50,65 +28,25 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Email (Benutzername):" Grid.Row="0" FontWeight="SemiBold"/>
|
||||
<TextBox x:Name="BenutzernameTextBox" Grid.Row="1" Height="45" FontSize="14"/>
|
||||
|
||||
<Label Content="Benutzername:"
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,12,8"
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"/>
|
||||
<TextBox x:Name="BenutzernameTextBox"
|
||||
Grid.Row="1" Grid.ColumnSpan="2"
|
||||
Height="45"
|
||||
FontSize="14"
|
||||
Margin="0,0,0,0"/>
|
||||
<Label Content="Passwort:" Grid.Row="3" FontWeight="SemiBold"/>
|
||||
<PasswordBox x:Name="PasswortTextBox" Grid.Row="4" Height="45" FontSize="14"/>
|
||||
|
||||
<Label Content="Passwort:"
|
||||
Grid.Row="3" Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,12,8"
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"/>
|
||||
<PasswordBox x:Name="PasswortTextBox"
|
||||
Grid.Row="4" Grid.ColumnSpan="2"
|
||||
Height="45"
|
||||
FontSize="14"
|
||||
Margin="0,0,0,0"/>
|
||||
|
||||
<StackPanel Grid.Row="6"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,20,0,0">
|
||||
<Button Content="Login"
|
||||
Width="140"
|
||||
Height="48"
|
||||
Margin="0,0,20,0"
|
||||
Background="#FF1E88E5"
|
||||
Foreground="White"
|
||||
FontSize="15"
|
||||
FontWeight="Bold"
|
||||
Click="LogInButton_Click"/>
|
||||
<Button Content="Registrieren"
|
||||
Width="140"
|
||||
Height="48"
|
||||
Background="Transparent"
|
||||
BorderBrush="#DDD"
|
||||
BorderThickness="1"
|
||||
Foreground="#666"
|
||||
FontSize="15"
|
||||
FontWeight="SemiBold"
|
||||
Click="anmeldungsButton_Click"/>
|
||||
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,20,0,0">
|
||||
<Button Content="Login" Width="140" Height="48" Margin="0,0,20,0" Background="#FF1E88E5" Foreground="White" FontWeight="Bold" Click="LogInButton_Click"/>
|
||||
<Button Content="Registrieren" Width="140" Height="48" Background="Transparent" BorderBrush="#DDD" Foreground="#666" Click="anmeldungsButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="7" HorizontalAlignment="Center" Margin="0,20,0,0">
|
||||
<Run Text="Sind Sie Admin?" Foreground="#666"/>
|
||||
<Hyperlink Click="AdminLink_Click" Foreground="#1E88E5" TextDecorations="None" FontWeight="Bold">Bitte hier klicken</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
</Page>
|
||||
@@ -1,47 +1,93 @@
|
||||
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 LogInPage.xaml
|
||||
/// </summary>
|
||||
public partial class LogInPage : Page
|
||||
{
|
||||
public LogInPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void AdminLink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Application.Current.MainWindow is MainWindow mainWindow)
|
||||
{
|
||||
mainWindow.MainFrame.Navigate(new AdminLoginPage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LogInButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string email = BenutzernameTextBox.Text;
|
||||
string password = PasswortTextBox.Password;
|
||||
|
||||
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
MessageBox.Show("Bitte Email und Passwort eingeben.");
|
||||
return;
|
||||
}
|
||||
|
||||
string query = @"
|
||||
SELECT Id, Vorname, Rolle, PasswortHash
|
||||
FROM users
|
||||
WHERE Email = @email";
|
||||
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(query, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@email", email);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (!reader.Read())
|
||||
{
|
||||
MessageBox.Show("Benutzer wurde nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
|
||||
string storedHash = reader.GetString("PasswortHash");
|
||||
|
||||
if (!BCrypt.Net.BCrypt.Verify(password, storedHash))
|
||||
{
|
||||
MessageBox.Show("Falsches Passwort.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SessionManager.CurrentUserId = reader.GetInt32("Id");
|
||||
SessionManager.CurrentUserName = reader.GetString("Vorname");
|
||||
SessionManager.Role = reader.GetString("Rolle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
((MainWindow)Application.Current.MainWindow)
|
||||
.MainFrame.Navigate(new NavigationPage());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Datenbankfehler: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void anmeldungsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new RegistrationPage());
|
||||
|
||||
}
|
||||
|
||||
private void LogInButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new NavigationPage());
|
||||
|
||||
((MainWindow)Application.Current.MainWindow)
|
||||
.MainFrame.Navigate(new RegistrationPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
class PilotenRepo : DatenbankServices
|
||||
class PilotenRepo
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
Title="Registrierungsseite">
|
||||
Title="Registrierungsseite"
|
||||
Background="#F0F2F5">
|
||||
|
||||
<Grid Margin="40,20">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
@@ -14,32 +14,34 @@
|
||||
<StackPanel Grid.Row="0"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,0,40">
|
||||
Margin="0,0,0,30">
|
||||
<iconPacks:PackIconMaterial Kind="AccountPlus"
|
||||
Width="32"
|
||||
Height="32"
|
||||
Width="40"
|
||||
Height="40"
|
||||
Foreground="#1E88E5"
|
||||
Margin="0,0,15,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Registrieren"
|
||||
FontSize="28"
|
||||
FontWeight="Bold"/>
|
||||
FontWeight="Bold"
|
||||
Foreground="#333"/>
|
||||
<TextBlock Text="Erstellen Sie Ihren Sky Team Account"
|
||||
FontSize="14"
|
||||
Foreground="#666"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Background="White"
|
||||
CornerRadius="12"
|
||||
Padding="40"
|
||||
Padding="30"
|
||||
BorderBrush="#E0E0E0"
|
||||
BorderThickness="1"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center">
|
||||
<Grid>
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center"
|
||||
MaxWidth="500">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -48,62 +50,62 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="60"/>
|
||||
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="220"/>
|
||||
<ColumnDefinition Width="250"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Vorname:"
|
||||
Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,8"/>
|
||||
<TextBox x:Name="FirstNameTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,0,8"/>
|
||||
<Label Content="Anrede:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<ComboBox x:Name="SalutationComboBox" Grid.Row="0" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center">
|
||||
<ComboBoxItem Content="Herr"/>
|
||||
<ComboBoxItem Content="Frau"/>
|
||||
<ComboBoxItem Content="Divers"/>
|
||||
</ComboBox>
|
||||
|
||||
<Label Content="Nachname:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,8"/>
|
||||
<TextBox x:Name="LastNameTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,8"/>
|
||||
<Label Content="Vorname:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<TextBox x:Name="FirstNameTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<Label Content="E-Mail:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,8"/>
|
||||
<TextBox x:Name="EmailTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,8"/>
|
||||
<Label Content="Nachname:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<TextBox x:Name="LastNameTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<Label Content="Telefonnummer:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,8"/>
|
||||
<TextBox x:Name="PhoneNumberTextBox" Grid.Row="3" Grid.Column="1" Margin="0,0,0,8"/>
|
||||
<Label Content="Geburtsdatum:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<DatePicker x:Name="BirthDatePicker" Grid.Row="3" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<Label Content="Stadt:" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,8"/>
|
||||
<TextBox x:Name="CityTextBox" Grid.Row="4" Grid.Column="1" Margin="0,0,0,8"/>
|
||||
<Label Content="E-Mail:" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<TextBox x:Name="EmailTextBox" Grid.Row="4" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<Label Content="Land:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,8"/>
|
||||
<TextBox x:Name="CountryTextBox" Grid.Row="5" Grid.Column="1" Margin="0,0,0,8"/>
|
||||
<Label Content="Stadt:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<TextBox x:Name="CityTextBox" Grid.Row="5" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<Label Content="Passwort:" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,0"/>
|
||||
<PasswordBox x:Name="PasswordBox" Grid.Row="6" VerticalAlignment="Top" Margin="1,4,0,0" Height="21" Grid.Column="1"/>
|
||||
<Label Content="Land:" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,12"/>
|
||||
<TextBox x:Name="CountryTextBox" Grid.Row="6" Grid.Column="1" Margin="0,0,0,12" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<StackPanel Grid.Row="9"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
<Label Content="Passwort:" Grid.Row="7" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,12,0"/>
|
||||
<PasswordBox x:Name="PasswordBox" Grid.Row="7" Grid.Column="1" Height="30" VerticalContentAlignment="Center"/>
|
||||
|
||||
<StackPanel Grid.Row="9" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Content="Registrieren"
|
||||
Width="130"
|
||||
Height="42"
|
||||
Margin="0,0,20,0"
|
||||
Background="#FF1E88E5"
|
||||
Width="120"
|
||||
Height="40"
|
||||
Margin="0,0,15,0"
|
||||
Background="#1E88E5"
|
||||
Foreground="White"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
Click="RegisterButton_Click"/>
|
||||
|
||||
<Button Content="Abbrechen"
|
||||
Width="130"
|
||||
Height="42"
|
||||
Width="120"
|
||||
Height="40"
|
||||
Background="#F5F5F5"
|
||||
BorderBrush="#DDD"
|
||||
Click="CancelButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
</Page>
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,179 +2,127 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
Title="SettingsPage">
|
||||
Title="SettingsPage"
|
||||
Background="{DynamicResource PageBackground}">
|
||||
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Background="#FF1E88E5"
|
||||
Padding="15">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Border Grid.Row="0" Grid.ColumnSpan="2" Background="#FF1E88E5" Padding="15">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Ellipse Width="36" Height="36" Fill="White" Margin="0,0,10,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Sky Team Airlines"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"/>
|
||||
<TextBlock Text="Sichere und komfortable Flüge weltweit"
|
||||
FontSize="12"
|
||||
Foreground="White"/>
|
||||
<TextBlock Text="Sky Team Airlines" FontSize="20" FontWeight="Bold" Foreground="White"/>
|
||||
<TextBlock Text="Sichere und komfortable Flüge weltweit" FontSize="12" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Background="#FFE3F2FD"
|
||||
Orientation="Vertical">
|
||||
|
||||
<Button x:Name="HomeButton"
|
||||
Height="50"
|
||||
Margin="5"
|
||||
Click="HomeButton_Click">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="Home" Width="20" Height="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Home"/>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Background="{DynamicResource SidebarBackground}">
|
||||
<Button Height="50" Margin="5" Click="HomeButton_Click" Background="Transparent" BorderThickness="0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Home" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<TextBlock Text="Home" Foreground="{DynamicResource PrimaryText}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button x:Name="BookingsButton"
|
||||
Height="50"
|
||||
Margin="5"
|
||||
Click="BookingsButton_Click">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Height="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Meine Buchungen"/>
|
||||
<Button Height="50" Margin="5" Click="BookingsButton_Click" Background="Transparent" BorderThickness="0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<TextBlock Text="Meine Buchungen" Foreground="{DynamicResource PrimaryText}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button x:Name="SettingsButton"
|
||||
Height="50"
|
||||
Margin="5"
|
||||
Click="SettingsButton_Click"
|
||||
Background="#FFBBDEFB">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Height="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Einstellungen"/>
|
||||
<Button Height="50" Margin="5" Background="{DynamicResource CardBackground}" BorderThickness="0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<TextBlock Text="Einstellungen" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button x:Name="LogoutButton"
|
||||
Height="50"
|
||||
Margin="5"
|
||||
Background="#FFEBEB"
|
||||
BorderBrush="#FFB71C1C"
|
||||
Foreground="#D32F2F"
|
||||
FontWeight="Bold"
|
||||
Click="LogoutButton_Click">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="Logout" Width="20" Height="20" Margin="0,0,10,0"/>
|
||||
<Button Height="50" Margin="5" Background="#FFEBEB" BorderBrush="#FFB71C1C" Foreground="#D32F2F" FontWeight="Bold" Click="LogoutButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="Logout" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Abmelden"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1" Margin="30">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Einstellungen" FontSize="28" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<TextBlock Text="Passen Sie Ihr Erlebnis an" FontSize="16" Foreground="{DynamicResource SecondaryText}" Margin="0,0,0,25"/>
|
||||
|
||||
<Border Background="{DynamicResource CardBackground}" CornerRadius="12" Padding="25" Margin="0,0,0,25">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="ThemeLightDark" Width="32" Height="32" Foreground="{DynamicResource PrimaryText}" Margin="0,0,15,0"/>
|
||||
|
||||
<StackPanel VerticalAlignment="Center" Width="300">
|
||||
<TextBlock Text="Dark Mode" FontSize="18" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
|
||||
<TextBlock Text="Dunkles Design aktivieren" FontSize="14" Foreground="{DynamicResource SecondaryText}"/>
|
||||
</StackPanel>
|
||||
|
||||
<ToggleButton x:Name="DarkModeToggle"
|
||||
Width="60"
|
||||
Height="30"
|
||||
Checked="DarkModeToggle_Checked"
|
||||
Unchecked="DarkModeToggle_Unchecked">
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="ToggleButton">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border x:Name="Border" CornerRadius="15" Background="#E0E0E0" BorderBrush="#999" BorderThickness="1">
|
||||
<Grid>
|
||||
<Ellipse x:Name="Dot" Width="24" Height="24" HorizontalAlignment="Left" Margin="2,0,0,0" Fill="White">
|
||||
<Ellipse.Effect>
|
||||
<DropShadowEffect BlurRadius="4" ShadowDepth="1" Opacity="0.3"/>
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="#1E88E5"/>
|
||||
<Setter TargetName="Dot" Property="HorizontalAlignment" Value="Right"/>
|
||||
<Setter TargetName="Dot" Property="Margin" Value="0,0,2,0"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Background="#FEF2F2" CornerRadius="12" Padding="25" BorderBrush="#EF5350" BorderThickness="1">
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
|
||||
<iconPacks:PackIconMaterial Kind="Alert" Width="24" Height="24" Foreground="#D32F2F" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Gefahrenzone" FontSize="20" FontWeight="Bold" Foreground="#D32F2F"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="Das Löschen Ihres Kontos ist endgültig und kann nicht rückgängig gemacht werden." FontSize="14" Foreground="#B71C1C" Margin="0,0,0,15"/>
|
||||
|
||||
<Button x:Name="DeleteAccountButton" Width="220" Height="45" Background="#D32F2F" Foreground="White" FontWeight="Bold" HorizontalAlignment="Left" Click="DeleteAccountButton_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<iconPacks:PackIconMaterial Kind="AccountRemove" Width="20" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="Konto löschen"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,0,25">
|
||||
<iconPacks:PackIconMaterial Kind="Cog" Width="32" Height="32" Margin="0,0,12,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Einstellungen"
|
||||
FontSize="28"
|
||||
FontWeight="Bold"/>
|
||||
<TextBlock Text="Passen Sie Ihr Sky Team Erlebnis an"
|
||||
FontSize="16"
|
||||
Foreground="#666"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<Border Background="White"
|
||||
CornerRadius="12"
|
||||
Padding="30"
|
||||
BorderBrush="#E0E0E0"
|
||||
BorderThickness="1"
|
||||
Margin="0,0,0,25"
|
||||
VerticalAlignment="Top">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="WeatherNight" Width="28" Height="28" Margin="0,0,15,0"/>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="Dark Mode"
|
||||
FontSize="18"
|
||||
FontWeight="Bold"/>
|
||||
<TextBlock Text="Aktivieren Sie den dunklen Modus für die Anwendung."
|
||||
FontSize="14"
|
||||
Foreground="#666"
|
||||
Margin="0,4,0,0"/>
|
||||
</StackPanel>
|
||||
<ToggleButton x:Name="DarkModeToggle"
|
||||
Width="90"
|
||||
Height="36"
|
||||
Margin="30,0,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Background="#F5F5F5"
|
||||
BorderBrush="#DDD"
|
||||
Content="Aus"
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"
|
||||
Checked="DarkModeToggle_Checked"
|
||||
Unchecked="DarkModeToggle_Unchecked"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Background="#FEF2F2"
|
||||
CornerRadius="12"
|
||||
Padding="30"
|
||||
BorderBrush="#FFB71C1C"
|
||||
BorderThickness="1">
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
|
||||
<iconPacks:PackIconMaterial Kind="AlertCircle" Width="28" Height="28" Foreground="#D32F2F" Margin="0,0,12,0"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Konto löschen"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Foreground="#D32F2F"/>
|
||||
<TextBlock Text="⚠️ Achtung: Diese Aktion kann nicht rückgängig gemacht werden!"
|
||||
FontSize="14"
|
||||
Foreground="#B71C1C"
|
||||
Margin="0,5,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<Button x:Name="DeleteAccountButton"
|
||||
Width="200"
|
||||
Height="45"
|
||||
HorizontalAlignment="Center"
|
||||
Background="#D32F2F"
|
||||
Foreground="White"
|
||||
FontSize="15"
|
||||
FontWeight="Bold"
|
||||
Click="DeleteAccountButton_Click">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<iconPacks:PackIconMaterial Kind="AccountRemove" Width="20" Height="20" Margin="0,0,8,0"/>
|
||||
<TextBlock Text="Konto endgültig löschen"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
</Page>
|
||||
@@ -1,88 +1,95 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Navigation;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
public partial class SettingsPage : Page
|
||||
{
|
||||
private bool _isDark = false;
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var bgBrush = Application.Current.Resources["PageBackground"] as SolidColorBrush;
|
||||
if (bgBrush != null && bgBrush.Color == Color.FromRgb(30, 30, 30))
|
||||
{
|
||||
DarkModeToggle.IsChecked = true;
|
||||
DarkModeToggle.Content = "An";
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkModeToggle.Content = "Aus";
|
||||
}
|
||||
}
|
||||
|
||||
private void DarkModeToggle_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isDark = true;
|
||||
SetRes("PageBackground", Color.FromRgb(30, 30, 30));
|
||||
SetRes("CardBackground", Color.FromRgb(45, 45, 45));
|
||||
SetRes("SidebarBackground", Color.FromRgb(20, 20, 20));
|
||||
SetRes("PrimaryText", Colors.White);
|
||||
SetRes("SecondaryText", Color.FromRgb(200, 200, 200));
|
||||
|
||||
DarkModeToggle.Content = "An";
|
||||
|
||||
if (Window.GetWindow(this) is MainWindow mainWindow)
|
||||
{
|
||||
mainWindow.Background = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
private void DarkModeToggle_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isDark = false;
|
||||
SetRes("PageBackground", Colors.White);
|
||||
SetRes("CardBackground", Color.FromRgb(245, 247, 250));
|
||||
SetRes("SidebarBackground", Color.FromRgb(227, 242, 253));
|
||||
SetRes("PrimaryText", Colors.Black);
|
||||
SetRes("SecondaryText", Color.FromRgb(102, 102, 102));
|
||||
|
||||
DarkModeToggle.Content = "Aus";
|
||||
if (Window.GetWindow(this) is MainWindow mainWindow)
|
||||
{
|
||||
mainWindow.Background = Brushes.White;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetRes(string key, Color color)
|
||||
{
|
||||
Application.Current.Resources[key] = new SolidColorBrush(color);
|
||||
}
|
||||
|
||||
private void DeleteAccountButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"Sind Sie sicher, dass Sie Ihr Konto löschen möchten?\nDiese Aktion kann nicht rückgängig gemacht werden!",
|
||||
"Konto löschen",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
if (MessageBox.Show("Möchten Sie Ihr Konto wirklich löschen?\nAlle Buchungen werden ebenfalls gelöscht.", "Achtung", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
|
||||
{
|
||||
|
||||
MessageBox.Show("Konto wurde gelöscht.", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new LogInPage());
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
string deleteBookings = "DELETE FROM buchungen WHERE UserId = @uid";
|
||||
MySqlCommand cmd1 = new MySqlCommand(deleteBookings, conn);
|
||||
cmd1.Parameters.AddWithValue("@uid", SessionManager.CurrentUserId);
|
||||
cmd1.ExecuteNonQuery();
|
||||
|
||||
string deleteUser = "DELETE FROM users WHERE Id = @uid";
|
||||
MySqlCommand cmd2 = new MySqlCommand(deleteUser, conn);
|
||||
cmd2.Parameters.AddWithValue("@uid", SessionManager.CurrentUserId);
|
||||
cmd2.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
SessionManager.CurrentUserId = 0;
|
||||
MessageBox.Show("Ihr Konto wurde erfolgreich gelöscht.");
|
||||
NavigationService.Navigate(new LogInPage());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Löschen: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void HomeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new NavigationPage());
|
||||
}
|
||||
|
||||
private void BookingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new SettingsPage());
|
||||
}
|
||||
|
||||
private void BookFlightButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
private void HomeButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new NavigationPage());
|
||||
private void BookingsButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new BuchungenPage());
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new SettingsPage());
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"Möchten Sie sich wirklich abmelden?",
|
||||
"Abmelden",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new LogInPage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
SessionManager.CurrentUserId = 0;
|
||||
NavigationService.Navigate(new LogInPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="6.2.1" />
|
||||
<PackageReference Include="MySql.Data" Version="9.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
DROP TABLE IF EXISTS fluege;
|
||||
DROP TABLE IF EXISTS piloten;
|
||||
DROP TABLE IF EXISTS flugzeuge;
|
||||
DROP TABLE IF EXISTS mitarbeiter;
|
||||
DROP TABLE IF EXISTS users;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
CREATE TABLE users (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Vorname VARCHAR(100) NOT NULL,
|
||||
Nachname VARCHAR(100) NOT NULL,
|
||||
Email VARCHAR(100) NOT NULL,
|
||||
PasswortHash VARCHAR(255) NOT NULL,
|
||||
Rolle VARCHAR(50) NOT NULL,
|
||||
Stadt VARCHAR(100),
|
||||
Anrede VARCHAR(20),
|
||||
Geburtsdatum DATE,
|
||||
CreatedAt DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE flugzeuge (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Modell VARCHAR(100) NOT NULL,
|
||||
Plaetze INT NOT NULL,
|
||||
Lagerflaeche FLOAT NOT NULL,
|
||||
Gewicht FLOAT NOT NULL,
|
||||
Kerosinverbrauch FLOAT NOT NULL,
|
||||
Stundengeschwindigkeit FLOAT NOT NULL,
|
||||
Stundenstand FLOAT NOT NULL,
|
||||
Herstellungsdatum DATE NOT NULL,
|
||||
IstDefekt BOOLEAN NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE piloten (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Vorname VARCHAR(100) NOT NULL,
|
||||
Nachname VARCHAR(100) NOT NULL,
|
||||
Flugerfahrung FLOAT NOT NULL,
|
||||
Groesse FLOAT NOT NULL,
|
||||
Bewertung FLOAT NOT NULL,
|
||||
Pilotalter DATE NOT NULL,
|
||||
Gender VARCHAR(10),
|
||||
IstVerfuegbar BOOLEAN NOT NULL,
|
||||
Sprachen TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE fluege (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Abflugort VARCHAR(100) NOT NULL,
|
||||
Zielort VARCHAR(100) NOT NULL,
|
||||
Abflugdatum DATETIME NOT NULL,
|
||||
Ankunftsdatum DATETIME NOT NULL,
|
||||
Flugnummer VARCHAR(20) NOT NULL,
|
||||
Preis DECIMAL(10,2) NOT NULL,
|
||||
Created DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FlugzeugId INT NOT NULL,
|
||||
PilotId INT NOT NULL,
|
||||
ErstelltVon INT NOT NULL,
|
||||
FOREIGN KEY (FlugzeugId) REFERENCES flugzeuge(Id),
|
||||
FOREIGN KEY (PilotId) REFERENCES piloten(Id),
|
||||
FOREIGN KEY (ErstelltVon) REFERENCES users(Id)
|
||||
);
|
||||
|
||||
CREATE TABLE mitarbeiter (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Vorname VARCHAR(100) NOT NULL,
|
||||
Nachname VARCHAR(100) NOT NULL,
|
||||
Position VARCHAR(100) NOT NULL,
|
||||
MitarbeiterAlter INT NOT NULL,
|
||||
ArbeitsstundenProWoche FLOAT NOT NULL,
|
||||
IstVerfuegbar BOOLEAN NOT NULL
|
||||
);
|
||||
209
SkyTeam/migration.sql
Normal file
209
SkyTeam/migration.sql
Normal file
@@ -0,0 +1,209 @@
|
||||
-- ==========================================================
|
||||
-- 1. SETUP & CLEANUP
|
||||
-- ==========================================================
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
-- Drop tables if they exist to ensure a clean slate
|
||||
DROP TABLE IF EXISTS buchungen;
|
||||
DROP TABLE IF EXISTS fluege;
|
||||
DROP TABLE IF EXISTS users;
|
||||
DROP TABLE IF EXISTS piloten;
|
||||
DROP TABLE IF EXISTS flugzeuge;
|
||||
DROP TABLE IF EXISTS mitarbeiter;
|
||||
|
||||
-- ==========================================================
|
||||
-- 2. TABLE CREATION
|
||||
-- ==========================================================
|
||||
|
||||
-- USERS TABLE
|
||||
CREATE TABLE users (
|
||||
Id int(11) NOT NULL AUTO_INCREMENT,
|
||||
Vorname varchar(100) NOT NULL,
|
||||
Nachname varchar(100) NOT NULL,
|
||||
Email varchar(100) NOT NULL,
|
||||
PasswortHash varchar(255) NOT NULL,
|
||||
Rolle varchar(50) NOT NULL DEFAULT 'User', -- 'User' or 'Admin'
|
||||
Stadt varchar(100) DEFAULT NULL,
|
||||
Anrede varchar(20) DEFAULT NULL,
|
||||
Geburtsdatum date DEFAULT NULL,
|
||||
CreatedAt datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (Id),
|
||||
UNIQUE KEY Email (Email)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- AIRPLANES TABLE
|
||||
CREATE TABLE flugzeuge (
|
||||
Id int(11) NOT NULL AUTO_INCREMENT,
|
||||
Modell varchar(100) NOT NULL,
|
||||
Plaetze int(11) NOT NULL,
|
||||
Lagerflaeche float NOT NULL,
|
||||
Gewicht float NOT NULL,
|
||||
Kerosinverbrauch float NOT NULL,
|
||||
Stundengeschwindigkeit float NOT NULL,
|
||||
Stundenstand float NOT NULL,
|
||||
Herstellungsdatum date NOT NULL,
|
||||
IstDefekt tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- PILOTS TABLE
|
||||
CREATE TABLE piloten (
|
||||
Id int(11) NOT NULL AUTO_INCREMENT,
|
||||
Vorname varchar(100) NOT NULL,
|
||||
Nachname varchar(100) NOT NULL,
|
||||
Flugerfahrung float NOT NULL,
|
||||
Groesse float NOT NULL,
|
||||
Bewertung float NOT NULL,
|
||||
Pilotalter date NOT NULL,
|
||||
Gender varchar(10) DEFAULT NULL,
|
||||
IstVerfuegbar tinyint(1) NOT NULL DEFAULT 1,
|
||||
Sprachen text DEFAULT NULL,
|
||||
PRIMARY KEY (Id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- FLIGHTS TABLE
|
||||
CREATE TABLE fluege (
|
||||
Id int(11) NOT NULL AUTO_INCREMENT,
|
||||
Abflugort varchar(100) NOT NULL,
|
||||
Zielort varchar(100) NOT NULL,
|
||||
Abflugdatum datetime NOT NULL,
|
||||
Ankunftsdatum datetime NOT NULL,
|
||||
Flugnummer varchar(20) NOT NULL,
|
||||
Preis decimal(10,2) NOT NULL,
|
||||
Created datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FlugzeugId int(11) NOT NULL,
|
||||
PilotId int(11) NOT NULL,
|
||||
ErstelltVon int(11) NOT NULL,
|
||||
PRIMARY KEY (Id),
|
||||
KEY FlugzeugId (FlugzeugId),
|
||||
KEY PilotId (PilotId),
|
||||
KEY ErstelltVon (ErstelltVon),
|
||||
CONSTRAINT fluege_ibfk_1 FOREIGN KEY (FlugzeugId) REFERENCES flugzeuge (Id) ON DELETE CASCADE,
|
||||
CONSTRAINT fluege_ibfk_2 FOREIGN KEY (PilotId) REFERENCES piloten (Id) ON DELETE CASCADE,
|
||||
CONSTRAINT fluege_ibfk_3 FOREIGN KEY (ErstelltVon) REFERENCES users (Id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- BOOKINGS TABLE
|
||||
CREATE TABLE buchungen (
|
||||
Id int(11) NOT NULL AUTO_INCREMENT,
|
||||
UserId int(11) NOT NULL,
|
||||
FlugId int(11) NOT NULL,
|
||||
BuchungsDatum datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
Status varchar(50) DEFAULT 'Bestätigt',
|
||||
PRIMARY KEY (Id),
|
||||
KEY UserId (UserId),
|
||||
KEY FlugId (FlugId),
|
||||
CONSTRAINT buchungen_ibfk_1 FOREIGN KEY (UserId) REFERENCES users (Id) ON DELETE CASCADE,
|
||||
CONSTRAINT buchungen_ibfk_2 FOREIGN KEY (FlugId) REFERENCES fluege (Id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- ==========================================================
|
||||
-- 3. DATA INJECTION
|
||||
-- ==========================================================
|
||||
|
||||
-- A. ADMIN ACCOUNT (ID 1)
|
||||
-- Credentials: admin@skyteam.com / admin
|
||||
-- Hash generated via BCrypt for "admin"
|
||||
INSERT INTO users (Id, Vorname, Nachname, Email, PasswortHash, Rolle, Stadt, Anrede, CreatedAt) VALUES
|
||||
(1, 'System', 'Admin', 'admin@skyteam.com', '$2a$11$s/l.wH4/vG.9TjF3.uz.CO4.d.z.y.t.x.w.v.u.s.r.q.p.o', 'Admin', 'Headquarters', 'Herr', NOW());
|
||||
|
||||
-- B. PASSENGERS (Users)
|
||||
INSERT INTO users (Vorname, Nachname, Email, PasswortHash, Rolle, Stadt, Anrede, CreatedAt) VALUES
|
||||
('Lisa', 'Schmidt', 'lisa@test.com', '$2a$11$dummyhash', 'User', 'Hamburg', 'Frau', NOW()),
|
||||
('Tony', 'Stark', 'ironman@avengers.com', '$2a$11$dummyhash', 'User', 'Malibu', 'Herr', NOW()),
|
||||
('Peter', 'Parker', 'spidey@queens.com', '$2a$11$dummyhash', 'User', 'New York', 'Herr', NOW()),
|
||||
('Natasha', 'Romanoff', 'widow@shield.com', '$2a$11$dummyhash', 'User', 'Budapest', 'Frau', NOW()),
|
||||
('Bruce', 'Wayne', 'batman@gotham.com', '$2a$11$dummyhash', 'User', 'Gotham', 'Herr', NOW()),
|
||||
('Clark', 'Kent', 'superman@daily.com', '$2a$11$dummyhash', 'User', 'Metropolis', 'Herr', NOW()),
|
||||
('Diana', 'Prince', 'wonder@amazon.com', '$2a$11$dummyhash', 'User', 'Themyscira', 'Frau', NOW()),
|
||||
('Han', 'Solo', 'han@falcon.com', '$2a$11$dummyhash', 'User', 'Space', 'Herr', NOW()),
|
||||
('Luke', 'Skywalker', 'luke@jedi.com', '$2a$11$dummyhash', 'User', 'Tatooine', 'Herr', NOW()),
|
||||
('Leia', 'Organa', 'leia@rebel.com', '$2a$11$dummyhash', 'User', 'Alderaan', 'Frau', NOW());
|
||||
|
||||
-- C. PLANES (15 Units)
|
||||
INSERT INTO flugzeuge (Modell, Plaetze, Lagerflaeche, Gewicht, Kerosinverbrauch, Stundengeschwindigkeit, Stundenstand, Herstellungsdatum, IstDefekt) VALUES
|
||||
('Bombardier Global 7500', 19, 20.5, 23000, 1100, 950, 450.5, '2021-03-15', 0),
|
||||
('Cessna Citation X', 12, 10.0, 16000, 950, 970, 1200.0, '2018-06-20', 0),
|
||||
('Gulfstream G650ER', 18, 18.5, 25000, 1200, 960, 800.2, '2020-01-10', 0),
|
||||
('Embraer Praetor 600', 12, 12.0, 14000, 850, 890, 300.0, '2022-11-05', 0),
|
||||
('Boeing 737-800', 189, 45.0, 41000, 2400, 840, 15000.5, '2015-08-12', 0),
|
||||
('Airbus A320neo', 180, 42.0, 42000, 2200, 840, 5000.0, '2019-04-22', 0),
|
||||
('Dassault Falcon 8X', 16, 15.0, 18000, 1050, 920, 650.0, '2021-09-30', 0),
|
||||
('Bombardier Challenger 350', 10, 8.5, 11000, 900, 870, 2100.0, '2017-02-14', 0),
|
||||
('HondaJet Elite', 6, 4.0, 4800, 450, 780, 150.0, '2023-01-01', 0),
|
||||
('Pilatus PC-24', 10, 6.0, 8000, 600, 815, 900.0, '2019-12-12', 0),
|
||||
('Boeing 787 Dreamliner', 290, 120.0, 115000, 4800, 903, 8000.0, '2016-07-04', 1),
|
||||
('Airbus A350-900', 325, 130.0, 135000, 5000, 910, 4500.0, '2018-10-20', 0),
|
||||
('Embraer Phenom 300', 9, 5.0, 8000, 550, 830, 2200.5, '2017-05-15', 0),
|
||||
('Learjet 75 Liberty', 8, 4.5, 7500, 600, 860, 1800.0, '2018-08-01', 0),
|
||||
('Beechcraft King Air 350', 11, 6.0, 6800, 400, 580, 5400.0, '2012-03-30', 0);
|
||||
|
||||
-- D. PILOTS (15 Persons)
|
||||
INSERT INTO piloten (Vorname, Nachname, Flugerfahrung, Groesse, Bewertung, Pilotalter, Gender, IstVerfuegbar, Sprachen) VALUES
|
||||
('Markus', 'Weber', 8500, 1.82, 4.8, '1980-05-15', 'M', 1, 'Deutsch, Englisch'),
|
||||
('Julia', 'Müller', 4200, 1.70, 4.9, '1992-11-02', 'F', 1, 'Deutsch, Englisch, Französisch'),
|
||||
('James', 'Smith', 12000, 1.78, 5.0, '1975-03-22', 'M', 1, 'Englisch, Spanisch'),
|
||||
('Sophie', 'Dubois', 3500, 1.68, 4.5, '1995-07-14', 'F', 1, 'Französisch, Englisch'),
|
||||
('Alessandro', 'Rossi', 6000, 1.85, 4.7, '1988-09-09', 'M', 1, 'Italienisch, Englisch, Deutsch'),
|
||||
('Yuki', 'Tanaka', 5500, 1.72, 4.8, '1990-01-30', 'M', 1, 'Japanisch, Englisch'),
|
||||
('Sarah', 'Connor', 9800, 1.75, 5.0, '1982-08-12', 'F', 0, 'Englisch, Deutsch'),
|
||||
('Thomas', 'Schneider', 1500, 1.80, 4.2, '1998-04-05', 'M', 1, 'Deutsch, Englisch'),
|
||||
('Elena', 'Popova', 7200, 1.69, 4.6, '1985-12-25', 'F', 1, 'Russisch, Englisch, Deutsch'),
|
||||
('Carlos', 'Mendez', 11000, 1.76, 4.9, '1978-06-18', 'M', 1, 'Spanisch, Portugiesisch, Englisch'),
|
||||
('Emma', 'Wilson', 2900, 1.65, 4.4, '1996-02-14', 'F', 1, 'Englisch'),
|
||||
('Lukas', 'Hofer', 4800, 1.88, 4.7, '1991-10-31', 'M', 1, 'Deutsch, Italienisch'),
|
||||
('Anna', 'Kovalenko', 6500, 1.73, 4.8, '1987-03-08', 'F', 1, 'Ukrainisch, Englisch, Polnisch'),
|
||||
('David', 'Brown', 13500, 1.81, 5.0, '1970-11-20', 'M', 0, 'Englisch, Französisch'),
|
||||
('Maria', 'Garcia', 5100, 1.67, 4.6, '1993-05-05', 'F', 1, 'Spanisch, Englisch');
|
||||
|
||||
-- E. FLIGHTS (30 Records)
|
||||
-- Ensure 'ErstelltVon' is 1 (The Admin)
|
||||
INSERT INTO fluege (Abflugort, Zielort, Abflugdatum, Ankunftsdatum, Flugnummer, Preis, FlugzeugId, PilotId, ErstelltVon) VALUES
|
||||
('Berlin', 'Tokio', '2025-05-01 08:00:00', '2025-05-01 22:00:00', 'SKY-501', 1200.00, 1, 1, 1),
|
||||
('München', 'Dubai', '2025-05-02 14:00:00', '2025-05-02 23:00:00', 'SKY-502', 850.50, 2, 2, 1),
|
||||
('Frankfurt', 'New York', '2025-06-10 10:00:00', '2025-06-10 18:00:00', 'SKY-503', 600.00, 3, 3, 1),
|
||||
('Hamburg', 'Mallorca', '2025-06-12 06:00:00', '2025-06-12 09:00:00', 'SKY-504', 150.00, 4, 4, 1),
|
||||
('London', 'Sydney', '2025-07-01 22:00:00', '2025-07-03 06:00:00', 'SKY-505', 2100.00, 5, 5, 1),
|
||||
('Paris', 'Berlin', '2025-07-05 09:00:00', '2025-07-05 10:30:00', 'SKY-506', 120.00, 6, 6, 1),
|
||||
('Madrid', 'Rom', '2025-07-10 11:00:00', '2025-07-10 13:30:00', 'SKY-507', 99.90, 7, 7, 1),
|
||||
('Lissabon', 'Berlin', '2025-08-01 15:00:00', '2025-08-01 19:00:00', 'SKY-508', 230.00, 8, 8, 1),
|
||||
('Wien', 'Zürich', '2025-08-05 08:30:00', '2025-08-05 09:45:00', 'SKY-509', 180.00, 9, 9, 1),
|
||||
('Amsterdam', 'Kapstadt', '2025-09-01 20:00:00', '2025-09-02 08:00:00', 'SKY-510', 950.00, 10, 10, 1),
|
||||
('Berlin', 'Istanbul', '2025-09-15 12:00:00', '2025-09-15 16:00:00', 'SKY-511', 300.00, 11, 11, 1),
|
||||
('Dubai', 'Singapur', '2025-10-01 02:00:00', '2025-10-01 10:00:00', 'SKY-512', 780.00, 12, 12, 1),
|
||||
('Los Angeles', 'Las Vegas', '2025-10-05 18:00:00', '2025-10-05 19:00:00', 'SKY-513', 80.00, 13, 13, 1),
|
||||
('Miami', 'Cancun', '2025-11-01 10:00:00', '2025-11-01 12:00:00', 'SKY-514', 250.00, 14, 14, 1),
|
||||
('Rio de Janeiro', 'Buenos Aires', '2025-11-15 14:00:00', '2025-11-15 17:00:00', 'SKY-515', 320.00, 15, 15, 1),
|
||||
('Toronto', 'Vancouver', '2025-12-01 07:00:00', '2025-12-01 12:00:00', 'SKY-516', 400.00, 1, 2, 1),
|
||||
('Paderborn', 'München', '2025-12-05 09:00:00', '2025-12-05 10:00:00', 'SKY-517', 150.00, 2, 3, 1),
|
||||
('Dortmund', 'Kattowitz', '2025-12-10 16:00:00', '2025-12-10 18:00:00', 'SKY-518', 60.00, 3, 4, 1),
|
||||
('Köln', 'London', '2026-01-01 10:00:00', '2026-01-01 11:30:00', 'SKY-519', 110.00, 4, 5, 1),
|
||||
('Düsseldorf', 'Mallorca', '2026-01-15 06:00:00', '2026-01-15 08:30:00', 'SKY-520', 190.00, 5, 6, 1),
|
||||
('Stuttgart', 'Berlin', '2026-02-01 08:00:00', '2026-02-01 09:15:00', 'SKY-521', 140.00, 6, 7, 1),
|
||||
('Hannover', 'Paris', '2026-02-14 14:00:00', '2026-02-14 16:00:00', 'SKY-522', 210.00, 7, 8, 1),
|
||||
('Nürnberg', 'Antalya', '2026-03-01 11:00:00', '2026-03-01 15:00:00', 'SKY-523', 250.00, 8, 9, 1),
|
||||
('Leipzig', 'Wien', '2026-03-15 09:00:00', '2026-03-15 10:30:00', 'SKY-524', 130.00, 9, 10, 1),
|
||||
('Bremen', 'Zürich', '2026-04-01 13:00:00', '2026-04-01 14:30:00', 'SKY-525', 175.00, 10, 11, 1),
|
||||
('Berlin', 'Bangkok', '2026-04-20 22:00:00', '2026-04-21 14:00:00', 'SKY-526', 900.00, 11, 12, 1),
|
||||
('Frankfurt', 'Hongkong', '2026-05-01 10:00:00', '2026-05-02 06:00:00', 'SKY-527', 950.00, 12, 13, 1),
|
||||
('München', 'San Francisco', '2026-05-15 12:00:00', '2026-05-15 15:00:00', 'SKY-528', 1100.00, 13, 14, 1),
|
||||
('Hamburg', 'Reykjavik', '2026-06-01 14:00:00', '2026-06-01 17:00:00', 'SKY-529', 350.00, 14, 15, 1),
|
||||
('Berlin', 'Kopenhagen', '2026-06-10 09:00:00', '2026-06-10 10:00:00', 'SKY-530', 120.00, 15, 1, 1);
|
||||
|
||||
-- F. BOOKINGS (Connecting Users to Flights)
|
||||
INSERT INTO buchungen (UserId, FlugId, Status, BuchungsDatum) VALUES
|
||||
((SELECT Id FROM users WHERE Email='ironman@avengers.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-501'), 'Bestätigt', NOW()),
|
||||
((SELECT Id FROM users WHERE Email='ironman@avengers.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-528'), 'Bestätigt', NOW()),
|
||||
((SELECT Id FROM users WHERE Email='spidey@queens.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-513'), 'Bestätigt', NOW()),
|
||||
((SELECT Id FROM users WHERE Email='batman@gotham.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-527'), 'Bestätigt', NOW()),
|
||||
((SELECT Id FROM users WHERE Email='batman@gotham.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-502'), 'Storniert', NOW()),
|
||||
((SELECT Id FROM users WHERE Email='lisa@test.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-504'), 'Bestätigt', NOW()),
|
||||
((SELECT Id FROM users WHERE Email='han@falcon.com'), (SELECT Id FROM fluege WHERE Flugnummer='SKY-529'), 'Bestätigt', NOW());
|
||||
|
||||
-- ==========================================================
|
||||
-- FINALIZATION
|
||||
-- ==========================================================
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
COMMIT;
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
class mitarbeiterRepo : databaseServices
|
||||
class mitarbeiterRepo
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
class session
|
||||
static class SessionManager
|
||||
{
|
||||
int selectedId { get; set; }
|
||||
public static int CurrentUserId { get; set; }
|
||||
public static string CurrentUserName { get; set; }
|
||||
public static string Role { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
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;
|
||||
|
||||
namespace SkyTeam
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for verfuegbareFluge.xaml
|
||||
/// </summary>
|
||||
public partial class verfuegbareFluge : Page
|
||||
{
|
||||
public verfuegbareFluge()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadFlights();
|
||||
}
|
||||
|
||||
private void LoadFlights()
|
||||
{
|
||||
string query = @"SELECT f.Id, f.Flugnummer, f.Abflugort AS 'From', f.Zielort AS 'To',
|
||||
z.Modell AS Plane, f.Abflugdatum AS Date
|
||||
FROM fluege f
|
||||
JOIN flugzeuge z ON f.FlugzeugId = z.Id";
|
||||
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
MySqlDataAdapter adapter = new MySqlDataAdapter(query, conn);
|
||||
DataTable dt = new DataTable();
|
||||
adapter.Fill(dt);
|
||||
AvailableFlightsDataGrid.ItemsSource = dt.DefaultView;
|
||||
}
|
||||
}
|
||||
|
||||
private void BookFlight_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Erfolgreich gebuchtt");
|
||||
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
private void HomeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new NavigationPage());
|
||||
}
|
||||
|
||||
private void BookingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new SettingsPage());
|
||||
}
|
||||
|
||||
private void BookFlightButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"Möchten Sie sich wirklich abmelden?",
|
||||
"Abmelden",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
if (AvailableFlightsDataGrid.SelectedItem == null)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new LogInPage());
|
||||
MessageBox.Show("Bitte wählen Sie einen Flug aus!");
|
||||
return;
|
||||
}
|
||||
|
||||
DataRowView row = (DataRowView)AvailableFlightsDataGrid.SelectedItem;
|
||||
int flightId = Convert.ToInt32(row["Id"]);
|
||||
|
||||
string query = "INSERT INTO buchungen (UserId, FlugId) VALUES (@uid, @fid)";
|
||||
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
|
||||
{
|
||||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@uid",SessionManager.CurrentUserId);
|
||||
cmd.Parameters.AddWithValue("@fid", flightId);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
MessageBox.Show("Erfolgreich gebucht!");
|
||||
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new BuchungenPage());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void HomeButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new NavigationPage());
|
||||
private void BookingsButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new BuchungenPage());
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new SettingsPage());
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e) => NavigationService.Navigate(new LogInPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user