public void editFlight(Fly.Fly flight) { string query = "UPDATE fly SET destination='" + flight.Destination + "', start_point='" + flight.Start_point + "', departure_time='" + flight.Departure_time.ToString("yyyy-MM-dd HH:mm:ss") + "', landing_time='" + flight.Landing_time.ToString("yyyy-MM-dd HH:mm:ss") + "', airplane_id='" + flight.Airplane_id + "' WHERE id='" + flight.Id + "'"; if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = query; cmd.Connection = connection; cmd.ExecuteNonQuery(); this.CloseConnection(); } }
internal void addFlight(Fly.Fly flight) { string query = "INSERT INTO FLY (destination, start_point, departure_time, landing_time, airplane_id) VALUES ('" + flight.Destination + "', '" + flight.Start_point + "', '" + flight.Departure_time.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + flight.Landing_time.ToString("yyyy-MM-dd HH:mm:ss") + "', " + flight.Airplane_id + ")"; Console.WriteLine(query); if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); this.CloseConnection(); } Console.WriteLine("db add flight"); }
public Fly.Fly getFlight(int id) { string query = "SELECT * FROM FLY WHERE id='" + id + "'"; Fly.Fly flight = null; if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader data = cmd.ExecuteReader(); if (data.HasRows) { data.Read(); flight = new Fly.Fly(data.GetInt32(0), data.GetString(1), data.GetString(2), data.GetDateTime(3), data.GetDateTime(4), data.GetInt16(5).ToString()); return(flight); } data.Close(); this.CloseConnection(); } return(null); }
public Fly.Fly getFlight(string destination) { string query = "SELECT destination, start_point, departure_time, landing_time, airplane_id FROM FLY WHERE destination='" + destination + "'"; Fly.Fly flight = null; if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader data = cmd.ExecuteReader(); if (data.HasRows) { data.Read(); flight = new Fly.Fly(data.GetInt32(0), data.GetString(1), data.GetString(2), data.GetDateTime(3), data.GetDateTime(4), data.GetInt16(5).ToString()); return(flight); } data.Close(); this.CloseConnection(); } return(null); }
public List <Fly.Fly> getAllFlights() { List <Fly.Fly> listOfFlights = new List <Fly.Fly>(); string query = "SELECT * FROM FLY"; if (this.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader data = cmd.ExecuteReader(); Fly.Fly flight; if (data.HasRows) { while (data.Read()) { flight = new Fly.Fly(data.GetInt32(0), data.GetString(1), data.GetString(2), data.GetDateTime(3), data.GetDateTime(4), data.GetInt32(5)); listOfFlights.Add(flight); } } data.Close(); this.CloseConnection(); } return(listOfFlights); }