fix von viel errors in GUI und logik dahinter

This commit is contained in:
younes elhaddoury
2026-02-04 14:57:59 +01:00
parent a76ddb3acd
commit 57735cdf93
15 changed files with 355 additions and 416 deletions

View File

@@ -105,6 +105,7 @@
<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">
@@ -124,12 +125,50 @@
<StackPanel Margin="5">
<Label Content="Von:"/>
<TextBox x:Name="AddFromTxt"/>
<ComboBox x:Name="AddFromCombo" IsEditable="True">
<ComboBoxItem Content="Berlin"/>
<ComboBoxItem Content="München"/>
<ComboBoxItem Content="Frankfurt"/>
<ComboBoxItem Content="Hamburg"/>
<ComboBoxItem Content="Paris"/>
<ComboBoxItem Content="London"/>
<ComboBoxItem Content="Madrid"/>
<ComboBoxItem Content="Rom"/>
<ComboBoxItem Content="Lissabon"/>
<ComboBoxItem Content="Wien"/>
<ComboBoxItem Content="Zürich"/>
<ComboBoxItem Content="Amsterdam"/>
<ComboBoxItem Content="Prag"/>
<ComboBoxItem Content="Budapest"/>
<ComboBoxItem Content="Warschau"/>
<ComboBoxItem Content="Paderborn"/>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="1" Margin="5">
<Label Content="Nach:"/>
<TextBox x:Name="AddToTxt"/>
<ComboBox x:Name="AddToCombo" IsEditable="True">
<ComboBoxItem Content="Mallorca"/>
<ComboBoxItem Content="Berlin"/>
<ComboBoxItem Content="München"/>
<ComboBoxItem Content="Frankfurt"/>
<ComboBoxItem Content="Hamburg"/>
<ComboBoxItem Content="Paris"/>
<ComboBoxItem Content="London"/>
<ComboBoxItem Content="Madrid"/>
<ComboBoxItem Content="Rom"/>
<ComboBoxItem Content="Lissabon"/>
<ComboBoxItem Content="Wien"/>
<ComboBoxItem Content="Zürich"/>
<ComboBoxItem Content="Amsterdam"/>
<ComboBoxItem Content="Prag"/>
<ComboBoxItem Content="Budapest"/>
<ComboBoxItem Content="Tokio"/>
<ComboBoxItem Content="New York"/>
<ComboBoxItem Content="Dubai"/>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="2" Margin="5">
<Label Content="Datum:"/>
<DatePicker x:Name="AddDatePick"/>

View File

@@ -2,6 +2,7 @@
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using MySql.Data.MySqlClient;
namespace SkyTeam
@@ -37,7 +38,6 @@ namespace SkyTeam
if (MessageBox.Show($"User {uid} löschen?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
ExecuteSql($"DELETE FROM users WHERE Id={uid}");
LoadUsers();
UserBookingsGrid.ItemsSource = null;
@@ -46,8 +46,12 @@ namespace SkyTeam
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";
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);
}
@@ -64,17 +68,19 @@ namespace SkyTeam
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)
if (string.IsNullOrWhiteSpace(AddFromCombo.Text) ||
string.IsNullOrWhiteSpace(AddToCombo.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;
}
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)
@@ -86,15 +92,14 @@ namespace SkyTeam
{
conn.Open();
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@from", AddFromTxt.Text);
cmd.Parameters.AddWithValue("@to", AddToTxt.Text);
cmd.Parameters.AddWithValue("@from", AddFromCombo.Text);
cmd.Parameters.AddWithValue("@to", AddToCombo.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();
@@ -110,21 +115,39 @@ namespace SkyTeam
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()); }
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;
LoadFlights();
}
private void Logout_Click(object sender, RoutedEventArgs e)
{
SessionManager.CurrentUserId = 0;
NavigationService.Navigate(new LogInPage());
}
}
}

View File

