Exemplo n.º 1
0
        public static void insertCommune(DAOCommune c)
        {
            string           query       = "INSERT INTO Commune (`nom`,`idDepartement`) VALUES (\"" + c.nomDAOCommune + "\",\"" + c.idDAOCommune + "\"); ";
            MySqlCommand     cmd2        = new MySqlCommand(query, connection);
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
Exemplo n.º 2
0
        public static void updateCommune(DAOCommune c)
        {
            string           query       = "UPDATE commune set nom=\"" + c.nomDAOCommune + "\",idCommune=\"" + c.idDepartementDAOCommune + "\" where idCommune=" + c.idDAOCommune + ";";
            MySqlCommand     cmd         = new MySqlCommand(query, connection);
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
        public static CommuneViewModel getCommune(int idCommune)
        {
            DAOCommune           cDAO  = DAOCommune.getCommune(idCommune);
            int                  idDep = cDAO.idDepartementDAOCommune;
            DepartementViewModel d     = DepartementORM.getDepartement(idDep);
            CommuneViewModel     c     = new CommuneViewModel(cDAO.idDAOCommune, cDAO.nomDAOCommune, d);

            return(c);
        }
        private void OnPropertyChanged(string info)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(info));
                DAOCommune.updateCommune(this);
            }
        }
Exemplo n.º 5
0
        public static DAOCommune getCommune(int idDAOCommune)
        {
            string       query = "SELECT * FROM commune WHERE idCommune=" + idDAOCommune + ";";
            MySqlCommand cmd   = new MySqlCommand(query, connection);

            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            DAOCommune com = new DAOCommune(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2));

            reader.Close();
            return(com);
        }
        public static ObservableCollection <CommuneViewModel> listeCommune()
        {
            ObservableCollection <DAOCommune>       lDAO = DAOCommune.listeCommune();
            ObservableCollection <CommuneViewModel> l    = new ObservableCollection <CommuneViewModel>();

            foreach (DAOCommune element in lDAO)
            {
                int idDep = element.idDepartementDAOCommune;

                DepartementViewModel d = DepartementORM.getDepartement(idDep); // Plus propre que d'aller chercher le métier dans la DAO.
                CommuneViewModel     c = new CommuneViewModel(element.idDAOCommune, element.nomDAOCommune, d);
                l.Add(c);
            }
            return(l);
        }
Exemplo n.º 7
0
        public static ObservableCollection <DAOCommune> selectCommune()
        {
            ObservableCollection <DAOCommune> l = new ObservableCollection <DAOCommune>();
            string       query = "SELECT * FROM Commune;";
            MySqlCommand cmd   = new MySqlCommand(query, connection);

            cmd.ExecuteNonQuery();

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                DAOCommune c = new DAOCommune(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2));
                l.Add(c);
            }
            reader.Close();
            return(l);
        }
Exemplo n.º 8
0
        public static DAOCommune getCommune(int idCommune)
        {
            DAOCommune commune = DALCommune.getCommune(idCommune);

            return(commune);
        }
 public static void supprimerCommune(CommuneViewModel commune)
 {
     DAOCommune.deleteCommune(commune.idCommuneProperty);
 }
 public static void insertCommune(CommuneViewModel commune)
 {
     DAOCommune.insertCommune(commune);
 }