public static void DeleteClient(int IdClient) { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "DELETE FROM clients WHERE idclient = @idclient"; command.Parameters.AddWithValue("@idclient", IdClient); command.ExecuteNonQuery(); } }
public static void DeleteVol(int IdVol) { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "DELETE FROM vols WHERE idvol = @idvol"; command.Parameters.AddWithValue("@idvol", IdVol); command.ExecuteNonQuery(); } }
public static void AddToDb(Modele_Controller modele) { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "INSERT INTO modeles (idmodele, label) VALUES (@idmodele, @label)"; command.Parameters.AddWithValue("@idmodele", modele.IdProperty); command.Parameters.AddWithValue("@label", modele.LabelProperty); command.ExecuteNonQuery(); } }
public static void GetExistingAeroports() { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM aeroports"; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { ExistingAeroports.Add(new Aeroport_Controller(dr.GetString("idaeroport"), dr.GetString("nom"))); } } } }
public static void AddNewClient(Client_Controller client) { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "INSERT INTO clients (idclient, nom, prenom, adresse, telephone, mail) " + "VALUES (NULL, @nom, @prenom, @adresse, @telephone, @mail)"; command.Parameters.AddWithValue("@nom", client.NomProperty); command.Parameters.AddWithValue("@prenom", client.PrenomProperty); command.Parameters.AddWithValue("@adresse", client.AdresseProperty); command.Parameters.AddWithValue("@telephone", client.TelephoneProperty); command.Parameters.AddWithValue("@mail", client.MailProperty); command.ExecuteNonQuery(); } }
public static void GetExistingAvions() { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM avions"; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { ExistingAvions.Add(new Avion_Controller(dr.GetInt32("idavion"), Modele_Model.CheckExistsThenAdd(dr.GetInt32("modele")), dr.GetBoolean("maintenance"), dr.GetBoolean("envol"))); } dr.Close(); } } }
public static void GetExistingModeles() { //MySqlDataReader dr = cmd.ExecuteReader(); using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM modeles"; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { ExistingModeles.Add(new Modele_Controller(dr.GetInt32("idmodele"), dr.GetString("label"))); } } } }
public static void GetExistingClients() { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM clients"; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { if (!ExistingClients.Any(vol => vol.IdProperty == dr.GetInt32("idclient"))) { ExistingClients.Add(new Client_Controller(dr.GetInt32("idclient"), dr.GetString("nom"), dr.GetString("prenom"), dr.GetString("adresse"), dr.GetString("telephone"), dr.GetString("mail"), dr.GetInt32("points"))); } } } } }
static public Dictionary <string, int> GetInfos(int Id) { Dictionary <string, int> dict = new Dictionary <string, int>(); using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM avions WHERE idavion = @idavion"; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { dict["idavion"] = Id; dict["idmodele"] = dr.GetInt32("modele"); } } } return(dict); }
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(); } }
static public Dictionary <string, int> GetInfosInt(int Id) { Dictionary <string, int> dict = new Dictionary <string, int>(); using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM vols WHERE idvol = @idvol"; command.Parameters.Add("@idvol", MySqlDbType.Int32).Value = Id; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { dict["idvol"] = Id; dict["idavion"] = dr.GetInt32("avion"); } } } return(dict); }
public static void GetExistingVols() { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM vols"; using (MySqlDataReader dr = command.ExecuteReader()) { DataTable table = new DataTable(); table.Load(dr); foreach (DataRow row in table.Rows) { if (!ExistingVols.Any(vol => vol.IdProperty == Convert.ToInt32(row["idvol"]))) { Vol_Controller v = new Vol_Controller(Convert.ToInt32(row["idvol"]), Avion_Model.CheckExistsThenAdd(Convert.ToInt32(row["avion"])), Aeroport_Model.CheckExistsThenAdd(row["adepart"].ToString()), Aeroport_Model.CheckExistsThenAdd(row["aarrivee"].ToString()), row["datedepart"].ToString(), row["heuredepart"].ToString(), row["heurearrivee"].ToString()); v.HeaderProperty = GetHeader(v); ExistingVols.Add(v); } } } } }
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(); } }
static public Dictionary <string, string> GetInfosString(int Id) { Dictionary <string, string> dict = new Dictionary <string, string>(); using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "SELECT * FROM vols"; using (MySqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { dict["adepart"] = dr.GetString("adepart"); dict["aarrivee"] = dr.GetString("aarrivee"); dict["date"] = dr.GetString("date"); dict["heurearrivee"] = dr.GetString("heurearrivee"); dict["heuredepart"] = dr.GetString("heuredepart"); } } } return(dict); }