Esempio n. 1
0
        public void UpdateAvion(ViewModel.AvionBinder a)
        {
            ConnectionBdd   bdd        = new ConnectionBdd();
            MySqlConnection connection = bdd.getConnection();

            MySqlCommand cmd = connection.CreateCommand();

            cmd.CommandText = "UPDATE avion SET `matricule`=@matricule,`motorisation`=@motorisation,`maintenance`=@maintenance,`disponible`=@disponible,`type`=@type,`capacite`=@capacite,`premiere`=@premiere,`business`=@business,`premium`=@premium,`economique`=@economique  WHERE id=@id";

            cmd.Parameters.AddWithValue("@matricule", a.MatriculeProperty);
            cmd.Parameters.AddWithValue("@motorisation", a.MotorisationProperty);
            cmd.Parameters.AddWithValue("@maintenance", a.MaintenanceProperty);
            cmd.Parameters.AddWithValue("@disponible", a.DisponibleProperty);
            cmd.Parameters.AddWithValue("@type", a.TypeProperty);
            cmd.Parameters.AddWithValue("@capacite", a.CapaciteProperty);
            cmd.Parameters.AddWithValue("@premiere", a.PremiereProperty);
            cmd.Parameters.AddWithValue("@business", a.BusinessProperty);
            cmd.Parameters.AddWithValue("@premium", a.PremiumProperty);
            cmd.Parameters.AddWithValue("@economique", a.EconomiqueProperty);
            cmd.Parameters.AddWithValue("@id", a.IdProperty);

            //cmd.Parameters.AddWithValue("@id", a.IdProperty);
            //  MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);
            cmd.ExecuteNonQuery();
        }
 public VolBinder(int id, string dateHeureA, string dateHeureD, int annule, string lieuA, string lieuD, int nbPassager, ViewModel.AvionBinder avion)
 {
     this.IdProperty         = id;
     this.DateHeureAProperty = dateHeureA;
     this.DateHeureDProperty = dateHeureD;
     this.AnnuleProperty     = annule;
     this.LieuAProperty      = lieuA;
     this.LieuDProperty      = lieuD;
     this.NbPassagerProperty = nbPassager;
     this.AvionProperty      = avion;
 }
Esempio n. 3
0
        public static ViewModel.AvionBinder SelectAvion(int idavion)
        {
            ViewModel.AvionBinder unavion = null;
            try
            {
                ConnectionBdd   bdd        = new ConnectionBdd();
                MySqlConnection connection = bdd.getConnection();
                // Requête SQL
                string query = "SELECT * from avion where id=" + idavion + "";

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

                while (reader.Read())
                {
                    int    Id = reader.GetInt32(0);
                    string MatriculeProprty     = reader.GetString(1);
                    string MotorisationProperty = reader.GetString(2);
                    int    MaintenanceProperty  = reader.GetInt32(3);
                    int    DisponibleProperty   = reader.GetInt32(4);
                    string TypeProperty         = reader.GetString(5);
                    int    CapaciteProperty     = reader.GetInt32(6);
                    int    PremiereProperty     = reader.GetInt32(7);
                    int    BusinessProperty     = reader.GetInt32(8);
                    int    PremiumProperty      = reader.GetInt32(9);
                    int    EconomiqueProperty   = reader.GetInt32(10);
                    unavion = new ViewModel.AvionBinder(Id, MatriculeProprty, MotorisationProperty, MaintenanceProperty, DisponibleProperty, TypeProperty, CapaciteProperty, PremiereProperty, BusinessProperty, PremiumProperty, EconomiqueProperty);
                }

                //Fermeture de la connexion
                reader.Close();
                connection.Close();
                return(unavion);
            }
            catch
            {
                // Gestion des erreurs :
                // Possibilité de créer un Logger pour les exceptions SQL reçus
                // Possibilité de créer une méthode avec un booléan en retour pour savoir si le contact à été ajouté correctement.
            }
            return(unavion);
        }
        private void Button_Click_Insert_Vol(object sender, RoutedEventArgs e)
        {
            Model.DAL.DALVol      bdd       = new Model.DAL.DALVol();
            ViewModel.AvionBinder matricule = avion.SelectedItem as ViewModel.AvionBinder;


            //Convertir la date DD/MM/YYYY en YYYY-MM-DD
            string sdateD = dateD.Text;

            string[] depart     = sdateD.Split('/');
            string   dayD       = depart[0];
            string   monthD     = depart[1];
            string   yearD      = depart[2];
            string   dateDepart = yearD + "-" + monthD + "-" + dayD;

            string sdateA = dateA.Text;

            string[] arrivee     = sdateA.Split('/');
            string   dayA        = arrivee[0];
            string   monthA      = arrivee[1];
            string   yearA       = arrivee[2];
            string   dateArrivee = yearA + "-" + monthA + "-" + dayA;

            DigitalTime a          = heureA.Time;
            int         ha         = a.Hour;
            int         ma         = a.Minute;
            string      dateHeureA = dateArrivee + " " + ha + ":" + ma;

            DigitalTime d          = heureD.Time;
            int         hd         = d.Hour;
            int         md         = d.Minute;
            string      dateHeureD = dateDepart + " " + hd + ":" + md;

            bdd.AddVol(dateHeureA, dateHeureD, lieuA.Text, lieuD.Text, Convert.ToInt32(nbPassager.Text), matricule.IdProperty);

            lieuA.Clear();
            lieuD.Clear();
            nbPassager.Clear();
        }