@@ -26,24 +26,28 @@
</Border>
<StackPanel Grid.Row="1" Grid.Column="0" Background="{DynamicResource SidebarBackground}">
<Button Height="50" Margin="5" Click="HomeButton_Click">
<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"/>
<TextBlock Text="Home"/>
<iconPacks:PackIconMaterial Kind="Home" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Home" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<Button Height="50" Margin="5" Background="#FFBBDEFB" Click="BookingsButton_Click">
<Button Height="50" Margin="5" Click="BookingsButton_Click" Background="{DynamicResource CardBackground}" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0"/>
<TextBlock Text="Meine Buchungen"/>
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Meine Buchungen" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<Button Height="50" Margin="5" Click="SettingsButton_Click">
<Button Height="50" Margin="5" Click="SettingsButton_Click" Background="Transparent" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0"/>
<TextBlock Text="Einstellungen"/>
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Einstellungen" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<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"/>
@@ -65,7 +69,14 @@
</StackPanel>
</Border>
<DataGrid x:Name="BookingsGrid" Visibility="Collapsed" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="True" Height="400" Background="{DynamicResource CardBackground}">
<DataGrid x:Name="BookingsGrid"
Visibility="Collapsed"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
Height="400"
Background="{DynamicResource CardBackground}"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Header="Buchungs ID" Binding="{Binding BuchungId}" Width="80"/>
<DataGridTextColumn Header="Flug Nr." Binding="{Binding Flugnummer}" Width="*"/>

View File

