pull victor

This commit is contained in:
allavenavr 2025-03-27 16:43:25 +01:00
commit 7f05f4f634
4 changed files with 164 additions and 0 deletions

View File

@ -21,5 +21,8 @@
<Button Text="Gérer les Réservations"
Clicked="OnReservationsClicked"
Margin="0,10"/>
<Button Text="Gérer les départs et arrivées"
Clicked="OnGestionDepartClicked"
Margin="0,10"/>
</StackLayout>
</ContentPage>

View File

@ -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());
}
}
}

View File

@ -0,0 +1,99 @@
<?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.GestionDepart.GestionDepartPage"
Title="Gestion des départs et arrivées"
Appearing="GestionPage_OnAppearing">
<ContentPage.Content>
<StackLayout>
<StackLayout>
<StackLayout Padding="20" Orientation="Horizontal">
<BoxView HeightRequest="5" Color="MediumPurple"/>
<Label Text="Arrivée(s)"
FontSize="24"
FontAttributes="Bold"
HorizontalOptions="Center"/>
</StackLayout>
<ListView x:Name="GestionArriveListView" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="ID chambre :"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding ChambreId}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="Nombres de personnes :"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding NbPersonnes}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="Date d'arrivée : aujourd'hui"
VerticalOptions="Center"
WidthRequest="100"/>
<Label Text="Date de départ :"
VerticalOptions="Center"
WidthRequest="100"/>
<Label Text="{Binding DateFin, StringFormat='{0:dd/MM/yyyy}'}"
VerticalOptions="Center"
WidthRequest="100"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout>
<StackLayout Padding="20" Orientation="Horizontal">
<BoxView HeightRequest="5" Color="MediumPurple"/>
<Label Text="Départ(s)"
FontSize="24"
FontAttributes="Bold"
HorizontalOptions="Center" />
</StackLayout>
<ListView x:Name="GestionDepartListView" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="ID chambre :"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding ChambreId}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="Nombres de personnes :"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding NbPersonnes}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="Date d'arrivée :"
VerticalOptions="Center"
WidthRequest="100"/>
<Label Text="{Binding DateDebut, StringFormat='{0:dd/MM/yyyy}'}"
VerticalOptions="Center"
WidthRequest="100"/>
<Label Text="Date de départ : aujourd'hui"
VerticalOptions="Center"
WidthRequest="100"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -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<Models.Reservation> ReservationsDeb { get; set; } = new ObservableCollection<Models.Reservation>();
public ObservableCollection<Models.Reservation> ReservationsFin { get; set; } = new ObservableCollection<Models.Reservation>();
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<Models.Reservation>().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();
}
}