Compare commits

..

No commits in common. "1920b8a164ff504a5d15e3464d31e990049d8b11" and "dde7dd9f732b3ae6e69efc902269b78b6ba3c3fa" have entirely different histories.

9 changed files with 65 additions and 116 deletions

View File

@ -17,8 +17,4 @@ public class Chambre
public int NbPersonne { get; set; } public int NbPersonne { get; set; }
public int StatusId { get; set; } public int StatusId { get; set; }
// Propriété de navigation pour associer l'objet Status (non stockée en base)
[Ignore]
public Status Status { get; set; }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HegreHotel.Views.Chambre.ChambresPage" x:Class="HegreHotel.Views.Chambre.ChambresPage"
Title="Gestion des Chambres" Title="Gestion des Chambres"
Appearing="ChambresPage_OnAppearing"> Appearing="ChambresPage_OnAppearing">
<StackLayout Padding="10"> <StackLayout Padding="10">
<Picker x:Name="PickerFiltreStatus" Title="Filtrer par statut" SelectedIndexChanged="OnFiltreChanged"/> <Picker x:Name="PickerFiltreStatus" Title="Filtrer par statut" SelectedIndexChanged="OnFiltreChanged"/>
<Button Text="Ajouter Chambre" <Button Text="Ajouter Chambre"
@ -16,34 +18,26 @@
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell>
<StackLayout Orientation="Horizontal" Padding="5" Spacing="10"> <StackLayout Orientation="Horizontal" Padding="5">
<!-- Nom de la chambre -->
<Label Text="{Binding Nom}" <Label Text="{Binding Nom}"
FontAttributes="Bold" FontAttributes="Bold"
VerticalOptions="Center"
WidthRequest="120"/> <!-- Ajusté pour laisser de la place -->
<!-- Statut de la chambre -->
<Label Text="{Binding Status.Libelle}"
FontAttributes="Italic"
VerticalOptions="Center"
WidthRequest="100"/> WidthRequest="100"/>
<Label Text="{Binding Description}"
WidthRequest="150"/>
<Label Text="{Binding Status.Libelle}"
TextColor="Gray"/>
<!-- Icônes Modifier / Supprimer --> <Button Text="Modifier"
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Spacing="5"> CommandParameter="{Binding .}"
<ImageButton Source="edit_icon.png" Clicked="OnModifierChambreClicked"
Clicked="OnModifierChambreClicked" HorizontalOptions="EndAndExpand"
CommandParameter="{Binding .}" Margin="5,0"/>
HeightRequest="30"
WidthRequest="30" <Button Text="Supprimer"
BackgroundColor="Transparent"/> CommandParameter="{Binding .}"
<ImageButton Source="delete_icon.png" Clicked="OnSupprimerChambreClicked"
Clicked="OnSupprimerChambreClicked" HorizontalOptions="End"
CommandParameter="{Binding .}" Margin="5,0"/>
HeightRequest="30"
WidthRequest="30"
BackgroundColor="Transparent"/>
</StackLayout>
</StackLayout> </StackLayout>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>

View File

