Gestion depart arrivées qui fonctionne

This commit is contained in:
leroyv 2025-03-27 15:39:42 +01:00
parent a6f04a142a
commit c53896f8bd
2 changed files with 51 additions and 38 deletions

View File

@ -8,8 +8,40 @@
<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="{Binding Id}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding NbPersonnes}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding DateDebut, StringFormat='{0:dd/MM/yyyy}'}"
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">
@ -44,38 +76,6 @@
</ListView>
</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="{Binding Id}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding NbPersonnes}"
VerticalOptions="Center"
WidthRequest="50"/>
<Label Text="{Binding DateDebut, StringFormat='{0:dd/MM/yyyy}'}"
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>
</ContentPage.Content>
</ContentPage>

View File

@ -14,7 +14,9 @@ namespace HegreHotel.Views.GestionDepart;
public partial class GestionDepartPage : ContentPage
{
public ObservableCollection<Models.Reservation> Reservations { get; set; } = new ObservableCollection<Models.Reservation>();
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();
@ -26,14 +28,25 @@ public partial class GestionDepartPage : ContentPage
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
var db = SingletonConnection.GetInstance(dbPath);
var reservationList = await db.Table<Models.Reservation>().ToListAsync();
Reservations.Clear();
ReservationsDeb.Clear();
ReservationsFin.Clear();
foreach (var reservation in reservationList)
{
Reservations.Add(reservation);
if (reservation.DateDebut == DateTime.Now.Date)
{
ReservationsDeb.Add(reservation);
} else if (reservation.DateFin == DateTime.Now.Date)
{
ReservationsFin.Add(reservation);
}
}
GestionDepartListView.ItemsSource = Reservations;
GestionArriveListView.ItemsSource = Reservations;
GestionArriveListView.ItemsSource = ReservationsDeb;
GestionDepartListView.ItemsSource = ReservationsFin;
}
private void GestionPage_OnAppearing(object? sender, EventArgs e)