public bool UpdateStatutChambre(Chambre chambre) { string request = "UPDATE chambre set statut = @statut where id = @id"; command = new SqlCommand(request, connection); command.Parameters.Add(new SqlParameter("statut", chambre.Statut.ToString())); command.Parameters.Add(new SqlParameter("id", chambre.Id)); connection.Open(); int nbRow = command.ExecuteNonQuery(); command.Dispose(); connection.Close(); return(nbRow == 1); }
public List <Chambre> GetChambresHotel(int hotelId) { List <Chambre> chambres = new List <Chambre>(); string request = "SELECT id, numero, capacite, statut, tarif from chambre where hotel_id=@hotel_id"; command = new SqlCommand(request, connection); command.Parameters.Add(new SqlParameter("@hotel_id", hotelId)); connection.Open(); reader = command.ExecuteReader(); while (reader.Read()) { Chambre c = new Chambre(reader.GetInt32(1), reader.GetInt32(2), reader.GetString(3), reader.GetDecimal(4), reader.GetInt32(0)); chambres.Add(c); } reader.Close(); command.Dispose(); connection.Close(); return(chambres); }
public List <Chambre> GetChambresReservation(int reservationId) { List <Chambre> chambres = new List <Chambre>(); string request = "SELECT rc.chambre_id, c.numero, c.capacite, c.statut, c.tarif from reservation_chambre as rc " + "inner join chambre as c on c.id = rc.chambre_id where rc.reservation_id = @reservation_id"; command = new SqlCommand(request, connection); command.Parameters.Add(new SqlParameter("@reservation_id", reservationId)); connection.Open(); reader = command.ExecuteReader(); while (reader.Read()) { Chambre c = new Chambre(reader.GetInt32(1), reader.GetInt32(2), reader.GetString(3), reader.GetDecimal(4), reader.GetInt32(0)); chambres.Add(c); } reader.Close(); command.Dispose(); connection.Close(); return(chambres); }