Esempio n. 1
0
        public static List <ClasseFamille> chargerLesFamilles()
        {
            List <ClasseFamille> lesFamille = new List <ClasseFamille>();
            int    id_famille;
            string libelle;

            MySqlConnection connexion = new MySqlConnection();
            MySqlCommand    cmd       = new MySqlCommand();

            connexion.ConnectionString = ClassePConnexion.DBConnection();

            connexion.Open();

            cmd             = connexion.CreateCommand();
            cmd.CommandText = "SELECT * FROM famille";
            MySqlDataReader drr = cmd.ExecuteReader();

            while (drr.Read())
            {
                id_famille = int.Parse(drr.GetString(0));
                libelle    = drr.GetString(1);
                ClasseFamille laFamille = new ClasseFamille(id_famille, libelle);
                lesFamille.Add(laFamille);
            }

            drr.Close();
            connexion.Close();

            return(lesFamille);
        }
Esempio n. 2
0
        // BOUTON MODIFIER
        private void buttonModifierMedicament_Click(object sender, EventArgs e)
        {
            if (dgwGererMedicament.CurrentRow.Selected)
            {
                // VARIABLE POUR LA REQUETE SQL
                string laFamille = dgwGererMedicament.CurrentRow.Cells[2].Value.ToString();;


                //REQUETE SQL
                int idFamille = ClassePMedicament.recupererIdFamille(laFamille);

                // INSTANCIATION DE LA FAMILLE
                ClasseFamille instanFam = new ClasseFamille(idFamille, laFamille.ToString());

                // INSTANCIATION
                ClasseMedicament modifier = new ClasseMedicament(int.Parse(dgwGererMedicament.CurrentRow.Cells[0].Value.ToString()), dgwGererMedicament.CurrentRow.Cells[1].Value.ToString(), dgwGererMedicament.CurrentRow.Cells[3].Value.ToString(), dgwGererMedicament.CurrentRow.Cells[4].Value.ToString(), dgwGererMedicament.CurrentRow.Cells[5].Value.ToString(), instanFam);

                // PLACEMENT DANS LES TEXTBOX ET SELECTION DANS LE COMBOBOX
                txtNomMedicament.Text                  = modifier.NomCommercial;
                txtCompositionMedicament.Text          = modifier.Composition;
                txtEffetMedicament.Text                = modifier.Effets;
                txtContreIndicationMedicament.Text     = modifier.Contreindictions;
                comboBoxFamilleMedicament.SelectedItem = laFamille;
                buttonValiderModification.Visible      = true;
                AfficherBox();
                btnRetour.Visible = true;
            }
            else
            {
                MessageBox.Show("Il faut sélectionner un médicament dans le tableau !");
            }
        }
        public static List <ClasseMedicament> chargerLaCI(string CI)
        {
            //VARIABLES
            List <ClasseMedicament> LesMedicaments = new List <ClasseMedicament>();
            int    id;
            string Nom;
            string composition;
            string effets;
            string contreindications;
            int    idfamille;
            string libFam;


            //CONNEXION BDD
            MySqlConnection connexion = new MySqlConnection();
            MySqlCommand    cmd       = new MySqlCommand();

            connexion.ConnectionString = ClassePConnexion.DBConnection();

            connexion.Open();

            cmd = connexion.CreateCommand();
            //REQUETE SQL
            cmd.CommandText = "SELECT idMedicament, nomCommercialMedicament, idFamilleMedicament, libFamille, compositionMedicament, effetsMedicament, contreIndicationsMedicament " +
                              "FROM medicament INNER JOIN famille " +
                              "ON famille.idFamille = medicament.idFamilleMedicament " +
                              "WHERE contreIndicationsMedicament = '" + CI + "'";
            //EXECUTION REQUETE
            MySqlDataReader drr = cmd.ExecuteReader();

            //LECTURE REQUETE
            while (drr.Read())
            {
                //ON RECUPERE LES VARIABLES
                id                = int.Parse(drr.GetString(0));
                Nom               = drr.GetString(1);
                idfamille         = int.Parse(drr.GetString(2));
                libFam            = drr.GetString(3);
                composition       = drr.GetString(4);
                effets            = drr.GetString(5);
                contreindications = drr.GetString(6);

                //ON INSTANCIE UN OBJET CLASSEFAMILLE
                ClasseFamille laFamille = new ClasseFamille(idfamille, libFam);
                //ON INSTANCIE UN OBJET CLASSEMEDICAMENT
                ClasseMedicament leMedicament = new ClasseMedicament(id, Nom, composition, effets, contreindications, laFamille);
                //ON AJOUTE UN OBJET CLASSEMEDICAMENT DANS UNE LISTE CLASSEMEDICAMENT
                LesMedicaments.Add(leMedicament);
            }

            drr.Close();
            connexion.Close();

            return(LesMedicaments);
        }
        public static ClasseMedicament chargerLeMedicament(int idMedicament)
        {
            //VARIABLES
            ClasseMedicament LeMedicament = new ClasseMedicament();
            int    id;
            string nomcomposition;
            string composition;
            string effets;
            string contreindications;
            int    idfamille;
            string libFam;

            //CONNEXION BDD
            MySqlConnection connexion = new MySqlConnection();
            MySqlCommand    cmd       = new MySqlCommand();

            connexion.ConnectionString = ClassePConnexion.DBConnection();

            connexion.Open();

            cmd = connexion.CreateCommand();
            //REQUETE SQL
            cmd.CommandText = "SELECT idMedicament, nomCommercialMedicament, idFamilleMedicament, libFamille, compositionMedicament, effetsMedicament, contreIndicationsMedicament " +
                              "FROM medicament INNER JOIN famille ON idFamilleMedicament " +
                              "WHERE medicament.idFamilleMedicament = famille.idFamille && medicament.idMedicament = " + idMedicament + "";
            //EXECUTION REQUETE
            MySqlDataReader drr = cmd.ExecuteReader();

            //LECTURE REQUETE
            while (drr.Read())
            {
                //ON RECUPERE LES VARIABLES
                id                = drr.GetInt16(0);
                nomcomposition    = drr.GetString(1);
                idfamille         = drr.GetInt16(2);
                libFam            = drr.GetString(3);
                composition       = drr.GetString(4);
                effets            = drr.GetString(5);
                contreindications = drr.GetString(6);

                //ON INSTANCIE UN OBJET CLASSEFAMILLE
                ClasseFamille laFamille = new ClasseFamille(idfamille, libFam);
                //ON INSTANCIE UN OBJET CLASSEMEDICAMENT
                LeMedicament = new ClasseMedicament(id, nomcomposition, composition, effets, contreindications, laFamille);
            }

            drr.Close();
            connexion.Close();

            return(LeMedicament);
        }