public List <Habitacion> getHabitacionesByReservaId(Reserva reserva) { List <Habitacion> habitaciones = new List <Habitacion>(); String connectionString = ConfigurationManager.AppSettings["BaseLocal"]; SqlConnection sqlConnection = new SqlConnection(connectionString); SqlCommand sqlCommand = new SqlCommand(); SqlDataReader reader; sqlCommand.Parameters.AddWithValue("@idReserva", reserva.getIdReserva()); sqlCommand.CommandType = CommandType.Text; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "SELECT * FROM LOS_BORBOTONES.Reserva_X_Habitacion_X_Cliente AS RXH " + "WHERE RXH.idReserva = @idReserva"; sqlConnection.Open(); reader = sqlCommand.ExecuteReader(); while (reader.Read()) { int idHabitacion = reader.GetInt32(reader.GetOrdinal("idHabitacion")); RepositorioHabitacion repoHabitacion = new RepositorioHabitacion(); Habitacion habitacion = repoHabitacion.getById(idHabitacion); habitaciones.Add(habitacion); } //Cierro Primera Consulta sqlConnection.Close(); return(habitaciones); }
//metodo para traer el monto de una reserva public Decimal getMonto(Reserva reserva) { /*El valor de la habitación se obtiene a través de su precio base (ver abm de régimen) * multiplicando la cantidad de personas que se alojarán en la habitación (tipo de habitación) y * luego de ello aplicando un incremento en función de la categoría del Hotel (cantidad de * estrellas)*/ Decimal total = 0; RepositorioRegimen repoRegimen = new RepositorioRegimen(); RepositorioHabitacion repoHabitacion = new RepositorioHabitacion(); String connectionString = ConfigurationManager.AppSettings["BaseLocal"]; SqlConnection sqlConnection = new SqlConnection(connectionString); SqlCommand sqlCommand = new SqlCommand(); SqlDataReader reader; //traigo el monto del regimen Decimal montoRegimen = repoRegimen.getMonto(reserva.getRegimen().getIdRegimen()); sqlCommand.Parameters.AddWithValue("@idReserva", reserva.getIdReserva()); sqlCommand.CommandType = CommandType.Text; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "SELECT idHabitacion FROM LOS_BORBOTONES.Reserva_X_Habitacion_X_Cliente WHERE idReserva = @idReserva"; sqlConnection.Open(); reader = sqlCommand.ExecuteReader(); while (reader.Read()) { Habitacion habitacion = repoHabitacion.getById(reader.GetInt32(reader.GetOrdinal("idHabitacion"))); TipoHabitacion tipoHabitacion = habitacion.getTipoHabitacion(); total = montoRegimen * tipoHabitacion.getPorcentual(); } sqlConnection.Close(); //falta la suma por cantidad de estrellas Hotel hotel = reserva.getHotel(); Categoria categoria = hotel.getCategoria(); Decimal recargaEstrellas = categoria.getRecargaEstrellas(); //Devuelve el monto total de las habitaciones para esa reserva. total = total + recargaEstrellas; return(total); }