@@ -10,7 +10,7 @@ namespace SkyTeam
static class DatenbankServices
{
// 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;";
private static readonly string connectionString ="Server=mysql.pb.bib.de;uid=pbt3h24akh;pwd=Dd3dwQgPeNxW;database=pbt3h24akh_SkyTeam;";
public static string GetConnection()
{

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SkyTeam
{
class FlugeRepo
{
}
}

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SkyTeam
{
class FlugzeugRepo
{
}
}

View File

@@ -2,150 +2,77 @@
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="NavigationPage">
Title="NavigationPage"
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">
<Ellipse Width="36"
Height="36"
Fill="White"
Margin="0,0,10,0"/>
<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">
<StackPanel Grid.Row="1" Grid.Column="0" Background="{DynamicResource SidebarBackground}">
<Button x:Name="HomeButton"
Height="50"
Margin="5"
Click="HomeButton_Click"
Background="#FFBBDEFB">
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center">
<iconPacks:PackIconMaterial Kind="Home"
Width="20"
Height="20"
Margin="0,0,10,0"/>
<TextBlock Text="Home"/>
<Button x:Name="HomeButton" Height="50" Margin="5" Click="HomeButton_Click" Background="{DynamicResource CardBackground}" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Home" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Home" FontWeight="Bold" 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 x:Name="BookingsButton" 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">
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center">
<iconPacks:PackIconMaterial Kind="Cog"
Width="20"
Height="20"
Margin="0,0,10,0"/>
<TextBlock Text="Einstellungen"/>
<Button x:Name="SettingsButton" Height="50" Margin="5" Click="SettingsButton_Click" Background="Transparent" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Einstellungen" 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 x:Name="LogoutButton" 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>
<ScrollViewer Grid.Row="1"
Grid.Column="1"
Margin="30"
VerticalScrollBarVisibility="Auto">
<ScrollViewer Grid.Row="1" Grid.Column="1" Margin="30" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="0,0,0,30">
<StackPanel Orientation="Horizontal"
Margin="0,0,0,30">
<iconPacks:PackIconMaterial Kind="AirplaneTakeoff"
Width="48"
Height="48"
Margin="0,0,15,0"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,30">
<iconPacks:PackIconMaterial Kind="AirplaneTakeoff" Width="48" Height="48" Foreground="{DynamicResource PrimaryText}" Margin="0,0,15,0"/>
<StackPanel>
<TextBlock Text="Willkommen bei Sky Team Airlines"
FontSize="28"
FontWeight="Bold"/>
<TextBlock Text="Exklusive Flugservices für Privatzylinder"
FontSize="16"
Foreground="Gray"/>
<TextBlock Text="Willkommen bei Sky Team Airlines" FontSize="28" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Exklusive Flugservices für Privatjets" FontSize="16" Foreground="{DynamicResource SecondaryText}"/>
</StackPanel>
</StackPanel>
<Border Background="#F8F9FA"
Padding="25"
CornerRadius="8"
Margin="0,0,0,25">
<TextBlock Text="Sky Team Airlines bietet konfortable Veranstaltung von Privatjets für Geschäftsreisende. Unsere moderne Flotte mit den neuesten Businessjets garantiert Ihnen maximale Komfort auf Ihren Flügen."
FontSize="14"
LineHeight="22"
TextWrapping="Wrap"/>
<Border Background="{DynamicResource CardBackground}" Padding="25" CornerRadius="8" Margin="0,0,0,25">
<TextBlock Text="Sky Team Airlines bietet komfortable Veranstaltung von Privatjets für Geschäftsreisende. Unsere moderne Flotte mit den neuesten Businessjets garantiert Ihnen maximalen Komfort auf Ihren Flügen."
FontSize="14" LineHeight="22" TextWrapping="Wrap" Foreground="{DynamicResource PrimaryText}"/>
</Border>
<TextBlock Text="Unsere Services"
FontSize="20"
FontWeight="Bold"
Margin="0,0,15,0"/>
<TextBlock Text="Unsere Services" FontSize="20" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" Margin="0,0,15,0"/>
<Grid>
<Grid.ColumnDefinitions>
@@ -153,63 +80,27 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0"
Margin="0,0,15,0"
Padding="20"
Background="#E3F2FD"
CornerRadius="8">
<Border Grid.Column="0" Margin="0,0,15,0" Padding="20" Background="{DynamicResource CardBackground}" CornerRadius="8">
<StackPanel>
<iconPacks:PackIconMaterial Kind="AccountGroup"
Width="32"
Height="32"
Foreground="#1E88E5"/>
<TextBlock Text="Persönliche Kundenbetreuung"
FontSize="16"
FontWeight="Bold"
Margin="0,10,0,5"/>
<TextBlock Text="Dedizierte Flugplanung und individuelle Bedürfnisse"
FontSize="13"
Foreground="Gray"
TextWrapping="Wrap"/>
<iconPacks:PackIconMaterial Kind="AccountGroup" Width="32" Height="32" Foreground="#1E88E5"/>
<TextBlock Text="Persönliche Kundenbetreuung" FontSize="16" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" Margin="0,10,0,5"/>
<TextBlock Text="Dedizierte Flugplanung und individuelle Bedürfnisse" FontSize="13" Foreground="{DynamicResource SecondaryText}" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Border Grid.Column="1"
Padding="20"
Background="#E8F5E8"
CornerRadius="8">
<Border Grid.Column="1" Padding="20" Background="{DynamicResource CardBackground}" CornerRadius="8">
<StackPanel>
<iconPacks:PackIconMaterial Kind="Database"
Width="32"
Height="32"
Foreground="#388E3C"/>
<TextBlock Text="Sichere Datenverwaltung"
FontSize="16"
FontWeight="Bold"
Margin="0,10,0,5"/>
<TextBlock Text="Vollständiger CRUD für Kunden, Flüge, Piloten"
FontSize="13"
Foreground="Gray"
TextWrapping="Wrap"/>
<iconPacks:PackIconMaterial Kind="Database" Width="32" Height="32" Foreground="#388E3C"/>
<TextBlock Text="Sichere Datenverwaltung" FontSize="16" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" Margin="0,10,0,5"/>
<TextBlock Text="Vollständiger CRUD für Kunden, Flüge, Piloten" FontSize="13" Foreground="{DynamicResource SecondaryText}" TextWrapping="Wrap"/>
</StackPanel>
</Border>
</Grid>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="0,40,0,0">
<Button Width="200"
Height="50"
Background="#FF1E88E5"
Foreground="White"
FontSize="16"
FontWeight="Bold"
Click="BookFlightButton_Click">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,40,0,0">
<Button Width="200" Height="50" Background="#FF1E88E5" Foreground="White" FontSize="16" FontWeight="Bold" Click="BookFlightButton_Click">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Airplane"
Width="24"
Height="24"
Margin="0,0,12,0"/>
<iconPacks:PackIconMaterial Kind="Airplane" Width="24" Height="24" Margin="0,0,12,0"/>
<TextBlock Text="Jetzt Flug buchen"/>
</StackPanel>
</Button>
@@ -217,6 +108,5 @@
</StackPanel>
</ScrollViewer>
</Grid>
</Page>

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SkyTeam
{
class PilotenRepo
{
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Text.RegularExpressions;
using MySql.Data.MySqlClient;
using BCrypt.Net;
@@ -15,33 +16,54 @@ namespace SkyTeam
private void RegisterButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(PasswordBox.Password))
if (string.IsNullOrWhiteSpace(EmailTextBox.Text) || string.IsNullOrWhiteSpace(PasswordBox.Password))
{
MessageBox.Show("Bitte geben Sie ein Passwort ein.");
MessageBox.Show("Bitte geben Sie Email und Passwort ein.");
return;
}
string hashedPassword = BCrypt.Net.BCrypt.HashPassword(PasswordBox.Password);
if (!IsValidEmail(EmailTextBox.Text))
{
MessageBox.Show("Bitte geben Sie eine gültige E-Mail-Adresse ein (z.B. name@domain.com).");
return;
}
string query = "INSERT INTO users (Vorname, Nachname, Email, PasswortHash, Rolle, Stadt, Anrede, Geburtsdatum) " +
"VALUES (@vorname, @nachname, @email, @password, 'User', @stadt, @anrede, @geburtsdatum)";
string emailToCheck = EmailTextBox.Text;
try
{
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand(query, conn))
string checkQuery = "SELECT COUNT(*) FROM users WHERE Email = @email";
using (MySqlCommand checkCmd = new MySqlCommand(checkQuery, conn))
{
checkCmd.Parameters.AddWithValue("@email", emailToCheck);
long userCount = (long)checkCmd.ExecuteScalar();
if (userCount > 0)
{
MessageBox.Show("Sie haben bereits ein Konto mit dieser E-Mail. Bitte löschen Sie es, bevor Sie ein neues erstellen.",
"Konto existiert bereits", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
string hashedPassword = BCrypt.Net.BCrypt.HashPassword(PasswordBox.Password);
string insertQuery = "INSERT INTO users (Vorname, Nachname, Email, PasswortHash, Rolle, Stadt, Anrede, Geburtsdatum) " +
"VALUES (@vorname, @nachname, @email, @password, 'User', @stadt, @anrede, @geburtsdatum)";
using (MySqlCommand cmd = new MySqlCommand(insertQuery, 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("@email", emailToCheck);
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);
@@ -69,5 +91,22 @@ namespace SkyTeam
mainWindow.MainFrame.Navigate(new LogInPage());
}
}
private bool IsValidEmail(string email)
{
if (string.IsNullOrWhiteSpace(email))
return false;
try
{
return Regex.IsMatch(email,
@"^[^@\s]+@[^@\s]+\.[^@\s]+$",
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
}
catch (RegexMatchTimeoutException)
{
return false;
}
}
}
}

View File

@@ -26,6 +26,7 @@
</Border>
<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}"/>
@@ -69,11 +70,7 @@
<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 x:Name="DarkModeToggle" Width="60" Height="30" Checked="DarkModeToggle_Checked" Unchecked="DarkModeToggle_Unchecked">
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="Template">

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SkyTeam
{
class mitarbeiterRepo
{
}
}

View File

@@ -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="ReservierungssuchePage">
Title="ReservierungssuchePage"
Background="{DynamicResource PageBackground}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
@@ -16,95 +16,100 @@
<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">
<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"/>
<TextBlock Text="Home"/>
<iconPacks:PackIconMaterial Kind="Home" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Home" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<Button Height="50" Margin="5" Click="BookingsButton_Click">
<Button Height="50" Margin="5" Click="BookingsButton_Click" Background="{DynamicResource CardBackground}" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0"/>
<TextBlock Text="Meine Buchungen"/>
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Meine Buchungen" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<Button Height="50" Margin="5" Click="SettingsButton_Click">
<Button Height="50" Margin="5" Click="SettingsButton_Click" Background="Transparent" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0"/>
<TextBlock Text="Einstellungen"/>
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Einstellungen" Foreground="{DynamicResource PrimaryText}"/>
</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 Margin="0,0,0,25">
<TextBlock Text="Flug suchen"
FontSize="28"
FontWeight="Bold"/>
<TextBlock Text="Datum und Strecke eingeben"
FontSize="16"
Foreground="#666"/>
<TextBlock Text="Flug suchen" FontSize="28" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Wählen Sie Ihr Ziel aus der Liste" FontSize="16" Foreground="{DynamicResource SecondaryText}"/>
</StackPanel>
<Border Background="#F5F7FA"
CornerRadius="12"
Padding="30">
<Border Background="{DynamicResource CardBackground}" CornerRadius="12" Padding="30">
<StackPanel Width="350">
<TextBlock Text="Von"
FontWeight="SemiBold"
Margin="0,0,0,5"/>
<TextBox Height="40" Margin="0,0,0,15"/>
<TextBlock Text="Von" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="{DynamicResource PrimaryText}"/>
<ComboBox x:Name="FromBox" Height="40" Margin="0,0,0,15" IsEditable="True">
<ComboBoxItem Content="Berlin"/>
<ComboBoxItem Content="München"/>
<ComboBoxItem Content="Frankfurt"/>
<ComboBoxItem Content="Hamburg"/>
<ComboBoxItem Content="Paris"/>
<ComboBoxItem Content="London"/>
<ComboBoxItem Content="Madrid"/>
<ComboBoxItem Content="Rom"/>
<ComboBoxItem Content="Lissabon"/>
<ComboBoxItem Content="Wien"/>
<ComboBoxItem Content="Zürich"/>
<ComboBoxItem Content="Amsterdam"/>
<ComboBoxItem Content="Prag"/>
<ComboBoxItem Content="Budapest"/>
<ComboBoxItem Content="Warschau"/>
<ComboBoxItem Content="Paderborn"/>
</ComboBox>
<TextBlock Text="Nach"
FontWeight="SemiBold"
Margin="0,0,0,5"/>
<TextBox Height="40" Margin="0,0,0,15"/>
<TextBlock Text="Nach" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="{DynamicResource PrimaryText}"/>
<ComboBox x:Name="ToBox" Height="40" Margin="0,0,0,15" IsEditable="True">
<ComboBoxItem Content="Mallorca"/>
<ComboBoxItem Content="Berlin"/>
<ComboBoxItem Content="München"/>
<ComboBoxItem Content="Frankfurt"/>
<ComboBoxItem Content="Hamburg"/>
<ComboBoxItem Content="Paris"/>
<ComboBoxItem Content="London"/>
<ComboBoxItem Content="Madrid"/>
<ComboBoxItem Content="Rom"/>
<ComboBoxItem Content="Lissabon"/>
<ComboBoxItem Content="Wien"/>
<ComboBoxItem Content="Zürich"/>
<ComboBoxItem Content="Amsterdam"/>
<ComboBoxItem Content="Prag"/>
<ComboBoxItem Content="Budapest"/>
<ComboBoxItem Content="Tokio"/>
<ComboBoxItem Content="New York"/>
<ComboBoxItem Content="Dubai"/>
</ComboBox>
<TextBlock Text="Abflugdatum"
FontWeight="SemiBold"
Margin="0,0,0,5"/>
<DatePicker Height="40" Margin="0,0,0,25"/>
<TextBlock Text="Abflugdatum" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="{DynamicResource PrimaryText}"/>
<DatePicker x:Name="DateBox" Height="40" Margin="0,0,0,25"/>
<Button Content="Flüge suchen"
Height="45"
@@ -113,10 +118,7 @@
Foreground="White"
Click="SearchFlights_Click"/>
</StackPanel>
</Border>
</Grid>
</Grid>
</Page>

View File

@@ -1,21 +1,10 @@
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;
namespace SkyTeam
{
public partial class ReservierungssuchePage : Page
{
public ReservierungssuchePage()
@@ -23,42 +12,19 @@ namespace SkyTeam
InitializeComponent();
}
private void SearchFlights_Click(object sender, RoutedEventArgs e)
{
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new verfuegbareFluge());
}
private void HomeButton_Click(object sender, RoutedEventArgs e)
{
((MainWindow)Application.Current.MainWindow).MainFrame.Navigate(new NavigationPage());
string from = FromBox.Text;
string to = ToBox.Text;
DateTime? date = DateBox.SelectedDate;
NavigationService.Navigate(new verfuegbareFluge(from, to, date));
}
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 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());
}
}
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());
}
}

