예제 #1
0
파일: Dao.cs 프로젝트: Gustou91/competition
        public int insertPoule(Poule p)
        {
            int   id    = -1;
            Poule poule = getPoule(p.getNom());

            if (poule.getNom() == null)
            {
                openBase();

                // Insertion de la nouvelle poule.
                string sql = "INSERT INTO poule (pou_nom, pou_competition, pou_creation)"
                             + " values ('" + p.getNom() + "'," + getActiveCompetition() + ", DATETIME('NOW'))";
                logger.Info("insertPoule: requête = " + sql);

                using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
                {
                    cmd.ExecuteNonQuery();
                }

                poule = this.getPoule(p.getNom());
                id    = poule.getId();
                closeBase();
            }
            else
            {
                updatePoule(p);
                id = poule.getId();
            }

            return(id);
        }
예제 #2
0
파일: Dao.cs 프로젝트: Gustou91/competition
        public Boolean updatePoule(Poule poule)
        {
            openBase();

            string sql = "UPDATE poule SET pou_nom = '" + poule.getNom() + "', pou_modification = DATETIME('NOW')"
                         + " WHERE pou_id = " + poule.getId();

            logger.Info("updatePoule: requête = " + sql);

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                cmd.ExecuteNonQuery();
            }
            closeBase();

            return(true);
        }