コード例 #1
0
 protected void btnSeleccionarhot_Click(object sender, EventArgs e)
 {
     try
     {
         EstadoInicial();
         if (GVHoteles.SelectedIndex != -1)
         {
             int               indice   = GVHoteles.SelectedIndex;
             Hotel             hotel    = LogicaHoteles.Buscar(GVHoteles.Rows[GVHoteles.SelectedIndex].Cells[1].Text);
             List <Habitacion> ListaHab = LogicaHabitaciones.ListarHabitaciones(hotel);
             GVHabitaciones.DataBind();
             if (ListaHab.Count > 0)
             {
                 GVHabitaciones.DataSource = ListaHab;
                 GVHabitaciones.DataBind();
                 btnSeleccionarHab.Enabled = true;
             }
             else
             {
                 GVHabitaciones.DataSource = null;
                 GVHabitaciones.DataBind();
                 btnSeleccionarHab.Enabled = false;
                 lblMensaje.Text           = "El hotel no tiene habitaciones";
             }
         }
         else
         {
             lblMensaje.Text = "Seleccione un hotel primero.";
         }
     }
     catch (Exception ex)
     { lblMensaje.Text = ex.Message; }
 }
コード例 #2
0
    protected void btnBuscar_Click(object sender, EventArgs e)
    {
        try
        {
            Hotel hot = LogicaHoteles.Buscar(txtHotel.Text);
            if (hot == null)
            {
                throw new Exception("El hotel no existe en la base de datos");
            }

            Habitacion hab = LogicaHabitaciones.Buscar(hot, Convert.ToInt32(txtHabitacion.Text));

            if (hab == null)
            {
                lblMensaje.Text = ("No se ha encontrado una habitacion con esos datos.");
                HabilitarA();
            }
            else
            {
                HabilitarME();
                txtPiso.Text        = hab.Piso.ToString();
                txtHuespedes.Text   = hab.CantHuespedes.ToString();
                txtCostoDiario.Text = hab.CostoDiario.ToString();
                txtDescripcion.Text = hab.Descripcion;
            }
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }
コード例 #3
0
    protected void btnEliminar_Click(object sender, EventArgs e)
    {
        try
        {
            string hotel         = txtHotel.Text;
            int    nroHabitacion = Convert.ToInt32(txtHabitacion.Text.Trim());

            Hotel hot = LogicaHoteles.Buscar(hotel);
            if (hot == null)
            {
                throw new Exception("El hotel no existe.");
            }

            Habitacion hab = LogicaHabitaciones.Buscar(hot, nroHabitacion);
            if (hab == null)
            {
                throw new Exception("La habitacion no existe.");
            }

            LogicaHabitaciones.Eliminar(hab);
            EstadoInicial();
            lblMensaje.Text = ("Se ha eliminado correctamente la habitacion: " + hab.NroHabitacion + "Con de el hotel: " + hab.Hotel.NombreHotel);
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }
コード例 #4
0
    protected void btnAgregar_Click(object sender, EventArgs e)
    {
        try
        {
            string hotel = txtHotel.Text;

            int nroHabitacion = Convert.ToInt32(txtHabitacion.Text.Trim());

            int piso = Convert.ToInt32(txtPiso.Text.Trim());

            int huespedes = Convert.ToInt32(txtHuespedes.Text.Trim());

            int costoDiario = Convert.ToInt32(txtCostoDiario.Text.Trim());

            string descripcion = txtDescripcion.Text;

            Hotel hot = LogicaHoteles.Buscar(hotel);

            if (hot == null)
            {
                throw new Exception("El hotel no existe.");
            }

            Habitacion hab = new Habitacion(hot, Convert.ToInt32(txtHabitacion.Text), Convert.ToInt32(txtPiso.Text), Convert.ToInt32(txtHuespedes.Text), Convert.ToInt32(txtCostoDiario.Text), txtDescripcion.Text);
            LogicaHabitaciones.Agregar(hab);
            EstadoInicial();
            lblMensaje.Text = ("Se ha agregado correctamente la habitacion " + nroHabitacion) + "En el hotel: " + hotel;
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }
コード例 #5
0
 protected void btnBuscar_Click(object sender, EventArgs e)
 {
     try
     {
         Hotel hot = LogicaHoteles.Buscar(txtHotel.Text);
         if (hot == null)
         {
             lblMensaje.Text = ("No se ha encontrado un hotel con esos datos.");
             HabilitarA();
         }
         else
         {
             HabilitarME();
             txtCalle.Text     = hot.Calle.ToString();
             txtCiudad.Text    = hot.Ciudad;
             txtFax.Text       = hot.Fax.ToString();
             txtNroPuerta.Text = hot.NroPuerta.ToString();
             txtTelefono.Text  = hot.Telefono.ToString();
             RBEstrellas.Text  = hot.Estrellas.ToString();
             RBPiscina.Checked = hot.Piscina;
             RBPlaya.Checked   = hot.AccesoPlaya;
             img.ImageUrl      = hot.Foto.ToString();
         }
     }
     catch (Exception ex)
     { lblMensaje.Text = ex.Message; }
 }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            switch (Convert.ToInt32(cboCategorias.SelectedValue))
            {
            case 1:
                List <Hotel> ListaHoteles1 = LogicaHoteles.ListarHoteles(1);
                GVHoteles.DataSource = ListaHoteles1;
                GVHoteles.DataBind();
                break;

            case 2:
                List <Hotel> ListaHoteles2 = LogicaHoteles.ListarHoteles(2);
                GVHoteles.DataSource = ListaHoteles2;
                GVHoteles.DataBind();
                break;

            case 3:
                List <Hotel> ListaHoteles3 = LogicaHoteles.ListarHoteles(3);
                GVHoteles.DataSource = ListaHoteles3;
                GVHoteles.DataBind();
                break;

            case 4:
                List <Hotel> ListaHoteles4 = LogicaHoteles.ListarHoteles(4);
                GVHoteles.DataSource = ListaHoteles4;
                GVHoteles.DataBind();
                break;

            case 5:
                List <Hotel> ListaHoteles5 = LogicaHoteles.ListarHoteles(5);
                GVHoteles.DataSource = ListaHoteles5;
                GVHoteles.DataBind();
                break;
            }
            if (!IsPostBack)
            {
                EstadoInicial();
                btnSeleccionarHab.Enabled = false;
            }
            if (((List <Hotel>)GVHoteles.DataSource).Count == 0)
            {
                btnSeleccionarHab.Enabled = false;
                btnSeleccionarhot.Enabled = false;
                GVHabitaciones.DataSource = null;
                GVHabitaciones.DataBind();
                EstadoInicial();
            }
            else
            {
                btnSeleccionarhot.Enabled = true;
            }
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }
コード例 #7
0
    protected void btnModificar_Click(object sender, EventArgs e)
    {
        try
        {
            string imagen = "";
            if (fileimageFoto.HasFile)
            {
                //Guardo la ruta relativa
                imagen = "~/Images/" + fileimageFoto.FileName;

                //Para almacenar necesito la ruta ABSOLUTA
                fileimageFoto.SaveAs(Server.MapPath(imagen));


                //Después de guardar, puedo mostrar
                img.ImageUrl = imagen;
            }
            else
            {
                imagen = img.ImageUrl;
            }


            string hotel = txtHotel.Text;

            string calle = txtCalle.Text;

            int puerta = Convert.ToInt32(txtNroPuerta.Text.Trim());

            string ciudad = txtCiudad.Text;

            int telefono = Convert.ToInt32(txtTelefono.Text);

            int fax = Convert.ToInt32(txtFax.Text);

            bool playa = RBPlaya.Checked;

            bool piscina = RBPiscina.Checked;

            int estrellas = Convert.ToInt32(RBEstrellas.SelectedValue);

            Hotel hot = new Hotel(hotel, calle, puerta, ciudad, telefono, fax, playa, piscina, estrellas, imagen);

            LogicaHoteles.Modificar(hot);
            EstadoInicial();
            lblMensaje.Text = "Se modifico correctamente el hotel " + hotel + ".";
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }
コード例 #8
0
 protected void btnSeleccionarHab_Click(object sender, EventArgs e)
 {
     try
     {
         if (GVHabitaciones.SelectedIndex != -1)
         {
             Hotel      hot = LogicaHoteles.Buscar(GVHoteles.Rows[GVHoteles.SelectedIndex].Cells[1].Text);
             Habitacion hab = LogicaHabitaciones.Buscar(hot, Convert.ToInt32(GVHabitaciones.Rows[GVHabitaciones.SelectedIndex].Cells[1].Text));
             lblHabitacion.Text       = "Seleccion: " + hab.ToString();
             btnCalcularCosto.Enabled = true;
             btnReservar.Enabled      = false;
         }
         lblMensaje.Text = "Seleccione una habitacion primero.";
     }
     catch (Exception ex)
     { lblMensaje.Text = ex.Message; }
 }
コード例 #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            lblMensaje.Text = "";
            if (!IsPostBack)
            {
                Session["ListaHoteles"] = LogicaHoteles.ListarHoteles();
                if (((List <Hotel>)Session["ListaHoteles"]).Count != 0)
                {
                    cboHoteles.DataSource     = (List <Hotel>)Session["ListaHoteles"];
                    cboHoteles.DataTextField  = "NombreHotel";
                    cboHoteles.DataValueField = "NombreHotel";
                    cboHoteles.DataBind();
                }
                else
                {
                    lblMensaje.Text = "No hay hoteles en la base de datos.";
                }
            }

            //Muestro las Habitaciones para el Hotel Seleccionado.
            if (((List <Hotel>)Session["ListaHoteles"]).Count != 0)
            {
                Session["ListaHabitaciones"] = LogicaHabitaciones.ListarHabitaciones(LogicaHoteles.Buscar(cboHoteles.SelectedValue));
                if (((List <Habitacion>)Session["ListaHabitaciones"]).Count != 0)
                {
                    GVCompleto.DataSource = (List <Habitacion>)Session["ListaHabitaciones"];
                    GVCompleto.DataBind();
                    btnSeleccionar.Enabled = true;
                }
                else
                {
                    lblMensaje.Text       = "No hay habitaciones en este hotel.";
                    GVCompleto.DataSource = null;
                    GVCompleto.DataBind();
                    Session["ListaHabitaciones"] = null;
                    GVSeleccion.DataSource       = null;
                    GVSeleccion.DataBind();
                    btnSeleccionar.Enabled = false;
                }
            }
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }
コード例 #10
0
 protected void btnReservar_Click(object sender, EventArgs e)
 {
     try
     {
         Hotel      hot = LogicaHoteles.Buscar(GVHoteles.Rows[GVHoteles.SelectedIndex].Cells[1].Text);
         Habitacion hab = LogicaHabitaciones.Buscar(hot, Convert.ToInt32(GVHabitaciones.Rows[GVHabitaciones.SelectedIndex].Cells[1].Text));
         Reserva    r   = new Reserva(hab, (Cliente)Session["usuario"], cldFechaInicio.SelectedDate, cldFechaFin.SelectedDate, "Activa", 1);
         LogicaReservas.RealizarRes(r);
         EstadoInicial();
         lblMensaje.Text      = "Se ha realizado la reseva con exito";
         GVHoteles.DataSource = null;
         GVHoteles.DataBind();
         GVHabitaciones.DataSource = null;
         GVHabitaciones.DataBind();
     }
     catch (Exception ex)
     { lblMensaje.Text = ex.Message; }
 }
コード例 #11
0
 protected void btnCalcularCosto_Click(object sender, EventArgs e)
 {
     try
     {
         lblCostoTotal.Text = "";
         lblMensaje.Text    = "";
         int dias = Convert.ToInt32((cldFechaFin.SelectedDate - cldFechaInicio.SelectedDate).TotalDays);
         if (GVHoteles.SelectedIndex != -1 && GVHabitaciones.SelectedIndex != -1)
         {
             Hotel      hot = LogicaHoteles.Buscar(GVHoteles.Rows[GVHoteles.SelectedIndex].Cells[1].Text);
             Habitacion hab = LogicaHabitaciones.Buscar(hot, Convert.ToInt32(GVHabitaciones.Rows[GVHabitaciones.SelectedIndex].Cells[1].Text));
             Reserva    r   = new Reserva(hab, (Cliente)Session["usuario"], cldFechaInicio.SelectedDate, cldFechaFin.SelectedDate, "Activa", -1);
             lblCostoTotal.Text  = "$" + (hab.CostoDiario * dias).ToString();
             btnReservar.Enabled = true;
         }
     }
     catch (Exception ex)
     { lblMensaje.Text = ex.Message; }
 }
コード例 #12
0
    protected void btnEliminar_Click(object sender, EventArgs e)
    {
        try
        {
            string hotel = txtHotel.Text;

            Hotel hot = LogicaHoteles.Buscar(hotel);
            if (hot == null)
            {
                throw new Exception("El hotel no existe.");
            }

            LogicaHoteles.Eliminar(hot);
            EstadoInicial();
            lblMensaje.Text = ("Se ha eliminado correctamente el hotel: " + hot.NombreHotel);
        }
        catch (Exception ex)
        { lblMensaje.Text = ex.Message; }
    }