diff --git a/SkyTeam/App.xaml.cs b/SkyTeam/App.xaml.cs
index d1d331c..db32d18 100644
--- a/SkyTeam/App.xaml.cs
+++ b/SkyTeam/App.xaml.cs
@@ -1,8 +1,10 @@
using BCrypt.Net;
using MySql.Data.MySqlClient;
+using PdfSharp.Fonts;
using System.Globalization;
using System.Reflection;
using System.Windows;
+using static SkyTeam.BuchungenPage;
namespace SkyTeam
{
@@ -13,6 +15,7 @@ namespace SkyTeam
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
+ GlobalFontSettings.FontResolver = new CustomFontResolver();
}
private void CreateDefaultAdmin()
diff --git a/SkyTeam/BuchungenPage.xaml b/SkyTeam/BuchungenPage.xaml
index 8070566..aab8b8b 100644
--- a/SkyTeam/BuchungenPage.xaml
+++ b/SkyTeam/BuchungenPage.xaml
@@ -89,6 +89,7 @@
+
diff --git a/SkyTeam/BuchungenPage.xaml.cs b/SkyTeam/BuchungenPage.xaml.cs
index 99ecdc8..8c72467 100644
--- a/SkyTeam/BuchungenPage.xaml.cs
+++ b/SkyTeam/BuchungenPage.xaml.cs
@@ -1,8 +1,13 @@
-using System;
+using MySql.Data.MySqlClient;
+using PdfSharp.Drawing;
+using PdfSharp.Fonts;
+using PdfSharp.Pdf;
+using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
-using MySql.Data.MySqlClient;
+using static System.Runtime.InteropServices.JavaScript.JSType;
+using System.IO;
namespace SkyTeam
{
@@ -41,12 +46,14 @@ namespace SkyTeam
NoBookingsView.Visibility = Visibility.Collapsed;
BookingsGrid.Visibility = Visibility.Visible;
CancelBtn.Visibility = Visibility.Visible;
+ CreatePdfBtn.Visibility = Visibility.Visible;
}
else
{
NoBookingsView.Visibility = Visibility.Visible;
BookingsGrid.Visibility = Visibility.Collapsed;
CancelBtn.Visibility = Visibility.Collapsed;
+ CreatePdfBtn.Visibility = Visibility.Collapsed;
}
}
}
@@ -74,11 +81,81 @@ namespace SkyTeam
LoadBookings();
}
}
+ // Idee und Grundlage aus folgendem Video:
+ // https://www.youtube.com/watch?v=sfeJprlUT7E
+ // Datum: 05.03.2026
+ // Anpassung und Implementierung mit Unterstützung von ChatGPT (OpenAI)
+ public class CustomFontResolver : IFontResolver
+ {
+ private readonly string fontPath = "OpenSans-Regular.ttf";
+
+ public string DefaultFontName => "OpenSans";
+
+ public byte[] GetFont(string faceName)
+ {
+ return File.ReadAllBytes(fontPath);
+ }
+
+ public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
+ {
+ return new FontResolverInfo("OpenSans");
+ }
+ }
+
+ // Feature: PDF-Export für Flugbuchungen hinzugefügt
+ //Quelle:
+ //YouTube Tutorial: https://www.youtube.com/watch?v=C-yMypr_TdY
+ //Datum: 05.03.2026
+ private void CreatePdf_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 buchungId = Convert.ToInt32(row["BuchungId"]);
+ string flugNr = row["Flugnummer"].ToString();
+ string von = row["Abflugort"].ToString();
+ string nach = row["Zielort"].ToString();
+ DateTime datum = Convert.ToDateTime(row["Abflugdatum"]);
+ string status = row["Status"].ToString();
+
+ string logoPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "icon.png");
+ XImage logo = XImage.FromFile(logoPath);
+
+ PdfDocument document = new PdfDocument();
+ document.Info.Title = "Flugbuchung";
+
+ PdfPage page = document.AddPage();
+ XGraphics gfx = XGraphics.FromPdfPage(page);
+
+ XFont titleFont = new XFont("OpenSans", 30);
+ XFont textFont = new XFont("OpenSans", 20);
+
+ gfx.DrawImage(logo, 40, 20, 100, 100);
+ gfx.DrawString("Flugbuchung", titleFont, XBrushes.Black, new XPoint(200, 80));
+ gfx.DrawString($"Buchung-ID: {buchungId}", textFont, XBrushes.Black, new XPoint(40, 160));
+ gfx.DrawString($"Flug-Nr.: {flugNr}", textFont, XBrushes.Black, new XPoint(40, 200));
+ gfx.DrawString($"Von: {von}", textFont, XBrushes.Black, new XPoint(40, 240));
+ gfx.DrawString($"Nach: {nach}", textFont, XBrushes.Black, new XPoint(40, 280));
+ gfx.DrawString($"Datum: {datum:dd.MM.yyyy}", textFont, XBrushes.Black, new XPoint(40, 320));
+ gfx.DrawString($"Status: {status}", textFont, XBrushes.Black, new XPoint(40, 360));
+
+ string filename = $"Flugbuchung_{buchungId}.pdf";
+ document.Save(filename);
+
+ MessageBox.Show($"PDF erfolgreich erstellt: {filename}");
+ }
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());
+
+
}
}
\ No newline at end of file
diff --git a/SkyTeam/OpenSans-Regular.ttf b/SkyTeam/OpenSans-Regular.ttf
new file mode 100644
index 0000000..134d225
Binary files /dev/null and b/SkyTeam/OpenSans-Regular.ttf differ
diff --git a/SkyTeam/Resources.Designer.cs b/SkyTeam/Resources.Designer.cs
index a1c33d3..6a82d8c 100644
--- a/SkyTeam/Resources.Designer.cs
+++ b/SkyTeam/Resources.Designer.cs
@@ -222,6 +222,15 @@ namespace SkyTeam {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Als PDF exportieren ähnelt.
+ ///
+ public static string CreatePdfButton {
+ get {
+ return ResourceManager.GetString("CreatePdfButton", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Passen Sie Ihr Erlebnis an ähnelt.
///
diff --git a/SkyTeam/Resources.ar.resx b/SkyTeam/Resources.ar.resx
index 5a26552..013bc6a 100644
--- a/SkyTeam/Resources.ar.resx
+++ b/SkyTeam/Resources.ar.resx
@@ -285,4 +285,7 @@
إلغاء الرحلة
+
+ تصدير إلى PDF
+
\ No newline at end of file
diff --git a/SkyTeam/Resources.en.resx b/SkyTeam/Resources.en.resx
index 3f89ed5..a8c96b1 100644
--- a/SkyTeam/Resources.en.resx
+++ b/SkyTeam/Resources.en.resx
@@ -285,4 +285,7 @@
Cancel Flight
+
+ Export as PDF
+
\ No newline at end of file
diff --git a/SkyTeam/Resources.resx b/SkyTeam/Resources.resx
index 33754e0..1cb20e3 100644
--- a/SkyTeam/Resources.resx
+++ b/SkyTeam/Resources.resx
@@ -285,4 +285,7 @@
Flug stornieren
+
+ Als PDF exportieren
+
\ No newline at end of file
diff --git a/SkyTeam/Resources.uk.resx b/SkyTeam/Resources.uk.resx
index a7f083e..df7281e 100644
--- a/SkyTeam/Resources.uk.resx
+++ b/SkyTeam/Resources.uk.resx
@@ -285,4 +285,7 @@
Скасувати рейс
+
+ Експортувати у PDF
+
\ No newline at end of file
diff --git a/SkyTeam/SkyTeam.csproj b/SkyTeam/SkyTeam.csproj
index db3b342..2d8ad12 100644
--- a/SkyTeam/SkyTeam.csproj
+++ b/SkyTeam/SkyTeam.csproj
@@ -17,6 +17,9 @@
+
+
+