private void modifRapport_Load(object sender, EventArgs e)
        {
            CURS   cs      = new CURS(LoginPage.ChaineConnexion);
            string requete = "select RAP_NUM from rapport_visite WHERE COL_MATRICULE = '" + LoginPage.Id + "';";

            cs.ReqSelect(requete);
            while (!cs.Fin())
            {
                cbx_numrapport.Items.Add(cs.champ("RAP_NUM"));
                cs.suivant();
            }
            cs.fermer();
            cbx_numrapport.Show();

            CURS   csVis      = new CURS(LoginPage.ChaineConnexion);
            string requeteVis = "SELECT CONCAT(`COL_NOM`, ' ', `COL_PRENOM`) AS NomPrenom FROM `collaborateur` WHERE `COL_MATRICULE` = '" + LoginPage.Id + "';";

            csVis.ReqSelect(requeteVis);
            while (!csVis.Fin())
            {
                txtbox_vis.Text = csVis.champ("NomPrenom").ToString();
                csVis.suivant();
            }
            csVis.fermer();
            cbx_numrapport.Show();
        }
Example #2
0
        //Event au chargement de la page
        private void supprRapport_Load(object sender, EventArgs e)
        {
            //Création de la connection
            connect = new CURS(LoginPage.ChaineConnexion);

            //éxecution de la requête
            connect.ReqSelect(reqGetListRapport);
            //Tant qu'il y a un enregistrement apres celui en cours
            while (!connect.Fin())
            {
                //Ajout de l'id du rapport dans la combo box
                comboBox1.Items.Add(connect.champ("RAP_NUM"));
                //Passage à l'enregistrement suivant
                connect.suivant();
            }
            //Fermeture de la connection
            connect.fermer();

            connect = new CURS(LoginPage.ChaineConnexion);

            string reqRapVisiteur = "select CONCAT(COL_NOM, ' ', COL_PRENOM) AS NomPre FROM collaborateur where COL_MATRICULE = '" + LoginPage.Id + "';";

            connect.ReqSelect(reqRapVisiteur);
            while (!connect.Fin())
            {
                //Ajout de l'id du rapport dans la combo box
                txtbox_visi.Text = connect.champ("NomPre").ToString();
                //Passage à l'enregistrement suivant
                connect.suivant();
            }
            //Fermeture de la connection
            connect.fermer();
        }
        private void btn_modif_Click(object sender, EventArgs e)
        {
            string reqOffrir = "";


            for (int i = 0; i < dgv_echantillon.RowCount - 1; i++)
            {
                CURS csOffr = new CURS(LoginPage.ChaineConnexion);
                if (liste_med.ElementAtOrDefault(i) != null)
                {
                    reqOffrir  = "UPDATE offrir SET MED_DEPOTLEGAL='" + dgv_echantillon.Rows[i].Cells["cbx_medic"].Value + "', OFF_QTE=" + dgv_echantillon.Rows[i].Cells["txt_quantite"].Value;
                    reqOffrir += " WHERE RAP_NUM='" + cbx_numrapport.SelectedItem.ToString() + "' AND MED_DEPOTLEGAL='" + liste_med[i] + "' AND COL_MATRICULE = '" + LoginPage.Id + "';";
                    csOffr.ReqSelect(reqOffrir);
                    csOffr.fermer();
                }
                else
                {
                    reqOffrir  = "INSERT INTO offrir(COL_MATRICULE, RAP_NUM, MED_DEPOTLEGAL, OFF_QTE) VALUES ('" + LoginPage.Id + "', ";
                    reqOffrir += cbx_numrapport.SelectedItem.ToString() + ", '";
                    reqOffrir += dgv_echantillon.Rows[i].Cells["cbx_medic"].Value + "', ";
                    reqOffrir += dgv_echantillon.Rows[i].Cells["txt_quantite"].Value + ");";
                    liste_med.Add(dgv_echantillon.Rows[i].Cells["cbx_medic"].Value.ToString());
                    csOffr.ReqSelect(reqOffrir);
                    csOffr.fermer();
                }
            }

            CURS   csRapp  = new CURS(LoginPage.ChaineConnexion);
            string requete = "UPDATE rapport_visite SET id_motif=";

            requete += motifvalue + ", RAP_BILAN='";
            if (chkbox_date_rapport.Checked)
            {
                requete += txt_bilan.Text + "', RAP_DATE='";
                requete += dt_daterapp.Value.ToString("yyyy-MM-dd") + "', PRA_NUM=";
            }
            else
            {
                requete += txt_bilan.Text + "', PRA_NUM=";
            }
            requete += praticvalue + ", date_visite='";
            if (praticrempvalue != null)
            {
                requete += dt_datevis.Value.ToString("yyyy-MM-dd") + "', PRA_NUM_REMP=";
                requete += praticrempvalue + ", CoefConf=";
            }
            else
            {
                requete += dt_datevis.Value.ToString("yyyy-MM-dd") + "', CoefConf=";
            }
            requete += trb_coef.Value.ToString() + " WHERE RAP_NUM=";
            requete += cbx_numrapport.SelectedItem.ToString() + " AND COL_MATRICULE = '" + LoginPage.Id + "';";
            csRapp.ReqSelect(requete);
            MessageBox.Show("Les informations de ce rapport de visite ont bien été modifiées");
        }
