예제 #1
0
        private void AlimenterListeOffre()
        {
            lstOffre = new ObservableCollection <OVOffre>();
            String       loadOffre = "SELECT Identifiant, Libelle, Reference, DateDebutPublication, DateFinPublication, DateDebutContrat, DateFinContrat, DescriptionPoste, DescriptionProfil, NombresPoste, IdentifiantClient, IdentifiantMetier, IdentifiantContrat FROM offre";
            MySqlCommand cmd       = new MySqlCommand();

            cmd.CommandText = loadOffre;
            MySqlDataAdapter ad = new MySqlDataAdapter();

            ad.SelectCommand = cmd;
            cmd.Connection   = connect.con;
            DataSet ds = new DataSet();

            ad.Fill(ds);
            foreach (DataRowView rowView in ds.Tables[0].DefaultView)
            {
                OVOffre ovOffre = new OVOffre();

                ovOffre.Identifiant          = int.Parse(rowView["Identifiant"].ToString());
                ovOffre.Libelle              = rowView["Libelle"].ToString();
                ovOffre.Reference            = rowView["Reference"].ToString();
                ovOffre.DateDebutPublication = Convert.ToDateTime(rowView["DateDebutPublication"].ToString());
                ovOffre.DateFinPublication   = Convert.ToDateTime(rowView["DateFinPublication"].ToString());
                ovOffre.DateDebutContrat     = Convert.ToDateTime(rowView["DateDebutContrat"].ToString());
                ovOffre.DateFinContrat       = Convert.ToDateTime(rowView["DateFinContrat"].ToString());
                ovOffre.DescriptionPoste     = rowView["DescriptionPoste"].ToString();
                ovOffre.DescriptionProfil    = rowView["DescriptionProfil"].ToString();
                ovOffre.NombresPoste         = int.Parse(rowView["NombresPoste"].ToString());
                ovOffre.IdentifiantClient    = int.Parse(rowView["IdentifiantClient"].ToString());
                ovOffre.IdentifiantMetier    = int.Parse(rowView["IdentifiantMetier"].ToString());
                ovOffre.IdentifiantContrat   = int.Parse(rowView["IdentifiantContrat"].ToString());

                lstOffre.Add(ovOffre);
            }
        }
예제 #2
0
        private void listBoxOffre_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                OVOffre ovOffre = new OVOffre();
                ovOffre = (OVOffre)listBoxOffre.SelectedItem;
                string IdOffreChanged = ovOffre.Identifiant.ToString();

                string connectionString = "SERVER=localhost" + ";" + "DATABASE=megacastingv2" + ";" + "UID=root" + ";" + "PASSWORD="******";";
                string Query            = @"SELECT * FROM offre WHERE Identifiant = '" + IdOffreChanged + "';";


                MySqlConnection MyConn    = new MySqlConnection(connectionString);
                MySqlCommand    MyCommand = new MySqlCommand(Query, MyConn);
                MySqlDataReader MyReader;
                MyConn.Open();
                MyReader = MyCommand.ExecuteReader();

                //Remplir TextBox selon client selectionné
                tbLibelleEts.Text = ovOffre.Libelle;
                tbRef.Text        = ovOffre.Reference;
                dpDebutPub.Text   = ovOffre.DateDebutPublication.ToString();
                dpFinPub.Text     = ovOffre.DateFinPublication.ToString();
                dpDebutCtr.Text   = ovOffre.DateDebutContrat.ToString();
                dpFinCtr.Text     = ovOffre.DateFinContrat.ToString();
                tbDescPoste.Text  = ovOffre.DescriptionPoste;
                tbDescProfil.Text = ovOffre.DescriptionProfil;
                tbNbPoste.Text    = ovOffre.NombresPoste.ToString();
                cbIdClt.Text      = ovOffre.IdentifiantClient.ToString();
                cbIdMetier.Text   = ovOffre.IdentifiantMetier.ToString();
                cbIdCtr.Text      = ovOffre.IdentifiantContrat.ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }