Add a shark qui ajoute normalement les requins et edit qui les modifie (peut ^être qu'on pourrait faire mieux avec les linq pour éviter tous les if)

master
thchazot1 3 years ago
parent a47fc413fe
commit c5ba26aeef

@ -25,12 +25,13 @@
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<local:UserControlBoite Grid.Column="0" Grid.Row="0" Message="Nom"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="1" Message="Nom scientifique"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="2" Message="Lien de la photo"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="3" Message="Lien de la vidéo"/>
<local:UserControlBoite Grid.Column="1" Grid.Row="0" Message="Lien de la map"/>
<local:UserControlBoite Grid.Column="1" Grid.Row="1" Message="Fun fact (optionnel)"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="0" Message="Nom" x:Name="name"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="1" Message="Nom scientifique" x:Name="sciName"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="2" Message="Description" x:Name="desc"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="3" Message="Lien de la photo" x:Name="lienPhoto"/>
<local:UserControlBoite Grid.Column="0" Grid.Row="4" Message="Lien de la vidéo" x:Name="lienVid"/>
<local:UserControlBoite Grid.Column="1" Grid.Row="0" Message="Lien de la map" x:Name="lienMap"/>
<local:UserControlBoite Grid.Column="1" Grid.Row="1" Message="Fun fact (optionnel)" x:Name="funny"/>
<Grid Grid.Column="1" Grid.Row="2" ShowGridLines="True" Width="320" Height="19" VerticalAlignment="Top" Background="{StaticResource Couleur2}">
<Grid.RowDefinitions>
<RowDefinition/>
@ -46,10 +47,10 @@
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox Content="Océan Atlantique" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="40,0,0,0"/>
<CheckBox Content="Océan Arctique" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,20,0"/>
<CheckBox Content="Océan Indien" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="40,0,0,0"/>
<CheckBox Content="Océan Pacifique" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Margin="0,0,20,0"/>
<CheckBox Content="Océan Atlantique" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="40,0,0,0" x:Name="Atla"/>
<CheckBox Content="Océan Arctique" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,20,0" x:Name="Arct"/>
<CheckBox Content="Océan Indien" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="40,0,0,0" x:Name="Indi"/>
<CheckBox Content="Océan Pacifique" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Margin="0,0,20,0" x:Name="Paci"/>
</Grid>
<Grid Grid.Column="1" Grid.Row="3" ShowGridLines="True" Width="320" Height="19" VerticalAlignment="Top" Background="{StaticResource Couleur2}" Margin="40,0,40,0">
@ -58,8 +59,8 @@
</Grid.RowDefinitions>
<TextBlock Text="Conservation" HorizontalAlignment="Center" Grid.Row="0" Foreground="{StaticResource Couleur3}"/>
</Grid>
<Grid Grid.Column="1" Grid.Row="3" Margin="40,19,40,0" Width="320" Background="White">
<Grid.ColumnDefinitions>
<Grid x:Name="radio" Grid.Column="1" Grid.Row="3" Margin="40,19,40,0" Width="320" Background="White">
<Grid.ColumnDefinitions >
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
@ -71,17 +72,17 @@
<RowDefinition/>
</Grid.RowDefinitions>
<RadioButton Style="{StaticResource RadioGaga}" Content="EX" Grid.Column="0" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EW" Grid.Column="1" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="CR" Grid.Column="2" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EN" Grid.Column="3" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="VU" Grid.Column="4" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="VN" Grid.Column="0" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="LC" Grid.Column="1" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="DD" Grid.Column="2" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="NE" Grid.Column="3" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EX" Grid.Column="0" Grid.Row="0" x:Name="ex"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EW" Grid.Column="1" Grid.Row="0" x:Name="ew"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="CR" Grid.Column="2" Grid.Row="0" x:Name="cr"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EN" Grid.Column="3" Grid.Row="0" x:Name="en"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="VU" Grid.Column="4" Grid.Row="0" x:Name="vu"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="NT" Grid.Column="0" Grid.Row="1" x:Name="nt"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="LC" Grid.Column="1" Grid.Row="1" x:Name="lc"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="DD" Grid.Column="2" Grid.Row="1" x:Name="dd"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="NE" Grid.Column="3" Grid.Row="1" x:Name="ne"/>
</Grid>
<Button Style="{StaticResource Button1}" Grid.Column="1" Grid.Row="5" Content="Submit" Margin="15" Width="100"/>
<Button Style="{StaticResource Button1}" Grid.Column="1" Grid.Row="5" Content="Submit" Margin="15" Width="100" x:Name="submit" Click="submit_Click"/>
</Grid>
</DockPanel>
</DockPanel>

@ -11,6 +11,8 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Business;
using Modèle;
namespace WpfApp1
{
@ -22,11 +24,113 @@ namespace WpfApp1
public AddAShark()
{
InitializeComponent();
Manager.LoadRequins();
DataContext = Manager;
}
public Manager Manager => (Application.Current as App).LeManager;
private void exit_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void submit_Click(object sender, RoutedEventArgs e)
{
int testCons = 0;
Conservation cons = new Conservation();
List<Zone> lesZones = new List<Zone>();
string nom = name.LeContenu.Text;
string sciNam = sciName.LeContenu.Text;
string descri = desc.LeContenu.Text;
string photo = lienPhoto.LeContenu.Text;
string video = lienVid.LeContenu.Text;
string map = lienMap.LeContenu.Text;
string fun = funny.LeContenu.Text;
if (ex.IsChecked==true)
{
cons = Conservation.EX;
testCons++;
}
else if (ew.IsChecked == true)
{
cons = Conservation.EW;
testCons++;
}
else if (cr.IsChecked == true)
{
cons = Conservation.CR;
testCons++;
}
else if (en.IsChecked == true)
{
cons = Conservation.EN;
testCons++;
}
else if (vu.IsChecked == true)
{
cons = Conservation.VU;
testCons++;
}
else if (nt.IsChecked == true)
{
cons = Conservation.NT;
testCons++;
}
else if (lc.IsChecked == true)
{
cons = Conservation.LC;
}
else if (dd.IsChecked == true)
{
cons = Conservation.DD;
testCons++;
}
else if (ne.IsChecked == true)
{
cons = Conservation.NE;
testCons++;
}
if (Arct.IsChecked == true)
{
lesZones.Add(Zone.ARCTIQUE);
}
if (Atla.IsChecked == true)
{
lesZones.Add(Zone.ATLANTIQUE);
}
if (Indi.IsChecked == true)
{
lesZones.Add(Zone.INDIEN);
}
if (Paci.IsChecked == true)
{
lesZones.Add(Zone.PACIFIQUE);
}
if (testCons == 0 || lesZones.Count() == 0 || string.IsNullOrWhiteSpace(nom) || string.IsNullOrWhiteSpace(sciNam) || string.IsNullOrWhiteSpace(descri)
|| string.IsNullOrWhiteSpace(photo) || string.IsNullOrWhiteSpace(video) || string.IsNullOrWhiteSpace(map) || string.IsNullOrWhiteSpace(fun))
{
return;
}
else
{
Requin requin = new Requin(nom, sciNam, descri, photo, video, map, cons, lesZones, fun);
Manager.AjouterRequin(requin);
Close();
}
}
}
}