Example #4
0
        //Event quand l'utilisateur click sur le bouton supprimer
        private void button1_Click(object sender, EventArgs e)
        {
            //Création de la connection
            connect = new CURS(LoginPage.ChaineConnexion);
            //Requete de suppression avec l'id du rapport
            string supprRequest = requestSuppr + "'" + rapport[1].ToString() + "'";
            //Requete de sauvegarde
            string requete = "INSERT INTO save_rapport (COL_MATRICULE, RAP_NUM, PRA_NUM, RAP_DATE, RAP_BILAN, date_visite, CoefConf, id_motif, PRA_NUM_REMP)" +
                             " VALUES (";

            //Ajout des variables dans la requête de sauvegarde
            foreach (object rap in rapport)
            {
                //Test si la variable est null
                if (rap.ToString() == "")
                {
                    //Rajout de "null" si la variable est null
                    requete += "null";
                }
                else
                {
                    //Rajout de la variable en text si elle est différent de null
                    //Si c'est une date on l'enregistre spécialement car en base c'est un type DateTime
                    if (rap.ToString() == rapport[3].ToString() || rap.ToString() == rapport[5].ToString())
                    {
                        DateTime date = DateTime.Parse(rap.ToString());
                        requete += "'" + date.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    }
                    else
                    {
                        requete += "'" + rap.ToString() + "'";
                    }
                }
                //Ajout d'une virgule à chaque tour
                requete += ", ";
            }//foreach(object rap in rapport)
            //Ajout de la parenthèse a la fin de la requête
            requete = requete.Substring(0, requete.Length - 2) + ")";
            //éxecution de la sauvegarde dans une autre table
            connect.ReqAdmin(requete);
            //éxecution de la requête de suppression
            connect.ReqAdmin(supprRequest);
            //Fermeture de la connection a la base
            connect.fermer();

            //Fermeture de la fenêtre
            Close();
            //Réouverture de la fenêtre pour actualisé les données
            menu main = new menu();

            main.Show();
        }
