Changements des if dans edit et add a shark pour que ce soit des boucles (c'est plus bo)

master
thchazot1 3 years ago
parent 2e8f77c413
commit cec8973b0c

@ -197,5 +197,15 @@ namespace Business
}
return nvReq;
}
public bool verifierRequin(string nom, string nomSci, string description, string photo, string video, string photoCarte)
{
if (string.IsNullOrWhiteSpace(nom) || string.IsNullOrWhiteSpace(nomSci) || string.IsNullOrWhiteSpace(description) || string.IsNullOrWhiteSpace(photo)
|| string.IsNullOrWhiteSpace(video) || string.IsNullOrWhiteSpace(photoCarte))
{
return false;
}
return true;
}
}
}

@ -21,4 +21,6 @@ namespace Modèle
DD,
NE
}
}

@ -63,43 +63,6 @@ namespace Modèle
}
public void ModiferRequin(string description, string photo, string video, string photoCarte, Conservation statutCons, List<Zone> repartition, string funFact)
{
if (! string.IsNullOrWhiteSpace(description))
{
Description = description;
}
if(! string.IsNullOrWhiteSpace(photo))
{
Photo = photo;
}
if(!string.IsNullOrWhiteSpace(video))
{
Video = video;
}
if (!string.IsNullOrWhiteSpace(photoCarte))
{
Photo = photoCarte;
}
if (statutCons != Conservation.NE)
{
StatutCons = statutCons;
}
if (!string.IsNullOrWhiteSpace(funFact))
{
FunFact = funFact;
}
if (repartition.Count()!= 0){
Repartition.Clear();
foreach(Zone z in repartition)
{
Repartition.Add(z);
}
}
}
public bool Equals(Requin r)
{
@ -120,39 +83,5 @@ namespace Modèle
}
}
/*
public List<Requin> RechercheParNom(List<Requin> requins, string rech)
{
List<Requin> nvRequins = new List<Requin>();
foreach (Requin req in requins)
{
if (req.Nom.StartsWith(rech) || req.NomSci.StartsWith(rech))
{
nvRequins.Add(req);
}
}
return nvRequins;
}
public List<Requin> RechercheParZone(List<Requin> requins, Zone zone)
{
List<Requin> nvRequins = new List<Requin>();
foreach (Requin req in requins)
{
foreach (Zone laZone in req.Repartition)
{
if (laZone == zone)
{
nvRequins.Add(req);
break;
}
}
}
return nvRequins;
}
*/
}

@ -59,7 +59,7 @@
</Grid.RowDefinitions>
<TextBlock Text="Conservation" HorizontalAlignment="Center" Grid.Row="0" Foreground="{StaticResource Couleur3}"/>
</Grid>
<Grid x:Name="radio" Grid.Column="1" Grid.Row="3" Margin="40,19,40,0" Width="320" Background="White">
<Grid x:Name="radioButtons" Grid.Column="1" Grid.Row="3" Margin="40,19,40,0" Width="320" Background="White">
<Grid.ColumnDefinitions >
<ColumnDefinition/>
<ColumnDefinition/>

@ -33,7 +33,18 @@ namespace WpfApp1
public Manager Mgr => (Application.Current as App).LeManager;
private List<Conservation> consList = new List<Conservation>
{
Conservation.EX,
Conservation.EW,
Conservation.CR,
Conservation.EN,
Conservation.VU,
Conservation.NT,
Conservation.LC,
Conservation.DD,
Conservation.NE
};
private void exit_Click(object sender, RoutedEventArgs e)
@ -55,50 +66,28 @@ namespace WpfApp1
string fun = funny.LeContenu.Text;
if (ex.IsChecked==true)
foreach (Control control in this.radioButtons.Children)
{
cons = Conservation.EX;
testCons++;
}
else if (ew.IsChecked == true)
if (control is RadioButton)
{
cons = Conservation.EW;
testCons++;
}
else if (cr.IsChecked == true)
RadioButton radio = control as RadioButton;
if (radio.IsChecked == true)
{
cons = Conservation.CR;
testCons++;
}
else if (en.IsChecked == true)
if (radio.Content is string radString)
{
cons = Conservation.EN;
testCons++;
}
else if (vu.IsChecked == true)
foreach (Conservation conserv in consList)
{
cons = Conservation.VU;
testCons++;
}
else if (nt.IsChecked == true)
if (radString == conserv.ToString())
{
cons = Conservation.NT;
testCons++;
cons = conserv;
goto loopEnd;
}
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++;
}
}
}
loopEnd:
@ -121,7 +110,6 @@ namespace WpfApp1
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;
}

