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); }
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); }
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); }
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); }
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) { } }
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); } }
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); }