Exemplo n.º 1
0
        public static Avion_Controller CheckExistsThenAdd(int IdAvion)
        {
            if (ExistingAvions != null)
            {
                bool exists = ExistingAvions.Any(a => a.IdProperty == IdAvion);
                if (exists)
                {
                    return(ExistingAvions.Find(a => a.IdProperty == IdAvion));
                }
                else
                {
                    Avion_Controller avion = new Avion_Controller(IdAvion);
                    ExistingAvions.Add(avion);

                    return(avion);
                }
            }
            else
            {
                Avion_Controller avion = new Avion_Controller(IdAvion);
                ExistingAvions.Add(avion);

                return(avion);
            }
        }
Exemplo n.º 2
0
        private void ModifierVol(object sender, RoutedEventArgs e)
        {
            if (System.Windows.Forms.MessageBox.Show("Confirmer la modification de ce vol ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                                     MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
            {
                int IdVol = Convert.ToInt32(this.Title);
                Aeroport_Controller AD    = Aeroport_Model.ExistingAeroports[ADepart.SelectedIndex];
                Aeroport_Controller AA    = Aeroport_Model.ExistingAeroports[AArrivee.SelectedIndex];
                Avion_Controller    avion = Avion_Model.ExistingAvions[Avion.SelectedIndex];
                DateTime?           HD    = HDepart.Value;
                DateTime?           HA    = HArrivee.Value;
                string HDString           = HD.Value.Hour.ToString() + ":" + HD.Value.Minute.ToString() + ":" + HD.Value.Second.ToString();
                string HAString           = HA.Value.Hour.ToString() + ":" + HA.Value.Minute.ToString() + ":" + HA.Value.Second.ToString();
                string DString            = Date.SelectedDate.Value.Year.ToString() + "-" + Date.SelectedDate.Value.Month.ToString() + "-" + Date.SelectedDate.Value.Day.ToString();

                Vol_Model.UpdateVol(IdVol, avion, AD, AA, DString, HDString, HAString);
                System.Windows.MessageBox.Show("Vol modifié !");
                this.Close();
            }
        }
Exemplo n.º 3
0
        public static void AddNewVol(Avion_Controller Avion, Aeroport_Controller AD, Aeroport_Controller AA, string Date, string HD, string HA)
        {
            int    IdAvion = Avion.IdProperty;
            string IdAD    = AD.IdProperty;
            string IdAA    = AA.IdProperty;

            using (MySqlConnection c = BddSQL.InitConnexion())
            {
                MySqlCommand command = c.CreateCommand();
                command.CommandText = "INSERT INTO vols (idvol, avion, adepart, aarrivee, heuredepart, heurearrivee, datedepart) " +
                                      "VALUES (NULL, @idAvion, @IdAD, @IdAA, @HD, @HA, @Date)";
                command.Parameters.AddWithValue("@idAvion", IdAvion);
                command.Parameters.AddWithValue("@IdAD", IdAD);
                command.Parameters.AddWithValue("@IdAA", IdAA);
                command.Parameters.AddWithValue("@Date", Date);
                command.Parameters.AddWithValue("@HD", HD);
                command.Parameters.AddWithValue("@HA", HA);

                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 4
0
        public static void UpdateVol(int IdVol, Avion_Controller Avion, Aeroport_Controller AD, Aeroport_Controller AA, string Date, string HD, string HA)
        {
            IdVol = 1;
            int    IdAvion = Avion.IdProperty;
            string IdAD    = AD.IdProperty;
            string IdAA    = AA.IdProperty;

            using (MySqlConnection c = BddSQL.InitConnexion())
            {
                MySqlCommand command = c.CreateCommand();
                command.CommandText = "UPDATE vols SET avion=@idavion, adepart=@IdAD, aarrivee=@IdAA, heuredepart=@HD, heurearrivee=@HA, date=@Date WHERE idvol=@idvol";
                command.Parameters.AddWithValue("@idAvion", IdAvion);
                command.Parameters.AddWithValue("@IdAD", IdAD);
                command.Parameters.AddWithValue("@IdAA", IdAA);
                command.Parameters.AddWithValue("@Date", Date);
                command.Parameters.AddWithValue("@HD", HD);
                command.Parameters.AddWithValue("@HA", HA);
                command.Parameters.AddWithValue("@idvol", IdVol);

                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 5
0
        private void AddNewVol(object sender, RoutedEventArgs e)
        {
            if (System.Windows.Forms.MessageBox.Show("Confirmer l'enregistrement de ce vol ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                                     MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
            {
                Aeroport_Controller AD    = Aeroport_Model.ExistingAeroports[ADepart.SelectedIndex];
                Aeroport_Controller AA    = Aeroport_Model.ExistingAeroports[AArrivee.SelectedIndex];
                Avion_Controller    avion = Avion_Model.ExistingAvions[Avion.SelectedIndex];
                DateTime?           HD    = HDepart.Value;
                DateTime?           HA    = HArrivee.Value;
                string HDString           = HD.Value.Hour.ToString() + ":" + HD.Value.Minute.ToString() + ":" + HD.Value.Second.ToString();
                string HAString           = HA.Value.Hour.ToString() + ":" + HA.Value.Minute.ToString() + ":" + HA.Value.Second.ToString();
                string DString            = Date.SelectedDate.Value.Year.ToString() + "-" + Date.SelectedDate.Value.Month.ToString() + "-" + Date.SelectedDate.Value.Day.ToString();

                Vol_Model.AddNewVol(avion, AD, AA, DString, HDString, HAString);

                MainWindow m = new MainWindow();
                m.Activate();
                m.Show();


                this.Close();
            }
        }