Big commit
This commit is contained in:
parent
f9a764e550
commit
cab1fcacbf
10
App.xaml.cs
10
App.xaml.cs
@ -1,4 +1,6 @@
|
|||||||
namespace HegreHotel;
|
using HegreHotel.Views;
|
||||||
|
|
||||||
|
namespace HegreHotel;
|
||||||
|
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
@ -6,6 +8,8 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
MainPage = new AppShell();
|
Task.Run(async () => await Database.CreateDatabaseAsync()).Wait();
|
||||||
|
|
||||||
|
MainPage = new NavigationPage(new MainPage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
Database.cs
35
Database.cs
@ -1,26 +1,25 @@
|
|||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using HegreHotel.Models;
|
using HegreHotel.Models;
|
||||||
using SQLite;
|
|
||||||
|
|
||||||
namespace HegreHotel;
|
namespace HegreHotel
|
||||||
|
|
||||||
public class Database
|
|
||||||
{
|
{
|
||||||
private static SQLiteAsyncConnection _database;
|
public class Database
|
||||||
|
|
||||||
public static async Task<SQLiteAsyncConnection> GetConnection()
|
|
||||||
{
|
{
|
||||||
if (_database == null)
|
public static async Task CreateDatabaseAsync()
|
||||||
{
|
{
|
||||||
var databasePath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db");
|
// Construction du chemin de la BDD dans le dossier AppData
|
||||||
_database = new SQLiteAsyncConnection(databasePath);
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
|
||||||
// Créer les tables
|
// Récupération de l'instance unique du Singleton
|
||||||
await _database.CreateTableAsync<Client>();
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
await _database.CreateTableAsync<Chambre>();
|
|
||||||
await _database.CreateTableAsync<Reservation>();
|
// Création des tables
|
||||||
await _database.CreateTableAsync<Status>();
|
await db.CreateTableAsync<Client>();
|
||||||
|
await db.CreateTableAsync<Reservation>();
|
||||||
|
await db.CreateTableAsync<Chambre>();
|
||||||
|
await db.CreateTableAsync<Status>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _database;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -66,4 +66,8 @@
|
|||||||
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Services\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,36 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="HegreHotel.MainPage">
|
x:Class="HegreHotel.MainPage"
|
||||||
|
Title="HegreHotel">
|
||||||
|
<StackLayout Padding="20" VerticalOptions="Center">
|
||||||
|
<Label Text="Bienvenue à HegreHotel"
|
||||||
|
FontSize="24"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
Margin="0,20"/>
|
||||||
|
|
||||||
<ScrollView>
|
<Button Text="Gérer les Clients"
|
||||||
<VerticalStackLayout
|
Clicked="OnClientsClicked"
|
||||||
Padding="30,0"
|
Margin="0,10"/>
|
||||||
Spacing="25">
|
|
||||||
<Image
|
|
||||||
Source="dotnet_bot.png"
|
|
||||||
HeightRequest="185"
|
|
||||||
Aspect="AspectFit"
|
|
||||||
SemanticProperties.Description="dot net bot in a race car number eight" />
|
|
||||||
|
|
||||||
<Label
|
<Button Text="Gérer les Chambres"
|
||||||
Text="Hello, World!"
|
Clicked="OnChambresClicked"
|
||||||
Style="{StaticResource Headline}"
|
Margin="0,10"/>
|
||||||
SemanticProperties.HeadingLevel="Level1" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="Welcome to .NET Multi-platform App UI"
|
|
||||||
Style="{StaticResource SubHeadline}"
|
|
||||||
SemanticProperties.HeadingLevel="Level2"
|
|
||||||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
x:Name="CounterBtn"
|
|
||||||
Text="Click me"
|
|
||||||
SemanticProperties.Hint="Counts the number of times you click"
|
|
||||||
Clicked="OnCounterClicked"
|
|
||||||
HorizontalOptions="Fill" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
|
<Button Text="Gérer les Réservations"
|
||||||
|
Clicked="OnReservationsClicked"
|
||||||
|
Margin="0,10"/>
|
||||||
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
@ -1,23 +1,30 @@
|
|||||||
namespace HegreHotel;
|
using HegreHotel.Views;
|
||||||
|
using HegreHotel.Views.Chambre;
|
||||||
|
using HegreHotel.Views.Reservation;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
|
||||||
public partial class MainPage : ContentPage
|
namespace HegreHotel
|
||||||
{
|
{
|
||||||
int count = 0;
|
public partial class MainPage : ContentPage
|
||||||
|
|
||||||
public MainPage()
|
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
public MainPage()
|
||||||
}
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnCounterClicked(object sender, EventArgs e)
|
private async void OnClientsClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
count++;
|
await Navigation.PushAsync(new ClientsPage());
|
||||||
|
}
|
||||||
|
|
||||||
if (count == 1)
|
private async void OnChambresClicked(object sender, EventArgs e)
|
||||||
CounterBtn.Text = $"Clicked {count} time";
|
{
|
||||||
else
|
await Navigation.PushAsync(new ChambresPage());
|
||||||
CounterBtn.Text = $"Clicked {count} times";
|
}
|
||||||
|
|
||||||
SemanticScreenReader.Announce(CounterBtn.Text);
|
private async void OnReservationsClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new ReservationsPage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,5 +14,5 @@ public class Chambre
|
|||||||
|
|
||||||
public decimal Tarif { get; set; }
|
public decimal Tarif { get; set; }
|
||||||
|
|
||||||
public int NombrePersonnes { get; set; }
|
public int NbPersonne { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -18,4 +18,6 @@ public class Client
|
|||||||
|
|
||||||
[MaxLength(15), Unique]
|
[MaxLength(15), Unique]
|
||||||
public string? Telephone { get; set; }
|
public string? Telephone { get; set; }
|
||||||
|
|
||||||
|
public override string ToString() => $"{Nom} {Prenom}";
|
||||||
}
|
}
|
@ -11,19 +11,8 @@ public class Reservation
|
|||||||
|
|
||||||
public DateTime DateFin { get; set; }
|
public DateTime DateFin { get; set; }
|
||||||
|
|
||||||
public string? Demandes { get; set; }
|
public string? DemandeSpecifique { get; set; }
|
||||||
|
|
||||||
// Navigation properties (ignorées dans SQLite)
|
|
||||||
|
|
||||||
[Indexed]
|
public int NbPersonnes { get; set; }
|
||||||
public int ClientId { get; set; }
|
|
||||||
|
|
||||||
[Indexed]
|
|
||||||
public int ChambreId { get; set; }
|
|
||||||
|
|
||||||
[Ignore]
|
|
||||||
public Client Client { get; set; }
|
|
||||||
|
|
||||||
[Ignore]
|
|
||||||
public Chambre Chambre { get; set; }
|
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
using SQLite;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using HegreHotel;
|
|
||||||
using HegreHotel.Models;
|
|
||||||
|
|
||||||
public class ClientService
|
|
||||||
{
|
|
||||||
// Ajouter un client
|
|
||||||
public static async Task AjouterClient(Client client)
|
|
||||||
{
|
|
||||||
var db = await Database.GetConnection();
|
|
||||||
await db.InsertAsync(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Récupérer tous les clients
|
|
||||||
public static async Task<List<Client>> GetClientsAsync()
|
|
||||||
{
|
|
||||||
var db = await Database.GetConnection();
|
|
||||||
return await db.Table<Client>().ToListAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifier un client
|
|
||||||
public static async Task ModifierClient(Client client)
|
|
||||||
{
|
|
||||||
var db = await Database.GetConnection();
|
|
||||||
await db.UpdateAsync(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Supprimer un client
|
|
||||||
public static async Task SupprimerClient(Client client)
|
|
||||||
{
|
|
||||||
var db = await Database.GetConnection();
|
|
||||||
await db.DeleteAsync(client);
|
|
||||||
}
|
|
||||||
}
|
|
27
SingletonConnection.cs
Normal file
27
SingletonConnection.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using SQLite;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel
|
||||||
|
{
|
||||||
|
public class SingletonConnection : SQLiteAsyncConnection
|
||||||
|
{
|
||||||
|
// Instance unique de la connexion
|
||||||
|
private static SingletonConnection instance;
|
||||||
|
|
||||||
|
// Constructeur privé qui appelle le constructeur parent avec le chemin de la BDD
|
||||||
|
private SingletonConnection(string dbPath) : base(dbPath)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Point d'accès global à l'instance
|
||||||
|
public static SingletonConnection GetInstance(string dbPath)
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = new SingletonConnection(dbPath);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
Views/AjouterClientPage.xaml
Normal file
14
Views/AjouterClientPage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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.AjouterClientPage"
|
||||||
|
Title="Ajouter un Client">
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Entry x:Name="EntryNom" Placeholder="Nom du client"/>
|
||||||
|
<Entry x:Name="EntryPrenom" Placeholder="Prenom"/>
|
||||||
|
<Entry x:Name="EntryEmail" Placeholder="Email" />
|
||||||
|
<Entry x:Name="EntryTelephone" Placeholder="Téléphone" Keyboard="Numeric"/>
|
||||||
|
<Button Text="Enregistrer" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
31
Views/AjouterClientPage.xaml.cs
Normal file
31
Views/AjouterClientPage.xaml.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views
|
||||||
|
{
|
||||||
|
public partial class AjouterClientPage : ContentPage
|
||||||
|
{
|
||||||
|
public AjouterClientPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEnregistrerClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var client = new Client()
|
||||||
|
{
|
||||||
|
Nom = EntryNom.Text,
|
||||||
|
Prenom = EntryPrenom.Text,
|
||||||
|
Email = EntryEmail.Text,
|
||||||
|
Telephone = EntryTelephone.Text,
|
||||||
|
};
|
||||||
|
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.InsertAsync(client);
|
||||||
|
await Navigation.PopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
Views/Chambre/AjouterChambrePage.xaml
Normal file
14
Views/Chambre/AjouterChambrePage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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.AjouterChambrePage"
|
||||||
|
Title="Ajouter une Chambre">
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Entry x:Name="EntryNom" Placeholder="Nom de la chambre"/>
|
||||||
|
<Entry x:Name="EntryDescription" Placeholder="Description"/>
|
||||||
|
<Entry x:Name="EntryTarif" Placeholder="Tarif" Keyboard="Numeric"/>
|
||||||
|
<Entry x:Name="EntryNbPersonne" Placeholder="Nombre de personnes" Keyboard="Numeric"/>
|
||||||
|
<Button Text="Enregistrer" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
31
Views/Chambre/AjouterChambrePage.xaml.cs
Normal file
31
Views/Chambre/AjouterChambrePage.xaml.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Chambre
|
||||||
|
{
|
||||||
|
public partial class AjouterChambrePage : ContentPage
|
||||||
|
{
|
||||||
|
public AjouterChambrePage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEnregistrerClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var chambre = new Models.Chambre
|
||||||
|
{
|
||||||
|
Nom = EntryNom.Text,
|
||||||
|
Description = EntryDescription.Text,
|
||||||
|
Tarif = decimal.TryParse(EntryTarif.Text, out decimal tarif) ? tarif : 0,
|
||||||
|
NbPersonne = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : 0
|
||||||
|
};
|
||||||
|
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.InsertAsync(chambre);
|
||||||
|
await Navigation.PopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
Views/Chambre/ChambresPage.xaml
Normal file
49
Views/Chambre/ChambresPage.xaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?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">
|
||||||
|
<!-- Bouton pour ajouter une chambre -->
|
||||||
|
<Button Text="Ajouter Chambre"
|
||||||
|
Clicked="OnAjouterChambreClicked"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
Margin="0,10"/>
|
||||||
|
|
||||||
|
<!-- Liste des chambres -->
|
||||||
|
<ListView x:Name="ChambresListView" HasUnevenRows="True">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ViewCell>
|
||||||
|
<StackLayout Orientation="Horizontal" Padding="5">
|
||||||
|
<!-- Affichage des informations de la chambre -->
|
||||||
|
<Label Text="{Binding Nom}"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
WidthRequest="100"/>
|
||||||
|
<Label Text="{Binding Description}"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
WidthRequest="150"/>
|
||||||
|
|
||||||
|
<!-- Bouton Modifier -->
|
||||||
|
<Button Text="Modifier"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Clicked="OnModifierChambreClicked"
|
||||||
|
HorizontalOptions="EndAndExpand"
|
||||||
|
Margin="5,0"/>
|
||||||
|
|
||||||
|
<!-- Bouton Supprimer -->
|
||||||
|
<Button Text="Supprimer"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Clicked="OnSupprimerChambreClicked"
|
||||||
|
HorizontalOptions="End"
|
||||||
|
Margin="5,0"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
67
Views/Chambre/ChambresPage.xaml.cs
Normal file
67
Views/Chambre/ChambresPage.xaml.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Chambre
|
||||||
|
{
|
||||||
|
public partial class ChambresPage : ContentPage
|
||||||
|
{
|
||||||
|
public ObservableCollection<Models.Chambre> Chambres { get; set; } = new ObservableCollection<Models.Chambre>();
|
||||||
|
|
||||||
|
public ChambresPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadChambres();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void LoadChambres()
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
var chambresList = await db.Table<Models.Chambre>().ToListAsync();
|
||||||
|
Chambres.Clear();
|
||||||
|
foreach (var chambre in chambresList)
|
||||||
|
{
|
||||||
|
Chambres.Add(chambre);
|
||||||
|
}
|
||||||
|
ChambresListView.ItemsSource = Chambres;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnAjouterChambreClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new AjouterChambrePage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnModifierChambreClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var chambre = ((Button)sender).CommandParameter as Models.Chambre;
|
||||||
|
if (chambre != null)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new ModifierChambrePage(chambre));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnSupprimerChambreClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.DeleteAsync(chambre);
|
||||||
|
LoadChambres();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChambresPage_OnAppearing(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadChambres();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
Views/Chambre/ModifierChambrePage.xaml
Normal file
14
Views/Chambre/ModifierChambrePage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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.ModifierChambrePage"
|
||||||
|
Title="Modifier la Chambre">
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Entry x:Name="EntryNom" Placeholder="Nom de la chambre"/>
|
||||||
|
<Entry x:Name="EntryDescription" Placeholder="Description"/>
|
||||||
|
<Entry x:Name="EntryTarif" Placeholder="Tarif" Keyboard="Numeric"/>
|
||||||
|
<Entry x:Name="EntryNbPersonne" Placeholder="Nombre de personnes" Keyboard="Numeric"/>
|
||||||
|
<Button Text="Enregistrer les modifications" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
35
Views/Chambre/ModifierChambrePage.xaml.cs
Normal file
35
Views/Chambre/ModifierChambrePage.xaml.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Chambre
|
||||||
|
{
|
||||||
|
public partial class ModifierChambrePage : ContentPage
|
||||||
|
{
|
||||||
|
Models.Chambre _chambre;
|
||||||
|
public ModifierChambrePage(Models.Chambre chambre)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_chambre = chambre;
|
||||||
|
// Préremplissage des champs
|
||||||
|
EntryNom.Text = _chambre.Nom;
|
||||||
|
EntryDescription.Text = _chambre.Description;
|
||||||
|
EntryTarif.Text = _chambre.Tarif.ToString();
|
||||||
|
EntryNbPersonne.Text = _chambre.NbPersonne.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEnregistrerClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_chambre.Nom = EntryNom.Text;
|
||||||
|
_chambre.Description = EntryDescription.Text;
|
||||||
|
_chambre.Tarif = decimal.TryParse(EntryTarif.Text, out decimal tarif) ? tarif : _chambre.Tarif;
|
||||||
|
_chambre.NbPersonne = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : _chambre.NbPersonne;
|
||||||
|
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.UpdateAsync(_chambre);
|
||||||
|
await Navigation.PopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,16 +3,47 @@
|
|||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="HegreHotel.Views.ClientsPage"
|
x:Class="HegreHotel.Views.ClientsPage"
|
||||||
Title="Clients">
|
Title="Gestion des Clients"
|
||||||
|
Appearing="ClientsPage_OnAppearing">
|
||||||
<StackLayout>
|
<StackLayout Padding="10">
|
||||||
<Button Text="Ajouter un Client" Clicked="OnAjouterClientClicked" />
|
<!-- Bouton pour ajouter un client -->
|
||||||
<CollectionView x:Name="ClientsList">
|
<Button Text="Ajouter Client"
|
||||||
<CollectionView.ItemTemplate>
|
Clicked="OnAjouterClientClicked"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
Margin="0,10"/>
|
||||||
|
|
||||||
|
<!-- Liste des clients -->
|
||||||
|
<ListView x:Name="ClientsListView" HasUnevenRows="True">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Label Text="{Binding Nom}" />
|
<ViewCell>
|
||||||
|
<StackLayout Orientation="Horizontal" Padding="5">
|
||||||
|
<!-- Affichage des infos du client -->
|
||||||
|
<Label Text="{Binding Nom}"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
WidthRequest="100"/>
|
||||||
|
<Label Text="{Binding Prenom}"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
WidthRequest="100"/>
|
||||||
|
|
||||||
|
<!-- Bouton Modifier -->
|
||||||
|
<Button Text="Modifier"
|
||||||
|
Clicked="OnModifierClientClicked"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
HorizontalOptions="EndAndExpand"
|
||||||
|
Margin="5,0"/>
|
||||||
|
|
||||||
|
<!-- Bouton Supprimer -->
|
||||||
|
<Button Text="Supprimer"
|
||||||
|
Clicked="OnSupprimerClientClicked"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
HorizontalOptions="End"
|
||||||
|
Margin="5,0"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</CollectionView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</CollectionView>
|
</ListView>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
@ -1,37 +1,71 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using HegreHotel.Models;
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
namespace HegreHotel.Views;
|
namespace HegreHotel.Views
|
||||||
|
|
||||||
public partial class ClientsPage : ContentPage
|
|
||||||
{
|
{
|
||||||
public ClientsPage()
|
public partial class ClientsPage : ContentPage
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
public ObservableCollection<Client> Clients { get; set; } = new ObservableCollection<Client>();
|
||||||
ChargerClients();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ChargerClients()
|
|
||||||
{
|
|
||||||
var clients = await ClientService.GetClientsAsync();
|
|
||||||
ClientsList.ItemsSource = clients;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void OnAjouterClientClicked(object sender, EventArgs e)
|
public ClientsPage()
|
||||||
{
|
|
||||||
var nouveauClient = new Client
|
|
||||||
{
|
{
|
||||||
Nom = "Dupont",
|
InitializeComponent();
|
||||||
Prenom = "Jean",
|
LoadClients();
|
||||||
Email = "jean.dupont@example.com",
|
}
|
||||||
Telephone = "0123456789"
|
|
||||||
};
|
|
||||||
|
|
||||||
await ClientService.AjouterClient(nouveauClient);
|
// Chargement des clients depuis la BDD
|
||||||
ChargerClients();
|
private async void LoadClients()
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
var clientsList = await db.Table<Client>().ToListAsync();
|
||||||
|
Clients.Clear();
|
||||||
|
foreach (var client in clientsList)
|
||||||
|
{
|
||||||
|
Clients.Add(client);
|
||||||
|
}
|
||||||
|
ClientsListView.ItemsSource = Clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirige vers la page d'ajout de client
|
||||||
|
private async void OnAjouterClientClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new AjouterClientPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirige vers la page de modification du client sélectionné
|
||||||
|
private async void OnModifierClientClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var client = ((Button)sender).CommandParameter as Client;
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new ModifierClientPage(client));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Suppression du client après confirmation
|
||||||
|
private async void OnSupprimerClientClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var client = ((Button)sender).CommandParameter as Client;
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
bool confirmation = await DisplayAlert("Suppression", "Voulez-vous vraiment supprimer ce client ?", "Oui", "Non");
|
||||||
|
if (confirmation)
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.DeleteAsync(client);
|
||||||
|
LoadClients();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClientsPage_OnAppearing(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadClients();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
Views/ModifierClientPage.xaml
Normal file
14
Views/ModifierClientPage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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.ModifierClientPage"
|
||||||
|
Title="Modifier le Client">
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Entry x:Name="EntryNom" Placeholder="Nom du client"/>
|
||||||
|
<Entry x:Name="EntryPrenom" Placeholder="Prenom"/>
|
||||||
|
<Entry x:Name="EntryEmail" Placeholder="Email" />
|
||||||
|
<Entry x:Name="EntryTelephone" Placeholder="Téléphone" Keyboard="Numeric"/>
|
||||||
|
<Button Text="Enregistrer" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
35
Views/ModifierClientPage.xaml.cs
Normal file
35
Views/ModifierClientPage.xaml.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views
|
||||||
|
{
|
||||||
|
public partial class ModifierClientPage : ContentPage
|
||||||
|
{
|
||||||
|
Client _client;
|
||||||
|
public ModifierClientPage(Client client)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_client = client;
|
||||||
|
// Préremplissage des champs
|
||||||
|
EntryNom.Text = _client.Nom;
|
||||||
|
EntryPrenom.Text = _client.Prenom;
|
||||||
|
EntryEmail.Text = _client.Email;
|
||||||
|
EntryTelephone.Text = _client.Telephone;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEnregistrerClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_client.Nom = EntryNom.Text;
|
||||||
|
_client.Prenom = EntryPrenom.Text;
|
||||||
|
_client.Email = EntryEmail.Text;
|
||||||
|
_client.Telephone = EntryTelephone.Text;
|
||||||
|
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.UpdateAsync(_client);
|
||||||
|
await Navigation.PopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
Views/Reservation/AjouterReservationPage.xaml
Normal file
14
Views/Reservation/AjouterReservationPage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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.AjouterReservationPage"
|
||||||
|
Title="Ajouter une Réservation">
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Entry x:Name="EntryNbInvite" Placeholder="Nombre d'invités" Keyboard="Numeric"/>
|
||||||
|
<DatePicker x:Name="DatePickerDebut" />
|
||||||
|
<DatePicker x:Name="DatePickerFin" />
|
||||||
|
<Entry x:Name="EntryDemandeSpecifique" Placeholder="Demandes spécifiques"/>
|
||||||
|
<Button Text="Enregistrer" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
31
Views/Reservation/AjouterReservationPage.xaml.cs
Normal file
31
Views/Reservation/AjouterReservationPage.xaml.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Reservation
|
||||||
|
{
|
||||||
|
public partial class AjouterReservationPage : ContentPage
|
||||||
|
{
|
||||||
|
public AjouterReservationPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEnregistrerClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var reservation = new Models.Reservation
|
||||||
|
{
|
||||||
|
NbPersonnes = int.TryParse(EntryNbInvite.Text, out int nb) ? nb : 0,
|
||||||
|
DateDebut = DatePickerDebut.Date,
|
||||||
|
DateFin = DatePickerFin.Date,
|
||||||
|
DemandeSpecifique = EntryDemandeSpecifique.Text
|
||||||
|
};
|
||||||
|
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.InsertAsync(reservation);
|
||||||
|
await Navigation.PopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
Views/Reservation/ModifierReservationPage.xaml
Normal file
14
Views/Reservation/ModifierReservationPage.xaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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.ModifierReservationPage"
|
||||||
|
Title="Modifier la Réservation">
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Entry x:Name="EntryNbInvite" Placeholder="Nombre d'invités" Keyboard="Numeric"/>
|
||||||
|
<DatePicker x:Name="DatePickerDebut" />
|
||||||
|
<DatePicker x:Name="DatePickerFin" />
|
||||||
|
<Entry x:Name="EntryDemandeSpecifique" Placeholder="Demandes spécifiques"/>
|
||||||
|
<Button Text="Enregistrer les modifications" Clicked="OnEnregistrerClicked" Margin="0,20"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
35
Views/Reservation/ModifierReservationPage.xaml.cs
Normal file
35
Views/Reservation/ModifierReservationPage.xaml.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Reservation
|
||||||
|
{
|
||||||
|
public partial class ModifierReservationPage : ContentPage
|
||||||
|
{
|
||||||
|
Models.Reservation _reservation;
|
||||||
|
public ModifierReservationPage(Models.Reservation reservation)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_reservation = reservation;
|
||||||
|
// Préremplir les champs
|
||||||
|
EntryNbInvite.Text = _reservation.NbPersonnes.ToString();
|
||||||
|
DatePickerDebut.Date = _reservation.DateDebut;
|
||||||
|
DatePickerFin.Date = _reservation.DateFin;
|
||||||
|
EntryDemandeSpecifique.Text = _reservation.DemandeSpecifique;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEnregistrerClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_reservation.NbPersonnes = int.TryParse(EntryNbInvite.Text, out int nb) ? nb : _reservation.NbPersonnes;
|
||||||
|
_reservation.DateDebut = DatePickerDebut.Date;
|
||||||
|
_reservation.DateFin = DatePickerFin.Date;
|
||||||
|
_reservation.DemandeSpecifique = EntryDemandeSpecifique.Text;
|
||||||
|
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.UpdateAsync(_reservation);
|
||||||
|
await Navigation.PopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
Views/Reservation/ReservationsPage.xaml
Normal file
51
Views/Reservation/ReservationsPage.xaml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?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">
|
||||||
|
<!-- Bouton pour ajouter une réservation -->
|
||||||
|
<Button Text="Ajouter Réservation"
|
||||||
|
Clicked="OnAjouterReservationClicked"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
Margin="0,10"/>
|
||||||
|
|
||||||
|
<!-- Liste des réservations -->
|
||||||
|
<ListView x:Name="ReservationsListView" HasUnevenRows="True">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ViewCell>
|
||||||
|
<StackLayout Orientation="Horizontal" Padding="5">
|
||||||
|
<!-- Affichage des infos de la réservation -->
|
||||||
|
<Label Text="{Binding NbInvite}"
|
||||||
|
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"/>
|
||||||
|
|
||||||
|
<!-- Bouton Modifier -->
|
||||||
|
<Button Text="Modifier"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Clicked="OnModifierReservationClicked"
|
||||||
|
HorizontalOptions="EndAndExpand"
|
||||||
|
Margin="5,0"/>
|
||||||
|
|
||||||
|
<!-- Bouton Supprimer -->
|
||||||
|
<Button Text="Supprimer"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Clicked="OnSupprimerReservationClicked"
|
||||||
|
HorizontalOptions="End"
|
||||||
|
Margin="5,0"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
67
Views/Reservation/ReservationsPage.xaml.cs
Normal file
67
Views/Reservation/ReservationsPage.xaml.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using HegreHotel.Models;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
|
namespace HegreHotel.Views.Reservation
|
||||||
|
{
|
||||||
|
public partial class ReservationsPage : ContentPage
|
||||||
|
{
|
||||||
|
public ObservableCollection<Models.Reservation> Reservations { get; set; } = new ObservableCollection<Models.Reservation>();
|
||||||
|
|
||||||
|
public ReservationsPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadReservations();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void LoadReservations()
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
var reservationsList = await db.Table<Models.Reservation>().ToListAsync();
|
||||||
|
Reservations.Clear();
|
||||||
|
foreach (var reservation in reservationsList)
|
||||||
|
{
|
||||||
|
Reservations.Add(reservation);
|
||||||
|
}
|
||||||
|
ReservationsListView.ItemsSource = Reservations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnAjouterReservationClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new AjouterReservationPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnModifierReservationClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var reservation = ((Button)sender).CommandParameter as Models.Reservation;
|
||||||
|
if (reservation != null)
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new ModifierReservationPage(reservation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnSupprimerReservationClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
|
||||||
|
var db = SingletonConnection.GetInstance(dbPath);
|
||||||
|
await db.DeleteAsync(reservation);
|
||||||
|
LoadReservations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReservationsPage_OnAppearing(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadReservations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user