Beispiel #1
0
        public CommuneB()
        {
            InitializeComponent();

            lp2 = CommuneORM.ListeCommunes();
            listeCommunes.ItemsSource = lp2;
        }
        private void ajouterButton(object sender, RoutedEventArgs e)
        {
            myDataObject.nomPlageProperty = nomTextBox.Text;

            int defaultValueCommune = 1; //si la string est abhérente, le département par défaut est 1 -> mauvaisNumDépartement
            int resultCommune;

            myDataObject.communePlage = CommuneORM.getCommune(int.TryParse(idCommuneTextBox.Text, out resultCommune) ? resultCommune : defaultValueCommune);

            int.TryParse(nbEspecesDifferentesTextBox.Text, out int resultNbEspeces);
            myDataObject.nbEspecesDifferentesPlageProperty = resultNbEspeces;

            float resultSurface;
            float defaultValueSurface = 0.0F;

            myDataObject.surfacePlageProperty = float.TryParse(surfaceTextBox.Text, out resultSurface) ? resultSurface : defaultValueSurface;

            PlageViewModel nouveau = new PlageViewModel(PlageDAL.getMaxIdPlage() + 1, myDataObject.nomPlageProperty, myDataObject.communePlage, myDataObject.nbEspecesDifferentesPlageProperty, myDataObject.surfacePlageProperty);

            lp.Add(nouveau);
            PlageORM.insertPlage(nouveau);
            listePlages.Items.Refresh();
            compteur     = lp.Count();
            myDataObject = new PlageViewModel(PlageDAL.getMaxIdPlage() + 1, "", myDataObject.communePlage, myDataObject.nbEspecesDifferentesPlageProperty, myDataObject.surfacePlageProperty);
        }
        public MainWindow()
        {
            InitializeComponent();
            DALConnection.OpenConnection();

            lp  = DepartementORM.listeDepartement();
            lp1 = PersonenORM.listePersonne();
            lp2 = EtudeORM.listeEtude();
            lp3 = AnimauxORM.listeAnimaux();
            lp4 = CommuneORM.listeCommune();
            lp5 = PlageORM.listePlage();
            lp7 = ZoneEtudeORM.listeZoneEtude();



            //LIEN AVEC la VIEW
            listeDepartement.ItemsSource = lp;
            listeCommune.ItemsSource     = lp4;
            listePlage.ItemsSource       = PlageZone;
            listeEtude.ItemsSource       = lp2;
            // listeDepartement2.ItemsSource = lp;
            // listeCommune2.ItemsSource = CommuneParDepartement;
            listePlage2.ItemsSource = lp5;
            // this.DataContext = lp; // bind de la liste avec la source, permettant le binding mais de façon globale sur toute la fenetre
        }
 private void AjoutCommune_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (codePosatelDepartementTextBox.Text.Length > 5)
         {
             throw new CodePostalCommuneInvalideException("Code Postal trop long");
         }
         if (codePosatelDepartementTextBox.Text.Length < 5)
         {
             throw new CodePostalCommuneInvalideException("Code Postal trop court");
         }
         if (codePosatelDepartementTextBox.Text.Length == 0)
         {
             throw new CodePostalCommuneInvalideException("Code Postal requit");
         }
         myDataObject4 = new CommuneViewModel();
         myDataObject4.nomCommuneProperty = nomCommuneTextBox.Text;
         myDataObject4.codePostalProperty = codePosatelDepartementTextBox.Text;
         DepartementViewModel departement = (DepartementViewModel)listeDepartement.SelectedItem;
         CommuneViewModel     nouveau     = new CommuneViewModel(0, myDataObject4.nomCommuneProperty, myDataObject4.codePostalProperty, departement);
         lp4.Add(nouveau);
         CommuneORM.insertCommune(nouveau);
         lp4 = CommuneORM.listeCommune();
         nomCommuneTextBox.Text             = string.Empty;
         codePosatelDepartementTextBox.Text = string.Empty;
         listeDepartement.Items.Refresh();
     }
     catch (CodePostalCommuneInvalideException exptcodepostal)
     {
         MessageBox.Show(exptcodepostal.Message);
     }
 }
