diff --git a/Models/Chambre.cs b/Models/Chambre.cs
index a9fae54..1e86e71 100644
--- a/Models/Chambre.cs
+++ b/Models/Chambre.cs
@@ -18,7 +18,6 @@ public class Chambre
public int StatusId { get; set; }
- // Propriété de navigation pour associer l'objet Status (non stockée en base)
[Ignore]
public Status Status { get; set; }
}
\ No newline at end of file
diff --git a/Views/Chambre/ModifierChambrePage.xaml b/Views/Chambre/ModifierChambrePage.xaml
index 9294ca1..d410090 100644
--- a/Views/Chambre/ModifierChambrePage.xaml
+++ b/Views/Chambre/ModifierChambrePage.xaml
@@ -9,6 +9,10 @@
+
+
+
+
diff --git a/Views/Chambre/ModifierChambrePage.xaml.cs b/Views/Chambre/ModifierChambrePage.xaml.cs
index 1452eb6..c052563 100644
--- a/Views/Chambre/ModifierChambrePage.xaml.cs
+++ b/Views/Chambre/ModifierChambrePage.xaml.cs
@@ -8,6 +8,8 @@ namespace HegreHotel.Views.Chambre
public partial class ModifierChambrePage : ContentPage
{
Models.Chambre _chambre;
+ private List _statuts;
+
public ModifierChambrePage(Models.Chambre chambre)
{
InitializeComponent();
@@ -17,17 +19,40 @@ namespace HegreHotel.Views.Chambre
EntryDescription.Text = _chambre.Description;
EntryTarif.Text = _chambre.Tarif.ToString();
EntryNbPersonne.Text = _chambre.NbPersonne.ToString();
+
+ LoadStatuts();
+ }
+
+ private async void LoadStatuts()
+ {
+ string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
+ var db = SingletonConnection.GetInstance(dbPath);
+
+ _statuts = await db.Table().ToListAsync();
+
+ PickerStatut.ItemsSource = _statuts.Select(s => s.Libelle).ToList();
+ PickerStatut.SelectedIndex = _statuts.FindIndex(s => s.Id == _chambre.StatusId);
}
private async void OnEnregistrerClicked(object sender, EventArgs e)
{
+ if (PickerStatut.SelectedIndex == -1)
+ {
+ await DisplayAlert("Erreur", "Veuillez sélectionner un statut", "OK");
+ return;
+ }
+
_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;
+
+ _chambre.StatusId = _statuts[PickerStatut.SelectedIndex].Id;
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3");
var db = SingletonConnection.GetInstance(dbPath);
+
+ Console.WriteLine(_chambre.StatusId);
await db.UpdateAsync(_chambre);
await Navigation.PopAsync();
}
diff --git a/Views/Client/ClientsPage.xaml.cs b/Views/Client/ClientsPage.xaml.cs
index 7f13f1f..edd06ad 100644
--- a/Views/Client/ClientsPage.xaml.cs
+++ b/Views/Client/ClientsPage.xaml.cs
@@ -69,13 +69,10 @@ namespace HegreHotel.Views.Client
{
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));
}
}