|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
|
ex.IsChecked = true;
|
|
|
|
|
}
|
|
|
|
|
else if (requin.StatutCons == Conservation.EW)
|
|
|
|
|
{
|
|
|
|
|
ew.IsChecked = true;
|
|
|
|
|
}
|
|
|
|
|
else if (requin.StatutCons == Conservation.CR)
|
|
|
|
|
{
|
|
|
|
|
cr.IsChecked = true;
|
|
|
|
|
}
|
|
|
|
|
else if (requin.StatutCons == Conservation.EN)
|
|
|
|
|
{
|
|
|
|
|
en.IsChecked = true;
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Control control in this.radioButtons.Children)
|
|
|
|
|
{
|
|
|
|
|
ne.IsChecked = true;
|
|
|
|
|
if (control is RadioButton)
|
|
|
|
|
{
|
|
|
|
|
RadioButton radio = control as RadioButton;
|
|
|
|
|
if (radio.Content is string radString)
|
|
|
|
|
{
|
|
|
|
|
if (radString == requin.StatutCons.ToString())
|
|
|
|
|
{
|
|
|
|
|
radio.IsChecked = true;
|
|
|
|
|
goto loopEnd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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,73 +130,69 @@ 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)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.EW;
|
|
|
|
|
}
|
|
|
|
|
else if (cr.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.CR;
|
|
|
|
|
}
|
|
|
|
|
else if (en.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.EN;
|
|
|
|
|
}
|
|
|
|
|
else if (vu.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.VU;
|
|
|
|
|
}
|
|
|
|
|
else if (nt.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.NT;
|
|
|
|
|
}
|
|
|
|
|
else if (lc.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.LC;
|
|
|
|
|
}
|
|
|
|
|
else if (dd.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.DD;
|
|
|
|
|
}
|
|
|
|
|
else if (ne.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
cons = Conservation.NE;
|
|
|
|
|
if (control is RadioButton)
|
|
|
|
|
{
|
|
|
|
|
RadioButton radio = control as RadioButton;
|
|
|
|
|
if (radio.IsChecked == true)
|
|
|
|
|
{
|
|
|
|
|
if (radio.Content is string radString)
|
|
|
|
|
{
|
|
|
|
|
foreach (Conservation conserv in consList)
|
|
|
|
|
{
|
|
|
|
|
if (radString == conserv.ToString())
|
|
|
|
|
{
|
|
|
|
|
cons = conserv;
|
|
|
|
|
goto loopEnd ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (test == 0 || lesZones==null || Mgr.verifierRequin(nom, sciNam, descri, photo, video, map)==false)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Veuillez remplir tout les champs obligatoires");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (string.IsNullOrWhiteSpace(fun))
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Requin requin = new Requin(nom, sciNam, descri, photo, video, map, cons, lesZones, fun);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Requin req in Manager.Requins)
|
|
|
|
|
{
|
|
|
|
|
if (req.Equals(requin))
|
|
|
|
|
{
|
|
|
|
|
Manager.ModifieRequin(req, requin);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapDes(requin);
|
|
|
|
|
}
|
|
|
|
|