View File

@@ -2,94 +2,67 @@
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="verfuegbareFluge">
Title="verfuegbareFluge"
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">
<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"/>
<TextBlock Text="Home"/>
<iconPacks:PackIconMaterial Kind="Home" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Home" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<Button Height="50" Margin="5" Click="BookingsButton_Click">
<Button Height="50" Margin="5" Click="BookingsButton_Click" Background="{DynamicResource CardBackground}" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0"/>
<TextBlock Text="Meine Buchungen"/>
<iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Meine Buchungen" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
</StackPanel>
</Button>
<Button Height="50" Margin="5" Click="SettingsButton_Click">
<Button Height="50" Margin="5" Click="SettingsButton_Click" Background="Transparent" BorderThickness="0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0"/>
<TextBlock Text="Einstellungen"/>
<iconPacks:PackIconMaterial Kind="Cog" Width="20" Margin="0,0,10,0" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Einstellungen" Foreground="{DynamicResource PrimaryText}"/>
</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 Margin="0,0,0,25">
<TextBlock Text="Verfügbare Flüge"
FontSize="28"
FontWeight="Bold"/>
<TextBlock Text="Wählen Sie einen Flug aus und klicken Sie auf Buchen"
FontSize="16"
Foreground="#666"/>
<TextBlock Text="Verfügbare Flüge" FontSize="28" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>
<TextBlock Text="Wählen Sie einen Flug aus und klicken Sie auf Buchen" FontSize="16" Foreground="{DynamicResource SecondaryText}"/>
</StackPanel>
<Border Background="#F5F7FA"
CornerRadius="12"
Padding="20">
<Border Background="{DynamicResource CardBackground}" CornerRadius="12" Padding="20">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@@ -125,10 +98,7 @@
FontWeight="Bold"
Click="BookFlight_Click"/>
</Grid>
</Border>
</Grid>
</Grid>
</Page>