@ -17,8 +17,8 @@ namespace WpfApp1
{
public static IPersistanceManager strat { get; private set; }
= new DataContractPersistance();
public Manager LeManager { get; private set; } = new Manager(strat);
public ManagerUsers LeManagerUsers { get; private set; } = new ManagerUsers(strat);
public Manager LeManager { get; private set; } = new Manager(new StubLib.Stub());
public ManagerUsers LeManagerUsers { get; private set; } = new ManagerUsers(new StubLib.Stub());
public void Temp()
{
@ -35,5 +35,6 @@ namespace WpfApp1
LeManagerUsers.Pers = new DataContractPersistance();
LeManagerUsers.SaveUsers();
}
}
}

@ -49,6 +49,10 @@ namespace WpfApp1
{
MessageBox.Show("Les mots de passe doivent être identiques");
}
if (string.IsNullOrWhiteSpace(mail) && string.IsNullOrWhiteSpace(password))
{
MessageBox.Show("Veuillez remplir toutes les cases");
}
else
{
Utilisateur user = new Utilisateur(mail, password);

@ -67,11 +67,13 @@ namespace WpfApp1
{
Mgr.AjouterRequin(requin);
Mgr.SupprimerRequinAdd(requin);
Close();
}
private void refuser_Click(object sender, RoutedEventArgs e)
{
Mgr.SupprimerRequinAdd(requin);
Close();
}
}

@ -42,14 +42,16 @@ namespace WpfApp1
DataContext = Mgr;
chargerUC();
}
Mgr.Requins.CollectionChanged += Requins_CollectionChanged;
}
private void Requins_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
chargerUC();
}
private void Region_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

@ -62,7 +62,7 @@
</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 Grid.Column="1" Grid.Row="3" Margin="40,19,40,0" Width="320" Background="White" x:Name="radioButtons">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>

