diff --git a/MainPage.xaml b/MainPage.xaml
index 9e50782..8c00611 100644
--- a/MainPage.xaml
+++ b/MainPage.xaml
@@ -21,5 +21,8 @@
+
diff --git a/MainPage.xaml.cs b/MainPage.xaml.cs
index 7d78e2f..c7c4233 100644
--- a/MainPage.xaml.cs
+++ b/MainPage.xaml.cs
@@ -2,6 +2,7 @@ using HegreHotel.Views;
using HegreHotel.Views.Chambre;
using HegreHotel.Views.Client;
using HegreHotel.Views.Reservation;
+using HegreHotel.Views.GestionDepart;
using Microsoft.Maui.Controls;
namespace HegreHotel
@@ -27,5 +28,10 @@ namespace HegreHotel
{
await Navigation.PushAsync(new ReservationsPage());
}
+
+ private async void OnGestionDepartClicked(object sender, EventArgs e)
+ {
+ await Navigation.PushAsync(new GestionDepartPage());
+ }
}
}
\ No newline at end of file
diff --git a/Models/Chambre.cs b/Models/Chambre.cs
index d3460ca..1e86e71 100644
--- a/Models/Chambre.cs
+++ b/Models/Chambre.cs
@@ -17,4 +17,7 @@ public class Chambre
public int NbPersonne { get; set; }
public int StatusId { get; set; }
-}
+
+ [Ignore]
+ public Status Status { get; set; }
+}
\ No newline at end of file
diff --git a/Resources/Images/delete_icon.png b/Resources/Images/delete_icon.png
new file mode 100644
index 0000000..c83937f
Binary files /dev/null and b/Resources/Images/delete_icon.png differ
diff --git a/Resources/Images/edit_icon.png b/Resources/Images/edit_icon.png
new file mode 100644
index 0000000..cbf3dce
Binary files /dev/null and b/Resources/Images/edit_icon.png differ
diff --git a/SingletonConnection.cs b/SingletonConnection.cs
index e69aa38..8776e37 100644
--- a/SingletonConnection.cs
+++ b/SingletonConnection.cs
@@ -6,7 +6,7 @@ namespace HegreHotel
{
public class SingletonConnection : SQLiteAsyncConnection
{
- private static SingletonConnection instance;
+ private static SingletonConnection? _instance;
private SingletonConnection(string dbPath) : base(dbPath)
{
@@ -14,11 +14,11 @@ namespace HegreHotel
public static SingletonConnection GetInstance(string dbPath)
{
- if (instance == null)
+ if (_instance == null)
{
- instance = new SingletonConnection(dbPath);
+ _instance = new SingletonConnection(dbPath);
}
- return instance;
+ return _instance;
}
}
}
\ No newline at end of file
diff --git a/Views/Chambre/ChambresPage.xaml b/Views/Chambre/ChambresPage.xaml
index 649a51d..26e48eb 100644
--- a/Views/Chambre/ChambresPage.xaml
+++ b/Views/Chambre/ChambresPage.xaml
@@ -1,12 +1,10 @@
-
-
diff --git a/Views/Chambre/ModifierChambrePage.xaml.cs b/Views/Chambre/ModifierChambrePage.xaml.cs
index 1452eb6..c052563 100644
--- a/Views/Chambre/ModifierChambrePage.xaml.cs
+++ b/Views/Chambre/ModifierChambrePage.xaml.cs
@@ -8,6 +8,8 @@ namespace HegreHotel.Views.Chambre
public partial class ModifierChambrePage : ContentPage
{
Models.Chambre _chambre;
+ private List _statuts;
+
public ModifierChambrePage(Models.Chambre chambre)
{
InitializeComponent();
@@ -17,17 +19,40 @@ namespace HegreHotel.Views.Chambre
EntryDescription.Text = _chambre.Description;
EntryTarif.Text = _chambre.Tarif.ToString();
EntryNbPersonne.Text = _chambre.NbPersonne.ToString();
+
+ LoadStatuts();
+ }
+
+ private async void LoadStatuts()
+ {
+ string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
+ var db = SingletonConnection.GetInstance(dbPath);
+
+ _statuts = await db.Table().ToListAsync();
+
+ PickerStatut.ItemsSource = _statuts.Select(s => s.Libelle).ToList();
+ PickerStatut.SelectedIndex = _statuts.FindIndex(s => s.Id == _chambre.StatusId);
}
private async void OnEnregistrerClicked(object sender, EventArgs e)
{
+ if (PickerStatut.SelectedIndex == -1)
+ {
+ await DisplayAlert("Erreur", "Veuillez sélectionner un statut", "OK");
+ return;
+ }
+
_chambre.Nom = EntryNom.Text;
_chambre.Description = EntryDescription.Text;
_chambre.Tarif = decimal.TryParse(EntryTarif.Text, out decimal tarif) ? tarif : _chambre.Tarif;
_chambre.NbPersonne = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : _chambre.NbPersonne;
+
+ _chambre.StatusId = _statuts[PickerStatut.SelectedIndex].Id;
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
var db = SingletonConnection.GetInstance(dbPath);
+
+ Console.WriteLine(_chambre.StatusId);
await db.UpdateAsync(_chambre);
await Navigation.PopAsync();
}
diff --git a/Views/Client/ClientsPage.xaml b/Views/Client/ClientsPage.xaml
index ff78046..34996f0 100644
--- a/Views/Client/ClientsPage.xaml
+++ b/Views/Client/ClientsPage.xaml
@@ -1,46 +1,69 @@
-
-
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
-
+
\ No newline at end of file
diff --git a/Views/Client/ClientsPage.xaml.cs b/Views/Client/ClientsPage.xaml.cs
index c2cc533..3599cc3 100644
--- a/Views/Client/ClientsPage.xaml.cs
+++ b/Views/Client/ClientsPage.xaml.cs
@@ -18,16 +18,25 @@ namespace HegreHotel.Views.Client
private async void LoadClients()
{
- string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
- var db = SingletonConnection.GetInstance(dbPath);
- var clientsList = await db.Table().ToListAsync();
- Clients.Clear();
- foreach (var client in clientsList)
+ try
{
- Clients.Add(client);
+ string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
+ var db = SingletonConnection.GetInstance(dbPath);
+ var clientsList = await db.Table().ToListAsync();
+
+ MainThread.BeginInvokeOnMainThread(() =>
+ {
+ Clients.Clear();
+ foreach (var client in clientsList)
+ Clients.Add(client);
+
+ ClientsCollectionView.ItemsSource = Clients;
+ });
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Erreur lors du chargement des clients : {ex.Message}");
}
- ClientsListView.ItemsSource = Clients;
-
}
private async void OnAjouterClientClicked(object sender, EventArgs e)
@@ -37,8 +46,7 @@ namespace HegreHotel.Views.Client
private async void OnModifierClientClicked(object sender, EventArgs e)
{
- var client = ((Button)sender).CommandParameter as Models.Client;
- if (client != null)
+ if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Client client)
{
await Navigation.PushAsync(new ModifierClientPage(client));
}
@@ -46,8 +54,7 @@ namespace HegreHotel.Views.Client
private async void OnSupprimerClientClicked(object sender, EventArgs e)
{
- var client = ((Button)sender).CommandParameter as Models.Client;
- if (client != null)
+ if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Client client)
{
bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer ce client ?", "Oui", "Non");
if (confirmation)
@@ -55,27 +62,24 @@ namespace HegreHotel.Views.Client
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
var db = SingletonConnection.GetInstance(dbPath);
await db.DeleteAsync(client);
- LoadClients();
+
+ MainThread.BeginInvokeOnMainThread(() =>
+ {
+ Clients.Remove(client);
+ });
}
}
}
- private void ClientsPage_OnAppearing(object? sender, EventArgs e)
+ private void ClientsPage_OnAppearing(object sender, EventArgs e)
{
LoadClients();
}
- private async void OnClientTapped(object sender, ItemTappedEventArgs e)
+ private async void OnClientTapped(object sender, EventArgs e)
{
- if (e.Item != null)
+ if (sender is Frame frame && frame.BindingContext is Models.Client client)
{
- // Désélectionne l'élément tappé
- ((ListView)sender).SelectedItem = null;
-
- // Récupère le client sélectionné
- var client = e.Item as Models.Client;
-
- // Navigue vers la page de détails du client
await Navigation.PushAsync(new DetailsClientPage(client));
}
}
diff --git a/Views/Client/DetailsClientPage.xaml b/Views/Client/DetailsClientPage.xaml
index 78066aa..b0ebd89 100644
--- a/Views/Client/DetailsClientPage.xaml
+++ b/Views/Client/DetailsClientPage.xaml
@@ -1,35 +1,59 @@
-
-
-
-
-
-
-
+ x:Class="HegreHotel.Views.Client.DetailsClientPage"
+ Title="Détails du Client">
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
diff --git a/Views/Client/ModifierClientPage.xaml b/Views/Client/ModifierClientPage.xaml
index 63861d9..4b7d282 100644
--- a/Views/Client/ModifierClientPage.xaml
+++ b/Views/Client/ModifierClientPage.xaml
@@ -1,14 +1,47 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Views/GestionDepart/GestionDepartPage.xaml b/Views/GestionDepart/GestionDepartPage.xaml
new file mode 100644
index 0000000..172f79b
--- /dev/null
+++ b/Views/GestionDepart/GestionDepartPage.xaml
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Views/GestionDepart/GestionDepartPage.xaml.cs b/Views/GestionDepart/GestionDepartPage.xaml.cs
new file mode 100644
index 0000000..78d9697
--- /dev/null
+++ b/Views/GestionDepart/GestionDepartPage.xaml.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using HegreHotel.Models;
+using Microsoft.Maui.Controls;
+using System.Collections.ObjectModel;
+using System.IO;
+using Microsoft.Maui.Storage;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HegreHotel.Views.GestionDepart;
+
+public partial class GestionDepartPage : ContentPage
+{
+ public ObservableCollection ReservationsDeb { get; set; } = new ObservableCollection();
+ public ObservableCollection ReservationsFin { get; set; } = new ObservableCollection();
+
+ public GestionDepartPage()
+ {
+ InitializeComponent();
+ LoadReservations();
+ }
+
+ private async void LoadReservations()
+ {
+ string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
+ var db = SingletonConnection.GetInstance(dbPath);
+ var reservationList = await db.Table().ToListAsync();
+ ReservationsDeb.Clear();
+ ReservationsFin.Clear();
+ foreach (var reservation in reservationList)
+ {
+ if (reservation.DateDebut == DateTime.Now.Date)
+ {
+ ReservationsDeb.Add(reservation);
+ } else if (reservation.DateFin == DateTime.Now.Date)
+ {
+ ReservationsFin.Add(reservation);
+ }
+
+ }
+
+
+ GestionArriveListView.ItemsSource = ReservationsDeb;
+
+ GestionDepartListView.ItemsSource = ReservationsFin;
+
+ }
+
+ private void GestionPage_OnAppearing(object? sender, EventArgs e)
+ {
+ LoadReservations();
+ }
+}
\ No newline at end of file
diff --git a/Views/Reservation/ReservationsPage.xaml b/Views/Reservation/ReservationsPage.xaml
index 520bfe9..348ff4d 100644
--- a/Views/Reservation/ReservationsPage.xaml
+++ b/Views/Reservation/ReservationsPage.xaml
@@ -1,24 +1,20 @@
-
-
-
-
-
+
@@ -29,17 +25,20 @@
VerticalOptions="Center"
WidthRequest="100"/>
-
-
-
+
+
+
+
diff --git a/Views/Reservation/ReservationsPage.xaml.cs b/Views/Reservation/ReservationsPage.xaml.cs
index 9b8cd4b..fdbf784 100644
--- a/Views/Reservation/ReservationsPage.xaml.cs
+++ b/Views/Reservation/ReservationsPage.xaml.cs
@@ -36,8 +36,7 @@ namespace HegreHotel.Views.Reservation
private async void OnModifierReservationClicked(object sender, EventArgs e)
{
- var reservation = ((Button)sender).CommandParameter as Models.Reservation;
- if (reservation != null)
+ if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Reservation reservation)
{
await Navigation.PushAsync(new ModifierReservationPage(reservation));
}
@@ -45,8 +44,7 @@ namespace HegreHotel.Views.Reservation
private async void OnSupprimerReservationClicked(object sender, EventArgs e)
{
- var reservation = ((Button)sender).CommandParameter as Models.Reservation;
- if (reservation != null)
+ if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Reservation reservation)
{
bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer cette réservation ?", "Oui", "Non");
if (confirmation)