예제 #1
0
파일: VolDao.cs 프로젝트: nyckas/AirMad
        public Vol[] AirFrance()
        {
            Vol[]         valiny = new Vol[100];
            Connexion     con    = new Connexion();
            SqlConnection conn   = con.ConnectToSql();

            conn.Open();
            SqlCommand    cmd;
            SqlDataReader reader;
            string        requete = ("select v.id,a.id as avion,a.nom,v.compagnie,v.depart, v.destination, v.heureDepart, v.heureArrivee, v.prixBillet from Compagnie v, Avion a where v.avion = a.id order by v.id ASC");

            cmd    = new SqlCommand(requete, conn);
            reader = cmd.ExecuteReader();
            //MessageBox.Show("Affichage reussit");

            for (int i = 0; reader.Read(); i++)
            {
                String   id          = reader["id"].ToString();
                String   avionid     = reader["avion"].ToString();
                String   avion       = reader["nom"].ToString();
                String   compagnie   = reader["compagnie"].ToString();
                String   depart      = reader["depart"].ToString();
                String   destination = reader["destination"].ToString();
                DateTime heureDep    = DateTime.Parse(reader["heureDepart"].ToString());
                DateTime heureAr     = DateTime.Parse(reader["heureArrivee"].ToString());
                Double   prix        = Double.Parse(reader["prixBillet"].ToString());
                Console.Out.WriteLine("{0} {1} {2} {3} {4} {5} {6}", id, avionid, avion, compagnie, depart, destination, heureDep, heureAr, prix);
                valiny[i] = new Vol(id, avionid, avion, compagnie, depart, destination, heureDep, heureAr, prix);
            }
            reader.Close();
            cmd.Dispose();
            conn.Close();
            return(valiny);
        }
예제 #2
0
        void Button2Click(object sender, EventArgs e)
        {
            VolDao medoc = new VolDao();
            Vol    me    = new Vol(textBox4.Text, textBox9.Text, textBox3.Text, textBox7.Text, Convert.ToDateTime(textBox8.Text), Convert.ToDateTime(textBox11.Text), int.Parse(textBox14.Text), int.Parse(textBox12.Text), int.Parse(textBox15.Text), int.Parse(textBox6.Text), Double.Parse(textBox10.Text), textBox13.Text, textBox16.Text);

            medoc.insert(me);
        }
예제 #3
0
파일: VolDao.cs 프로젝트: nyckas/AirMad
        public Vol[] findPlaceLibre()
        {
            Vol[]         valiny = new Vol[100];
            Connexion     con    = new Connexion();
            SqlConnection conn   = con.ConnectToSql();

            conn.Open();
            SqlCommand    cmd;
            SqlDataReader reader;
            string        requete = ("select v.destination,a.nom,v.placeTotal from avion a, reservation r, Vol v where r.destination = v.destination and v.avion = a.id group by v.destination, a.nom, v.placeTotal");

            cmd    = new SqlCommand(requete, conn);
            reader = cmd.ExecuteReader();
            for (int i = 0; reader.Read(); i++)
            {
                String destination = reader["destination"].ToString();
                String nom         = reader["nom"].ToString();
                int    capacite    = int.Parse(reader["placeTotal"].ToString());
                Console.Out.WriteLine("{0} {1}", destination, nom, capacite);
                valiny[i] = new Vol(destination, nom, capacite);
            }
            reader.Close();
            cmd.Dispose();
            conn.Close();
            return(valiny);
        }
예제 #4
0
파일: VolDao.cs 프로젝트: nyckas/AirMad
        public Vol[] finddateVol()
        {
            Vol[]         valiny = new Vol[100];
            Connexion     con    = new Connexion();
            SqlConnection conn   = con.ConnectToSql();

            conn.Open();
            SqlCommand    cmd;
            SqlDataReader reader;
            string        requete = ("select v.heureDepart,v.destination from Vol v,Reservation r where v.destination = r.destination");

            cmd    = new SqlCommand(requete, conn);
            reader = cmd.ExecuteReader();
            //MessageBox.Show("Affichage reussit");

            for (int i = 0; reader.Read(); i++)
            {
                DateTime heureDep    = DateTime.Parse(reader["heureDepart"].ToString());
                String   destination = reader["destination"].ToString();
                //Console.Out.WriteLine("{0} {1} {2} {3} {4} {5} {6}",id,avion,depart,destination,heureDep,heureAr,prix);
                valiny[i] = new Vol(heureDep, destination);
            }
            reader.Close();
            cmd.Dispose();
            conn.Close();
            return(valiny);
        }
