コード例 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            logger.Info("frmMembre.btnOk_Click: Validation du formulaire.");
            Categorie.Sexe sexe   = cbSexe.SelectedItem == "Fille" ? Categorie.Sexe.FEMALE : Categorie.Sexe.MALE;
            Membre         membre = new Membre();

            ComboboxItem cbItem = (ComboboxItem)cblstClub.SelectedItem;

            if (cbItem == null)
            {
                MessageBox.Show("Le choix d'un club est obligatoire.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                int clubId = (int)cbItem.Value;

                if (_selectedMembreId != null)
                {
                    logger.Info("frmMembre.btnOk_Click: L'identifiant est connu.");
                    membre = new Membre(Convert.ToInt32(_selectedMembreId), tb_nom.Text, tb_prenom.Text, sexe, (int)nudAge.Value, (int)nudPoids.Value, clubId);
                }
                else
                {
                    logger.Info("frmMembre.btnOk_Click: L'identifiant n'est pas connu.");
                    membre = new Membre(tb_nom.Text, tb_prenom.Text, sexe, (int)nudAge.Value, (int)nudPoids.Value, clubId);
                }
                membre.insert();
                _selectedMembreId = null;

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

                clearForm();
            }
        }
コード例 #2
0
ファイル: Dao.cs プロジェクト: Gustou91/competition
        public Membre getMembre(int id)
        {
            openBase();

            string sql = "SELECT mem_id, mem_nom, mem_prenom, mem_sexe, mem_age, mem_poids, mem_club FROM membre WHERE mem_id = " + id;

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

            Membre membre = new Membre();

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Categorie.Sexe sexe = reader.GetString(3) == "F" ? Categorie.Sexe.FEMALE : Categorie.Sexe.MALE;
                        membre = new Membre((int)reader.GetInt16(0),
                                            reader.GetString(1),
                                            reader.GetString(2),
                                            sexe,
                                            (int)reader.GetInt16(4),
                                            (int)reader.GetInt16(5),
                                            (int)reader.GetInt16(6));
                    }
                }
            }



            closeBase();

            return(membre);
        }
コード例 #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            logger.Info("frmCateg.btnOk_Click: Validation du formulaire.");

            Categorie.Sexe sexe  = cbSexe.SelectedItem == "Fille" ? Categorie.Sexe.FEMALE : Categorie.Sexe.MALE;
            Categorie      categ = new Categorie();

            if (_selectedCategId != null)
            {
                logger.Info("frmCateg.btnOk_Click: L'identifiant est connu.");
                categ = new Categorie(Convert.ToInt32(_selectedCategId), tb_nom.Text, (int)nudAgeMin.Value, (int)nudAgeMax.Value, sexe, (int)nudPoidsMin.Value, (int)nudPoidsMax.Value);
            }
            else
            {
                logger.Info("frmCateg.btnOk_Click: L'identifiant n'est pas connu.");
                categ = new Categorie(tb_nom.Text, (int)nudAgeMin.Value, (int)nudAgeMax.Value, sexe, (int)nudPoidsMin.Value, (int)nudPoidsMax.Value);
            }
            categ.insert();
            _selectedCategId = null;

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

            clearForm();
        }
コード例 #4
0
ファイル: Dao.cs プロジェクト: Gustou91/competition
        public Categorie getCategorie(int id)
        {
            openBase();

            string sql = "SELECT cat_id, cat_nom, cat_agemin, cat_agemax, cat_sexe, cat_poidsmin, cat_poidsmax, cat_creation FROM categorie WHERE cat_id = " + id;

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

            Categorie categ = new Categorie();

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Categorie.Sexe sexe = reader.GetString(4) == "F" ? Categorie.Sexe.FEMALE : Categorie.Sexe.MALE;
                        categ = new Categorie((int)reader.GetInt16(0),
                                              reader.GetString(1),
                                              (int)reader.GetInt16(2),
                                              (int)reader.GetInt16(3),
                                              sexe,
                                              (int)reader.GetInt16(5),
                                              (int)reader.GetInt16(6));
                    }
                }
            }



            closeBase();

            return(categ);
        }
コード例 #5
0
        public Membre(int id, string name, string firstName, Categorie.Sexe sexe, int age, int poids, int clubId)
        {
            if (id != null)
            {
                _id = id;
            }
            else
            {
                throw new System.ArgumentException("L'identifiant doit être initialisé.");
            }

            createMembre(name, firstName, sexe, age, poids, clubId);
        }
コード例 #6
0
        public Categorie(int id, string name, int ageMin, int ageMax, Categorie.Sexe sexe, int poidsMin, int poidsMax)
        {
            if (id != null)
            {
                _id = id;
                logger.Info("Categorie: Création de l'instance " + _id);
            }
            else
            {
                logger.Error("Categorie: L'identifiant doit être initialisé.");
                throw new System.ArgumentException("L'identifiant doit être initialisé.");
            }

            createCategorie(name, ageMin, ageMax, sexe, poidsMin, poidsMax);
        }
