Пример #1
0
        private void Button5_Click_1(object sender, EventArgs e)
        {
            this.Hide();
            GestionPersonnel fm = new GestionPersonnel();

            fm.Show();
        }
        private void Button2_Click(object sender, EventArgs e)
        {
            if (textBoxPrenom.Text == "" || comboBoxFonction.Text == "" || textBoxEmail.Text == "" || textBoxDateNaisse.Text == "" || textBoxNom.Text == "" || textBoxAdresse.Text == "" || textBoxTelephone.Text == "")
            {
                MessageBox.Show("Veuillez remplir tous les champs");
            }

            else
            {
                System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
                if (textBoxEmail.Text.Length > 0)
                {
                    if (!rEMail.IsMatch(textBoxEmail.Text))
                    {
                        MessageBox.Show("l'adresse e-mail n'est pas valide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBoxEmail.SelectAll();
                    }
                }

                conn.Open();
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                //define the command text
                cmd.CommandText = "insert into  personnel (Prenom,Nom,Fonction,Date_De_Naissance,Email,Telephone,Adresse) values ('" + textBoxPrenom.Text + "','" + textBoxNom.Text + "','" + comboBoxFonction.Text + "','" + textBoxDateNaisse.Text + "','" + textBoxEmail.Text + "','" + textBoxTelephone.Text + "','" + textBoxAdresse.Text + "');";
                cmd.ExecuteNonQuery();
                MessageBox.Show("Insertion effectué avec succés ! ");
                conn.Close();
                this.Hide();
                GestionPersonnel fm = new GestionPersonnel();
                fm.Show();
            }
        }