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); }
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); }