@ -25,14 +25,15 @@ namespace WpfApp1
public UserControlEdit()
{
InitializeComponent();
Manager.LoadRequins();
DataContext = Manager;
DataContext = Mgr;
}
public Manager Manager => (Application.Current as App).LeManager;
public ManagerUsers ManagerUser => (Application.Current as App).LeManagerUsers;
public Manager Mgr => (Application.Current as App).LeManager;
public ManagerUsers MgrUser => (Application.Current as App).LeManagerUsers;
private Requin _requin;
public Requin requin
@ -46,6 +47,18 @@ namespace WpfApp1
}
private List<Conservation> consList = new List<Conservation>
{
Conservation.EX,
Conservation.EW,
Conservation.CR,
Conservation.EN,
Conservation.VU,
Conservation.NT,
Conservation.LC,
Conservation.DD,
Conservation.NE
};
@ -58,42 +71,25 @@ namespace WpfApp1
LienVid.Contenu = requin.Video;
LienMap.Contenu = requin.PhotoCarte;
funFact.Contenu = requin.FunFact;
if (requin.StatutCons == Conservation.EX)
foreach (Control control in this.radioButtons.Children)
{
ex.IsChecked = true;
}
else if (requin.StatutCons == Conservation.EW)
if (control is RadioButton)
{
ew.IsChecked = true;
}
else if (requin.StatutCons == Conservation.CR)
RadioButton radio = control as RadioButton;
if (radio.Content is string radString)
{
cr.IsChecked = true;
}
else if (requin.StatutCons == Conservation.EN)
if (radString == requin.StatutCons.ToString())
{
en.IsChecked = true;
radio.IsChecked = true;
goto loopEnd;
}
else if (requin.StatutCons == Conservation.VU)
{
vu.IsChecked = true;
}
else if (requin.StatutCons == Conservation.NT)
{
nt.IsChecked = true;
}
else if (requin.StatutCons == Conservation.LC)
{
lc.IsChecked = true;
}
else if (requin.StatutCons == Conservation.DD)
{
dd.IsChecked = true;
}
else if (requin.StatutCons == Conservation.NE)
{
ne.IsChecked = true;
}
loopEnd:
foreach (Zone z in requin.Repartition)
{
@ -123,6 +119,7 @@ namespace WpfApp1
private void submit_Click(object sender, RoutedEventArgs e)
{
int test = 0;
List<Zone> lesZones = new List<Zone>();
Conservation cons = new Conservation();
string nom = leNom.LeContenu.Text;
@ -133,74 +130,70 @@ namespace WpfApp1
string map = LienMap.LeContenu.Text;
string fun = funFact.LeContenu.Text;
if (ex.IsChecked == true)
foreach (Control control in this.radioButtons.Children)
{
cons = Conservation.EX;
}
else if (ew.IsChecked == true)
if (control is RadioButton)
{
cons = Conservation.EW;
}
else if (cr.IsChecked == true)
RadioButton radio = control as RadioButton;
if (radio.IsChecked == true)
{
cons = Conservation.CR;
}
else if (en.IsChecked == true)
if (radio.Content is string radString)
{
cons = Conservation.EN;
}
else if (vu.IsChecked == true)
foreach (Conservation conserv in consList)
{
cons = Conservation.VU;
}
else if (nt.IsChecked == true)
if (radString == conserv.ToString())
{
cons = Conservation.NT;
cons = conserv;
goto loopEnd ;
}
else if (lc.IsChecked == true)
{
cons = Conservation.LC;
}
else if (dd.IsChecked == true)
{
cons = Conservation.DD;
}
else if (ne.IsChecked == true)
{
cons = Conservation.NE;
}
}
}
loopEnd:
if (Arct.IsChecked == true)
{
test++;
lesZones.Add(Zone.ARCTIQUE);
}
if (Atla.IsChecked == true)
{
test++;
lesZones.Add(Zone.ATLANTIQUE);
}
if (Indi.IsChecked == true)
{
test++;
lesZones.Add(Zone.INDIEN);
}
if (Paci.IsChecked == true)
{
test++;
lesZones.Add(Zone.PACIFIQUE);
}
Requin requin = new Requin(nom, sciNam, descri, photo, video, map, cons, lesZones, fun);
foreach (Requin req in Manager.Requins)
if (test == 0 || lesZones==null || Mgr.verifierRequin(nom, sciNam, descri, photo, video, map)==false)
{
if (req.Equals(requin))
MessageBox.Show("Veuillez remplir tout les champs obligatoires");
}
else if (string.IsNullOrWhiteSpace(fun))
{
Manager.ModifieRequin(req, requin);
break;
Requin req = new Requin(nom, sciNam, descri, photo, video, map, cons, lesZones, fun);
Mgr.AjouterRequinEdit(req);
}
else
{
Requin req = new Requin(nom, sciNam, descri, photo, video, map, cons, lesZones, fun);
Mgr.AjouterRequinEdit(req);
}
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapDes(requin);
}
}

@ -39,6 +39,9 @@ namespace WpfApp1
private void add_Click(object sender, RoutedEventArgs e)
{
var addSharkWindow = new AddAShark();
addSharkWindow.ShowDialog();
/*
if (MgrUser.SelectedUser == null)
{
MessageBox.Show("Vous avez besoin d'être connecté pour accéder à cette fonctionnalité");
@ -55,6 +58,7 @@ namespace WpfApp1
var validerSumbit = new ValiderSubmit();
validerSumbit.ShowDialog();
}
*/
}

@ -50,6 +50,8 @@ namespace WpfApp1
private void edit_Click(object sender, RoutedEventArgs e)
{
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapEdit(requin);
/*
if (MgrUser.SelectedUser == null)
{
MessageBox.Show("Vous avez besoin d'être connecté pour accéder à cette fonctionnalité");
@ -60,6 +62,7 @@ namespace WpfApp1
{
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapEdit(requin);
}
*/
}

Loading…
Cancel
Save