Exemplo n.º 1
0
        /// <summary>
        /// Permet d'insérer dans la table distribuer
        /// </summary>
        /// <param name="ListEchantillon">Le dictionnaire d'échantillon</param>
        /// <param name="rapNum">Le numéro du rapport</param>
        /// <param name="offert">true si l'échantillon est offert</param>
        private void Insert_distribuer(Dictionary <string, int> ListEchantillon, string rapNum, bool offert)
        {
            foreach (KeyValuePair <string, int> item in ListEchantillon)
            {
                Curs Insert_Distri = new Curs(connection);

                string echoffquantite = item.Value.ToString();
                if (offert)
                {
                    Insert_Distri.DefFonctStockee("insert_distribuer_offert");
                }
                else
                {
                    Insert_Distri.DefFonctStockee("insert_distribuer_presente");
                }

                Insert_Distri.AjouteparametreCol("MED_NOM", item.Key);
                Insert_Distri.DirectionparametreCol("MED_NOM", ParameterDirection.Input);
                Insert_Distri.AjouteparametreCol("COL_MAT", _colMatricule);
                Insert_Distri.DirectionparametreCol("COL_MAT", ParameterDirection.Input);
                Insert_Distri.AjouteparametreCol("RAP_NUM", rapNum);
                Insert_Distri.DirectionparametreCol("RAP_NUM", ParameterDirection.Input);
                Insert_Distri.AjouteparametreCol("QUANTITE", echoffquantite);
                Insert_Distri.DirectionparametreCol("QUANTITE", ParameterDirection.Input);

                Insert_Distri.Appelfonctstockee();
            }
        }
        // Constructeur, le rôle est important pour savoir si on donne l'autorisation de modifier le secteur
        public ModificationMyInformations(string matricule, string nom, string role)
        {
            InitializeComponent();
            _matricule = matricule;
            _nom       = nom;
            _role      = role;

            Curs cs = new Curs(chaineConnexion);

            if (_role == "visiteur")
            {
                // Si l'utilisateur est un visiteur, inutile d'afficher le secteur (responsable)
                lbl_secteur.Hide();
                cbx_secteur.Hide();
            }
            else
            {
                // Sinon récupération des secteurs
                cs.ReqSelect("SELECT SEC_CODE, SEC_LIBELLE FROM secteur");
                while (!cs.Fin())
                {
                    // Ajout au dictionnaire de secteurs
                    secteur.Add(cs.Champ("SEC_CODE").ToString(), cs.Champ("SEC_LIBELLE").ToString());
                    cbx_secteur.Items.Add(cs.Champ("SEC_LIBELLE").ToString());
                    cs.Suivant();
                }
                cs.Fermer();
            }

            string laboCode = setChamps(matricule);

            addItemsToLabo(laboCode);
        }
        // Permet de remplir les champs de formulaire
        private string setChamps(string matricule)
        {
            Curs cs = new Curs(chaineConnexion);

            // Récupération du collaborateur
            cs.ReqSelect("SELECT * FROM collaborateur WHERE COL_MATRICULE = '" + matricule + "';");
            string laboCode = "";

            while (!cs.Fin())
            {
                // Remplissage des champs
                txb_nom.Text     = cs.Champ("COL_NOM").ToString();
                txb_prenom.Text  = cs.Champ("COL_PRENOM").ToString();
                txb_adresse.Text = cs.Champ("COL_ADRESSE").ToString();
                txb_ville.Text   = cs.Champ("COL_VILLE").ToString();
                txb_cp.Text      = cs.Champ("COL_CP").ToString();

                laboCode = cs.Champ("LAB_CODE").ToString();

                // Si responsable, remplissage du secteur
                if (_role == "responsable")
                {
                    cbx_secteur.SelectedItem = secteur[cs.Champ("SEC_CODE").ToString()];
                }

                cs.Suivant();
            }

            cs.Fermer();
            return(laboCode);
        }
