Esempio n. 1
0
        private void Btn_modif_Click(object sender, EventArgs e)
        {
            Lapins leLapin = (Lapins)lb_mesLapins.Items[lb_mesLapins.SelectedIndex];

            leLapin.SetSurnom(tb_sur.Text);
            if (leLapin.GetState() == state.unChanged || leLapin.GetState() == state.modified)
            {
                leLapin.SetState(state.modified);
            }
            lb_mesLapins.Items.RemoveAt(lb_mesLapins.SelectedIndex);
            lb_mesLapins.Items.Add(leLapin);
        }
Esempio n. 2
0
        private void Btn_bannir_Click(object sender, EventArgs e)
        {
            if (lb_mesLapins.SelectedIndex == -1)
            {
                return;
            }
            Lapins a = (Lapins)lb_mesLapins.Items[lb_mesLapins.SelectedIndex];

            a.SetState(state.modified);
            a.SetIdGerant(0);
            string val = Regex.Replace(this.l_budget.Text, "[^0-9.]", "");

            this.l_budget.Text = (Convert.ToInt32(val) + (a.Valeur / 2)).ToString() + " $";
            lb_mesLapins.Items.RemoveAt(lb_mesLapins.SelectedIndex);
            lb_LapinsLibres.Items.Add(a);
            this.l_place.Text = (5 - lb_mesLapins.Items.Count).ToString() + " / 5";
        }
Esempio n. 3
0
 private void insert(Lapins lapin)
 {
     using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection())
     {
         cnx.Open();
         if (lapin.GetIdGerant() == 0)
         {
             using (MySqlCommand cmd = new MySqlCommand("insert into Lapin(surnom,age,vitesse,endurance,chance) values(@surnom,@age,@vitesse,@endurance,@chance)", cnx))
             {
                 cmd.Parameters.Add(new MySqlParameter("@surnom", MySqlDbType.VarChar));
                 cmd.Parameters.Add(new MySqlParameter("@age", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@vitesse", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@endurance", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@chance", MySqlDbType.Int32));
                 cmd.Parameters["@surnom"].Value    = lapin.GetSurnom();
                 cmd.Parameters["@age"].Value       = lapin.GetAge();
                 cmd.Parameters["@vitesse"].Value   = lapin.Vitesse;
                 cmd.Parameters["@endurance"].Value = lapin.Endurance;
                 cmd.Parameters["@chance"].Value    = lapin.Chance;
                 cmd.ExecuteNonQuery();
             }
         }
         else
         {
             using (MySqlCommand cmd = new MySqlCommand("insert into Lapin(surnom,age,vitesse,endurance,chance,idGerant) values(@surnom,@age,@vitesse,@endurance,@chance,@idGerant)", cnx))
             {
                 cmd.Parameters.Add(new MySqlParameter("@surnom", MySqlDbType.VarChar));
                 cmd.Parameters.Add(new MySqlParameter("@age", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@vitesse", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@endurance", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@chance", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@idGerant", MySqlDbType.Int32));
                 cmd.Parameters["@surnom"].Value    = lapin.GetSurnom();
                 cmd.Parameters["@age"].Value       = lapin.GetAge();
                 cmd.Parameters["@vitesse"].Value   = lapin.Vitesse;
                 cmd.Parameters["@endurance"].Value = lapin.Endurance;
                 cmd.Parameters["@chance"].Value    = lapin.Chance;
                 cmd.Parameters["@idGerant"].Value  = lapin.GetIdGerant();
                 cmd.ExecuteNonQuery();
             }
         }
     }
     lapin.SetState(state.unChanged);
 }
Esempio n. 4
0
 private void update(Lapins lapin)
 {
     using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection())
     {
         cnx.Open();
         if (lapin.GetIdGerant() == 0)
         {
             using (MySqlCommand cmd = new MySqlCommand("update Lapin set surnom=@surnom,age=@age, idGerant=NULL where id=@id", cnx))
             {
                 cmd.Parameters.Add(new MySqlParameter("@id", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@age", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@surnom", MySqlDbType.VarChar));
                 cmd.Parameters["@id"].Value     = lapin.GetId();
                 cmd.Parameters["@age"].Value    = lapin.GetAge();
                 cmd.Parameters["@surnom"].Value = lapin.GetSurnom();
                 cmd.ExecuteNonQuery();
             }
         }
         else
         {
             using (MySqlCommand cmd = new MySqlCommand("update Lapin set surnom=@surnom,age=@age,idGerant=@idGerant where id=@id", cnx))
             {
                 cmd.Parameters.Add(new MySqlParameter("@id", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@age", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@idGerant", MySqlDbType.Int32));
                 cmd.Parameters.Add(new MySqlParameter("@surnom", MySqlDbType.VarChar));
                 cmd.Parameters["@id"].Value       = lapin.GetId();
                 cmd.Parameters["@age"].Value      = lapin.GetAge();
                 cmd.Parameters["@surnom"].Value   = lapin.GetSurnom();
                 cmd.Parameters["@idGerant"].Value = lapin.GetIdGerant();
                 cmd.ExecuteNonQuery();
             }
         }
     }
     lapin.SetState(state.unChanged);
 }