Beispiel #1
0
        //Select statement
        public static void insertFlight(Modele.ORM.plane APlane, string longdatetimeD, string longdatetimeA)
        {
            int seat    = APlane.Type.NbSeatingPlaces;
            int idPlane = APlane.IdPlane;
            //Open connection
            ConnexionWorkBench connection = new ConnexionWorkBench();

            if (connection.OpenConnection() == true)
            {
                string query = "INSERT INTO flight ( id_Plane, Available_Places, Hours_Departure,Hours_Arrival)" +
                               " VALUES( @idPlane,@seat, @HoursD,@HoursA)";
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection.GetConnection());

                //shield injection
                cmd.Parameters.AddWithValue("@seat", seat);
                cmd.Parameters.AddWithValue("@idPlane", idPlane);
                cmd.Parameters.AddWithValue("@HoursD", longdatetimeD);
                cmd.Parameters.AddWithValue("@HoursA", longdatetimeA);

                //Execute the command
                cmd.ExecuteNonQuery();


                //close Connection
                connection.CloseConnection();
            }
            else
            {
                MessageBox.Show("Connexion failed !");
            }
        }
Beispiel #2
0
 public flight(int thisId, Modele.ORM.plane thisPlane, int thisAvailablePlaces, DateTime thisHoursDeparture, DateTime thisHoursArrival)
 {
     Id              = thisId;
     Plane           = thisPlane;
     AvailablePlaces = thisAvailablePlaces;
     HoursDeparture  = thisHoursDeparture;
     HoursArrival    = thisHoursArrival;
 }
Beispiel #3
0
        //Select statement
        public static ObservableCollection <Modele.ORM.plane> getPlanes()


        {
            ObservableCollection <Modele.ORM.plane> Planes = new ObservableCollection <Modele.ORM.plane>();
            string query = "SELECT * FROM plane;";


            //Open connection
            ConnexionWorkBench connection = new ConnexionWorkBench();

            if (connection.OpenConnection() == true)

            {
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection.GetConnection());
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int             idplane = dataReader.GetInt32(0);
                    Modele.ORM.type Type    = Modele.ORM.type.GetType(dataReader.GetInt32(1));
                    Modele.ORM.crew Crew;
                    if (dataReader[2] != DBNull.Value)
                    {
                        Crew = Modele.ORM.crew.GetCrew(dataReader.GetInt32(2));
                    }
                    else
                    {
                        Crew = null;
                    }

                    Modele.ORM.warehouse Warehouse = Modele.ORM.warehouse.GetWarehouse(dataReader.GetInt32(3));
                    bool status = dataReader.GetBoolean(4);



                    Modele.ORM.plane Plane = new Modele.ORM.plane(idplane, Type, Crew, Warehouse, status);
                    Planes.Add(Plane);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                connection.CloseConnection();

                //return list to be displayed
                return(Planes);
            }
            else
            {
                return(Planes);
            }
        }
Beispiel #4
0
        private void InsertFlightClick(object sender, RoutedEventArgs e)
        {
            string longdatetimeD = DateD.SelectedDate.Value.ToString("yyyy/MM/dd") + " " + HourD.SelectedTime.Value.ToShortTimeString();
            string longdatetimeA = DateA.SelectedDate.Value.ToString("yyyy/MM/dd") + " " + HourA.SelectedTime.Value.ToShortTimeString();

            Modele.ORM.plane APlane = Plane.SelectedItem as Modele.ORM.plane;
            //test récupération valeur
            //MessageBox.Show("L'avion : "+APlane.IdPlane.ToString()+" a une date de départ = " + longdatetimeA + " Date arrivé = "+ longdatetimeA);
            vue.insertFlight(APlane, longdatetimeD, longdatetimeA);
            gridFlights.ItemsSource        = vue.getFlights();
            this.ModalAddFlight.Visibility = Visibility.Collapsed;
        }
Beispiel #5
0
        //Select statement
        public static ObservableCollection <Modele.ORM.flight> getFlights()
        {
            ObservableCollection <Modele.ORM.flight> Flights = new ObservableCollection <Modele.ORM.flight>();
            string query = "SELECT * FROM flight;";


            //Open connection
            ConnexionWorkBench connection = new ConnexionWorkBench();

            if (connection.OpenConnection() == true)

            {
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection.GetConnection());
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int idvol = dataReader.GetInt32(0);
                    Modele.ORM.plane Plane  = Modele.ORM.plane.getPlane(dataReader.GetInt32(1));
                    int      freePlaces     = dataReader.GetInt32(2);
                    DateTime hoursDeparture = dataReader.GetDateTime(3);
                    DateTime hoursArrival   = dataReader.GetDateTime(3);



                    Modele.ORM.flight Flight = new Modele.ORM.flight(idvol, Plane, freePlaces, hoursDeparture, hoursArrival);
                    Flights.Add(Flight);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                connection.CloseConnection();

                //return list to be displayed
                return(Flights);
            }
            else
            {
                return(Flights);
            }
        }
Beispiel #6
0
 //public void deletePlane(int idPlane)
 //{
 //    Modele.ORM.plane.deletePlane(idPlane);
 //}
 public void insertFlight(Modele.ORM.plane APlane, string longdatetimeD, string longdatetimeA)
 {
     Modele.ORM.flight.insertFlight(APlane, longdatetimeD, longdatetimeA);
 }
Beispiel #7
0
 public static void insertFlight(Modele.ORM.plane APlane, string longdatetimeD, string longdatetimeA)
 {
     Modele.DAL.Request.FlightRequest.insertFlight(APlane, longdatetimeD, longdatetimeA);
 }