Exemplo n.º 4
0
        private void Button_modifier_Click(object sender, EventArgs e)
        {
            if (_previous == "ShowAllRaports")
            {
                RapportVisite rapport_modif = new RapportVisite(_colNom, _colMatricule, "Modif", _numRap);
                Hide();
                rapport_modif.Show();
            }
            else
            {
                int Error = Verif_error("Modif");

                if (Error == 0)
                {
                    string        dateJour        = DateTime.Today.ToString("yyyy-MM-dd H:mm:ss");
                    List <string> Recup_All_Value = new List <string>();
                    Recup_All_Value = Recup_All();
                    string requete = "";

                    string rapBilan = Recup_All_Value[0];
                    string rapMotif = Recup_All_Value[1];
                    string rapConnaissancePraticien = Recup_All_Value[2];
                    string rapConnaissanceLabo      = Recup_All_Value[3];
                    string rapDate               = Recup_All_Value[4];
                    string rapDateProVisite      = Recup_All_Value[5];
                    string rapPresenceConcurence = Recup_All_Value[6];
                    string praNum = Recup_All_Value[7];
                    string rapNum = Recup_All_Value[8];

                    requete = "UPDATE `rapport_visite` " +
                              "SET `COL_MATRICULE`='" + _colMatricule + "',`RAP_NUM`='" + rapNum + "',`RAP_DATE`='" + dateJour + "',`RAP_BILAN`='" + rapBilan + "',`RAP_MOTIF`='" + rapMotif + "',`RAP_CONNAISSANCE_PRACTICIEN`=" + rapConnaissancePraticien + ",`RAP_CONFIANCE_LABO`=" + rapConnaissanceLabo + ",`RAP_DATE_VISITE`='" + rapDate + "',`RAP_DATE_PROCHAINE_VISITE`= ";
                    requete += comboBox_NewRDV.Text == "Oui"
                       ? "'" + rapDateProVisite + "'"
                       : rapDateProVisite;
                    requete += ", `RAP_PRESENCE_CONCURENCE`=" + rapPresenceConcurence + ",`PRA_NUM`='" + praNum + "' WHERE `COL_MATRICULE` = '" + _colMatricule + "' AND `RAP_NUM` ='" + rapNum + "'";

                    Curs cs = new Curs(connection);
                    cs.ReqAdmin(requete);
                    cs.Fermer();

                    requete = "DELETE FROM `distribuer`" +
                              " WHERE `distribuer`.`COL_MATRICULE` ='" + _colMatricule + "'" +
                              " AND `distribuer`.`RAP_NUM` =" + rapNum;

                    Curs cs2 = new Curs(connection);
                    cs2.ReqAdmin(requete);
                    cs2.Fermer();

                    Insert_distribuer(echantillonsOffert, rapNum, true);
                    Insert_distribuer(echantillonsPresente, rapNum, false);

                    MessageBox.Show("Votre rapport à été modifié !");
                    Form.ActiveForm.Close();
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Permet de récupérer tout les valeurs
        /// </summary>
        /// <returns>Une liste de toutes valeurs</returns>
        private List <string> Recup_All()
        {
            string        requete;
            string        rapNum   = "";
            int           nbRapNum = -1;
            List <string> Result   = new List <string>();

            foreach (KeyValuePair <string, int> item in echantillonsOffert)
            {
                if (echantillonsPresente.ContainsKey(item.Key))
                {
                    echantillonsPresente.Remove(item.Key);
                }
            }
            Curs cs2 = new Curs(connection);

            requete = "SELECT RAP_NUM" +
                      " FROM `rapport_visite`" +
                      " WHERE `rapport_visite`.`COL_MATRICULE` = '" + _colMatricule +
                      "' ORDER  BY RAP_NUM DESC LIMIT 1";
            cs2.ReqSelect(requete);
            while (!cs2.Fin())
            {
                nbRapNum = Convert.ToInt32(cs2.Champ("RAP_NUM").ToString());
                if (_previous != "Modif")
                {
                    nbRapNum++;
                }
                cs2.Suivant();
            }
            cs2.Fermer();
            if (nbRapNum == -1)
            {
                nbRapNum = 1;
            }
            rapNum = nbRapNum.ToString();

            Result.Add(Recup_textBox_BilanRap());
            Result.Add(Recup_comboBox_Motif());
            Result.Add(Recup_comboBox_connaissancePraticien());
            Result.Add(Recup_comboBox_confianceLabo());
            Result.Add(Recup_dateTimePicker_DateRap());
            Result.Add(Recup_dateTimePicker_DateProVisite());
            Result.Add(Recup_comboBox_presenceconcurrence());
            Result.Add(Recup_comboBox_Praticiens());
            Result.Add(rapNum);

            return(Result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Rempli le dataGridViewComboBox pour médicaments présentés et offerts
        /// </summary>
        private void Add_comboBox_Medicament()
        {
            Curs   cs2     = new Curs(connection);
            string requete = "SELECT `medicament`.`MED_NOMCOMMERCIAL` " +
                             "FROM `medicament` " +
                             "ORDER BY `medicament`.`MED_NOMCOMMERCIAL` ASC";

            cs2.ReqSelect(requete);
            while (!cs2.Fin())
            {
                Medicaments.Items.Add(cs2.Champ("MED_NOMCOMMERCIAL").ToString());
                dataGridViewComboBoxColumn1.Items.Add(cs2.Champ("MED_NOMCOMMERCIAL").ToString());
                cs2.Suivant();
            }
            cs2.Fermer();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Affichage d'un praticien, modification d'un praticien
        /// </summary>
        /// <param name="NumPraticiens">numéro du praticien </param>
        /// <param name="previous">valeur de la page précédente</param>
        public DetailsPraticien(int NumPraticiens, string previous = "AllPraticiens")
        {
            InitializeComponent();
            //On remplit les variables
            _previous      = previous;
            _NumPraticiens = NumPraticiens;

            // Récuperation des données du praticien
            Curs   cs2     = new Curs(connection);
            string requete = "SELECT praticien.`PRA_NUM`,`praticien`.`PRA_NOM`,`praticien`.`PRA_PRENOM`,`praticien`.`PRA_ADRESSE`,`praticien`.`PRA_CP`" +
                             ",`praticien`.`PRA_VILLE`,`praticien`.`PRA_COEFNOTORIETE`,`type_praticien`.`TYP_LIBELLE` FROM praticien,`type_praticien`" +
                             " WHERE type_praticien.`TYP_CODE` = praticien.`TYP_CODE` AND praticien.`PRA_NUM` = " + NumPraticiens.ToString();
            Curs   cs3 = new Curs(connection);
            string req = "SELECT TYP_CODE, TYP_LIBELLE FROM type_praticien;";

            cs2.ReqSelect(requete);
            cs3.ReqSelect(req);

            //Remplissage des champs
            while (!cs2.Fin())
            {
                textBox_num.Text     = cs2.Champ("PRA_NUM").ToString();
                textBox_nom.Text     = cs2.Champ("PRA_NOM").ToString();
                textBox_prenom.Text  = cs2.Champ("PRA_PRENOM").ToString();
                textBox_adresse.Text = cs2.Champ("PRA_ADRESSE").ToString();
                textBox_CP.Text      = cs2.Champ("PRA_CP").ToString();
                textBox_ville.Text   = cs2.Champ("PRA_VILLE").ToString();
                textBox_coef.Text    = cs2.Champ("PRA_COEFNOTORIETE").ToString();
                textBox_lieu.Text    = cs2.Champ("TYP_LIBELLE").ToString();
                cbx_tp.SelectedItem  = cs2.Champ("TYP_LIBELLE").ToString();
                cs2.Suivant();
            }
            cs2.Fermer();

            //Remplissage du comboBox
            while (!cs3.Fin())
            {
                typePraticiens.Add(cs3.Champ("TYP_CODE").ToString(), cs3.Champ("TYP_LIBELLE").ToString());
                cs3.Suivant();
            }
            cs3.Fermer();

            if (_previous == "RapportVisite")
            {
                btn_modif.Visible = false;
            }
        }
        // Au chagement d'état
        private void Consulter_medicament_combobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string nommed = Consulter_medicament_combobox.Text;

            Curs   cs      = new Curs(chaineconnexion);
            string requete = "SELECT * FROM `medicament` WHERE `medicament`.`MED_NOMCOMMERCIAL` = '" + nommed + "'";

            cs.ReqSelect(requete);
            Consulter_medicament_hidden_nom.Text         = cs.Champ("MED_NOMCOMMERCIAL").ToString();
            Consulter_medicament_hidden_depot_legal.Text = cs.Champ("MED_DEPOTLEGAL").ToString();
            Consulter_medicament_hidden_code.Text        = cs.Champ("FAM_CODE").ToString();
            Consulter_medicament_hidden_composition.Text = cs.Champ("MED_COMPOSITION").ToString();
            Consulter_medicament_box_effets.Text         = cs.Champ("MED_EFFETS").ToString();
            Consulter_medicament_box_contreindic.Text    = cs.Champ("MED_CONTREINDIC").ToString();
            Consulter_medicament_hidden_prixechant.Text  = cs.Champ("MED_PRIXECHANTILLON").ToString();
            cs.Fermer();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Rempli le dictionnaire de données des praticiens et rempli le comboBox_Praticiens
        /// </summary>
        private void Add_comboBox_Praticiens()
        {
            string Name    = "";
            Curs   cs      = new Curs(connection);
            string requete = "SELECT `praticien`.`PRA_NUM`, `praticien`.`PRA_NOM`, `praticien`.`PRA_PRENOM`" +
                             " FROM `praticien`" +
                             " ORDER BY `praticien`.`PRA_NOM`";

            cs.ReqSelect(requete);
            while (!cs.Fin())
            {
                Name = cs.Champ("PRA_NOM").ToString() + " " + cs.Champ("PRA_PRENOM").ToString();
                praticiens.Add(Convert.ToInt16(cs.Champ("PRA_NUM").ToString()), Name);
                comboBox_Praticiens.Items.Add(Name);
                cs.Suivant();
            }
            cs.Fermer();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Requetes nécessaire pour remplir les dataGridViews selon un numéro de rapport
        /// </summary>
        private void Prefill_Medicament()
        {
            string requete = "SELECT `medicament`.`MED_NOMCOMMERCIAL`,`distribuer`.`QUANTITE`,`distribuer`.`OFFERT`" +
                             " FROM `distribuer`,`echantillon`,`medicament`" +
                             " WHERE `distribuer`.`RAP_NUM` = " + _numRap +
                             " AND `echantillon`.`ECH_ID` = `distribuer`.`ECH_ID`" +
                             " AND `medicament`.`MED_DEPOTLEGAL` = `echantillon`.`MED_ID`" +
                             " AND `distribuer`.`COL_MATRICULE` = '";

            string Medicament = "";
            int    NbMedicament = 0, indexOffert = 0, IndexPresente = 0;

            if (_role == "responsable")
            {
                requete += _colMatClic + "'";
            }
            else
            {
                requete += _colMatricule + "'";
            }

            Curs cs3 = new Curs(connection);

            cs3.ReqSelect(requete);
            while (!cs3.Fin())
            {
                Medicament   = cs3.Champ("MED_NOMCOMMERCIAL").ToString();
                NbMedicament = Convert.ToInt16(cs3.Champ("QUANTITE"));
                if (cs3.Champ("OFFERT").ToString() == "True")
                {
                    Fill_Combobox_Medicament(dataGridView_echantillonOffert, Medicament, NbMedicament, indexOffert);
                    indexOffert++;
                }
                else
                {
                    Fill_Combobox_Medicament(dataGridView_echantillonPresente, Medicament, NbMedicament, IndexPresente);
                    IndexPresente++;
                }
                cs3.Suivant();
            }
            cs3.Fermer();
        }
Exemplo n.º 11
0
        private void Button_Nouveau_Click(object sender, EventArgs e)
        {
            int Error = Verif_error("Creer");

            if (Error == 0)
            {
                string        dateJour        = DateTime.Today.ToString("yyyy-MM-dd H:mm:ss");
                List <string> Recup_All_Value = new List <string>();
                Recup_All_Value = Recup_All();
                string requete = "";

                string rapBilan = Recup_All_Value[0];
                string rapMotif = Recup_All_Value[1];
                string rapConnaissancePraticien = Recup_All_Value[2];
                string rapConnaissanceLabo      = Recup_All_Value[3];
                string rapDate               = Recup_All_Value[4];
                string rapDateProVisite      = Recup_All_Value[5];
                string rapPresenceConcurence = Recup_All_Value[6];
                string praNum = Recup_All_Value[7];
                string rapNum = Recup_All_Value[8];

                requete = "INSERT INTO `rapport_visite`(`COL_MATRICULE`, `RAP_NUM`, `RAP_DATE`, `RAP_BILAN`, `RAP_MOTIF`, `RAP_CONNAISSANCE_PRACTICIEN`," +
                          " `RAP_CONFIANCE_LABO`, `RAP_DATE_VISITE`, `RAP_DATE_PROCHAINE_VISITE`, `RAP_PRESENCE_CONCURENCE`, `PRA_NUM`)" +
                          " VALUES ('" + _colMatricule + "', '" + rapNum + "', '" + dateJour + "', '" + rapBilan + "', '" + rapMotif + "', " + rapConnaissancePraticien +
                          ", " + rapConnaissanceLabo + ", '" + rapDate + "',";
                requete += comboBox_NewRDV.Text == "Oui"
                    ? "'" + rapDateProVisite + "'"
                    : rapDateProVisite;
                requete += ", " + rapPresenceConcurence + ", " + praNum + ")";

                Curs cs = new Curs(connection);
                cs.ReqAdmin(requete);
                cs.Fermer();

                Insert_distribuer(echantillonsPresente, rapNum, false);
                Insert_distribuer(echantillonsOffert, rapNum, true);

                MessageBox.Show("Votre rapport à été enregistré !");
                Form.ActiveForm.Close();
            }
        }
Exemplo n.º 12
0
        // Constructeur
        public Consulter_Medicament(string idMedicament = "a")
        {
            InitializeComponent();

            Curs cs = new Curs(chaineconnexion);
            // Sélection des médicaments
            string requete = "SELECT `medicament`.`MED_NOMCOMMERCIAL` FROM `medicament` ORDER BY `medicament`.`MED_NOMCOMMERCIAL`";

            cs.ReqSelect(requete);
            string nom = "";

            while (!cs.Fin())
            {
                nom = cs.Champ("MED_NOMCOMMERCIAL").ToString();
                // Ajout des items
                Consulter_medicament_combobox.Items.Add(nom);
                cs.Suivant();
            }

            cs.Fermer();
            // Si un id est définit
            if (idMedicament != "a")
            {
                cs = new Curs(chaineconnexion);

                cs.ReqSelect("SELECT MED_NOMCOMMERCIAL FROM medicament WHERE MED_DEPOTLEGAL = '" + idMedicament + "';");

                string medicamentParameter;
                while (!cs.Fin())
                {
                    medicamentParameter = cs.Champ("MED_NOMCOMMERCIAL").ToString();
                    Consulter_medicament_combobox.SelectedItem = medicamentParameter;

                    cs.Suivant();
                }
                cs.Fermer();
            }
        }
        // Ajoute les laboratoire au comboBox labo
        private void addItemsToLabo(string laboCode)
        {
            Curs cs = new Curs(chaineConnexion);

            // Récupération des labos
            cs.ReqSelect("SELECT LAB_CODE, LAB_NOM FROM labo");

            while (!cs.Fin())
            {
                // Ajout au dictionnaire
                labo.Add(cs.Champ("LAB_CODE").ToString(), cs.Champ("LAB_NOM").ToString());

                cbx_labo.Items.Add(cs.Champ("LAB_NOM").ToString());

                // Si le labo récupérer est le même que celui de l'utilisateur, on le sélectionne
                if (laboCode == cs.Champ("LAB_CODE").ToString())
                {
                    cbx_labo.SelectedItem = cs.Champ("LAB_NOM").ToString();
                }

                cs.Suivant();
            }
            cs.Suivant();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Rempli tout les champs sauf les dataGridViews
        /// </summary>
        private void Add_allChamp()
        {
            string requete = "SELECT `RAP_DATE`, `RAP_BILAN`, `RAP_MOTIF`, `RAP_CONNAISSANCE_PRACTICIEN`, `RAP_CONFIANCE_LABO`, `RAP_DATE_VISITE`, `RAP_DATE_PROCHAINE_VISITE`, `RAP_PRESENCE_CONCURENCE`,`PRA_NUM`" +
                             " FROM `rapport_visite`" +
                             " WHERE `rapport_visite`.`RAP_NUM` = " + _numRap +
                             " AND `rapport_visite`.`COL_MATRICULE` = '";

            if (_role == "responsable")
            {
                requete += _colMatClic + "'";
            }
            else
            {
                requete += _colMatricule + "'";
            }

            Curs cs2 = new Curs(connection);

            cs2.ReqSelect(requete);
            while (!cs2.Fin())
            {
                //comboBox
                comboBox_connaissancePraticien.SelectedItem = cs2.Champ("RAP_CONNAISSANCE_PRACTICIEN").ToString() == "" ? "Je ne sais pas" : cs2.Champ("RAP_CONNAISSANCE_PRACTICIEN").ToString();
                comboBox_confianceLabo.SelectedItem         = cs2.Champ("RAP_CONFIANCE_LABO").ToString() == "" ? "Je ne sais pas" : cs2.Champ("RAP_CONFIANCE_LABO").ToString();
                comboBox_Praticiens.SelectedItem            = praticiens[Convert.ToInt16(cs2.Champ("PRA_NUM").ToString())];
                comboBox_Motif.SelectedItem = cs2.Champ("RAP_MOTIF").ToString();
                //Textbox
                textBox_BilanRap.Text = cs2.Champ("RAP_BILAN").ToString();
                //dateTime

                try
                {
                    dateTimePicker_DateRap.Value = DateTime.Parse(cs2.Champ("RAP_DATE_VISITE").ToString());
                }
                catch (Exception)
                {
                    DateTime.TryParse(cs2.Champ("RAP_DATE_VISITE").ToString(), out test);
                    dateTimePicker_DateRap.Value = test.AddYears(1980);
                }



                bool verifDate = cs2.Champ("RAP_DATE_PROCHAINE_VISITE").ToString() == "" ? false : true;
                if (!verifDate)
                {
                    comboBox_NewRDV.SelectedItem = "Non";
                }
                else
                {
                    comboBox_NewRDV.SelectedItem         = "Oui";
                    DateProVisite.Visible                = true;
                    dateTimePicker_DateProVisite.Visible = true;
                    dateTimePicker_DateProVisite.Value   = DateTime.Parse(cs2.Champ("RAP_DATE_PROCHAINE_VISITE").ToString());
                }

                if (comboBox_Motif.Text.Trim() == "")
                {
                    comboBox_Motif.SelectedItem = "Autre";
                    textBox_AutreMotif.Visible  = true;
                    textBox_AutreMotif.Text     = cs2.Champ("RAP_MOTIF").ToString();
                }
                switch (cs2.Champ("RAP_PRESENCE_CONCURENCE").ToString())
                {
                case "":
                    comboBox_presenceconcurrence.SelectedItem = "Je ne sais pas";
                    break;

                case "True":
                    comboBox_presenceconcurrence.SelectedItem = "Oui";
                    break;

                case "False":
                    comboBox_presenceconcurrence.SelectedItem = "Non";
                    break;
                }
                cs2.Suivant();
            }
            cs2.Fermer();
        }
        // Lors de l'appui sur le bouton modifier
        private void btn_modifier_Click(object sender, EventArgs e)
        {
            string nom, prenom, adresse, ville, cp, secteur, labo;

            // Récupération des champs
            nom     = txb_nom.Text.Trim();
            prenom  = txb_prenom.Text.Trim();
            adresse = txb_adresse.Text.Trim();
            ville   = txb_ville.Text.Trim();
            cp      = txb_cp.Text.Trim();

            if (_role == "responsable")
            {
                secteur = cbx_secteur.SelectedItem.ToString();
            }
            else
            {
                secteur = null;
            }

            labo = cbx_labo.SelectedItem.ToString();

            // Remplis les erreurs si il y en a
            dispatchErrors(nom, prenom, adresse, ville, cp, secteur, labo);

            // Vérification de champs vides
            if (nom.Length != 0 && prenom.Length != 0 && ville.Length != 0 && cp.Length != 0 && labo.Length != 0)
            {
                bool error = false;

                // Try parse en numérique
                if (!int.TryParse(cp, out int codePostal))
                {
                    lbl_error_cp.Text = "Veuillez renseigner une valeur numérique";
                    error             = true;
                }

                // Si pas d'erreurs
                if (!error)
                {
                    Curs cs = new Curs(chaineConnexion);
                    // Récupération du labo dans le dictionnaire
                    labo = this.labo.FirstOrDefault(x => x.Value == labo).Key;

                    string req;

                    if (_role == "responsable")
                    {
                        // Récupération du secteur dans le dictionnaire
                        secteur = this.secteur.FirstOrDefault(x => x.Value == secteur).Key;

                        req = "UPDATE collaborateur SET COL_NOM = '" + nom + "', COL_PRENOM = '" + prenom + "', COL_ADRESSE = '" + adresse + "'" +
                              ", COL_VILLE = '" + ville + "', COL_CP = '" + cp + "', LAB_CODE = '" + labo + "', SEC_CODE = '" + secteur + "'" +
                              " WHERE COL_MATRICULE = '" + _matricule + "';";
                    }
                    else
                    {
                        req = "UPDATE collaborateur SET COL_NOM = '" + nom + "', COL_PRENOM = '" + prenom + "', COL_ADRESSE = '" + adresse + "'" +
                              ", COL_VILLE = '" + ville + "', COL_CP = '" + cp + "', LAB_CODE = '" + labo + "'" +
                              " WHERE COL_MATRICULE = '" + _matricule + "';";
                    }

                    try
                    {
                        // Update de l'utilisateur
                        cs.ReqAdmin(req);
                        cs.Fermer();

                        // Message de confirmation
                        MessageBox.Show("Mise à jour effectué", "Success lors de la mise à jour", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Close();
                    }
                    catch (Exception)
                    {
                        // Erreur lors de la maj
                        lbl_error_general.Text = "Erreur lors de la mise à jour";
                    }
                }
            }
        }
Exemplo n.º 16
0
        //Modification des informations suite à la pression du bouton "mettre à jour"
        private void btn_maj_Click(object sender, EventArgs e)
        {
            string numero, nom, prenom, adresse, cp, ville, coefnot, typePraticiens;

            //Récupération des champs et suppression des espaces blancs ("trim()")
            numero         = textBox_num.Text.Trim();
            nom            = textBox_nom.Text.Trim();
            prenom         = textBox_prenom.Text.Trim();
            adresse        = textBox_adresse.Text.Trim();
            ville          = textBox_ville.Text.Trim();
            cp             = textBox_CP.Text.Trim();
            coefnot        = textBox_coef.Text.Trim().Replace(',', '.');
            typePraticiens = cbx_tp.SelectedItem.ToString();

            // Remplis les erreurs si il y en a
            dispatchErrors(numero, nom, prenom, adresse, ville, cp, coefnot, typePraticiens);

            // Vérification de champs vides
            if (numero.Length != 0 && nom.Length != 0 && prenom.Length != 0 && adresse.Length != 0 && ville.Length != 0 && cp.Length != 0 && coefnot.Length != 0 && typePraticiens.Length != 0)
            {
                bool error = false;

                // Try parse en numérique
                if (!int.TryParse(cp, out int codePostal))
                {
                    lbl_error_cp.Text = "Veuillez renseigner une valeur numérique";
                    error             = true;
                }

                // Si pas d'erreurs
                if (!error)
                {
                    Curs cs = new Curs(connection);

                    // Récupération du type de praticien dans le dictionnaire
                    typePraticiens = this.typePraticiens.FirstOrDefault(x => x.Value == typePraticiens).Key;

                    string req;

                    req = "UPDATE praticien SET PRA_NUM = " + numero + ", PRA_NOM = '" + nom + "', PRA_PRENOM = '" + prenom + "'" +
                          ", PRA_ADRESSE = '" + adresse + "', PRA_VILLE = '" + ville + "', PRA_CP = '" + cp + "', PRA_COEFNOTORIETE = " + coefnot + ", TYP_CODE = '" + typePraticiens + "'" +
                          " WHERE PRA_NUM = " + _NumPraticiens.ToString() + ";";

                    try
                    {
                        //Envoie de la requête pour effectuer la mise à jour
                        cs.ReqAdmin(req);
                        cs.Fermer();

                        //Message de validation si la mise à jour est bonne
                        MessageBox.Show("Mise à jour effectué", "Success lors de la mise à jour", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Close();
                    }
                    catch (Exception)
                    {
                        //Message d'erreur si la mise à jour est ratée
                        lbl_error_general.Text = "Erreur lors de la mise à jour";
                    }
                }
            }
        }