Example #5
0
        //Event lors de la sélection dans la combo box
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Création de la connection
            connect = new CURS(LoginPage.ChaineConnexion);
            //Création de la requete selon l'id du rapport sélectionner
            String requete = reqGetRapportById + "'" + comboBox1.SelectedItem.ToString() + "'";

            //Création de la connection
            connect.ReqSelect(requete);

            //Récupération des valeurs de la requête
            object COL_MATRICULE = connect.champ("COL_MATRICULE");
            object RAP_NUM       = connect.champ("RAP_NUM");
            object PRA_NUM       = connect.champ("PRA_NUM");
            object RAP_DATE      = connect.champ("RAP_DATE");
            object RAP_BILAN     = connect.champ("RAP_BILAN");
            object DATE_VISITE   = connect.champ("date_visite");
            object COEFCONF      = connect.champ("CoefConf");
            object ID_MOTIF      = connect.champ("id_motif");
            object PRA_NUM_EMP   = connect.champ("PRA_NUM_REMP");

            string MOTIF_LIBELLE      = connect.champ("libelle").ToString();
            string PRA_PRENOM_NOM     = connect.champ("PRA_NOM").ToString() + " " + connect.champ("PRA_PRENOM").ToString();
            string PRA_PRENOM_NOM_EMP = connect.champ("PRA_NOM").ToString() + " " + connect.champ("PRA_PRENOM").ToString();

            //Vidage de la liste + ajout des variables à l'intérieur afin de les récupérer lors de l'activation de la suppression
            rapport.Clear();
            rapport.Add(COL_MATRICULE);
            rapport.Add(RAP_NUM);
            rapport.Add(PRA_NUM);
            rapport.Add(RAP_DATE);
            rapport.Add(RAP_BILAN);
            rapport.Add(DATE_VISITE);
            rapport.Add(COEFCONF);
            rapport.Add(ID_MOTIF);
            rapport.Add(PRA_NUM_EMP);

            //Ajout des variables dans leur box respective
            textBox1.Text     = PRA_PRENOM_NOM;
            textBox2.Text     = RAP_DATE.ToString();
            richTextBox1.Text = RAP_BILAN.ToString();
            textBox3.Text     = DATE_VISITE.ToString();
            textBox4.Text     = PRA_PRENOM_NOM_EMP;
            textBox5.Text     = MOTIF_LIBELLE;
            textBox6.Text     = COEFCONF.ToString();

            //Fermeture de la connection
            connect.fermer();
        }
Example #6
0
        private string getNomPrenom_Visiteur()
        {
            string nom_Prenom = "";
            CURS   cs         = new CURS(LoginPage.ChaineConnexion);
            string req        = "SELECT CONCAT(`COL_NOM`, ' ', `COL_PRENOM`) AS NomPrenom FROM `collaborateur` WHERE `COL_MATRICULE` = '" + LoginPage.Id + "';";

            cs.ReqSelect(req);
            while (!cs.Fin())
            {
                nom_Prenom = cs.champ("NomPrenom").ToString();
                cs.suivant();
            }
            cs.fermer();
            return(nom_Prenom);
        }
Example #7
0
        private string getMotif(string motif)
        {
            string mot = "";
            CURS   cs  = new CURS(LoginPage.ChaineConnexion);
            string req = "SELECT `libelle` FROM `motifs` WHERE `id` = " + motif + ";";

            cs.ReqSelect(req);
            while (!cs.Fin())
            {
                mot = cs.champ("libelle").ToString();
                cs.suivant();
            }
            cs.fermer();
            return(mot);
        }
Example #8
0
        private string getPrac(string prac)
        {
            string nom_prenom = "";
            CURS   cs         = new CURS(LoginPage.ChaineConnexion);
            string req        = "SELECT `PRA_NOM`, `PRA_PRENOM` FROM `praticien` WHERE `PRA_NUM` = '" + prac + "';";

            cs.ReqSelect(req);
            while (!cs.Fin())
            {
                nom_prenom = cs.champ("PRA_NOM").ToString() + " " + cs.champ("PRA_PRENOM").ToString();
                cs.suivant();
            }
            cs.fermer();
            return(nom_prenom);
        }
