protected void btnCargarCat_Click(object sender, EventArgs e)

    {
        try
        {
            btnReservar.Enabled = false;
            btnCalcular.Enabled = false;
            if (lstCategoria.SelectedIndex != 0)
            {
                pnlHabitacion.Visible   = false;
                lblHabitaciones.Visible = false;
                ddlHabitaciones.Visible = false;
                gvReserva.SelectedIndex = -1;
                gvReserva.DataSource    = LogicaHotel.ListaCat(Convert.ToInt32(lstCategoria.Text));
                gvReserva.DataBind();
                lblHot.Visible = true;
                lblHot.Text    = "Hoteles:";
            }
            else
            {
                gvReserva.Visible       = false;
                pnlHabitacion.Visible   = false;
                ddlHabitaciones.Visible = false;
            }
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
    /** MODIFICAR */
    protected void btnModificarH_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (Control txtBox in listOfCtrls())
            {
                if (txtBox is TextBox && String.IsNullOrEmpty(((TextBox)txtBox).Text))
                {
                    throw new Exception("Existen campos vacíos");
                }
            }
            string rutaImg = txtFotoH.FileName != "" ? "imagenes/hoteles/" + txtFotoH.FileName : imgFotoH.ImageUrl;

            Session["hotel"] = new Hotel(txtHotel.Text, txtCalleH.Text, Convert.ToInt32(txtNumeroH.Text), txtCuidadH.Text,
                                         Convert.ToInt32(txtCategoriaH.Text), txtTelH.Text, txtFaxH.Text, rutaImg,
                                         chkPlayaH.Checked, chkPiscinaH.Checked);

            LogicaHotel.Modificar(((Hotel)Session["hotel"]));

            if (txtFotoH.FileName != "")
            {
                txtFotoH.SaveAs(Server.MapPath(rutaImg));
            }

            lblMsj.Text = "Hotel modificado correctamente";
            limpiarFomulario();
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 3
0
    /** BOTONES ABM HOTEL */
    /** AGREGAR */
    protected void btnAgregarH_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (Control txtBox in listOfTxtBox())
            {
                if (String.IsNullOrEmpty(((TextBox)txtBox).Text))
                {
                    throw new Exception("Existen campos vacíos");
                }
            }

            string rutaImg = "~/imagenes/hoteles/" + txtFotoH.FileName;

            Hotel hotel = new Hotel(txtHotel.Text, txtCalleH.Text, Convert.ToInt32(txtNumeroH.Text), txtCuidadH.Text,
                                    Convert.ToInt32(txtCategoriaH.Text), txtTelH.Text, txtFaxH.Text, rutaImg,
                                    chkPlayaH.Checked, chkPiscinaH.Checked);

            LogicaHotel.Agregar(hotel);
            txtFotoH.SaveAs(Server.MapPath(rutaImg));
            lblMsj.Text = "Hotel agregado correctamente";
            // TO DO limpiar campos
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 4
0
    /** BUSCAR HOTEL */
    protected void btnBuscarH_Click(object sender, EventArgs e)
    {
        try
        {
            if (String.IsNullOrEmpty(txtBuscarH.Text))
            {
                throw new Exception("El campo de busqueda se encuetra vacío");
            }

            Hotel hotel = LogicaHotel.Buscar(txtBuscarH.Text);

            txtHotel.Text       = hotel.Nombre;
            txtCategoriaH.Text  = hotel.Categoria.ToString();
            txtCalleH.Text      = hotel.Calle;
            txtNumeroH.Text     = hotel.Numero.ToString();
            txtCuidadH.Text     = hotel.Ciudad;
            txtTelH.Text        = hotel.Telefono;
            txtFaxH.Text        = hotel.Fax;
            chkPlayaH.Checked   = hotel.Playa;
            chkPiscinaH.Checked = hotel.Piscina;

            imgFotoH.ImageUrl = hotel.UrlFoto;

            lblMsj.Text = String.Empty;
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 5
0
    protected void gvResActivas_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            Reserva res = null;
            pnlDatosRes.Visible = true;
            int num = Convert.ToInt32(gvResActivas.SelectedRow.Cells[1].Text);
            res = LogicaReserva.Buscar(num);
            Session["reservaActiva"] = res;

            Hotel hot = LogicaHotel.Buscar(res.Hab.Hotel.Nombre);

            txtNum.Text      = res.Numero.ToString();
            txtEstado.Text   = res.EstadoRes;
            txtFechaIn.Text  = res.FechaIni.ToString();
            txtFechaFin.Text = res.FechaFin.ToString();
            txtCli.Text      = res.Cli.Nombre;
            txtNumHab.Text   = res.Hab.Numero.ToString();
            txtNomHot.Text   = res.Hab.Hotel.Nombre;
            tbDesc.InnerHtml = res.Hab.Descripcion;
            txtCantidad.Text = res.Hab.CantHuesped.ToString();
            txtCosto.Text    = res.Hab.Costo.ToString();
            txtPiso.Text     = res.Hab.Piso.ToString();
            txtNomHot2.Text  = hot.Nombre;
            txtCalle.Text    = hot.Calle;
            txtNum2.Text     = hot.Numero.ToString();
            txtCiudad.Text   = hot.Ciudad;
            txtCat.Text      = hot.Categoria.ToString();
            txtTel.Text      = hot.Telefono;
            txtFax.Text      = hot.Fax;

            if (hot.Piscina == true)
            {
                chkPiscina.Checked = true;
            }
            else
            {
                chkPiscina.Checked = false;
            }

            if (hot.Playa == true)
            {
                chkPlaya.Checked = true;
            }
            else
            {
                chkPlaya.Checked = false;
            }

            imgFtoHotel.ImageUrl = hot.UrlFoto;
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
    /** ELIMINAR */
    protected void btnEliminarH_Click(object sender, EventArgs e)
    {
        try
        {
            LogicaHotel.Eliminar((Hotel)Session["hotel"]);

            lblMsj.Text = "Hotel eliminado correctamente con sus dependecias";

            limpiarFomulario();
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         lblMsj.Text = "";
         if (!IsPostBack)
         {
             foreach (Hotel h in LogicaHotel.ListaHoteles())
             {
                 lstHoteles.Items.Add(h.Nombre);
             }
         }
     }
     catch (Exception ex)
     { lblMsj.Text = ex.Message; }
 }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            btnHab.Enabled          = false;
            gvHabActivas.DataSource = LogicaHabitacion.ConReservasActivas();
            gvHabActivas.DataBind();

            foreach (Hotel h in LogicaHotel.ListaHoteles())
            {
                lstHoteles.Items.Add(h.Nombre);
            }
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         List <Hotel> lista = LogicaHotel.Listado();
         if (lista.Count > 0)
         {
             ddlHotel.DataSource     = lista;
             ddlHotel.DataTextField  = "Nombre";
             ddlHotel.DataValueField = "Rut";
             ddlHotel.DataBind();
         }
         else
         {
             lblError.Text = "No hay hoteles. ";
         }
     }
 }
Exemplo n.º 10
0
    protected void btnModificarHab_Click(object sender, EventArgs e)
    {
        try
        {
            lblMsj.Text = String.Empty;
            foreach (Control campo in listaRequeridos())
            {
                if (campo is DropDownList)
                {
                    if (((DropDownList)campo).SelectedIndex == -1)
                    {
                        throw new Exception("Existen campos sin completar");
                    }
                }
                if (campo is TextBox)
                {
                    string box = ((TextBox)campo).Text;
                    if (String.IsNullOrEmpty(box))
                    {
                        throw new Exception("Existen campos sin completar");
                    }
                }
            }

            ((Habitacion)Session["habitacion"]).Numero      = Convert.ToInt32(txtNumeroHab.Text);
            ((Habitacion)Session["habitacion"]).Hotel       = LogicaHotel.Buscar((string)lstHoteles.Text);
            ((Habitacion)Session["habitacion"]).Descripcion = (string)txtDescripcionHab.Text;
            ((Habitacion)Session["habitacion"]).CantHuesped = Convert.ToInt32(txtHuespedHab.Text);
            ((Habitacion)Session["habitacion"]).Costo       = Convert.ToDecimal(txtCosto.Text);
            ((Habitacion)Session["habitacion"]).Piso        = Convert.ToInt32(txtPisoHab.Text);

            LogicaHabitacion.Modificar(((Habitacion)Session["habitacion"]));
            lblMsj.Text = "Se modificó correctamente";
            LimpiarFormulario();
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 11
0
    protected void btnAgregarHab_Click(object sender, EventArgs e)
    {
        try
        {
            lblMsj.Text = String.Empty;
            foreach (Control campo in listaRequeridos())
            {
                if (campo is DropDownList)
                {
                    if (((DropDownList)campo).SelectedIndex == -1)
                    {
                        throw new Exception("Existen campos sin completar");
                    }
                }
                if (campo is TextBox)
                {
                    if (String.IsNullOrEmpty(((TextBox)campo).Text))
                    {
                        throw new Exception("Existen campos sin completar");
                    }
                }
            }

            Session["habitacion"] = new Habitacion(
                Convert.ToInt32(txtNumeroHab.Text.Trim()),
                LogicaHotel.Buscar(lstHoteles.Text.Trim()),
                txtDescripcionHab.Text.Trim(),
                Convert.ToInt32(txtHuespedHab.Text.Trim()),
                Convert.ToDecimal(txtCosto.Text.Trim()),
                Convert.ToInt32(txtPisoHab.Text.Trim()));

            LogicaHabitacion.Agregar((Habitacion)Session["habitacion"]);
            lblMsj.Text = "Se agrego correctamente";
            LimpiarFormulario();
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                foreach (Hotel h in LogicaHotel.ListaHoteles())
                {
                    lstHoteles.Items.Add(h.Nombre);
                }

                foreach (Control item in listaRequeridos())
                {
                    if (item is TextBox && item.ID != "txtNumeroHab")
                    {
                        ((TextBox)item).Enabled = false;
                    }
                }
            }
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
    /** BUSCAR HOTEL */
    protected void btnBuscarH_Click(object sender, EventArgs e)
    {
        try
        {
            if (String.IsNullOrEmpty(txtBuscarH.Text))
            {
                throw new Exception("El campo de busqueda se encuetra vacío");
            }

            Session["hotel"] = LogicaHotel.Buscar(txtBuscarH.Text.Trim());

            if ((Hotel)Session["hotel"] != null)
            {
                foreach (Control item in listOfCtrls())
                {
                    if (item is TextBox && item.ID != "txtHotel")
                    {
                        ((TextBox)item).Enabled = true;
                    }
                }
                btnModificarH.Enabled = true;
                btnEliminarH.Enabled  = true;
                imgFotoH.Visible      = true;
                txtFotoH.Enabled      = true;
                chkPiscinaH.Enabled   = true;
                chkPlayaH.Enabled     = true;

                txtHotel.Text       = ((Hotel)Session["hotel"]).Nombre;
                txtCategoriaH.Text  = ((Hotel)Session["hotel"]).Categoria.ToString();
                txtCalleH.Text      = ((Hotel)Session["hotel"]).Calle;
                txtNumeroH.Text     = ((Hotel)Session["hotel"]).Numero.ToString();
                txtCuidadH.Text     = ((Hotel)Session["hotel"]).Ciudad;
                txtTelH.Text        = ((Hotel)Session["hotel"]).Telefono;
                txtFaxH.Text        = ((Hotel)Session["hotel"]).Fax;
                chkPlayaH.Checked   = ((Hotel)Session["hotel"]).Playa;
                chkPiscinaH.Checked = ((Hotel)Session["hotel"]).Piscina;
                imgFotoH.ImageUrl   = ((Hotel)Session["hotel"]).UrlFoto;
            }
            else
            {
                foreach (Control item in listOfCtrls())
                {
                    if (item is TextBox)
                    {
                        ((TextBox)item).Text    = String.Empty;
                        ((TextBox)item).Enabled = true;
                    }
                    if (item is Button && item.ID != "btnAgregarH")
                    {
                        ((Button)item).Enabled = false;
                    }
                }

                imgFotoH.Visible    = false;
                imgFotoH.ImageUrl   = String.Empty;
                txtFotoH.Enabled    = true;
                chkPiscinaH.Checked = true;
                chkPlayaH.Checked   = true;
                btnAgregarH.Enabled = true;
            }
            lblMsj.Text = String.Empty;
        }
        catch (Exception ex)
        { lblMsj.Text = ex.Message; }
    }
Exemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     gdvListadoHoteles.DataSource = LogicaHotel.Listado();
     gdvListadoHoteles.DataBind();
 }