@ -4,7 +4,6 @@ using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.Maui.Storage; using Microsoft.Maui.Storage;
using System.Collections.Generic;
namespace HegreHotel.Views.Chambre namespace HegreHotel.Views.Chambre
{ {
@ -25,47 +24,12 @@ namespace HegreHotel.Views.Chambre
var db = SingletonConnection.GetInstance(dbPath); var db = SingletonConnection.GetInstance(dbPath);
_statuts = await db.Table<Status>().ToListAsync(); _statuts = await db.Table<Status>().ToListAsync();
var statutsAvecTous = new List<string> { "Tous" }; var statutsAvecTous = new List<string> { "Tous" };
statutsAvecTous.AddRange(_statuts.Select(s => s.Libelle)); statutsAvecTous.AddRange(_statuts.Select(s => s.Libelle));
PickerFiltreStatus.ItemsSource = statutsAvecTous; PickerFiltreStatus.ItemsSource = statutsAvecTous;
var chambresList = await db.Table<Models.Chambre>().ToListAsync(); var chambresList = await db.Table<Models.Chambre>().ToListAsync();
var reservationsList = await db.Table<Models.Reservation>().ToListAsync();
DateTime today = DateTime.Today;
foreach (var chambre in chambresList)
{
var chambreReservee = reservationsList
.Where(r => r.ChambreId == chambre.Id && r.DateDebut <= today && r.DateFin >= today)
.OrderByDescending(r => r.DateFin)
.FirstOrDefault();
if (chambreReservee != null)
{
chambre.StatusId = 2;
}
else
{
var chambreFinieRecemment = reservationsList
.Where(r => r.ChambreId == chambre.Id && r.DateFin >= today.AddDays(-2) && r.DateFin < today)
.OrderByDescending(r => r.DateFin)
.FirstOrDefault();
if (chambreFinieRecemment != null)
{
chambre.StatusId = 3;
}
else
{
chambre.StatusId = 1;
}
}
chambre.Status = _statuts.FirstOrDefault(s => s.Id == chambre.StatusId);
await db.UpdateAsync(chambre);
}
_toutesLesChambres.Clear(); _toutesLesChambres.Clear();
foreach (var chambre in chambresList) foreach (var chambre in chambresList)
{ {
@ -88,17 +52,8 @@ namespace HegreHotel.Views.Chambre
} }
else else
{ {
string statutSelectionne = PickerFiltreStatus.SelectedItem.ToString(); var statutSelectionne = _statuts[PickerFiltreStatus.SelectedIndex - 1].Id;
var statut = _statuts.FirstOrDefault(s => s.Libelle == statutSelectionne); ChambresListView.ItemsSource = _toutesLesChambres.Where(c => c.StatusId == statutSelectionne).ToList();
if (statut != null)
{
ChambresListView.ItemsSource = _toutesLesChambres.Where(c => c.StatusId == statut.Id).ToList();
}
else
{
Console.WriteLine($"⚠ Filtrage impossible : statut '{statutSelectionne}' introuvable.");
}
} }
} }
@ -109,7 +64,8 @@ namespace HegreHotel.Views.Chambre
private async void OnModifierChambreClicked(object sender, EventArgs e) private async void OnModifierChambreClicked(object sender, EventArgs e)
{ {
if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Chambre chambre) var chambre = ((Button)sender).CommandParameter as Models.Chambre;
if (chambre != null)
{ {
await Navigation.PushAsync(new ModifierChambrePage(chambre)); await Navigation.PushAsync(new ModifierChambrePage(chambre));
} }
@ -117,7 +73,8 @@ namespace HegreHotel.Views.Chambre
private async void OnSupprimerChambreClicked(object sender, EventArgs e) private async void OnSupprimerChambreClicked(object sender, EventArgs e)
{ {
if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Chambre chambre) var chambre = ((Button)sender).CommandParameter as Models.Chambre;
if (chambre != null)
{ {
bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer cette chambre ?", "Oui", "Non"); bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer cette chambre ?", "Oui", "Non");
if (confirmation) if (confirmation)

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HegreHotel.Views.Client.ClientsPage" x:Class="HegreHotel.Views.Client.ClientsPage"
@ -14,7 +15,7 @@
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell>
<StackLayout Orientation="Horizontal" Padding="5" Spacing="10"> <StackLayout Orientation="Horizontal" Padding="5">
<Label Text="{Binding Nom}" <Label Text="{Binding Nom}"
VerticalOptions="Center" VerticalOptions="Center"
FontAttributes="Bold" FontAttributes="Bold"
@ -22,20 +23,18 @@
<Label Text="{Binding Prenom}" <Label Text="{Binding Prenom}"
VerticalOptions="Center" VerticalOptions="Center"
WidthRequest="100"/> WidthRequest="100"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Spacing="5">
<ImageButton Source="edit_icon.png" <Button Text="Modifier"
Clicked="OnModifierClientClicked" Clicked="OnModifierClientClicked"
CommandParameter="{Binding .}" CommandParameter="{Binding .}"
HeightRequest="30" HorizontalOptions="EndAndExpand"
WidthRequest="30" Margin="5,0"/>
BackgroundColor="Transparent"/>
<ImageButton Source="delete_icon.png" <Button Text="Supprimer"
Clicked="OnSupprimerClientClicked" Clicked="OnSupprimerClientClicked"
CommandParameter="{Binding .}" CommandParameter="{Binding .}"
HeightRequest="30" HorizontalOptions="End"
WidthRequest="30" Margin="5,0"/>
BackgroundColor="Transparent"/>
</StackLayout>
</StackLayout> </StackLayout>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>

View File

@ -37,16 +37,17 @@ namespace HegreHotel.Views.Client
private async void OnModifierClientClicked(object sender, EventArgs e) private async void OnModifierClientClicked(object sender, EventArgs e)
{ {
if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Client client) var client = ((Button)sender).CommandParameter as Models.Client;
if (client != null)
{ {
await Navigation.PushAsync(new ModifierClientPage(client)); await Navigation.PushAsync(new ModifierClientPage(client));
} }
} }
private async void OnSupprimerClientClicked(object sender, EventArgs e) private async void OnSupprimerClientClicked(object sender, EventArgs e)
{ {
if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Client client) var client = ((Button)sender).CommandParameter as Models.Client;
if (client != null)
{ {
bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer ce client ?", "Oui", "Non"); bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer ce client ?", "Oui", "Non");
if (confirmation) if (confirmation)
@ -59,7 +60,6 @@ namespace HegreHotel.Views.Client
} }
} }
private void ClientsPage_OnAppearing(object? sender, EventArgs e) private void ClientsPage_OnAppearing(object? sender, EventArgs e)
{ {
LoadClients(); LoadClients();

View File

@ -1,20 +1,24 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HegreHotel.Views.Reservation.ReservationsPage" x:Class="HegreHotel.Views.Reservation.ReservationsPage"
Title="Gestion des Réservations" Title="Gestion des Réservations"
Appearing="ReservationsPage_OnAppearing"> Appearing="ReservationsPage_OnAppearing">
<StackLayout Padding="10"> <StackLayout Padding="10">
<Button Text="Ajouter Réservation" <Button Text="Ajouter Réservation"
Clicked="OnAjouterReservationClicked" Clicked="OnAjouterReservationClicked"
HorizontalOptions="Center" HorizontalOptions="Center"
Margin="0,10"/> Margin="0,10"/>
<ListView x:Name="ReservationsListView" HasUnevenRows="True"> <ListView x:Name="ReservationsListView" HasUnevenRows="True">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell>
<StackLayout Orientation="Horizontal" Padding="5" Spacing="10"> <StackLayout Orientation="Horizontal" Padding="5">
<Label Text="{Binding NbInvite}" <Label Text="{Binding NbInvite}"
VerticalOptions="Center" VerticalOptions="Center"
WidthRequest="50"/> WidthRequest="50"/>
@ -25,20 +29,17 @@
VerticalOptions="Center" VerticalOptions="Center"
WidthRequest="100"/> WidthRequest="100"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Spacing="5"> <Button Text="Modifier"
<ImageButton Source="edit_icon.png" CommandParameter="{Binding .}"
Clicked="OnModifierReservationClicked" Clicked="OnModifierReservationClicked"
CommandParameter="{Binding .}" HorizontalOptions="EndAndExpand"
HeightRequest="30" Margin="5,0"/>
WidthRequest="30"
BackgroundColor="Transparent"/> <Button Text="Supprimer"
<ImageButton Source="delete_icon.png" CommandParameter="{Binding .}"
Clicked="OnSupprimerReservationClicked" Clicked="OnSupprimerReservationClicked"
CommandParameter="{Binding .}" HorizontalOptions="End"
HeightRequest="30" Margin="5,0"/>
WidthRequest="30"
BackgroundColor="Transparent"/>
</StackLayout>
</StackLayout> </StackLayout>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>

View File

@ -36,7 +36,8 @@ namespace HegreHotel.Views.Reservation
private async void OnModifierReservationClicked(object sender, EventArgs e) private async void OnModifierReservationClicked(object sender, EventArgs e)
{ {
if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Reservation reservation) var reservation = ((Button)sender).CommandParameter as Models.Reservation;
if (reservation != null)
{ {
await Navigation.PushAsync(new ModifierReservationPage(reservation)); await Navigation.PushAsync(new ModifierReservationPage(reservation));
} }
@ -44,7 +45,8 @@ namespace HegreHotel.Views.Reservation
private async void OnSupprimerReservationClicked(object sender, EventArgs e) private async void OnSupprimerReservationClicked(object sender, EventArgs e)
{ {
if (sender is ImageButton imageButton && imageButton.CommandParameter is Models.Reservation reservation) var reservation = ((Button)sender).CommandParameter as Models.Reservation;
if (reservation != null)
{ {
bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer cette réservation ?", "Oui", "Non"); bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer cette réservation ?", "Oui", "Non");
if (confirmation) if (confirmation)