@ -47,10 +47,10 @@
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox Content="Océan Atlantique" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="40,0,0,0"/>
<CheckBox Content="Océan Arctique" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,20,0"/>
<CheckBox Content="Océan Indien" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="40,0,0,0"/>
<CheckBox Content="Océan Pacifique" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Margin="0,0,20,0"/>
<CheckBox Content="Océan Atlantique" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="40,0,0,0" x:Name="Atla"/>
<CheckBox Content="Océan Arctique" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,20,0" x:Name="Arct"/>
<CheckBox Content="Océan Indien" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="40,0,0,0" x:Name="Indi"/>
<CheckBox Content="Océan Pacifique" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Margin="0,0,20,0" x:Name="Paci"/>
</Grid>
@ -74,15 +74,15 @@
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<RadioButton Style="{StaticResource RadioGaga}" Content="EX" Grid.Column="0" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EW" Grid.Column="1" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="CR" Grid.Column="2" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EN" Grid.Column="3" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="VU" Grid.Column="4" Grid.Row="0"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="VN" Grid.Column="0" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="LC" Grid.Column="1" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="DD" Grid.Column="2" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="NE" Grid.Column="3" Grid.Row="1"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EX" Grid.Column="0" Grid.Row="0" x:Name="ex"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EW" Grid.Column="1" Grid.Row="0" x:Name="ew"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="CR" Grid.Column="2" Grid.Row="0" x:Name="cr"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="EN" Grid.Column="3" Grid.Row="0" x:Name="en"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="VU" Grid.Column="4" Grid.Row="0" x:Name="vu"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="NT" Grid.Column="0" Grid.Row="1" x:Name="nt"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="LC" Grid.Column="1" Grid.Row="1" x:Name="lc"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="DD" Grid.Column="2" Grid.Row="1" x:Name="dd"/>
<RadioButton Style="{StaticResource RadioGaga}" Content="NE" Grid.Column="3" Grid.Row="1" x:Name="ne"/>
</Grid>
<Button Style="{StaticResource Button1}" Grid.Column="2" Grid.Row="4" Content="Submit" Margin="150,15,150,15" Width="100" x:Name="submit" Click="submit_Click"/>

