client page par id
This commit is contained in:
parent
8168c8844d
commit
76e4e68799
@ -11,7 +11,7 @@
|
|||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
Margin="0,10"/>
|
Margin="0,10"/>
|
||||||
|
|
||||||
<ListView x:Name="ClientsListView" HasUnevenRows="True">
|
<ListView x:Name="ClientsListView" HasUnevenRows="True" ItemTapped="OnClientTapped">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
@ -40,5 +40,7 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
|
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
@ -27,6 +27,7 @@ namespace HegreHotel.Views.Client
|
|||||||
Clients.Add(client);
|
Clients.Add(client);
|
||||||
}
|
}
|
||||||
ClientsListView.ItemsSource = Clients;
|
ClientsListView.ItemsSource = Clients;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnAjouterClientClicked(object sender, EventArgs e)
|
private async void OnAjouterClientClicked(object sender, EventArgs e)
|
||||||
@ -63,5 +64,20 @@ namespace HegreHotel.Views.Client
|
|||||||
{
|
{
|
||||||
LoadClients();
|
LoadClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void OnClientTapped(object sender, ItemTappedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Item != null)
|
||||||
|
{
|
||||||
|
// 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
Views/Client/DetailsClientPage.xaml
Normal file
35
Views/Client/DetailsClientPage.xaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?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.DetailsClientPage">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<ScrollView>
|
||||||
|
<StackLayout Padding="10" Spacing="5">
|
||||||
|
<HorizontalStackLayout Spacing="5">
|
||||||
|
<Label Text="{Binding Nom}" FontAttributes="Bold" FontSize="18"/>
|
||||||
|
<Label Text="{Binding Prenom}" FontSize="18"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
<VerticalStackLayout>
|
||||||
|
<Label Text="{Binding Email}"/>
|
||||||
|
<Label Text="{Binding Telephone}"/>
|
||||||
|
</VerticalStackLayout>
|
||||||
|
<Label Text="Historique des réservations :" FontAttributes="Bold" FontSize="Large"/>
|
||||||
|
<ListView x:Name="ListeReservations">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ViewCell>
|
||||||
|
<StackLayout Orientation="Horizontal" Padding="5" Spacing="10">
|
||||||
|
<Label Text="{Binding DateDebut, StringFormat='{0:dd/MM/yyyy}'}"/>
|
||||||
|
<Label Text="{Binding DateFin, StringFormat='{0:dd/MM/yyyy}'}"/>
|
||||||
|
<Label Text="{Binding NbInvite}"/>
|
||||||
|
<Label Text="{Binding ChambreNom}"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
71
Views/Client/DetailsClientPage.xaml.cs
Normal file
71
Views/Client/DetailsClientPage.xaml.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Client;
|
||||||
|
|
||||||
|
public partial class DetailsClientPage : ContentPage
|
||||||
|
{
|
||||||
|
public Models.Client Client { get; set; }
|
||||||
|
|
||||||
|
public DetailsClientPage(Models.Client client)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
BindingContext = client;
|
||||||
|
Client = client;
|
||||||
|
LoadReservations();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void LoadReservations()
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
List<Models.Reservation> reservationsList = await db.Table<Models.Reservation>().Where(x => x.ClientId == Client.Id).ToListAsync();
|
||||||
|
List<Models.Chambre> cahmbresList = await db.Table<Models.Chambre>().ToListAsync();
|
||||||
|
List<ReservationInfo> reservationInfoList = new List<ReservationInfo>();
|
||||||
|
|
||||||
|
if (reservationsList is null)
|
||||||
|
{
|
||||||
|
await DisplayAlert("Aucune réservation", "Le client n'a pas de réservations", "OK");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Models.Reservation reservation in reservationsList)
|
||||||
|
{
|
||||||
|
ReservationInfo reservationInfo = new ReservationInfo()
|
||||||
|
{
|
||||||
|
DateDebut = reservation.DateDebut,
|
||||||
|
DateFin = reservation.DateFin,
|
||||||
|
DemandeSpecifique = reservation.DemandeSpecifique,
|
||||||
|
NbInvite = reservation.NbInvite
|
||||||
|
};
|
||||||
|
foreach (Models.Chambre chambre in cahmbresList)
|
||||||
|
{
|
||||||
|
if (reservation.ChambreId == chambre.Id)
|
||||||
|
{
|
||||||
|
reservationInfo.ChambreNom = chambre.Nom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reservationInfoList.Add(reservationInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListeReservations.ItemsSource = reservationInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReservationInfo
|
||||||
|
{
|
||||||
|
public DateTime DateDebut { get; set; }
|
||||||
|
|
||||||
|
public DateTime DateFin { get; set; }
|
||||||
|
|
||||||
|
public string? DemandeSpecifique { get; set; }
|
||||||
|
|
||||||
|
public int NbInvite { get; set; }
|
||||||
|
|
||||||
|
public string? ChambreNom { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user