예제 #1
0
        public void SelectVols(ObservableCollection <Vols> l)
        {
            connection.Close();

            string query = "SELECT * FROM vols";

            connection.Open();
            MySqlCommand    cmd    = new MySqlCommand(query, connection);
            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    if (reader.IsDBNull(2))
                    {
                        value2 = "NULL";
                    }


                    else
                    {
                        value2 = reader.GetString(2);
                    }

                    if (reader.IsDBNull(4))
                    {
                        value4 = "NULL";
                    }
                    else
                    {
                        value4 = reader.GetString(4);
                    }

                    idvol = reader.GetInt32(0);

                    date_dep = reader.GetString(1);

                    date_arr = reader.GetString(3);
                    idavion  = reader.GetInt32(5);

                    id1 = reader.GetInt32(6);
                    id2 = reader.GetInt32(7);

                    reader.GetString(3);



                    Vols a = new Vols(idvol, date_dep, value2, date_arr, value4, idavion, id1, id2);

                    l.Add(a);
                }

                reader.Close();
                connection.Close();
            }
        }
예제 #2
0
        public void SelectHistoVols(ObservableCollection <Vols> l, int id)
        {
            connection.Close();
            connection.Open();
            string       query = "SELECT * From vols v Inner Join histo_vols h ON h.id_vol = v.idVols AND h.id_client=@id";
            MySqlCommand cmd   = new MySqlCommand(query, connection);

            cmd.Parameters.AddWithValue("@id", id);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Vols c = new Vols(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetInt32(5), reader.GetInt32(6), reader.GetInt32(7));
                l.Add(c);
            }
            reader.Close();
            connection.Close();
        }
예제 #3
0
        public static void updateVols(Vols v)
        {
            connection.Close();
            connection.Open();

            string       query = " UPDATE vols SET depart_prevu = @depart_prevu, depart_reel = @depart_reel, arrive_prevu = @arrive_prevu, arrive_reel = @arrive_reel, id_avion = @id_avion, id_arrive = @id_arrive WHERE idVols = @idvols";
            MySqlCommand cmd   = new MySqlCommand(query, connection);

            cmd.Parameters.AddWithValue("@depart_prevu", v.DepartprevuProperty);
            cmd.Parameters.AddWithValue("@depart_reel", v.DepartreelProperty);
            cmd.Parameters.AddWithValue("@arrive_prevu", v.ArriveprevuProperty);
            cmd.Parameters.AddWithValue("@arrive_reel", v.ArrivereelProperty);
            cmd.Parameters.AddWithValue("@id_avion", v.IdAvionProperty);
            //cmd.Parameters.AddWithValue("@id_dep", id_dep);
            cmd.Parameters.AddWithValue("@id_arrive", v.IdArriveProperty);
            cmd.Parameters.AddWithValue("@idvols", v.idVolsProperty);


            cmd.ExecuteNonQuery();
            connection.Close();
        }