Example #9
0
        private void consultRapport_Load(object sender, EventArgs e)
        {
            cacherItem();
            txtbox_visiteur.Text = getNomPrenom_Visiteur();

            CURS cs = new CURS(LoginPage.ChaineConnexion);


            string req_id = "SELECT `RAP_NUM` FROM `rapport_visite` WHERE `COL_MATRICULE` = '" + LoginPage.Id + "';";

            cs.ReqSelect(req_id);
            while (!cs.Fin())
            {
                cbx_numrap.Items.Add(cs.champ("RAP_NUM"));
                cs.suivant();
            }
            cs.fermer();
        }
        private void cbx_prat_SelectedIndexChanged(object sender, EventArgs e)
        {
            //cbx_prat_remp.Items.Clear();
            Dictionary <string, string> comboPratRemp = new Dictionary <string, string>();

            CURS   cs2      = new CURS(LoginPage.ChaineConnexion);
            string requete2 = "select PRA_NUM, PRA_NOM, PRA_PRENOM from praticien WHERE PRA_NUM <> " + ((KeyValuePair <string, string>)cbx_prat.SelectedItem).Key + " ORDER BY PRA_NOM ASC;";

            cs2.ReqSelect(requete2);

            comboPratRemp.Add("NULL", " ");
            while (!cs2.Fin())
            {
                string nom_prenom = cs2.champ("PRA_NOM") + " " + cs2.champ("PRA_PRENOM");
                comboPratRemp.Add(cs2.champ("PRA_NUM").ToString(), nom_prenom);
                //cbx_prat_remp.Items.Add(cs2.champ("PRA_NOM") + " " + cs2.champ("PRA_PRENOM"));
                cs2.suivant();
            }
            cbx_prat_remp.DataSource    = new BindingSource(comboPratRemp, null);
            cbx_prat_remp.DisplayMember = "Value";
            cbx_prat_remp.ValueMember   = "Key";
            cs2.fermer();
        }