Beispiel #5
0
        private void supprimerButton_Click(object sender, EventArgs e)
        {
            CommuneViewModel toRemove = (CommuneViewModel)listeCommunes.SelectedItem;

            lu.Remove(toRemove);
            listeCommunes.Items.Refresh();
            CommuneORM.supprimerCommune(selectedCommuneId);
        }
Beispiel #6
0
 public AfficherCommunes()
 {
     InitializeComponent();
     lu = CommuneORM.listeCommunes();
     listeCommunes.ItemsSource = lu;
     myDataObject = new CommuneViewModel();
     lp           = DepartementORM.listeDepartements();
     listeDepartementsCombo.ItemsSource = lp;
 }
        public Plage()
        {
            InitializeComponent();
            lp1 = PlageORM.listePlages();
            listePlages.ItemsSource = lp1;

            lp2 = CommuneORM.ListeCommunes();
            listeCommunesCombo.ItemsSource = lp2;
        }
        public Commune()
        {
            InitializeComponent();

            lp2 = CommuneORM.ListeCommunes();
            listeCommunes.ItemsSource = lp2;

            lp3 = DepartementORM.ListeDepartements();
            listeDepartementsCombo.ItemsSource = lp3;
        }
            private void OnPropertyChanged(string info)
            {
                PropertyChangedEventHandler handler = PropertyChanged;

                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(info));
                    CommuneORM.updateCommune(this);
                }
            }
        private void ajouterButton(object sender, RoutedEventArgs e)
        {
            myDataObject.nomCommuneProperty = nomTextBox.Text;

            myDataObject.departementCommune = (DepartementViewModel)listeDepartementsCombo.SelectedItem;
            CommuneViewModel nouveau = new CommuneViewModel(CommuneDAL.getMaxIdCommune() + 1, myDataObject.nomCommuneProperty, myDataObject.departementCommuneProperty);

            le.Add(nouveau);
            CommuneORM.insertCommune(nouveau);
            listeCommunes.Items.Refresh();
        }
        private void supprimerButton_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            CommuneViewModel toRemove = (CommuneViewModel)listeCommunes.SelectedItem;

            lp2.Remove(toRemove);

            listeDepartementsCombo.ItemsSource = lp3;
            listeCommunes.Items.Refresh();
            listeDepartementsCombo.Items.Refresh();

            CommuneORM.supprimerCommune(selectedCommunesId);
            MessageBox.Show("Commune supprimée avec succes ! ");
        }
Beispiel #12
0
        public static PlageViewModel getPlage(int idPlage)
        {
            PlageDAO pDAO          = PlageDAO.getPlage(idPlage);
            int      idPrelevement = pDAO.prelevement_idprelevementDAO;
            int      idVille       = pDAO.Ville_idVilleDAO;
            int      iDepartement  = pDAO.Departement_idDepartementDAO;

            PrelevementViewModel pr = PrelevementORM.getPrelevement(idPrelevement);
            CommuneViewModel     c  = CommuneORM.getCommune(idVille);
            DepartementViewModel d  = DepartementORM.getDepartement(iDepartement);

            PlageViewModel p = new PlageViewModel(pDAO.idPlageDAO, pDAO.nomDAO, c, pr, d);

            return(p);
        }
Beispiel #13
0
        private void ajouterCommune_Click(object sender, EventArgs e)
        {
            myDataObject.nomCommuneProperty = Nom.Text;
            if ((DepartementViewModel)listeDepartementsCombo.SelectedItem != null)
            {
                myDataObject.departementCommune = (DepartementViewModel)listeDepartementsCombo.SelectedItem;
            }
            else
            {
                myDataObject.departementCommune = new DepartementViewModel(1, "MauvaisNumeroDepartement", 0);
            }
            CommuneViewModel nouveau = new CommuneViewModel(CommuneDAL.getMaxIdCommune() + 1, myDataObject.nomCommuneProperty, myDataObject.departementCommune);

            lu.Add(nouveau);
            CommuneORM.insertCommune(nouveau);
            listeDepartementsCombo.ItemsSource = lp;
            listeCommunes.Items.Refresh();
            listeDepartementsCombo.Items.Refresh();
            listeCommunes.ItemsSource = lu;
        }
