|
|
@ -3,13 +3,19 @@ using ParionsCuite.Views.Participations;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ParionsCuite.Views.Participations.NewFolder1;
|
|
|
|
namespace ParionsCuite.Views.Participations.NewFolder1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Represents a ContentView for managing food items (Nourriture) related to a specific event (Evenement).
|
|
|
|
|
|
|
|
*/
|
|
|
|
public partial class Nourri : ContentView
|
|
|
|
public partial class Nourri : ContentView
|
|
|
|
{
|
|
|
|
{
|
|
|
|
readonly Evenement EventSelect;
|
|
|
|
readonly Evenement EventSelect;
|
|
|
|
|
|
|
|
|
|
|
|
public Manageur mgr => (App.Current as App).MyManager;
|
|
|
|
public Manageur mgr => (App.Current as App).MyManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Initializes a new instance of the Nourri class.
|
|
|
|
|
|
|
|
* @param EventSelect The selected event (Evenement).
|
|
|
|
|
|
|
|
*/
|
|
|
|
public Nourri(Evenement EventSelect)
|
|
|
|
public Nourri(Evenement EventSelect)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.EventSelect = EventSelect;
|
|
|
|
this.EventSelect = EventSelect;
|
|
|
@ -18,10 +24,12 @@ public partial class Nourri : ContentView
|
|
|
|
BindingContext = this;
|
|
|
|
BindingContext = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Restores the display of food items (Nourriture) for the selected event (Evenement).
|
|
|
|
|
|
|
|
* @param EventSelect The selected event (Evenement).
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void restoreListFood(Evenement EventSelect)
|
|
|
|
public void restoreListFood(Evenement EventSelect)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
List<Modeles.Nourriture> listFood = EventSelect.Participation.Nourriture;
|
|
|
|
List<Modeles.Nourriture> listFood = EventSelect.Participation.Nourriture;
|
|
|
|
Debug.WriteLine("TEst " + listFood.Count());
|
|
|
|
Debug.WriteLine("TEst " + listFood.Count());
|
|
|
|
int len = 1;
|
|
|
|
int len = 1;
|
|
|
@ -31,7 +39,6 @@ public partial class Nourri : ContentView
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
|
|
|
|
|
|
|
|
// AJout Nourriture
|
|
|
|
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
foodLabel.Text = food.Nom.ToString();
|
|
|
|
foodLabel.Text = food.Nom.ToString();
|
|
|
|
Debug.WriteLine(foodLabel);
|
|
|
|
Debug.WriteLine(foodLabel);
|
|
|
@ -39,16 +46,12 @@ public partial class Nourri : ContentView
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Quantite
|
|
|
|
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
qteLabel.Text = food.Quantite.ToString();
|
|
|
|
qteLabel.Text = food.Quantite.ToString();
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Bouton
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Button buttonMoins = new Button();
|
|
|
|
Button buttonMoins = new Button();
|
|
|
|
buttonMoins.Text = "-";
|
|
|
|
buttonMoins.Text = "-";
|
|
|
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
|
|
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
|
|
@ -58,14 +61,16 @@ public partial class Nourri : ContentView
|
|
|
|
|
|
|
|
|
|
|
|
len++;
|
|
|
|
len++;
|
|
|
|
Debug.WriteLine("Test test");
|
|
|
|
Debug.WriteLine("Test test");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Event handler for the AddFoodlist button.
|
|
|
|
|
|
|
|
* @param sender The object that raised the event.
|
|
|
|
|
|
|
|
* @param e The event arguments.
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void AddFoodlist(object sender, EventArgs e)
|
|
|
|
private void AddFoodlist(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//restoreListInvite();
|
|
|
|
|
|
|
|
string food = FoodInput.Text;
|
|
|
|
string food = FoodInput.Text;
|
|
|
|
string qte = QteInput.Text;
|
|
|
|
string qte = QteInput.Text;
|
|
|
|
if (int.TryParse(qte, out int value))
|
|
|
|
if (int.TryParse(qte, out int value))
|
|
|
@ -74,30 +79,24 @@ public partial class Nourri : ContentView
|
|
|
|
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
|
|
|
|
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
|
|
|
|
EventSelect.Participation.Nourriture.Add(food1);
|
|
|
|
EventSelect.Participation.Nourriture.Add(food1);
|
|
|
|
int len = 1;
|
|
|
|
int len = 1;
|
|
|
|
//if (len == 0 ) { len = 1; }
|
|
|
|
|
|
|
|
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
|
|
|
|
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RowDefinition row = new RowDefinition();
|
|
|
|
RowDefinition row = new RowDefinition();
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
|
|
|
|
|
|
|
|
// AJout Nourriture
|
|
|
|
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
foodLabel.Text = food2.Nom;
|
|
|
|
foodLabel.Text = food2.Nom;
|
|
|
|
Grid.SetRow(foodLabel, len);
|
|
|
|
Grid.SetRow(foodLabel, len);
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Quantite
|
|
|
|
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
qteLabel.Text = food2.Quantite.ToString();
|
|
|
|
qteLabel.Text = food2.Quantite.ToString();
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Bouton
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Button buttonMoins = new Button();
|
|
|
|
Button buttonMoins = new Button();
|
|
|
|
buttonMoins.Text = "-";
|
|
|
|
buttonMoins.Text = "-";
|
|
|
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
|
|
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
|
|
@ -109,33 +108,27 @@ public partial class Nourri : ContentView
|
|
|
|
Debug.WriteLine("Test test");
|
|
|
|
Debug.WriteLine("Test test");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
//await DisplayAlert("esv", "efds", "OK");
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mgr.Save_Data();
|
|
|
|
mgr.Save_Data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Event handler for the BoutonSupprimer_Clicked event.
|
|
|
|
|
|
|
|
* @param sender The object that raised the event.
|
|
|
|
|
|
|
|
* @param e The event arguments.
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
|
|
|
|
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Récupérer le bouton cliqué
|
|
|
|
|
|
|
|
Button button = (Button)sender;
|
|
|
|
Button button = (Button)sender;
|
|
|
|
|
|
|
|
|
|
|
|
// Récupérer la grille parente du bouton
|
|
|
|
|
|
|
|
Grid parentGrid = (Grid)button.Parent;
|
|
|
|
Grid parentGrid = (Grid)button.Parent;
|
|
|
|
|
|
|
|
|
|
|
|
// Récupérer la ligne parente du bouton
|
|
|
|
|
|
|
|
int rowIndex = Grid.GetRow(button);
|
|
|
|
int rowIndex = Grid.GetRow(button);
|
|
|
|
|
|
|
|
|
|
|
|
// Vérifier que l'indice rowIndex est valide
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Label foodLabel = null;
|
|
|
|
Label foodLabel = null;
|
|
|
|
Label qteLabel = null;
|
|
|
|
Label qteLabel = null;
|
|
|
|
|
|
|
|
|
|
|
|
// Parcourir les enfants de la grille pour trouver les labels de la ligne
|
|
|
|
|
|
|
|
foreach (View child in parentGrid.Children)
|
|
|
|
foreach (View child in parentGrid.Children)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int childRowIndex = Grid.GetRow(child);
|
|
|
|
int childRowIndex = Grid.GetRow(child);
|
|
|
@ -151,19 +144,15 @@ public partial class Nourri : ContentView
|
|
|
|
|
|
|
|
|
|
|
|
if (foodLabel != null && qteLabel != null)
|
|
|
|
if (foodLabel != null && qteLabel != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Récupérer le prénom et le nom de l'invité à supprimer
|
|
|
|
|
|
|
|
string nom = foodLabel.Text;
|
|
|
|
string nom = foodLabel.Text;
|
|
|
|
string qte = qteLabel.Text;
|
|
|
|
string qte = qteLabel.Text;
|
|
|
|
|
|
|
|
|
|
|
|
// Rechercher l'invité correspondant dans la liste
|
|
|
|
|
|
|
|
Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
|
|
|
|
Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
|
|
|
|
|
|
|
|
|
|
|
|
if (nourriture != null)
|
|
|
|
if (nourriture != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Supprimer l'invité de la liste
|
|
|
|
|
|
|
|
EventSelect.Participation.Nourriture.Remove(nourriture);
|
|
|
|
EventSelect.Participation.Nourriture.Remove(nourriture);
|
|
|
|
|
|
|
|
|
|
|
|
// Supprimer les éléments de la ligne de la grille
|
|
|
|
|
|
|
|
parentGrid.Children.Remove(foodLabel);
|
|
|
|
parentGrid.Children.Remove(foodLabel);
|
|
|
|
parentGrid.Children.Remove(qteLabel);
|
|
|
|
parentGrid.Children.Remove(qteLabel);
|
|
|
|
parentGrid.Children.Remove(button);
|
|
|
|
parentGrid.Children.Remove(button);
|
|
|
@ -171,6 +160,5 @@ public partial class Nourri : ContentView
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mgr.Save_Data();
|
|
|
|
mgr.Save_Data();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|