Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e) // connexion bdd
        {
            if (button1.Text == "Se connecter")
            {
                cn = new MySqlConnection("SERVER=193.191.240.67;user=nick;database=DataBase;port=63307;password=1234");
                try
                {
                    if (cn.State == ConnectionState.Closed)
                    {
                        cn.Open();
                    }
                    button1.Text = "Se déconnecter";
                    Connecter    = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                string identifiant;
                string password;

                using (Connexion m = new Connexion())
                {
                    identifiant = m.identifiant;
                    password    = m.password;

                    a = new Monteur(identifiant, password);
                    b = new Planning_Master(identifiant, password);

                    if (m.ShowDialog() == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand("Select FROM Users (userName,Password)", cn);
                        using (MySqlDataReader Lire = cmd.ExecuteReader())
                        {
                            while (Lire.Read())
                            {
                                string identDB = Lire["userName"].ToString();
                                string pwDB    = Lire["Password"].ToString();

                                if (identifiant == identDB && password == pwDB)
                                {
                                    MessageBox.Show("Bienvenue {0}", identifiant);
                                }
                                else
                                {
                                    rentrePas();
                                }
                            }
                        }
                    }
                }
            }
            else  //pour la deco
            {
                rentrePas();
            }
        }
Esempio n. 2
0
        private void myBananasAreRipeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)                    //je peux pas selectioner du vide
            {
                ListViewItem element    = listView1.SelectedItems[0]; //je rerentre mes données ds cette boucle, pour un code plus soignée on peut les sortir mais flemme
                string       idBike     = element.SubItems[0].Text;
                string       Type       = element.SubItems[1].Text;
                string       Color      = element.SubItems[2].Text;
                string       Size       = element.SubItems[3].Text;
                string       Monteur    = element.SubItems[4].Text;
                string       Horaire    = element.SubItems[5].Text;
                string       DureeTache = element.SubItems[6].Text;

                using (Détail_et_modification m = new Détail_et_modification()) //On crée notre nouvelle instante modification et detail
                {
                    GT = new Horaire(m.HoraireTache, m.DureeTache);
                    a  = new Monteur(m.Monteur);

                    m.idBike        = idBike;
                    a.getMonteur    = Monteur;
                    GT.HoraireTache = Horaire;
                    GT.DureeTache   = DureeTache;
                    m.Type          = Type;

                    if (m.ShowDialog() == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand("UPDATE Bike SET Monteur=@monteur, HoraireTache=@HoraireTache, Type=@Type, DureeTache=@DureeTache WHERE idBike=@idBike", cn);
                        cmd.Parameters.AddWithValue("@monteur", m.Monteur);
                        cmd.Parameters.AddWithValue("@HoraireTache", m.HoraireTache);
                        cmd.Parameters.AddWithValue("@DureeTache", m.DureeTache);
                        cmd.Parameters.AddWithValue("@Type", m.Type);
                        cmd.Parameters.AddWithValue("@idBike", idBike);  //comme readonly pas de m.ID car je ne fais que afficher
                        cmd.ExecuteNonQuery();

                        //je le met directement à jour sans le bouton "actualiser"
                        element.SubItems[1].Text = m.Type;
                        element.SubItems[4].Text = m.Monteur;
                        element.SubItems[5].Text = GT.HoraireTache;
                        element.SubItems[6].Text = GT.DureeTache;

                        MessageBox.Show("Modifier");
                    }
                }
            }
        }