예제 #1
0
 public plane(int idThisPlane, Modele.ORM.type thisType, Modele.ORM.crew thisCrew, Modele.ORM.warehouse thisWarehouse, bool thisStatus)
 {
     IdPlane   = idThisPlane;
     Type      = thisType;
     Crew      = thisCrew;
     Warehouse = thisWarehouse;
     Status    = thisStatus;
 }
예제 #2
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);
            }
        }
예제 #3
0
        private void InsertPlaneClick(object sender, RoutedEventArgs e)
        {
            Modele.ORM.type Type = PlaneType.SelectedItem as Modele.ORM.type;

            Modele.ORM.warehouse Warehouse = PlaneWarehouse.SelectedItem as Modele.ORM.warehouse;
            bool status = (bool)Status.IsChecked;

            vue.insertPlane(Type.IdType, Warehouse.IdWarehouse, status);
            gridPlanes.ItemsSource        = vue.getPlanes();
            this.ModalAddPlane.Visibility = Visibility.Collapsed;
        }
예제 #4
0
        //Select statement
        public static Modele.ORM.warehouse getWarehouse(int idWarehouse)


        {
            Modele.ORM.warehouse Warehouse = null;
            string query = "SELECT * FROM warehouse where id=@warehouse;";


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

            if (connection.OpenConnection() == true)

            {
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection.GetConnection());

                //shield sql injection
                cmd.Parameters.AddWithValue("@warehouse", idWarehouse);

                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    Warehouse = new Modele.ORM.warehouse(
                        dataReader.GetInt32(0),
                        Modele.ORM.airport.GetAirport(dataReader.GetInt32(1)),
                        dataReader.GetString(2),
                        dataReader.GetBoolean(3)
                        );
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                connection.CloseConnection();

                //return list to be displayed
                return(Warehouse);
            }
            else
            {
                return(Warehouse);
            }
        }
예제 #5
0
        //Select statement
        public static ObservableCollection <Modele.ORM.warehouse> getWarehouses()


        {
            Modele.ORM.warehouse Warehouse = null;
            ObservableCollection <Modele.ORM.warehouse> Warehouses = new ObservableCollection <Modele.ORM.warehouse>();
            string query = "SELECT id,name FROM warehouse;";


            //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())
                {
                    Warehouse = new Modele.ORM.warehouse(
                        dataReader.GetInt32(0),
                        dataReader.GetString(1)
                        );
                    Warehouses.Add(Warehouse);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                connection.CloseConnection();

                //return list to be displayed
                return(Warehouses);
            }
            else
            {
                return(Warehouses);
            }
        }