Beispiel #14
0
        public MainWindow(Window actual_window)
        {
            window = actual_window;
            InitializeComponent();
            DALConnection.OpenConnection();

            // Initialisation de la liste des personnes via la BDD.
            lp      = PersonneORM.listePersonnes();
            lp_prel = PrelevementORM.listePrelevements();
            lp_Esp  = EspeceORM.listeEspeces();
            lp_Et   = EtudeORM.listeEtude();
            lp_Pl   = PlageORM.listePlages();
            lc      = CommuneORM.listeCommunes();
            de      = DepartementORM.listeDepartements();

            //LIEN AVEC la VIEW
            listePersonnes.ItemsSource   = lp;
            listePrelevement.ItemsSource = lp_prel;
            listeEspece.ItemsSource      = lp_Esp;
            listeEtude.ItemsSource       = lp_Et;
            listePlages.ItemsSource      = lp_Pl;
            // bind de la liste avec la source, permettant le binding.
            // this.DataContext = lp; // bind de la liste avec la source, permettant le binding mais de façon globale sur toute la fenetre


            //COMBO BOX FONCTIONNEL
            foreach (var item in lc)
            {
                liste_box1.Items.Add(item.nomVilleProperty);
            }
            foreach (var item in de)
            {
                liste_box3.Items.Add(item.nomProperty);
            }
            foreach (var item2 in lp_prel)
            {
                liste_box2.Items.Add(item2.idprelevementProperty);
            }
        }
        /////////////////////////////////////   Commune     /////////////////////////////////////
        /////////////////////////////////////   Commune     /////////////////////////////////////
        private void ValideCommune_Click(object sender, RoutedEventArgs e)
        {
            myDataObject2 = new CommuneViewModel();
            myDataObject2.nomCommuneProperty  = NomCommune.Text;
            myDataObject2.CodePostaleProperty = CodePostale.Text;
            myDataObject2.DepartementCommune  = (DepartementViewModel)listeDepartementsCombo.SelectedItem;
            CommuneViewModel nouveau = new CommuneViewModel(CommuneDAL.getMaxIdCommune() + 1, myDataObject2.nomCommuneProperty, myDataObject2.CodePostaleProperty, myDataObject2.DepartementCommune);

            lp2.Add(nouveau);

            CommuneORM.insertCommune(nouveau);

            listeDepartementsCombo.ItemsSource = lp3;
            listeCommunes.Items.Refresh();
            listeDepartementsCombo.Items.Refresh();
            listeCommunes.ItemsSource = lp2;
            compteur = lp2.Count();

            ((TextBox)NomCommune).Text  = string.Empty;
            ((TextBox)CodePostale).Text = string.Empty;

            MessageBox.Show("Commune ajoutée avec succes ! ");
        }
        private void ajouterPlage_Click(object sender, EventArgs e)
        {
            myDataObject.nomPlageProperty = Nom.Text;
            string CommuneIdToParse = Commune.Text;
            int    result;
            int    defaultValue = 1; //si la string est abhérente, la commune par défaut est 1 -> mauvaisNumDépartement

            myDataObject.communePlage = CommuneORM.getCommune(int.TryParse(CommuneIdToParse, out result) ? result : defaultValue);
            string valueToParse = nbEspeces.Text;

            defaultValue = 0;
            myDataObject.nbEspecesDifferentesPlageProperty = int.TryParse(valueToParse, out result) ? result : defaultValue;
            valueToParse = surface.Text;
            float result2;
            float defaultValue2 = 0.0F;

            myDataObject.surfacePlageProperty = float.TryParse(valueToParse, out result2) ? result2 : defaultValue2;
            PlageViewModel nouveau = new PlageViewModel(PlageDAL.getMaxIdPlage() + 1, myDataObject.nomPlageProperty, myDataObject.communePlage, myDataObject.nbEspecesDifferentesPlageProperty, myDataObject.surfacePlageProperty);

            lu.Add(nouveau);
            PlageORM.insertPlage(nouveau);
            listePlages.Items.Refresh();
        }