Пример #1
0
        public static void enregistrerSalarie(salarie unSalarie)
        {
            string          connString = "Server = 127.0.0.1; Database = gsb_medic;Uid=dev;password=admin;SslMode=none;";
            MySqlConnection conn       = new MySqlConnection(connString);

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "INSERT INTO salarie VALUES (@Matricule, @Nom, @Prenom, @DateEmbauche)";
            cmd.Parameters.AddWithValue("@Matricule", unSalarie.Matricule1);
            cmd.Parameters.AddWithValue("@Nom", unSalarie.Nom1);
            cmd.Parameters.AddWithValue("@Prenom", unSalarie.Prenom1);
            cmd.Parameters.AddWithValue("@DateEmbauche", unSalarie.DateEmbauche1);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Ajouter à la base !");
            conn.Close();
        }
Пример #2
0
        public static List <salarie> selectSalarie()
        {
            List <salarie> LesSalaries = new List <salarie>();

            string          connString = "Server = 127.0.0.1; Database = gsb_medic;Uid=dev;password=admin;SslMode=none;";
            MySqlConnection conn       = new MySqlConnection(connString);

            conn.Open();

            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "SELECT Matricule, Nom, Prenom, DateEmbauche FROM salarie";
            MySqlDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                salarie unSalarie = new salarie(Convert.ToString(dataReader["Matricule"]), Convert.ToString(dataReader["Nom"]), Convert.ToString(dataReader["Prenom"]), Convert.ToString(dataReader["DateEmbauche"]));

                LesSalaries.Add(unSalarie);
            }

            conn.Close();
            return(LesSalaries);
        }
Пример #3
0
        private void buttonAjtS_Click(object sender, EventArgs e)
        {
            salarie lesalarie = new salarie(textBoxMatriculeS.Text, textBoxNomS.Text, textBoxPrenomS.Text, textBoxDateS.Text);

            BD.enregistrerSalarie(lesalarie);
        }