Compare commits
4 Commits
1cc7257f5f
...
dde7dd9f73
Author | SHA1 | Date | |
---|---|---|---|
dde7dd9f73 | |||
76e4e68799 | |||
8168c8844d | |||
abad40c9f6 |
@ -13,7 +13,7 @@ public class Reservation
|
|||||||
|
|
||||||
public string? DemandeSpecifique { get; set; }
|
public string? DemandeSpecifique { get; set; }
|
||||||
|
|
||||||
public int NbPersonnes { get; set; }
|
public int NbInvite { get; set; }
|
||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
public int ChambreId { get; set; }
|
public int ChambreId { get; set; }
|
||||||
|
@ -6,7 +6,7 @@ namespace HegreHotel
|
|||||||
{
|
{
|
||||||
public class SingletonConnection : SQLiteAsyncConnection
|
public class SingletonConnection : SQLiteAsyncConnection
|
||||||
{
|
{
|
||||||
private static SingletonConnection instance;
|
private static SingletonConnection? _instance;
|
||||||
|
|
||||||
private SingletonConnection(string dbPath) : base(dbPath)
|
private SingletonConnection(string dbPath) : base(dbPath)
|
||||||
{
|
{
|
||||||
@ -14,11 +14,11 @@ namespace HegreHotel
|
|||||||
|
|
||||||
public static SingletonConnection GetInstance(string dbPath)
|
public static SingletonConnection GetInstance(string dbPath)
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
instance = new SingletonConnection(dbPath);
|
_instance = new SingletonConnection(dbPath);
|
||||||
}
|
}
|
||||||
return instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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; }
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@
|
|||||||
<Label Text="Sélectionnez une chambre disponible" FontAttributes="Bold"/>
|
<Label Text="Sélectionnez une chambre disponible" FontAttributes="Bold"/>
|
||||||
<Picker x:Name="PickerChambre" Title="Sélectionner une chambre"/>
|
<Picker x:Name="PickerChambre" Title="Sélectionner une chambre"/>
|
||||||
|
|
||||||
<Entry x:Name="EntryNbPersonne" Placeholder="Nombre de personnes" Keyboard="Numeric"/>
|
<Entry x:Name="EntryNbInvite" Placeholder="Nombre de personnes" Keyboard="Numeric"/>
|
||||||
<Entry x:Name="EntryDemandeSpecifique" Placeholder="Demandes spécifiques"/>
|
<Entry x:Name="EntryDemandeSpecifique" Placeholder="Demandes spécifiques"/>
|
||||||
|
|
||||||
<Button Text="Enregistrer" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
<Button Text="Enregistrer" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
@ -69,7 +69,7 @@ namespace HegreHotel.Views.Reservation
|
|||||||
{
|
{
|
||||||
ClientId = _clients[PickerClient.SelectedIndex].Id,
|
ClientId = _clients[PickerClient.SelectedIndex].Id,
|
||||||
ChambreId = _chambresDispo[PickerChambre.SelectedIndex].Id,
|
ChambreId = _chambresDispo[PickerChambre.SelectedIndex].Id,
|
||||||
NbPersonnes = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : 0,
|
NbInvite = int.TryParse(EntryNbInvite.Text, out int nb) ? nb : 0,
|
||||||
DateDebut = DatePickerDebut.Date,
|
DateDebut = DatePickerDebut.Date,
|
||||||
DateFin = DatePickerFin.Date,
|
DateFin = DatePickerFin.Date,
|
||||||
DemandeSpecifique = EntryDemandeSpecifique.Text
|
DemandeSpecifique = EntryDemandeSpecifique.Text
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<Picker x:Name="PickerClient" Title="Sélectionner un client"/>
|
<Picker x:Name="PickerClient" Title="Sélectionner un client"/>
|
||||||
<Picker x:Name="PickerChambre" Title="Sélectionner une chambre"/>
|
<Picker x:Name="PickerChambre" Title="Sélectionner une chambre"/>
|
||||||
|
|
||||||
<Entry x:Name="EntryNbPersonne" Placeholder="Nombre d'invités" Keyboard="Numeric"/>
|
<Entry x:Name="EntryNbInvite" Placeholder="Nombre d'invités" Keyboard="Numeric"/>
|
||||||
<DatePicker x:Name="DatePickerDebut" />
|
<DatePicker x:Name="DatePickerDebut" />
|
||||||
<DatePicker x:Name="DatePickerFin" />
|
<DatePicker x:Name="DatePickerFin" />
|
||||||
<Entry x:Name="EntryDemandeSpecifique" Placeholder="Demandes spécifiques"/>
|
<Entry x:Name="EntryDemandeSpecifique" Placeholder="Demandes spécifiques"/>
|
||||||
|
@ -34,7 +34,7 @@ namespace HegreHotel.Views.Reservation
|
|||||||
PickerClient.SelectedIndex = _clients.FindIndex(c => c.Id == _reservation.ClientId);
|
PickerClient.SelectedIndex = _clients.FindIndex(c => c.Id == _reservation.ClientId);
|
||||||
PickerChambre.SelectedIndex = _chambres.FindIndex(ch => ch.Id == _reservation.ChambreId);
|
PickerChambre.SelectedIndex = _chambres.FindIndex(ch => ch.Id == _reservation.ChambreId);
|
||||||
|
|
||||||
EntryNbPersonne.Text = _reservation.NbPersonnes.ToString();
|
EntryNbInvite.Text = _reservation.NbInvite.ToString();
|
||||||
DatePickerDebut.Date = _reservation.DateDebut;
|
DatePickerDebut.Date = _reservation.DateDebut;
|
||||||
DatePickerFin.Date = _reservation.DateFin;
|
DatePickerFin.Date = _reservation.DateFin;
|
||||||
EntryDemandeSpecifique.Text = _reservation.DemandeSpecifique;
|
EntryDemandeSpecifique.Text = _reservation.DemandeSpecifique;
|
||||||
@ -50,7 +50,7 @@ namespace HegreHotel.Views.Reservation
|
|||||||
|
|
||||||
_reservation.ClientId = _clients[PickerClient.SelectedIndex].Id;
|
_reservation.ClientId = _clients[PickerClient.SelectedIndex].Id;
|
||||||
_reservation.ChambreId = _chambres[PickerChambre.SelectedIndex].Id;
|
_reservation.ChambreId = _chambres[PickerChambre.SelectedIndex].Id;
|
||||||
_reservation.NbPersonnes = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : _reservation.NbPersonnes;
|
_reservation.NbInvite = int.TryParse(EntryNbInvite.Text, out int nb) ? nb : _reservation.NbInvite;
|
||||||
_reservation.DateDebut = DatePickerDebut.Date;
|
_reservation.DateDebut = DatePickerDebut.Date;
|
||||||
_reservation.DateFin = DatePickerFin.Date;
|
_reservation.DateFin = DatePickerFin.Date;
|
||||||
_reservation.DemandeSpecifique = EntryDemandeSpecifique.Text;
|
_reservation.DemandeSpecifique = EntryDemandeSpecifique.Text;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user