@ -67,7 +67,9 @@ namespace WpfApp1
private void submit_Click(object sender, RoutedEventArgs e)
{
Requin oldR;
int testCons = 0;
List<Zone> lesZones = new List<Zone>();
Conservation cons = new Conservation();
string nom = leNom.LeContenu.Text;
string sciNam = nomSci.LeContenu.Text;
string descri = desc.LeContenu.Text;
@ -76,21 +78,91 @@ namespace WpfApp1
string map = LienMap.LeContenu.Text;
string fun = funFact.LeContenu.Text;
Requin requin = new Requin(nom, sciNam, descri, photo, video, map, Conservation.EW, null, fun);
foreach (Requin req in Manager.Requins)
if (ex.IsChecked == true)
{
if (req.Equals(requin))
{
Manager.ModifieRequin(req, requin);
break;
}
cons = Conservation.EX;
testCons++;
}
else if (ew.IsChecked == true)
{
cons = Conservation.EW;
testCons++;
}
else if (cr.IsChecked == true)
{
cons = Conservation.CR;
testCons++;
}
else if (en.IsChecked == true)
{
cons = Conservation.EN;
testCons++;
}
else if (vu.IsChecked == true)
{
cons = Conservation.VU;
testCons++;
}
foreach(Requin req in Manager.Requins)
else if (nt.IsChecked == true)
{
Console.WriteLine(req.Description);
cons = Conservation.NT;
testCons++;
}
else if (lc.IsChecked == true)
{
cons = Conservation.LC;
}
else if (dd.IsChecked == true)
{
cons = Conservation.DD;
testCons++;
}
else if (ne.IsChecked == true)
{
cons = Conservation.NE;
testCons++;
}
if (Arct.IsChecked == true)
{
lesZones.Add(Zone.ARCTIQUE);
}
if (Atla.IsChecked == true)
{
lesZones.Add(Zone.ATLANTIQUE);
}
if (Indi.IsChecked == true)
{
lesZones.Add(Zone.INDIEN);
}
if (Paci.IsChecked == true)
{
lesZones.Add(Zone.PACIFIQUE);
}
if (testCons == 0 || lesZones.Count() == 0 || string.IsNullOrWhiteSpace(nom) || string.IsNullOrWhiteSpace(sciNam) || string.IsNullOrWhiteSpace(descri)
|| string.IsNullOrWhiteSpace(photo) || string.IsNullOrWhiteSpace(video) || string.IsNullOrWhiteSpace(map) || string.IsNullOrWhiteSpace(fun))
{
return;
}
else
{
Requin requin = new Requin(nom, sciNam, descri, photo, video, map, Conservation.EW, null, fun);
foreach (Requin req in Manager.Requins)
{
if (req.Equals(requin))
{
Manager.ModifieRequin(req, requin);
break;
}
}
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapAcc();
}
}
}
}

@ -35,7 +35,7 @@ namespace WpfApp1
private void add_Click(object sender, RoutedEventArgs e)
{
var addSharkWindow = new ValiderSubmit();
var addSharkWindow = new AddAShark();
addSharkWindow.ShowDialog();
}

Loading…
Cancel
Save