public int eliminarDetalleReserva(int codigo) { Detalle_Reserva dr = contexto.Detalle_Reserva.Find(codigo); contexto.Detalle_Reserva.Remove(dr); return(contexto.SaveChanges()); }
private void reservar(int cantHab, Tipo_Habitacion tipo_seleccionado) { Reserva reserva = new Reserva(); reserva.CodigoRegimen = regimen_elegido.CodRegimen; reserva.Fecha_Inicio_struct = dateTimeEntrada.Value; reserva.Fecha_Fin_struct = dateTimeSalida.Value; reserva.Fecha_Reserva_struct = Globals.getFechaSistema(); reserva.Usr = Globals.infoSesion.User.Usr; reserva.cantHabitaciones = cantHab; reserva.tipo_habitacion = tipo_seleccionado; List <Habitacion> habitaciones_disponibles; habitaciones_disponibles = DAOReserva.habitacionDisponibles(Globals.infoSesion.Hotel.CodHotel, tipo_seleccionado.TipoCodigo, reserva.Fecha_Inicio, reserva.Fecha_Fin); if (habitaciones_disponibles.Count < cantHab) { DialogResult dr = MessageBox.Show("No existen suficientes habitaciones disponibles para efectuar la reserva.", "", MessageBoxButtons.OK); return; } for (int i = 0; i < cantHab; i++) { Detalle_Reserva det = new Detalle_Reserva(); det.CodigoHotel = Globals.infoSesion.Hotel.CodHotel; det.Habitacion = habitaciones_disponibles[i].Id_Habitacion; reserva.detalles_reserva.Add(det); } new ConfirmarReserva(reserva).Show(); Globals.deshabilitarAnterior(this); }
public int eliminarProducto(int codigo) { Producto p = contexto.Producto.Find(codigo); Detalle_Reserva DR = new Detalle_Reserva(); DR.id_producto_d = codigo; SqlConnection cn = new SqlConnection(CadenaConexion); cn.Open(); var cmd = new SqlCommand("select id_producto_d from Detalle_Reserva where id_producto_d=@id", cn); cmd.Parameters.Add("@id", SqlDbType.Int).Value = codigo; cmd.Connection = cn; int idprod = Convert.ToInt32(cmd.ExecuteScalar()); if (idprod != 0) { Console.WriteLine("no puede realizar la eliminaciòn, ya que el producto esta reservado"); return(contexto.SaveChanges()); } else { contexto.Producto.Remove(p); return(contexto.SaveChanges()); } }
public int actualizarDetalleReserva(Detalle_Reserva nueva) { Detalle_Reserva dr = contexto.Detalle_Reserva.Find(nueva.id_dr); dr = nueva; return(contexto.SaveChanges()); }
private void botonDisponibilidad_Click(object sender, EventArgs e) { if (!datos_alterados) { showToolTip("Hay disponibilidad ya que no se modificaron los datos.", botonDisponibilidad, botonDisponibilidad.Location); return; } if (chequearDatos()) { nueva_reserva = duplicarReserva(reserva_elegida); nueva_reserva.Fecha_Inicio_struct = dateTimeInicio.Value; nueva_reserva.Fecha_Fin_struct = dateTimeFin.Value; nueva_reserva.tipo_habitacion = tipos_habitacion[comboTipoHab.SelectedIndex]; nueva_reserva.CodigoRegimen = lista_regimenes[comboTipoRegimen.SelectedIndex].CodRegimen; int cantPersonas = Int32.Parse(textCant.Text); //Si se mantiene el tipo de habitacion, entonces solo tenemos que agregar o retirar habitaciones, que no sean las originales if (tipo_elegido.TipoCodigo == nueva_reserva.tipo_habitacion.TipoCodigo) { cantPersonas = cantPersonas - cantPersonas_originales; } List <Habitacion> habitaciones_disponibles; habitaciones_disponibles = DAOReserva.habitacionDisponibles(Globals.infoSesion.Hotel.CodHotel, nueva_reserva.tipo_habitacion.TipoCodigo, nueva_reserva.Fecha_Inicio, nueva_reserva.Fecha_Fin); int cantAreservar = cantPersonas / nueva_reserva.tipo_habitacion.CantPersonas; if (habitaciones_disponibles.Count < cantAreservar) { MessageBox.Show("No existen suficientes habitaciones disponibles para efectuar la reserva.", "", MessageBoxButtons.OK); return; } //Si es que faltan habitaciones (Tanto se mantenga o no el tipo de habitacion) for (int i = 0; i < cantAreservar; i++) { Detalle_Reserva det = new Detalle_Reserva(); det.CodigoHotel = Globals.infoSesion.Hotel.CodHotel; det.CodigoReserva = reserva_elegida.CodigoReserva; det.Habitacion = habitaciones_disponibles[i].Id_Habitacion; nueva_reserva.detalles_reserva.Add(det); } //Si es que sobran habitaciones (Si el tipo de habitacion se cambia, el numero es negativo y no cicla y queda vacio) for (int i = 0; i < -cantAreservar; i++) { Detalle_Reserva det = new Detalle_Reserva(); det.CodigoHotel = Globals.infoSesion.Hotel.CodHotel; det.CodigoReserva = reserva_elegida.CodigoReserva; det.Habitacion = habitaciones_disponibles[i].Id_Habitacion; detallesAremover.Add(det); } textPrecio.Text = Globals.obtenerPrecio(nueva_reserva.CodigoRegimen, cantPersonas + cantPersonas_originales, Globals.infoSesion.Hotel.Recargo).ToString(); //Simamos la cantPersonas_originales para obtener la cantidad total de personas ingresadas y no tener que levantar todo de nuevo MessageBox.Show("Hay disponibilidad para modificar la reserva.", "", MessageBoxButtons.OK); hab_confirmadas = true; } }
public bool CreateDetalleReserva(string id) { XmlSerializer serializador = new XmlSerializer(typeof(Detalle_Reserva)); StringReader lector = new StringReader(id); Detalle_Reserva nuevoUsuario = (Detalle_Reserva)serializador.Deserialize(lector); return(nuevoUsuario.CreateDetalleReserva()); }
public static bool quitarHabitacion(Detalle_Reserva detalle) { int codReserva = detalle.CodigoReserva; int codHotel = detalle.CodigoHotel; int hab = detalle.Habitacion; return(executeProcedure("deleteDetalleReserva", codReserva, codHotel, hab)); }
public static bool agregarHabitacion(Detalle_Reserva detalle) { int codReserva = detalle.CodigoReserva; int codHotel = detalle.CodigoHotel; int habitacion = detalle.Habitacion; return(executeProcedure("insertDetalleReserva", codReserva, codHotel, habitacion)); }
public string ReadDetalleReserva(int fechaSeleccionada) { XmlSerializer serialziador = new XmlSerializer(typeof(Detalle_Reserva)); Detalle_Reserva user = new Detalle_Reserva() { id_d_r = fechaSeleccionada }; StringWriter salida = new StringWriter(); user.ReadDetalleReserva(); serialziador.Serialize(salida, user); return(salida.ToString()); }
public static List <Detalle_Reserva> transductor_detalle(DataTable dt) { List <Detalle_Reserva> lista = new List <Detalle_Reserva>(); if (dt != null) { foreach (DataRow fila in dt.Rows) { Detalle_Reserva detalle = new Detalle_Reserva(); detalle.CodigoReserva = Convert.ToInt32(fila["codReserva"]); detalle.CodigoHotel = Convert.ToInt32(fila["codHotel"]); detalle.Habitacion = Convert.ToInt32(fila["habitacion"]); //Transcribir lista.Add(detalle); } } return(lista); }
public int UsoDeTramoSegunFechayServicio(string fecha, int tramo, int servicio) { Detalle_Reserva aux = new Detalle_Reserva(); return(aux.UsoDeTramoSegunFechayServicio(fecha, tramo, servicio)); }
public bool SP_Crear_Reserva_Residente_Desde_Funcionario(string RUTResidente, string RUT_Funcionario) { Detalle_Reserva aux = new Detalle_Reserva(); return(aux.SP_Crear_Reserva_Residente_Desde_Funcionario(RUTResidente, RUT_Funcionario)); }
public bool SP_Crear_Reserva_Residente(string RUTResidente) { Detalle_Reserva aux = new Detalle_Reserva(); return(aux.SP_Crear_Reserva_Residente(RUTResidente)); }
public bool SP_Crear_Detalle_Reserva(int idServicio, int tramo1, int tramo2, int tramo3, string fechaASeleccionar, string RUTResidente) { Detalle_Reserva aux = new Detalle_Reserva(); return(aux.SP_Crear_Detalle_Reserva(idServicio, tramo1, tramo2, tramo3, fechaASeleccionar, RUTResidente)); }
public int ContarFilas() { Detalle_Reserva aux = new Detalle_Reserva(); return(aux.ContarFilas()); }
protected void btn_reserva_Click(object sender, EventArgs e) { Detalle_ReservaADO adodr = new Detalle_ReservaADO(); ReservaADO ado = new ReservaADO(); Reserva r = new Reserva(); Detalle_Reserva dr = new Detalle_Reserva(); if (HttpContext.Current.Session["id"] == null) { MsgBox("Aún no ha iniciado sesión, no podrá realizar reservas hasta que inicie sesión", this.Page, this); } else if (txtciudad.Text == "" || txtregion.Text == "" || txtdireccion.Text == "" || txttelefono.Text == "") { lb_descr.Text = "Favor no ingresar campos vacíos"; } else { SqlConnection cn = new SqlConnection(CadenaConexion); cn.Open(); var cmd = new SqlCommand("select precio from Producto where nombre = @nombre ", cn); cmd.Parameters.Add("@nombre", SqlDbType.VarChar).Value = dlproducto.SelectedItem.Text; cmd.Connection = cn; int preciof = Convert.ToInt32(cmd.ExecuteScalar()); var cmd2 = new SqlCommand("update producto set stock = stock - 1 where id_producto = @id", cn); cmd2.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(dlproducto.SelectedItem.Value); cmd2.Connection = cn; cmd2.ExecuteNonQuery(); dr.precioFinal = preciof; cn.Close(); dr.id_reserva_d = r.id_reserva; dr.nombreProd = dlproducto.SelectedItem.Text; dr.id_producto_d = Convert.ToInt32(dlproducto.SelectedItem.Value); r.Detalle_Reserva.Add(dr); r.id_usuario = Convert.ToInt32(HttpContext.Current.Session["id"]); r.ciudad = txtciudad.Text.ToUpper(); r.telefono = Convert.ToInt32(txttelefono.Text); r.region = txtregion.Text.ToUpper(); r.direccion = txtdireccion.Text.ToUpper(); r.fecha_reserva = DateTime.Now; r.fecha_requerida = fecha_req.SelectedDate.Date; ado.agregarReserva(r); string cadena = "¡Reserva Realizada!" + "\\nProducto: " + dlproducto.SelectedItem.Text + "\\nCiudad: " + txtciudad.Text + "\\nFecha Requerida: " + fecha_req.SelectedDate + "\\nTelefono: " + txttelefono.Text + "\\nPrecio Final: $" + preciof; txtciudad.Text = ""; txtdireccion.Text = ""; txttelefono.Text = ""; txtregion.Text = ""; MsgBox(cadena, this.Page, this); BindData(); } }
public string SP_Pagar_Reservas_Tarjetas(string RUTResidente) { Detalle_Reserva aux = new Detalle_Reserva(); return(aux.SP_Pagar_Reservas_Tarjetas(RUTResidente)); }
public int agregarDetalleReserva(Detalle_Reserva nueva) { contexto.Detalle_Reserva.Add(nueva); return(contexto.SaveChanges()); }