last commit before tests

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

View File

@@ -1,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());
}
}
}