commit
de00e2679d
@ -1,50 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
x:Class="ParionsCuite.Views.Participations.Boisson.Boissons">
|
|
||||||
<VerticalStackLayout>
|
|
||||||
|
|
||||||
<!--Grid Participation-->
|
|
||||||
<Grid ColumnDefinitions="*,*,*">
|
|
||||||
<Button Text="Nourriture" />
|
|
||||||
<Button Text="Boisson" Grid.Column="1" BackgroundColor="Grey"/>
|
|
||||||
<Button Text="Autre" Grid.Column="2" />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<!--Grid Pincipale-->
|
|
||||||
<Grid ColumnDefinitions="*,*,*">
|
|
||||||
|
|
||||||
<!--Input des boissons et quantité-->
|
|
||||||
<StackLayout Grid.Column="0" >
|
|
||||||
<Entry Placeholder="Entrer boisson" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
|
||||||
<Entry Placeholder="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
|
||||||
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
|
|
||||||
</StackLayout>
|
|
||||||
|
|
||||||
<!--Grid quantité et boisson + output -->
|
|
||||||
<Grid Grid.Column="2" Margin="30">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="2*" />
|
|
||||||
<ColumnDefinition Width="2*" />
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
<!--Header Grille quantité+boisson-->
|
|
||||||
<Label Text="Boisson" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
|
||||||
<Label Text="Quantité" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
|
||||||
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
|
||||||
|
|
||||||
<!--Content Grille quantité+boisson-->
|
|
||||||
<Label Text="Vodka" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
|
|
||||||
<Label Text="2" Grid.Column="1" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
|
|
||||||
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ContentView>
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="ParionsCuite.Views.Participations.Boisson.Drink">
|
||||||
|
|
||||||
|
<VerticalStackLayout>
|
||||||
|
<Grid ColumnDefinitions="5*, 1*, 5*">
|
||||||
|
|
||||||
|
<!--Input des nourritures et quantité-->
|
||||||
|
<StackLayout Grid.Column="0" >
|
||||||
|
<Entry Placeholder="Entrer Boisson" x:Name="DrinkInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||||
|
<Entry Placeholder="Entrer quantité" Keyboard="Numeric" x:Name="QteInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||||
|
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AddDrinklist"/>
|
||||||
|
</StackLayout>
|
||||||
|
|
||||||
|
<!--Grid quantité et nourrite + output -->
|
||||||
|
<Grid Grid.Column="2" x:Name="GridDrink">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="2*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="3*" x:Name="sup"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--Header Grille quantité+nourritre-->
|
||||||
|
<Label Text="Boisson" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||||
|
<Label Text="Quantité" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||||
|
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</ContentView>
|
@ -0,0 +1,173 @@
|
|||||||
|
using ParionsCuite.Modeles;
|
||||||
|
using ParionsCuite.Views.Participations;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace ParionsCuite.Views.Participations.Boisson;
|
||||||
|
|
||||||
|
public partial class Drink : ContentView
|
||||||
|
{
|
||||||
|
|
||||||
|
readonly Evenement EventSelect;
|
||||||
|
|
||||||
|
public Manageur mgr => (App.Current as App).MyManager;
|
||||||
|
|
||||||
|
public Drink(Evenement EventSelect)
|
||||||
|
{
|
||||||
|
this.EventSelect = EventSelect;
|
||||||
|
InitializeComponent();
|
||||||
|
restoreListBoisson(EventSelect);
|
||||||
|
BindingContext = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreListBoisson(Evenement EventSelect)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<Modeles.Boisson> listDrink = EventSelect.Participation.Boissons;
|
||||||
|
Debug.WriteLine("TEst " + listDrink.Count());
|
||||||
|
int len = 1;
|
||||||
|
foreach (Modeles.Boisson food in listDrink)
|
||||||
|
{
|
||||||
|
RowDefinition row = new RowDefinition();
|
||||||
|
row.Height = new GridLength(45);
|
||||||
|
GridDrink.RowDefinitions.Add(row);
|
||||||
|
|
||||||
|
// AJout Nourriture
|
||||||
|
Label DrinkLabel = new Label();
|
||||||
|
DrinkLabel.Text = food.Nom.ToString();
|
||||||
|
Debug.WriteLine(DrinkLabel);
|
||||||
|
Grid.SetRow(DrinkLabel, len);
|
||||||
|
Grid.SetColumn(DrinkLabel, 0);
|
||||||
|
GridDrink.Children.Add(DrinkLabel);
|
||||||
|
|
||||||
|
|
||||||
|
// Ajout Quantite
|
||||||
|
Label qteLabel = new Label();
|
||||||
|
qteLabel.Text = food.Quantite.ToString();
|
||||||
|
Grid.SetRow(qteLabel, len);
|
||||||
|
Grid.SetColumn(qteLabel, 1);
|
||||||
|
GridDrink.Children.Add(qteLabel);
|
||||||
|
|
||||||
|
// Ajout Bouton
|
||||||
|
|
||||||
|
Button buttonMoins = new Button();
|
||||||
|
buttonMoins.Text = "-";
|
||||||
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
||||||
|
Grid.SetRow(buttonMoins, len);
|
||||||
|
Grid.SetColumn(buttonMoins, 2);
|
||||||
|
GridDrink.Children.Add(buttonMoins);
|
||||||
|
|
||||||
|
len++;
|
||||||
|
Debug.WriteLine("Test test");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void AddDrinklist(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//restoreListInvite();
|
||||||
|
string drink = DrinkInput.Text;
|
||||||
|
string qte = QteInput.Text;
|
||||||
|
if (int.TryParse(qte, out int value))
|
||||||
|
{
|
||||||
|
if (drink == null || qte == null) { return; }
|
||||||
|
Modeles.Boisson drink1 = new Modeles.Boisson(drink, Int32.Parse(qte));
|
||||||
|
EventSelect.Participation.Boissons.Add(drink1);
|
||||||
|
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);
|
||||||
|
GridDrink.RowDefinitions.Add(row);
|
||||||
|
|
||||||
|
// AJout Nourriture
|
||||||
|
Label DrinkLabel = new Label();
|
||||||
|
DrinkLabel.Text = food2.Nom;
|
||||||
|
Grid.SetRow(DrinkLabel, len);
|
||||||
|
Grid.SetColumn(DrinkLabel, 0);
|
||||||
|
GridDrink.Children.Add(DrinkLabel);
|
||||||
|
|
||||||
|
|
||||||
|
// Ajout Quantite
|
||||||
|
Label qteLabel = new Label();
|
||||||
|
qteLabel.Text = food2.Quantite.ToString();
|
||||||
|
Grid.SetRow(qteLabel, len);
|
||||||
|
Grid.SetColumn(qteLabel, 1);
|
||||||
|
GridDrink.Children.Add(qteLabel);
|
||||||
|
|
||||||
|
// Ajout Bouton
|
||||||
|
|
||||||
|
Button buttonMoins = new Button();
|
||||||
|
buttonMoins.Text = "-";
|
||||||
|
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
||||||
|
Grid.SetRow(buttonMoins, len);
|
||||||
|
Grid.SetColumn(buttonMoins, 2);
|
||||||
|
GridDrink.Children.Add(buttonMoins);
|
||||||
|
|
||||||
|
len++;
|
||||||
|
Debug.WriteLine("Test test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//await DisplayAlert("esv", "efds", "OK");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// Récupérer le bouton cliqué
|
||||||
|
Button button = (Button)sender;
|
||||||
|
|
||||||
|
// Récupérer la grille parente du bouton
|
||||||
|
Grid parentGrid = (Grid)button.Parent;
|
||||||
|
|
||||||
|
// Récupérer la ligne parente du bouton
|
||||||
|
int rowIndex = Grid.GetRow(button);
|
||||||
|
|
||||||
|
// Vérifier que l'indice rowIndex est valide
|
||||||
|
|
||||||
|
Label DrinkLabel = null;
|
||||||
|
Label qteLabel = null;
|
||||||
|
|
||||||
|
// Parcourir les enfants de la grille pour trouver les labels de la ligne
|
||||||
|
foreach (View child in parentGrid.Children)
|
||||||
|
{
|
||||||
|
int childRowIndex = Grid.GetRow(child);
|
||||||
|
|
||||||
|
if (childRowIndex == rowIndex)
|
||||||
|
{
|
||||||
|
if (Grid.GetColumn(child) == 0)
|
||||||
|
DrinkLabel = (Label)child;
|
||||||
|
else if (Grid.GetColumn(child) == 1)
|
||||||
|
qteLabel = (Label)child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DrinkLabel != null && qteLabel != null)
|
||||||
|
{
|
||||||
|
// Récupérer le prénom et le nom de l'invité à supprimer
|
||||||
|
string nom = DrinkLabel.Text;
|
||||||
|
string qte = qteLabel.Text;
|
||||||
|
|
||||||
|
// Rechercher l'invité correspondant dans la liste
|
||||||
|
Modeles.Boisson drink = EventSelect.Participation.Boissons.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
|
||||||
|
|
||||||
|
if (drink != null)
|
||||||
|
{
|
||||||
|
// Supprimer l'invité de la liste
|
||||||
|
EventSelect.Participation.Boissons.Remove(drink);
|
||||||
|
|
||||||
|
// Supprimer les éléments de la ligne de la grille
|
||||||
|
parentGrid.Children.Remove(DrinkLabel);
|
||||||
|
parentGrid.Children.Remove(qteLabel);
|
||||||
|
parentGrid.Children.Remove(button);
|
||||||
|
parentGrid.RowDefinitions.RemoveAt(rowIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue