You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
201 lines
5.8 KiB
201 lines
5.8 KiB
using Business;
|
|
using Modèle;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace WpfApp1
|
|
{
|
|
/// <summary>
|
|
/// Logique d'interaction pour UserControlEdit.xaml
|
|
/// </summary>
|
|
public partial class UserControlEdit : UserControl
|
|
{
|
|
public UserControlEdit()
|
|
{
|
|
InitializeComponent();
|
|
|
|
DataContext = Mgr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Manager Mgr => (Application.Current as App).LeManager;
|
|
public ManagerUsers MgrUser => (Application.Current as App).LeManagerUsers;
|
|
|
|
private Requin _requin;
|
|
public Requin requin
|
|
{
|
|
get { return _requin; }
|
|
set
|
|
{
|
|
_requin = value;
|
|
UptadeUi(_requin);
|
|
}
|
|
}
|
|
|
|
|
|
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
|
|
};
|
|
|
|
|
|
|
|
public void UptadeUi(Requin requin)
|
|
{
|
|
leNom.Contenu = requin.Nom;
|
|
nomSci.Contenu = requin.NomSci;
|
|
desc.Contenu = requin.Description;
|
|
LienPhoto.Contenu = requin.Photo;
|
|
LienVid.Contenu = requin.Video;
|
|
LienMap.Contenu = requin.PhotoCarte;
|
|
funFact.Contenu = requin.FunFact;
|
|
|
|
|
|
foreach (Control control in this.radioButtons.Children)
|
|
{
|
|
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)
|
|
{
|
|
if (z == Zone.ATLANTIQUE)
|
|
{
|
|
Atla.IsChecked = true;
|
|
}
|
|
if (z == Zone.ARCTIQUE)
|
|
{
|
|
Arct.IsChecked = true;
|
|
}
|
|
if (z == Zone.INDIEN)
|
|
{
|
|
Indi.IsChecked = true;
|
|
}
|
|
if (z == Zone.PACIFIQUE)
|
|
{
|
|
Paci.IsChecked = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void exit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapDes(requin);
|
|
}
|
|
|
|
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;
|
|
string sciNam = nomSci.LeContenu.Text;
|
|
string descri = desc.LeContenu.Text;
|
|
string photo = LienPhoto.LeContenu.Text;
|
|
string video = LienVid.LeContenu.Text;
|
|
string map = LienMap.LeContenu.Text;
|
|
string fun = funFact.LeContenu.Text;
|
|
|
|
foreach (Control control in this.radioButtons.Children)
|
|
{
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapDes(requin);
|
|
}
|
|
}
|
|
}
|