View File

@@ -2,15 +2,25 @@
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using MySql.Data.MySqlClient;
namespace SkyTeam
{
public partial class verfuegbareFluge : Page
{
public verfuegbareFluge()
private string _fromCity;
private string _toCity;
private DateTime? _flightDate;
public verfuegbareFluge(string from = "", string to = "", DateTime? date = null)
{
InitializeComponent();
_fromCity = from;
_toCity = to;
_flightDate = date;
LoadFlights();
}
@@ -19,15 +29,52 @@ namespace SkyTeam
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";
JOIN flugzeuge z ON f.FlugzeugId = z.Id
WHERE 1=1";
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
if (!string.IsNullOrWhiteSpace(_fromCity))
{
conn.Open();
MySqlDataAdapter adapter = new MySqlDataAdapter(query, conn);
DataTable dt = new DataTable();
adapter.Fill(dt);
AvailableFlightsDataGrid.ItemsSource = dt.DefaultView;
query += " AND f.Abflugort LIKE @from";
}
if (!string.IsNullOrWhiteSpace(_toCity))
{
query += " AND f.Zielort LIKE @to";
}
if (_flightDate.HasValue)
{
query += " AND DATE(f.Abflugdatum) = @date";
}
try
{
using (MySqlConnection conn = new MySqlConnection(DatenbankServices.GetConnection()))
{
conn.Open();
MySqlCommand cmd = new MySqlCommand(query, conn);
if (!string.IsNullOrWhiteSpace(_fromCity))
cmd.Parameters.AddWithValue("@from", "%" + _fromCity + "%");
if (!string.IsNullOrWhiteSpace(_toCity))
cmd.Parameters.AddWithValue("@to", "%" + _toCity + "%");
if (_flightDate.HasValue)
cmd.Parameters.AddWithValue("@date", _flightDate.Value.ToString("yyyy-MM-dd"));
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
AvailableFlightsDataGrid.ItemsSource = dt.DefaultView;
if (dt.Rows.Count == 0)
{
MessageBox.Show("Keine Flüge gefunden.");
}
}
}
catch (Exception ex)
{
MessageBox.Show("Fehler beim Laden: " + ex.Message);
}
}
@@ -42,6 +89,12 @@ namespace SkyTeam
DataRowView row = (DataRowView)AvailableFlightsDataGrid.SelectedItem;
int flightId = Convert.ToInt32(row["Id"]);
if (SessionManager.CurrentUserId == 0)
{
MessageBox.Show("Fehler: Nicht eingeloggt.");
return;
}
string query = "INSERT INTO buchungen (UserId, FlugId) VALUES (@uid, @fid)";
try
@@ -50,13 +103,13 @@ namespace SkyTeam
{
conn.Open();
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@uid",SessionManager.CurrentUserId);
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());
NavigationService.Navigate(new BuchungenPage());
}
catch (Exception ex)
{