コード例 #7
0
ファイル: Dao.cs プロジェクト: Gustou91/competition
        public List <Membre> getMembres(string sSexe, int age, int poids, int deltaAge, int deltaPoids, string lstClub, string lstDone)
        {
            openBase();

            int AgeMax   = age + deltaAge;
            int poidsMax = poids + deltaPoids;

            if (lstDone.EndsWith(","))
            {
                lstDone = lstDone.Substring(0, lstDone.Length - 1);
            }

            string sql = "SELECT mem_id, mem_nom, mem_prenom, mem_sexe, mem_age, mem_poids, mem_club FROM membre WHERE mem_sexe = '" + sSexe
                         + "' AND mem_age >= " + age + " AND mem_age <= " + AgeMax
                         + " AND mem_poids >= " + poids + " AND mem_poids <= " + poidsMax
                         + " AND MEM_POULE is null AND mem_id not in (" + lstDone + ")" + " AND mem_club not in (" + lstClub + ")";

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

            List <Membre> lstMembre = new List <Membre>();

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Categorie.Sexe sexe   = reader.GetString(3) == "F" ? Categorie.Sexe.FEMALE : Categorie.Sexe.MALE;
                        Membre         membre = new Membre((int)reader.GetInt16(0),
                                                           reader.GetString(1),
                                                           reader.GetString(2),
                                                           sexe,
                                                           (int)reader.GetInt16(4),
                                                           (int)reader.GetInt16(5),
                                                           (int)reader.GetInt16(6));
                        lstMembre.Add(membre);
                    }
                }
            }

            closeBase();

            return(lstMembre);
        }
コード例 #8
0
        private void createCategorie(string name, int ageMin, int ageMax, Categorie.Sexe sexe, int poidsMin, int poidsMax)
        {
            if (name != null && name != String.Empty)
            {
                _name = name;
            }
            else
            {
                logger.Error("createCategorie: Le nom ne peut être vide.");
                throw new System.ArgumentException("Le nom ne peut être vide.");
            }

            if (ageMin > 0 && ageMin <= ageMax)
            {
                _ageMin = ageMin;
                _ageMax = ageMax;
            }
            else
            {
                logger.Error("createCategorie: L'age minimal doit être > 0 et <= à l'age max.");
                throw new System.ArgumentException("L'age minimal doit être > 0 et <= à l'age max.");
            }

            if (poidsMin > 0 && poidsMin <= poidsMax)
            {
                _poidsMin = poidsMin;
                _poidsMax = poidsMax;
            }
            else
            {
                logger.Error("createCategorie: Le poids minimal doit être > 0 et <= au poids max.");
                throw new System.ArgumentException("Le poids minimal doit être > 0 et <= au poids max.");
            }

            _sexe = sexe;
            _init = true;

            logger.Info("createCategorie: nom = " + _name);
            logger.Info("createCategorie: age min =" + _ageMin);
            logger.Info("createCategorie: age max = " + _ageMax);
            logger.Info("createCategorie: poids min = " + _poidsMin);
            logger.Info("createCategorie: poids max = " + _poidsMax);
            logger.Info("createCategorie: sexe = " + _sexe.ToString());
        }
コード例 #9
0
        private void createMembre(string name, string firstName, Categorie.Sexe sexe, int age, int poids, int clubId)
        {
            if (name != null && name != String.Empty)
            {
                _nom = name;
            }
            else
            {
                throw new System.ArgumentException("Le nom ne peut être vide");
            }

            if (firstName != null && firstName != String.Empty)
            {
                _prenom = firstName;
            }
            else
            {
                throw new System.ArgumentException("Le prénom ne peut être vide");
            }

            if (age >= 3)
            {
                _age = age;
            }
            else
            {
                throw new System.ArgumentException("L'age minimal doit être >= 3.");
            }

            if (poids >= 10)
            {
                _poids = poids;
            }
            else
            {
                throw new System.ArgumentException("Le poids minimal doit être >= 10.");
            }

            _club = clubId;
            _sexe = sexe;
            _init = true;
        }
コード例 #10
0
ファイル: Dao.cs プロジェクト: Gustou91/competition
        public List <Membre> getMembres(int pouleId)
        {
            openBase();

            string sql = "SELECT mem_id, mem_nom, mem_prenom, mem_sexe, mem_age, mem_poids, mem_club FROM membre "
                         + "WHERE mem_poule = " + pouleId
                         + " ORDER BY mem_sexe, mem_age, mem_poids";

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

            List <Membre> lstMembre = new List <Membre>();

            using (SQLiteCommand cmd = new SQLiteCommand(sql, _dbConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Categorie.Sexe sexe   = reader.GetString(3) == "F" ? Categorie.Sexe.FEMALE : Categorie.Sexe.MALE;
                        Membre         membre = new Membre((int)reader.GetInt16(0),
                                                           reader.GetString(1),
                                                           reader.GetString(2),
                                                           sexe,
                                                           (int)reader.GetInt16(4),
                                                           (int)reader.GetInt16(5),
                                                           (int)reader.GetInt16(6));
                        lstMembre.Add(membre);
                    }
                }
            }



            closeBase();

            return(lstMembre);
        }
コード例 #11
0
 public Membre(string name, string firstName, Categorie.Sexe sexe, int age, int poids, int clubId)
 {
     createMembre(name, firstName, sexe, age, poids, clubId);
 }
コード例 #12
0
 public Categorie(string name, int ageMin, int ageMax, Categorie.Sexe sexe, int poidsMin, int poidsMax)
 {
     logger.Info("Categorie: Création de l'instance " + name);
     createCategorie(name, ageMin, ageMax, sexe, poidsMin, poidsMax);
 }