예제 #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
        // Création d'une poule.
        private int createPoule(string sexe, int poids)
        {
            // Création du nom de la poule.
            string nomPoule = sexe + "-" + poids;
            int    noPoule  = 1;

            if (lstNomsPoules.ContainsKey(nomPoule))
            {
                // La racine du nom existe. On incrémente.
                noPoule = lstNomsPoules[nomPoule];
                lstNomsPoules[nomPoule]++;
            }
            else
            {
                // La racine du nom n'existe pas. On l'ajoute.
                lstNomsPoules.Add(nomPoule, 1);
            }

            char lettrePoule = (char)(64 + noPoule);

            nomPoule = nomPoule + "-" + lettrePoule;


            // Création de la nouvelle poule.
            logger.Info("createPoule: Création de la poule " + nomPoule);
            Poule poule = new Poule(nomPoule);

            poule.insert();

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

            string sql = "SELECT clu_id, clu_nom FROM club WHERE clu_id = " + id;

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

            Poule poule = new Poule();

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        poule = new Poule((int)reader.GetInt16(0), reader.GetString(1));
                    }
                }
            }



            closeBase();

            return(poule);
        }
예제 #4
0
파일: Dao.cs 프로젝트: Gustou91/competition
        public Poule getPoule(string nom)
        {
            openBase();

            string sql = "SELECT pou_id, pou_nom FROM poule WHERE pou_nom = '" + nom + "'";

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

            Poule poule = new Poule();

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        poule = new Poule((int)reader.GetInt16(0), reader.GetString(1));
                    }
                }
            }

            closeBase();

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

            string sql = "DELETE FROM poule WHERE pou_id = " + poule.getId();

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

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

            return(true);
        }
예제 #6
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);
        }
예제 #7
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            logger.Info("frmPoule.btnOk_Click: Validation du formulaire.");

            Poule poule = new Poule();

            if (_selectedPouleId != null)
            {
                logger.Info("frmPoule.btnOk_Click: L'identifiant est connu.");
                poule = new Poule(Convert.ToInt32(_selectedPouleId), tb_nom.Text);
            }
            else
            {
                logger.Info("frmPoule.btnOk_Click: L'identifiant n'est pas connu.");
                poule = new Poule(tb_nom.Text);
            }
            poule.insert();
            _selectedPouleId = null;

            // Mise à jour de la liste.
            loadListPoule();

            clearForm();
        }