|
|
|
@ -14,7 +14,7 @@ public partial class Nourri : ContentView
|
|
|
|
|
{
|
|
|
|
|
this.EventSelect = EventSelect;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
//restoreListInvite(EventSelect);
|
|
|
|
|
restoreListInvite(EventSelect);
|
|
|
|
|
BindingContext = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -22,8 +22,8 @@ public partial class Nourri : ContentView
|
|
|
|
|
public void restoreListInvite(Evenement EventSelect)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var listFood = EventSelect.Participation.Nourriture;
|
|
|
|
|
Debug.WriteLine(listFood);
|
|
|
|
|
List<Modeles.Nourriture> listFood = EventSelect.Participation.Nourriture;
|
|
|
|
|
Debug.WriteLine("TEst " + listFood.Count());
|
|
|
|
|
int len = 1;
|
|
|
|
|
foreach (Modeles.Nourriture food in listFood)
|
|
|
|
|
{
|
|
|
|
@ -31,17 +31,18 @@ public partial class Nourri : ContentView
|
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
|
|
|
|
|
|
// AJout Prenom
|
|
|
|
|
// AJout Nourriture
|
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
|
foodLabel.Text = food.Nom;
|
|
|
|
|
foodLabel.Text = food.Nom.ToString();
|
|
|
|
|
Debug.WriteLine(foodLabel);
|
|
|
|
|
Grid.SetRow(foodLabel, len);
|
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Nom
|
|
|
|
|
// Ajout Quantite
|
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
|
food.Nom = food.Quantite.ToString();
|
|
|
|
|
qteLabel.Text = food.Quantite.ToString();
|
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
@ -62,49 +63,57 @@ public partial class Nourri : ContentView
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddFoodlist(object sender, EventArgs e)
|
|
|
|
|
private async void AddFoodlist(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//restoreListInvite();
|
|
|
|
|
string food = FoodInput.Text;
|
|
|
|
|
string qte = QteInput.Text;
|
|
|
|
|
if (food == null || qte == null) { return; }
|
|
|
|
|
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
|
|
|
|
|
EventSelect.Participation.Nourriture.Add(food1);
|
|
|
|
|
int len = 1;
|
|
|
|
|
//if (len == 0 ) { len = 1; }
|
|
|
|
|
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
|
|
|
|
|
if (int.TryParse(qte, out int value))
|
|
|
|
|
{
|
|
|
|
|
RowDefinition row = new RowDefinition();
|
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
|
|
|
|
|
|
// AJout Prenom
|
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
|
foodLabel.Text = food2.Nom;
|
|
|
|
|
Grid.SetRow(foodLabel, len);
|
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Nom
|
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
|
food2.Nom = food2.Quantite.ToString();
|
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
|
|
|
|
|
|
// Ajout Bouton
|
|
|
|
|
|
|
|
|
|
Button buttonMoins = new Button();
|
|
|
|
|
buttonMoins.Text = "-";
|
|
|
|
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
|
|
|
|
Grid.SetRow(buttonMoins, len);
|
|
|
|
|
Grid.SetColumn(buttonMoins, 2);
|
|
|
|
|
GridFood.Children.Add(buttonMoins);
|
|
|
|
|
|
|
|
|
|
len++;
|
|
|
|
|
Debug.WriteLine("Test test");
|
|
|
|
|
if (food == null || qte == null) { return; }
|
|
|
|
|
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
|
|
|
|
|
EventSelect.Participation.Nourriture.Add(food1);
|
|
|
|
|
int len = 1;
|
|
|
|
|
//if (len == 0 ) { len = 1; }
|
|
|
|
|
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
|
|
|
|
|
{
|
|
|
|
|
RowDefinition row = new RowDefinition();
|
|
|
|
|
row.Height = new GridLength(45);
|
|
|
|
|
GridFood.RowDefinitions.Add(row);
|
|
|
|
|
|
|
|
|
|
// AJout Nourriture
|
|
|
|
|
Label foodLabel = new Label();
|
|
|
|
|
foodLabel.Text = food2.Nom;
|
|
|
|
|
Grid.SetRow(foodLabel, len);
|
|
|
|
|
Grid.SetColumn(foodLabel, 0);
|
|
|
|
|
GridFood.Children.Add(foodLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajout Quantite
|
|
|
|
|
Label qteLabel = new Label();
|
|
|
|
|
qteLabel.Text = food2.Quantite.ToString();
|
|
|
|
|
Grid.SetRow(qteLabel, len);
|
|
|
|
|
Grid.SetColumn(qteLabel, 1);
|
|
|
|
|
GridFood.Children.Add(qteLabel);
|
|
|
|
|
|
|
|
|
|
// Ajout Bouton
|
|
|
|
|
|
|
|
|
|
Button buttonMoins = new Button();
|
|
|
|
|
buttonMoins.Text = "-";
|
|
|
|
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
|
|
|
|
Grid.SetRow(buttonMoins, len);
|
|
|
|
|
Grid.SetColumn(buttonMoins, 2);
|
|
|
|
|
GridFood.Children.Add(buttonMoins);
|
|
|
|
|
|
|
|
|
|
len++;
|
|
|
|
|
Debug.WriteLine("Test test");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//await DisplayAlert("esv", "efds", "OK");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -121,8 +130,8 @@ public partial class Nourri : ContentView
|
|
|
|
|
|
|
|
|
|
// Vérifier que l'indice rowIndex est valide
|
|
|
|
|
|
|
|
|
|
Label prenomLabel = null;
|
|
|
|
|
Label nomLabel = null;
|
|
|
|
|
Label foodLabel = null;
|
|
|
|
|
Label qteLabel = null;
|
|
|
|
|
|
|
|
|
|
// Parcourir les enfants de la grille pour trouver les labels de la ligne
|
|
|
|
|
foreach (View child in parentGrid.Children)
|
|
|
|
@ -132,29 +141,29 @@ public partial class Nourri : ContentView
|
|
|
|
|
if (childRowIndex == rowIndex)
|
|
|
|
|
{
|
|
|
|
|
if (Grid.GetColumn(child) == 0)
|
|
|
|
|
prenomLabel = (Label)child;
|
|
|
|
|
foodLabel = (Label)child;
|
|
|
|
|
else if (Grid.GetColumn(child) == 1)
|
|
|
|
|
nomLabel = (Label)child;
|
|
|
|
|
qteLabel = (Label)child;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prenomLabel != null && nomLabel != null)
|
|
|
|
|
if (foodLabel != null && qteLabel != null)
|
|
|
|
|
{
|
|
|
|
|
// Récupérer le prénom et le nom de l'invité à supprimer
|
|
|
|
|
string prenom = prenomLabel.Text;
|
|
|
|
|
string nom = nomLabel.Text;
|
|
|
|
|
string nom = foodLabel.Text;
|
|
|
|
|
string qte = qteLabel.Text;
|
|
|
|
|
|
|
|
|
|
// Rechercher l'invité correspondant dans la liste
|
|
|
|
|
Modeles.Inviter inviter = EventSelect.ListInviter.FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
|
|
|
|
|
Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
|
|
|
|
|
|
|
|
|
|
if (inviter != null)
|
|
|
|
|
if (nourriture != null)
|
|
|
|
|
{
|
|
|
|
|
// Supprimer l'invité de la liste
|
|
|
|
|
EventSelect.ListInviter.Remove(inviter);
|
|
|
|
|
EventSelect.Participation.Nourriture.Remove(nourriture);
|
|
|
|
|
|
|
|
|
|
// Supprimer les éléments de la ligne de la grille
|
|
|
|
|
parentGrid.Children.Remove(prenomLabel);
|
|
|
|
|
parentGrid.Children.Remove(nomLabel);
|
|
|
|
|
parentGrid.Children.Remove(foodLabel);
|
|
|
|
|
parentGrid.Children.Remove(qteLabel);
|
|
|
|
|
parentGrid.Children.Remove(button);
|
|
|
|
|
parentGrid.RowDefinitions.RemoveAt(rowIndex);
|
|
|
|
|
}
|
|
|
|
|