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 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"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HegreHotel.Views.Chambre.ChambresPage"
Title="Gestion des Chambres"
Appearing="ChambresPage_OnAppearing">
<StackLayout Padding="10">
<Picker x:Name="PickerFiltreStatus" Title="Filtrer par statut" SelectedIndexChanged="OnFiltreChanged"/>
<Button Text="Ajouter Chambre"
@ -16,34 +18,26 @@
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="5" Spacing="10">
<!-- Nom de la chambre -->
<StackLayout Orientation="Horizontal" Padding="5">
<Label Text="{Binding Nom}"
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"/>
<Label Text="{Binding Description}"
WidthRequest="150"/>
<Label Text="{Binding Status.Libelle}"
TextColor="Gray"/>
<!-- Icônes Modifier / Supprimer -->
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Spacing="5">
<ImageButton Source="edit_icon.png"
<Button Text="Modifier"
CommandParameter="{Binding .}"
Clicked="OnModifierChambreClicked"
HorizontalOptions="EndAndExpand"
Margin="5,0"/>
<Button Text="Supprimer"
CommandParameter="{Binding .}"
HeightRequest="30"
WidthRequest="30"
BackgroundColor="Transparent"/>
<ImageButton Source="delete_icon.png"
Clicked="OnSupprimerChambreClicked"
CommandParameter="{Binding .}"
HeightRequest="30"
WidthRequest="30"
BackgroundColor="Transparent"/>
</StackLayout>
HorizontalOptions="End"
Margin="5,0"/>
</StackLayout>
</ViewCell>
</DataTemplate>

View File

@ -4,7 +4,6 @@ using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Microsoft.Maui.Storage;
using System.Collections.Generic;
namespace HegreHotel.Views.Chambre
{
@ -25,47 +24,12 @@ namespace HegreHotel.Views.Chambre
var db = SingletonConnection.GetInstance(dbPath);
_statuts = await db.Table<Status>().ToListAsync();
var statutsAvecTous = new List<string> { "Tous" };
statutsAvecTous.AddRange(_statuts.Select(s => s.Libelle));
PickerFiltreStatus.ItemsSource = statutsAvecTous;
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();
foreach (var chambre in chambresList)
{
@ -88,17 +52,8 @@ namespace HegreHotel.Views.Chambre
}
else
{
string statutSelectionne = PickerFiltreStatus.SelectedItem.ToString();
var statut = _statuts.FirstOrDefault(s => s.Libelle == statutSelectionne);
if (statut != null)
{
ChambresListView.ItemsSource = _toutesLesChambres.Where(c => c.StatusId == statut.Id).ToList();
}
else
{
Console.WriteLine($"⚠ Filtrage impossible : statut '{statutSelectionne}' introuvable.");
}
var statutSelectionne = _statuts[PickerFiltreStatus.SelectedIndex - 1].Id;
ChambresListView.ItemsSource = _toutesLesChambres.Where(c => c.StatusId == statutSelectionne).ToList();
}
}
@ -109,7 +64,8 @@ namespace HegreHotel.Views.Chambre
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));
}
@ -117,7 +73,8 @@ namespace HegreHotel.Views.Chambre
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");
if (confirmation)

View File

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

View File

@ -37,16 +37,17 @@ namespace HegreHotel.Views.Client
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));
}
}
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");
if (confirmation)
@ -59,7 +60,6 @@ namespace HegreHotel.Views.Client
}
}
private void ClientsPage_OnAppearing(object? sender, EventArgs e)
{
LoadClients();

View File

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

View File

@ -36,7 +36,8 @@ namespace HegreHotel.Views.Reservation
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));
}
@ -44,7 +45,8 @@ namespace HegreHotel.Views.Reservation
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");
if (confirmation)