protected void calcularPrecio() { //me traen los precios HotelEntidad hotel = HotelDao.consultarHotelXID(int.Parse(ddl_hotel.SelectedValue)); ViajeEntidad viaje = ViajeDao.consultarViajeSeleccionado(int.Parse(ddl_viaje.SelectedValue)); //Para saber la cantidad de dias TimeSpan dias = DateTime.Parse(txt_fechaVuelta.Text) - DateTime.Parse(txt_fechaIda.Text); int cantidadDias = dias.Days; int cantidadTuristas = dgv_detalleReserva.Rows.Count; double precioViaje; double precioHotel = hotel.precio; if (viaje.soloIda.Value) { precioViaje = viaje.precioTotal / 2; } else { precioViaje = viaje.precioTotal; } switch (viaje.idTransporte) { //temporada alta case 1: precioViaje = (precioViaje * 1.5); precioHotel = (precioHotel * 1.5); break; //temporada media case 2: precioViaje = (precioViaje * 0.5); precioHotel = (precioHotel * 0.5); break; //temporada baja case 3: precioViaje = precioViaje * 1; precioHotel = (precioHotel * 1); break; default: break; } double precioTotal; //hago el calculo precioTotal = (cantidadTuristas * precioViaje) + (precioHotel * cantidadDias); //lo cargo al precio total txt_precioTotal.Text = precioTotal.ToString(); }
public static void registrarHotel(HotelEntidad hotel) { string query = "INSERT INTO Hotel(nombre, telefono, cuit, idTemporada, precio, idCategoria, idCiudad) VALUE(@nom, @tel, @Cuit, @temp, @pre, @categoria, @ciudad)"; SqlCommand cmd = new SqlCommand(query, obtenerDB()); cmd.Parameters.AddWithValue(@"nom", hotel.nombre); cmd.Parameters.AddWithValue(@"tel", hotel.telefono); cmd.Parameters.AddWithValue(@"Cuit", hotel.cuit); cmd.Parameters.AddWithValue(@"temp", hotel.idTemporada); cmd.Parameters.AddWithValue(@"pre", hotel.precio); cmd.Parameters.AddWithValue(@"categoria", hotel.idCategoria); cmd.Parameters.AddWithValue(@"ciudad", hotel.idCiudad); cmd.ExecuteNonQuery(); cmd.Connection.Close(); }
public static List <HotelEntidad> consultarHotel() { List <HotelEntidad> listaHotel = new List <HotelEntidad>(); string query = "SELECT * FROM Hotel"; SqlCommand cmd = new SqlCommand(query, obtenerDB()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { HotelEntidad hotel = new HotelEntidad(); hotel.idHotel = int.Parse(dr["idHotel"].ToString()); hotel.nombre = dr["nombre"].ToString(); listaHotel.Add(hotel); } dr.Close(); cmd.Connection.Close(); return(listaHotel); }
public static HotelEntidad consultarHotelXID(int id) { HotelEntidad hotel = new HotelEntidad(); //List<HotelEntidad> listaHotel = new List<HotelEntidad>(); string query = "SELECT * FROM Hotel where idHotel = @hotel"; SqlCommand cmd = new SqlCommand(query, obtenerDB()); cmd.Parameters.AddWithValue(@"hotel", id); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { hotel.idHotel = int.Parse(dr["idHotel"].ToString()); hotel.precio = float.Parse(dr["precio"].ToString()); } dr.Close(); cmd.Connection.Close(); return(hotel); }
public static List <HotelEntidad> consultarHotel() { List <HotelEntidad> listaHotel = new List <HotelEntidad>(); string query = "SELECT * FROM Hotel"; SqlCommand cmd = new SqlCommand(query, obtenerDB()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { HotelEntidad hotel = new HotelEntidad(); hotel.idHotel = int.Parse(dr["idHotel"].ToString()); hotel.cuit = int.Parse(dr["cuit"].ToString()); hotel.idCategoria = int.Parse(dr["idCategoria"].ToString()); hotel.idCiudad = int.Parse(dr["idCiudad"].ToString()); hotel.idTemporada = int.Parse(dr["idTemporada"].ToString()); hotel.nombre = dr["nombre"].ToString(); hotel.precio = float.Parse(dr["precio"].ToString()); hotel.telefono = int.Parse(dr["telefono"].ToString()); listaHotel.Add(hotel); } dr.Close(); cmd.Connection.Close(); return(listaHotel); }