Esempio n. 1
0
        public TableauBord(int idOffre, string unNomRH)
        {
            this.idOffre = idOffre;
            this.nomRH   = unNomRH;
            InitializeComponent();
            NpgsqlConnection conn = new NpgsqlConnection(Connexion.Connecter());

            conn.Open();

            using (NpgsqlCommand cmd2 = new NpgsqlCommand("SELECT N.nom_cand, N.prenom_cand, M.notemoyenne,N.noteTotal, N.nom_prenom_rh FROM NoteRH N INNER JOIN NoteMoy M ON M.nom_cand = N.nom_cand AND M.prenom_cand = N.prenom_cand ORDER BY  M.notemoyenne, N.nom_cand, N.prenom_cand ; ", conn))
                using (NpgsqlDataReader reader = cmd2.ExecuteReader())
                {
                    //detection de la première ligne
                    int first = 1;

                    //tant qu'on a des lignes sql
                    while (reader.Read())
                    {
                        bool verif = false;
                        int  comp  = 0;
                        //Colonne pour chaque l'évaluateur est marquer
                        for (int i = 0; i < dataGridViewTableauBord.Columns.Count; i++)
                        {
                            // si l'évalutateur est déjà entre dans la colonne
                            if (dataGridViewTableauBord.Columns[i].HeaderText == reader.GetString(4))
                            {
                                verif = true;
                                comp  = i;
                            }
                        }
                        //si l'evaluateur n'est pas déjà dans la colonne
                        if (verif == false)
                        {
                            //on ajoute l'évaluateur dans la dernière colonne
                            dataGridViewTableauBord.Columns.Add(reader.GetString(4), reader.GetString(4));
                            comp = dataGridViewTableauBord.ColumnCount - 1;
                        }

                        //Row
                        if (first != 1)
                        {
                            //si les données sont identiques on les ajoute à la ligne existante
                            if (dataGridViewTableauBord.Rows[0].Cells[0].Value.ToString() == reader.GetString(0) + " " + reader.GetString(1))
                            {
                                //on met la note du candidat à l'évalutateur
                                dataGridViewTableauBord.Rows[0].Cells[comp].Value = reader.GetInt32(3);
                            }
                            //Sinon on créer une nouvele ligne aves le nom et prenom cand et sa moyenne
                            else
                            {
                                dataGridViewTableauBord.Rows.Add();
                                dataGridViewTableauBord.Rows[0].Cells[0].Value    = reader.GetString(0) + " " + reader.GetString(1);
                                dataGridViewTableauBord.Rows[0].Cells[1].Value    = reader.GetInt32(2);
                                dataGridViewTableauBord.Rows[0].Cells[comp].Value = reader.GetInt32(3);
                            }
                        }
                        //on ajoute sans ajouter de ligne
                        else
                        {
                            dataGridViewTableauBord.Rows[0].Cells[0].Value    = reader.GetString(0) + " " + reader.GetString(1);
                            dataGridViewTableauBord.Rows[0].Cells[1].Value    = reader.GetInt32(2);
                            dataGridViewTableauBord.Rows[0].Cells[comp].Value = reader.GetInt32(3);
                            first = -1;
                        }
                    }
                    ;
                }
        }
Esempio n. 2
0
        public OffreCritereDRH(string unNomRH)
        {
            this.nomRH = unNomRH;
            InitializeComponent();

            //permet de ne pas supprimer à chaque fois les offres dans la bdd
            string id = "-1";

            using (var conn = new NpgsqlConnection(Connexion.Connecter()))
            {
                conn.Open();

                using (var cmd = new NpgsqlCommand("SELECT id_offre FROM OFFRE_EMPLOIS ORDER BY id_offre", conn))
                    using (var reader = cmd.ExecuteReader())
                        while (reader.Read())
                        {
                            id = reader.GetInt32(0).ToString();
                        }

                conn.Close();
            }

            //Ouverture du web sercive  et créattion du document xml
            sioservicePortClient webServive = new sioservicePortClient();
            string      web  = webServive.exportOffreList(id);
            XmlDocument doc1 = new XmlDocument();

            doc1.LoadXml(web);

            XmlNodeList id_offre     = doc1.GetElementsByTagName("id_offre");
            XmlNodeList libelle      = doc1.GetElementsByTagName("libelle");
            XmlNodeList description  = doc1.GetElementsByTagName("description");
            XmlNodeList lieu         = doc1.GetElementsByTagName("lieu");
            XmlNodeList type_contrat = doc1.GetElementsByTagName("type_contrat");
            XmlNodeList salaire      = doc1.GetElementsByTagName("salaire");
            XmlNodeList date_limite  = doc1.GetElementsByTagName("date_limite");
            XmlNodeList supprimer    = doc1.GetElementsByTagName("supprimer");

            //permet d'insérer les données qui se trouvent dans le xml dans la bdd posgres
            using (var conn = new NpgsqlConnection(Connexion.Connecter()))
            {
                conn.Open();

                for (int i = 0; i < id_offre.Count; i++)
                {
                    using (var cmd = new NpgsqlCommand())
                    {
                        cmd.Connection = conn;
                        //innerXML permet d'enlever les balises
                        cmd.CommandText = "INSERT INTO OFFRE_EMPLOIS (id_offre, libelle, description, lieu, type_contrat, salaire, date_limite, supprimer, date_limite_offre ) VALUES (" + id_offre[i].InnerXml + ",'" + libelle[i].InnerXml + "', '" + description[i].InnerXml + "','" + lieu[i].InnerXml + "','" + type_contrat[i].InnerXml + "','" + salaire[i].InnerXml + "', '" + date_limite[i].InnerXml + "', '" + supprimer[i].InnerXml + "', NOW())";
                        cmd.ExecuteNonQuery();
                    }
                }
                conn.Close();
            }
            string web2 = webServive.exportCandidatureList(id);

            XmlDocument doc2 = new XmlDocument();

            doc2.LoadXml(web2);

            XmlNodeList id_candidature       = doc2.GetElementsByTagName("id_candidature");
            XmlNodeList nom_candidature      = doc2.GetElementsByTagName("nom_candidature");
            XmlNodeList prenom_candidature   = doc2.GetElementsByTagName("prenom_candidature");
            XmlNodeList date_candidature     = doc2.GetElementsByTagName("date_candidature");
            XmlNodeList id_offre_candidature = doc2.GetElementsByTagName("id_offre_candidature");

            //permet d'insérer les données xml dans la bdd posgres
            using (var conn = new NpgsqlConnection(Connexion.Connecter()))
            {
                conn.Open();

                for (int i = 0; i < id_candidature.Count; i++)
                {
                    using (var cmd = new NpgsqlCommand())
                    {
                        cmd.Connection  = conn;
                        cmd.CommandText = "INSERT INTO CANDIDATURE (id_cand, nom_cand, prenom_cand, date_cand , statut_cand, id_offre ) VALUES (" + id_candidature[i].InnerXml + ",'" + nom_candidature[i].InnerXml + "', '" + prenom_candidature[i].InnerXml + "','" + date_candidature[i].InnerXml + "','Attente','" + id_offre_candidature[i].InnerXml + "')";
                        cmd.ExecuteNonQuery();
                    }
                }
                conn.Close();
            }

            //Pour afficher les offres au commencement de l'appli

            foreach (Offre o in DAOOffre.GetLesOffres())
            {
                listBoxOffre.Items.Add(o.GetIdOffre() + "-" + o.GetLibelle() + "-" + o.GetLieu());
                listBoxOffreID.Items.Add(o.GetIdOffre());
            }
            listBoxOffre.SetSelected(0, true);
        }