Example #11
0
        private void cbx_numrap_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            showItem();
            string praticien     = "";
            string dateRapport   = "";
            string bilan         = "";
            string dateVisi      = "";
            string motif         = "";
            string praticienRemp = "";
            string coef          = "";

            CURS cs = new CURS(LoginPage.ChaineConnexion);

            cs.DefFonctStockee("getRapport");
            cs.ajouteparametreCol("IdVisiteur", LoginPage.Id);
            cs.directionparametreCol("IdVisiteur", ParameterDirection.InputOutput);

            cs.ajouteparametreCol("IdRapport", cbx_numrap.SelectedItem.ToString());
            cs.directionparametreCol("IdRapport", ParameterDirection.InputOutput);

            cs.ajouteparametreCol("idPraticien", praticien);
            cs.directionparametreCol("idPraticien", ParameterDirection.Output);

            cs.ajouteparametreCol("dateRapport", dateRapport);
            cs.directionparametreCol("dateRapport", ParameterDirection.Output);

            cs.ajouteparametreCol("bilan", bilan);
            cs.directionparametreCol("bilan", ParameterDirection.Output);

            cs.ajouteparametreCol("dateVisite", dateVisi);
            cs.directionparametreCol("dateVisite", ParameterDirection.Output);

            cs.ajouteparametreCol("idMotif", motif);
            cs.directionparametreCol("idMotif", ParameterDirection.Output);

            cs.ajouteparametreCol("idPraticienRemp", praticienRemp);
            cs.directionparametreCol("idPraticienRemp", ParameterDirection.Output);

            cs.ajouteparametreCol("coef", coef);
            cs.directionparametreCol("coef", ParameterDirection.Output);

            cs.Appelfonctstockee();
            txtbox_prac.Text = getPrac(Convert.ToString(cs.getCol()[2].Value));

            //string req = "SELECT * FROM `rapport_visite` WHERE `COL_MATRICULE` = '" + LoginPage.Id + "' AND RAP_NUM = '" + cbx_numrap.SelectedItem.ToString() +"';";

            //cs.ReqSelect(req);

            /*while (!cs.Fin())
             * {*/
            //txtbox_prac.Text = getPrac(cs.champ("PRA_NUM").ToString());
            if (Convert.ToString(cs.getCol()[3].Value) == "")
            {
                chackDateRap.Checked = false;
            }
            else
            {
                chackDateRap.Checked = true;
                datebox.Text         = Convert.ToString(cs.getCol()[3].Value);
            }
            if (Convert.ToString(cs.getCol()[7].Value) == "")
            {
                chackPratRemp.Checked = false;
            }
            else
            {
                chackPratRemp.Checked = true;
                txtbox_PraRemp.Text   = getPrac(Convert.ToString(cs.getCol()[7].Value));
            }
            tbar_coef.Value   = Int32.Parse(Convert.ToString(cs.getCol()[8].Value));
            txt_coef.Text     = Convert.ToString(cs.getCol()[8].Value);
            dateVisite.Text   = Convert.ToString(cs.getCol()[5].Value);
            txtbox_motif.Text = getMotif(Convert.ToString(cs.getCol()[6].Value));
            richTextBox1.Text = Convert.ToString(cs.getCol()[4].Value);
            CURS   cs1 = new CURS(LoginPage.ChaineConnexion);
            string med = "SELECT `MED_DEPOTLEGAL`, `OFF_QTE` FROM `offrir` WHERE `COL_MATRICULE` = '" + LoginPage.Id + "' AND `RAP_NUM` = '" + cbx_numrap.SelectedItem.ToString() + "';";

            cs1.ReqSelect(med);
            while (!cs1.Fin())
            {
                CURS   cs2    = new CURS(LoginPage.ChaineConnexion);
                string reqmed = "SELECT `MED_NOMCOMMERCIAL` FROM `medicament` WHERE `MED_DEPOTLEGAL` = '" + cs1.champ("MED_DEPOTLEGAL") + "';";
                cs2.ReqSelect(reqmed);
                while (!cs2.Fin())
                {
                    dataGridView1.Rows.Add(cs2.champ("MED_NOMCOMMERCIAL"), cs1.champ("OFF_QTE"));
                    cs2.suivant();
                }
                cs1.suivant();
            }
            cs1.fermer();
        }
        private void cbx_numrapport_SelectedIndexChanged(object sender, EventArgs e)
        {
            string id;

            praticvalue     = null;
            motifvalue      = null;
            praticrempvalue = null;
            liste_med.Clear();

            id = cbx_numrapport.SelectedItem.ToString();
            CURS   cs      = new CURS(LoginPage.ChaineConnexion);
            string requete = "select COL_MATRICULE, RAP_NUM, PRA_NUM, RAP_DATE, RAP_BILAN, date_visite, motifs.libelle as motif, id_motif, PRA_NUM_REMP, date_visite from rapport_visite INNER JOIN motifs ON rapport_visite.id_motif=motifs.id WHERE RAP_NUM=";

            requete += id + " AND COL_MATRICULE = '" + LoginPage.Id + "';";

            cs.ReqSelect(requete);
            txt_bilan.Text   = cs.champ("RAP_BILAN").ToString();
            dt_daterapp.Text = cs.champ("RAP_DATE").ToString();
            dt_datevis.Text  = cs.champ("date_visite").ToString();

            //Debut Praticien

            CURS cs2 = new CURS(LoginPage.ChaineConnexion);

            requete = "SELECT PRA_NUM, PRA_NOM FROM praticien";
            Dictionary <string, string> praticien = new Dictionary <string, string>();

            cs2.ReqSelect(requete);
            cbx_pratic.DataSource = null;
            cbx_pratic.Items.Clear();
            while (!cs2.Fin())
            {
                praticien.Add(cs2.champ("PRA_NUM").ToString(), cs2.champ("PRA_NOM").ToString());
                cs2.suivant();
            }
            cbx_pratic.DataSource    = new BindingSource(praticien, null);
            cbx_pratic.DisplayMember = "Value";
            cbx_pratic.ValueMember   = "Key";
            cbx_pratic.Show();
            cs2.fermer();

            cbx_pratic.SelectedValue = praticien[cs.champ("PRA_NUM").ToString()]; //régler problème sémection
            cbx_pratic.SelectedItem  = praticien[cs.champ("PRA_NUM").ToString()];
            cbx_pratic.SelectedText  = praticien[cs.champ("PRA_NUM").ToString()];
            praticvalue = cs.champ("PRA_NUM").ToString();

            //fin praticien
            //Debut Motif
            CURS cs3 = new CURS(LoginPage.ChaineConnexion);

            requete = "SELECT id, libelle from motifs";
            Dictionary <string, string> motifs = new Dictionary <string, string>();

            cs3.ReqSelect(requete);
            cbx_motifs.DataSource = null;
            while (!cs3.Fin())
            {
                motifs.Add(cs3.champ("id").ToString(), cs3.champ("libelle").ToString());
                cs3.suivant();
            }
            cbx_motifs.DataSource    = new BindingSource(motifs, null);
            cbx_motifs.DisplayMember = "Value";
            cbx_motifs.ValueMember   = "Key";
            cbx_motifs.Show();
            cs3.fermer();
            cbx_motifs.SelectedValue = motifs[cs.champ("id_motif").ToString()]; //Régler problème de sélection
            cbx_motifs.SelectedItem  = motifs[cs.champ("id_motif").ToString()];
            cbx_motifs.SelectedText  = motifs[cs.champ("id_motif").ToString()];
            motifvalue = cs.champ("id_motif").ToString();
            // fin motif
            //debut pratic remplant

            CURS cs4 = new CURS(LoginPage.ChaineConnexion);

            requete = "SELECT PRA_NUM, PRA_NOM FROM praticien";
            Dictionary <string, string> praticienRemp = new Dictionary <string, string>();

            cs4.ReqSelect(requete);
            cbx_praticremp.DataSource = null;
            cbx_praticremp.Items.Clear();
            while (!cs4.Fin())
            {
                praticienRemp.Add(cs4.champ("PRA_NUM").ToString(), cs4.champ("PRA_NOM").ToString());
                cs4.suivant();
            }
            cbx_praticremp.DataSource    = new BindingSource(praticienRemp, null);
            cbx_praticremp.DisplayMember = "Value";
            cbx_praticremp.ValueMember   = "Key";
            cbx_praticremp.Show();
            cs4.fermer();
            if (cs.champ("PRA_NUM_REMP").ToString() != "")
            {
                cbx_praticremp.SelectedValue = praticienRemp[cs.champ("PRA_NUM_REMP").ToString()]; //régler problème sémection
                cbx_praticremp.SelectedItem  = praticienRemp[cs.champ("PRA_NUM_REMP").ToString()];
                cbx_praticremp.SelectedText  = praticienRemp[cs.champ("PRA_NUM_REMP").ToString()];
                praticrempvalue = cs.champ("PRA_NUM_REMP").ToString();
            }

            //fin pratic remplacant
            //debut echantillon
            dgv_echantillon.Rows.Clear();
            Dictionary <string, string> echantillons = new Dictionary <string, string>();

            CURS   cs5     = new CURS(LoginPage.ChaineConnexion);
            CURS   cs7     = new CURS(LoginPage.ChaineConnexion);
            string reqRapp = "select medicament.MED_DEPOTLEGAL, MED_NOMCOMMERCIAL, OFF_QTE from medicament INNER JOIN offrir ON medicament.MED_DEPOTLEGAL=offrir.MED_DEPOTLEGAL WHERE RAP_NUM=";

            reqRapp += id + " ORDER BY MED_NOMCOMMERCIAL;";
            string reqMedicament = "select MED_DEPOTLEGAL, MED_NOMCOMMERCIAL from medicament ORDER BY MED_NOMCOMMERCIAL ASC;";

            cs5.ReqSelect(reqMedicament);
            cs7.ReqSelect(reqRapp);

            while (!cs7.Fin())
            {
                dgv_echantillon.Rows.Add();
                cs7.suivant();
            }
            while (!cs5.Fin())
            {
                echantillons.Add(cs5.champ("MED_DEPOTLEGAL").ToString(), cs5.champ("MED_NOMCOMMERCIAL").ToString());
                cs5.suivant();
            }

            // on récupère le numéro de ligne du datagrid correspondant à la cellule sélectionnée
            //creationRapportBindingSource.DataSource = new BindingSource(comboMedicament, null);
            // lib_med.ValueMember = "Key";

            cbx_medic.DataSource = new BindingSource(echantillons, null);
            //lib_med.Items.AddRange(comboMedicament.ToDictionary());
            cbx_medic.DisplayMember = "Value";
            cbx_medic.ValueMember   = "Key";

            /*while(!cs7.Fin())
             * {
             *   cbx_medic.ValueMember = cs7.champ("MED_DEPOTLEGAL").ToString();
             *   cs7.suivant();
             * }*/

            int  compte = 0;
            CURS cs8    = new CURS(LoginPage.ChaineConnexion);

            cs8.ReqSelect(reqRapp);
            while (!cs8.Fin())
            {
                dgv_echantillon.Rows[compte].Cells["cbx_medic"].Value    = cs8.champ("MED_DEPOTLEGAL").ToString();
                dgv_echantillon.Rows[compte].Cells["txt_quantite"].Value = cs8.champ("OFF_QTE").ToString();
                liste_med.Add(cs8.champ("MED_DEPOTLEGAL").ToString());
                cs8.suivant();
                compte += 1;
            }
            cs5.fermer();
            //Fin echantillon

            //Debut Coef

            CURS cs6 = new CURS(LoginPage.ChaineConnexion);

            requete  = "SELECT CoefConf from rapport_visite WHERE RAP_NUM=";
            requete += id + ";";
            cs6.ReqSelect(requete);
            trb_coef.Value = Int32.Parse(cs6.champ("CoefConf").ToString());
        }
        private void creationRapport_Load(object sender, EventArgs e)
        {
            Dictionary <string, string> comboSource = new Dictionary <string, string>();

            CURS   cs      = new CURS(LoginPage.ChaineConnexion);
            string requete = "select PRA_NUM, PRA_NOM, PRA_PRENOM from praticien ORDER BY PRA_NOM ASC;";

            cs.ReqSelect(requete);

            while (!cs.Fin())
            {
                string nom_prenom = cs.champ("PRA_NOM") + " " + cs.champ("PRA_PRENOM");
                comboSource.Add(cs.champ("PRA_NUM").ToString(), nom_prenom);
                cs.suivant();
            }
            cbx_prat.DataSource    = new BindingSource(comboSource, null);
            cbx_prat.DisplayMember = "Value";
            cbx_prat.ValueMember   = "Key";

            cs.fermer();

            CURS   csRapNum  = new CURS(LoginPage.ChaineConnexion);
            string reqRapNum = "select MAX(RAP_NUM) as MaxRapNum from rapport_visite;";

            csRapNum.ReqSelect(reqRapNum);
            while (!csRapNum.Fin())
            {
                txtbox_numrap.Text = (Int32.Parse(csRapNum.champ("MaxRapNum").ToString()) + 1).ToString();
                csRapNum.suivant();
            }

            csRapNum.fermer();

            Dictionary <string, string> comboMotif = new Dictionary <string, string>();

            CURS   csMotif  = new CURS(LoginPage.ChaineConnexion);
            string reqMotif = "select id, libelle from motifs ORDER BY libelle ASC;";

            csMotif.ReqSelect(reqMotif);

            while (!csMotif.Fin())
            {
                comboMotif.Add(csMotif.champ("id").ToString(), csMotif.champ("libelle").ToString());
                csMotif.suivant();
            }
            cbx_motif.DataSource    = new BindingSource(comboMotif, null);
            cbx_motif.DisplayMember = "Value";
            cbx_motif.ValueMember   = "Key";

            csMotif.fermer();
            CURS   csRapVisiteur  = new CURS(LoginPage.ChaineConnexion);
            string reqRapVisiteur = "select CONCAT(COL_NOM, ' ', COL_PRENOM) AS NomPre FROM collaborateur where COL_MATRICULE = '" + LoginPage.Id + "';";

            csRapVisiteur.ReqSelect(reqRapVisiteur);
            while (!csRapVisiteur.Fin())
            {
                txtbox_visiteur.Text = csRapVisiteur.champ("NomPre").ToString();
                csRapVisiteur.suivant();
            }

            csRapVisiteur.fermer();

            Dictionary <string, string> comboMedicament = new Dictionary <string, string>();

            CURS   csMedicament  = new CURS(LoginPage.ChaineConnexion);
            string reqMedicament = "select MED_DEPOTLEGAL, MED_NOMCOMMERCIAL from medicament ORDER BY MED_NOMCOMMERCIAL ASC;";

            csMedicament.ReqSelect(reqMedicament);

            while (!csMedicament.Fin())
            {
                comboMedicament.Add(csMedicament.champ("MED_DEPOTLEGAL").ToString(), csMedicament.champ("MED_NOMCOMMERCIAL").ToString());
                csMedicament.suivant();
            }


            cbx_lib_med.DataSource = new BindingSource(comboMedicament, null);

            cbx_lib_med.DisplayMember = "Value";
            cbx_lib_med.ValueMember   = "Key";

            csMedicament.fermer();
        }
        private void btn_val_Click(object sender, EventArgs e)
        {
            string strErreur = "";

            if (cbx_prat.Text == "")
            {
                strErreur = " - Vous n'avez pas sélectionné un praticien \n";
            }
            if (richTextBox1.Text == "")
            {
                strErreur = strErreur + " - Vous n'avez pas saisi le bilan \n";
            }
            if (dateboxVisite.Value.ToString("dd/MM/yyyy") == "01/01/2020")
            {
                strErreur = strErreur + " - Vous n'avez pas sélectionné une date différente de celle de départ \n";
            }
            if (strErreur != "")
            {
                strErreur = "La création du rapport ne peut se faire : \n" + strErreur;
                DialogResult dresult = MessageBox.Show(strErreur, "Erreur de saisie");
            }
            else
            {
                string NumRapport          = txtbox_numrap.Text;
                string Nom_prenom_visiteur = txtbox_visiteur.Text;
                string NomPre_Praticien    = ((KeyValuePair <string, string>)cbx_prat.SelectedItem).Key;
                string NomPre_Prat_Remp    = ((KeyValuePair <string, string>)cbx_prat_remp.SelectedItem).Key;
                string datebox_rapport     = datebox.Value.ToString("yyyy/MM/dd");
                string datebox_visite      = dateboxVisite.Value.ToString("yyyy/MM/dd");
                string motif      = ((KeyValuePair <string, string>)cbx_motif.SelectedItem).Key;
                string bilan      = richTextBox1.Text;
                string coefConf   = trackBar_CoefConf.Value.ToString();
                string medicament = "";
                string quantite   = "";

                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    medicament = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    quantite   = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    CURS   csInsertEchantillons  = new CURS(LoginPage.ChaineConnexion);
                    string reqInsertEchantillons = "INSERT INTO `offrir`(`COL_MATRICULE`, `RAP_NUM`, `MED_DEPOTLEGAL`, `OFF_QTE`) VALUES ('";
                    reqInsertEchantillons += LoginPage.Id + "', ";
                    reqInsertEchantillons += NumRapport + ", '";
                    reqInsertEchantillons += medicament + "', ";
                    reqInsertEchantillons += quantite + ");";
                    csInsertEchantillons.ReqAdmin(reqInsertEchantillons);
                }

                //string resultat = NumRapport + " " + Nom_prenom_visiteur + " " + NomPre_Praticien + " " + NomPre_Prat_Remp + " " + datebox_rapport + " " + datebox_visite + " " + motif + " " + bilan + " " + medicament + " " + quantite + " " + coefConf;
                //richTest.Text = resultat;

                CURS   csInsert  = new CURS(LoginPage.ChaineConnexion);
                string reqInsert = "INSERT INTO rapport_visite (COL_MATRICULE, RAP_NUM, PRA_NUM, RAP_DATE, RAP_BILAN, date_visite, id_motif, PRA_NUM_REMP, CoefConf) VALUES ('";
                reqInsert += LoginPage.Id + "', ";
                reqInsert += NumRapport + ", ";
                reqInsert += NomPre_Praticien + ", ";
                if (chkbox_date_rapport.Checked)
                {
                    reqInsert += "'" + datebox_rapport + "', ";
                }
                else
                {
                    reqInsert += "NULL, ";
                }

                reqInsert += "'" + bilan + "', ";
                reqInsert += "'" + datebox_visite + "', ";
                reqInsert += motif + ", ";
                if (cbx_prat_remp.Text == " ")
                {
                    reqInsert += "NULL, ";
                }
                else
                {
                    reqInsert += NomPre_Prat_Remp + ", ";
                }
                reqInsert += coefConf + ");";
                csInsert.ReqAdmin(reqInsert);
                DialogResult dresult2 = MessageBox.Show("La création du rapport s'est bien passée.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
        }