예제 #5
0
        void Button2Click(object sender, EventArgs e)
        {
            VolDao vol = new VolDao();

            Vol[] volavo = new Vol[100];
            try{
                volavo = vol.findvol();
                this.dataGridView1.Rows.Clear();
                for (int i = 0; i < volavo.Length; i++)
                {
                    this.dataGridView1.Rows.Add(volavo[i].getnom().ToString(), volavo[i].getdepart().ToString(), volavo[i].getdestination().ToString(), volavo[i].getheureDepart().ToString(), volavo[i].getheureArrivee().ToString(), volavo[i].getheureVol().ToString() + " h", volavo[i].getprix().ToString("#,##0") + " €");
                }
            }catch (Exception ex) {
            }
        }
예제 #6
0
파일: VolDao.cs 프로젝트: nyckas/AirMad
 public void insert(Vol medoc)
 {
     try{
         Connexion     con  = new Connexion();
         SqlConnection conn = con.ConnectToSql();
         SqlCommand    cmd  = new SqlCommand();
         cmd.Connection = conn;
         conn.Open();
         cmd.CommandText = "insert into vol values('" + medoc.getid() + "','" + medoc.getavion() + "','" + medoc.getdepart() + "','" + medoc.getdestination() + "','" + medoc.getheureDepart() + "','" + medoc.getheureArrivee() + "','" + medoc.getplaceAffaire() + "','" + medoc.getplacePremium() + "','" + medoc.getplaceEco() + "','" + medoc.getplaceTotal() + "','" + medoc.getprix() + "','" + medoc.getaller() + "','" + medoc.getretour() + "')";
         cmd.ExecuteNonQuery();
         MessageBox.Show("Insertion reussit");
         conn.Close();
     } catch (Exception e) {
         Console.Out.Write(e.Message);
     }
 }
예제 #7
0
파일: VolDao.cs 프로젝트: nyckas/AirMad
        public Vol[] findvol()
        {
            Vol[]         valiny = new Vol[100];
            Connexion     con    = new Connexion();
            SqlConnection conn   = con.ConnectToSql();

            conn.Open();
            SqlCommand    cmd;
            SqlDataReader reader;
            string        requete = ("select v.id,a.id as avion,a.nom,v.depart, v.destination, v.heureDepart, v.heureArrivee,{fn HOUR(v.heureArrivee)}-{fn HOUR(v.heureDepart)} as heureVol, v.prixBillet from vol v, Avion a where v.avion = a.id order by v.id ASC");

            cmd    = new SqlCommand(requete, conn);
            reader = cmd.ExecuteReader();
            //MessageBox.Show("Affichage reussit");

            for (int i = 0; reader.Read(); i++)
            {
                String   id          = reader["id"].ToString();
                String   avionid     = reader["avion"].ToString();
                String   avion       = reader["nom"].ToString();
                String   depart      = reader["depart"].ToString();
                String   destination = reader["destination"].ToString();
                DateTime heureDep    = DateTime.Parse(reader["heureDepart"].ToString());
                DateTime heureAr     = DateTime.Parse(reader["heureArrivee"].ToString());
                int      heureDepart = Convert.ToInt32(heureDep.Hour);
                int      heureArrive = Convert.ToInt32(heureAr.Hour);
                int      heureDevol  = heureArrive - heureDepart;
                int      heuredevol  = int.Parse(reader["heureVol"].ToString());
                Double   prix        = Double.Parse(reader["prixBillet"].ToString());
                Console.Out.WriteLine("{0} {1} {2} {3} {4} {5} {6}", id, avionid, avion, depart, destination, heureDep, heureAr, heuredevol, prix);
                valiny[i] = new Vol(id, avionid, avion, depart, destination, heureDep, heureAr, heureDevol, prix);
            }
            reader.Close();
            cmd.Dispose();
            conn.Close();
            return(valiny);
        }