From cab1fcacbf77c4e21bf74309230817d42f6416bd Mon Sep 17 00:00:00 2001 From: allavenavr Date: Thu, 13 Mar 2025 17:49:25 +0100 Subject: [PATCH] Big commit --- App.xaml.cs | 10 ++- Database.cs | 35 ++++---- HegreHotel.csproj | 4 + MainPage.xaml | 49 ++++------ MainPage.xaml.cs | 37 ++++---- Models/Chambre.cs | 2 +- Models/Client.cs | 2 + Models/Reservation.cs | 15 +--- Services/ClientService.cs | 36 -------- SingletonConnection.cs | 27 ++++++ Views/AjouterClientPage.xaml | 14 +++ Views/AjouterClientPage.xaml.cs | 31 +++++++ Views/Chambre/AjouterChambrePage.xaml | 14 +++ Views/Chambre/AjouterChambrePage.xaml.cs | 31 +++++++ Views/Chambre/ChambresPage.xaml | 49 ++++++++++ Views/Chambre/ChambresPage.xaml.cs | 67 ++++++++++++++ Views/Chambre/ModifierChambrePage.xaml | 14 +++ Views/Chambre/ModifierChambrePage.xaml.cs | 35 ++++++++ Views/ClientsPage.xaml | 51 ++++++++--- Views/ClientsPage.xaml.cs | 90 +++++++++++++------ Views/ModifierClientPage.xaml | 14 +++ Views/ModifierClientPage.xaml.cs | 35 ++++++++ Views/Reservation/AjouterReservationPage.xaml | 14 +++ .../AjouterReservationPage.xaml.cs | 31 +++++++ .../Reservation/ModifierReservationPage.xaml | 14 +++ .../ModifierReservationPage.xaml.cs | 35 ++++++++ Views/Reservation/ReservationsPage.xaml | 51 +++++++++++ Views/Reservation/ReservationsPage.xaml.cs | 67 ++++++++++++++ 28 files changed, 720 insertions(+), 154 deletions(-) delete mode 100644 Services/ClientService.cs create mode 100644 SingletonConnection.cs create mode 100644 Views/AjouterClientPage.xaml create mode 100644 Views/AjouterClientPage.xaml.cs create mode 100644 Views/Chambre/AjouterChambrePage.xaml create mode 100644 Views/Chambre/AjouterChambrePage.xaml.cs create mode 100644 Views/Chambre/ChambresPage.xaml create mode 100644 Views/Chambre/ChambresPage.xaml.cs create mode 100644 Views/Chambre/ModifierChambrePage.xaml create mode 100644 Views/Chambre/ModifierChambrePage.xaml.cs create mode 100644 Views/ModifierClientPage.xaml create mode 100644 Views/ModifierClientPage.xaml.cs create mode 100644 Views/Reservation/AjouterReservationPage.xaml create mode 100644 Views/Reservation/AjouterReservationPage.xaml.cs create mode 100644 Views/Reservation/ModifierReservationPage.xaml create mode 100644 Views/Reservation/ModifierReservationPage.xaml.cs create mode 100644 Views/Reservation/ReservationsPage.xaml create mode 100644 Views/Reservation/ReservationsPage.xaml.cs diff --git a/App.xaml.cs b/App.xaml.cs index 54e907c..b94c348 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,4 +1,6 @@ -namespace HegreHotel; +using HegreHotel.Views; + +namespace HegreHotel; public partial class App : Application { @@ -6,6 +8,8 @@ public partial class App : Application { InitializeComponent(); - MainPage = new AppShell(); + Task.Run(async () => await Database.CreateDatabaseAsync()).Wait(); + + MainPage = new NavigationPage(new MainPage()); } -} \ No newline at end of file +} diff --git a/Database.cs b/Database.cs index d37bc3a..7fe6ab1 100644 --- a/Database.cs +++ b/Database.cs @@ -1,26 +1,25 @@ +using System.IO; +using Microsoft.Maui.Storage; +using System.Threading.Tasks; using HegreHotel.Models; -using SQLite; -namespace HegreHotel; - -public class Database +namespace HegreHotel { - private static SQLiteAsyncConnection _database; - - public static async Task GetConnection() + public class Database { - if (_database == null) + public static async Task CreateDatabaseAsync() { - var databasePath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db"); - _database = new SQLiteAsyncConnection(databasePath); + // Construction du chemin de la BDD dans le dossier AppData + string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3"); - // Créer les tables - await _database.CreateTableAsync(); - await _database.CreateTableAsync(); - await _database.CreateTableAsync(); - await _database.CreateTableAsync(); + // Récupération de l'instance unique du Singleton + var db = SingletonConnection.GetInstance(dbPath); + + // Création des tables + await db.CreateTableAsync(); + await db.CreateTableAsync(); + await db.CreateTableAsync(); + await db.CreateTableAsync(); } - - return _database; } -} +} \ No newline at end of file diff --git a/HegreHotel.csproj b/HegreHotel.csproj index cf89031..8908392 100644 --- a/HegreHotel.csproj +++ b/HegreHotel.csproj @@ -66,4 +66,8 @@ + + + + diff --git a/MainPage.xaml b/MainPage.xaml index 496cf86..9e50782 100644 --- a/MainPage.xaml +++ b/MainPage.xaml @@ -1,36 +1,25 @@ - + + + x:Class="HegreHotel.MainPage" + Title="HegreHotel"> + +