public List <LineaReserva> ListarLineaReservaReserva(Reserva o) { try { List <LineaReserva> lstreserva = new List <LineaReserva>(); LineaReserva lreserva = null; SqlConnection conn = db.ConectaDb(); string select = string.Format("select e.IdEmpleado,e.Nombre,e.Apellido,h.IdHabitacion,h.NumHabitacion,h.Tarifa,l.Cantidad from Reserva as r, LineaReserva as l,Empleado as e,Habitacion as h where r.IdReserva=l.IdReserva and h.IdHabitacion=l.IdHabitacion and e.IdEmpleado=l.IdEmpleado and r.IdReserva={0}", o.IdReserva); SqlCommand cmd = new SqlCommand(select, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { lreserva = new LineaReserva(); Persona a = new Persona(); a = new EmpleadoDAODB().BuscarPorId((int)reader["IdEmpleado"]); lreserva.empleado = a as Empleado; lreserva.habitacion = new HabitacionDAODB().BuscarPorId((int)reader["IdHabitacion"]); // lcarac.carac.Precio = new CaracDAODB().BuscarPorId((int)reader["IdCarac"]).Precio; SI DESEAS EL PRECIO DE CADA CARACTERISTICA lstreserva.Add(lreserva); } reader.Close(); return(lstreserva); } catch (Exception ex) { return(null); } finally { db.DesconectaDb(); } }
public List<LineaReserva> ListarLineaReservaReserva(Reserva o) { try { List<LineaReserva> lstreserva = new List<LineaReserva>(); LineaReserva lreserva = null; SqlConnection conn = db.ConectaDb(); string select = string.Format("select e.IdEmpleado,e.Nombre,e.Apellido,h.IdHabitacion,h.NumHabitacion,h.Tarifa,l.Cantidad from Reserva as r, LineaReserva as l,Empleado as e,Habitacion as h where r.IdReserva=l.IdReserva and h.IdHabitacion=l.IdHabitacion and e.IdEmpleado=l.IdEmpleado and r.IdReserva={0}", o.IdReserva); SqlCommand cmd = new SqlCommand(select, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { lreserva = new LineaReserva(); Persona a = new Persona(); a = new EmpleadoDAODB().BuscarPorId((int)reader["IdEmpleado"]); lreserva.empleado = a as Empleado; lreserva.habitacion = new HabitacionDAODB().BuscarPorId((int)reader["IdHabitacion"]); // lcarac.carac.Precio = new CaracDAODB().BuscarPorId((int)reader["IdCarac"]).Precio; SI DESEAS EL PRECIO DE CADA CARACTERISTICA lstreserva.Add(lreserva); } reader.Close(); return lstreserva; } catch (Exception ex) { return null; } finally { db.DesconectaDb(); } }