Ejemplo n.º 1
0
        private void mostrarNodosHab(TreeNode nodoHab)
        {
            //nodos para Habitaciones
            TreeNode nodoTitulo = new TreeNode();

            nodoTitulo.Text  = "HABITACIONES";
            nodoTitulo.Value = nodoHab.Value;

            nodoHab.ChildNodes.Add(nodoTitulo);

            DataSet dts = new DataSet();
            int     i   = 0;

            dts = getdtsHab("nodos", Convert.ToInt32(nodoHab.Value));
            for (i = 1; i <= dts.Tables[0].Rows.Count; i++)
            {
                string idHabitacion = dts.Tables[0].Rows[i - 1]["idHab"].ToString();

                Habitacion oRegistro = new Habitacion();
                oRegistro = (Habitacion)oRegistro.Get(typeof(Habitacion), int.Parse(idHabitacion));
                int cantCamasHab = oRegistro.getCantidadCamas();

                TreeNode nodo = new TreeNode();
                nodo.Text  = "Habitación: " + dts.Tables[0].Rows[i - 1]["nombre"].ToString() + " - Camas: " + cantCamasHab.ToString();
                nodo.Value = idHabitacion;

                nodo.NavigateUrl = "Catastro.aspx?tipo=Habitacion&idHabitacion=" + nodo.Value;
                //   nodo.Expand(); ///nodo que expande las camas
                ///
                nodoTitulo.ChildNodes.Add(nodo);
                nodoTitulo.Expand();

                mostrarNodosCama(nodo);
            }
            TreeNode nodoAgregar = new TreeNode();

            nodoAgregar.Text        = "<b>Agregar Habitacion</b>";
            nodoAgregar.Value       = "-1";
            nodoAgregar.ImageUrl    = "../app_themes/default/images/add.png";
            nodoAgregar.NavigateUrl = "Catastro.aspx?tipo=Habitacion&idPiso=" + nodoHab.Value;

            nodoHab.ChildNodes.Add(nodoAgregar);
            nodoHab.Expand();
        }
Ejemplo n.º 2
0
        protected void btnEliminarHab_Click(object sender, EventArgs e)
        {
            Habitacion oRegistro = new Habitacion();

            oRegistro = (Habitacion)oRegistro.Get(typeof(Habitacion), int.Parse(Request["idHabitacion"].ToString()));

            if (oRegistro.getCantidadCamas() == 0)
            {
                oRegistro.Baja = true;
                oRegistro.Save();
                CargarArbol();
                string popupScript = "<script language='JavaScript'> alert('Se ha eliminado la habitacion')</script>";
                ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript", popupScript);
            }
            else
            {
                string popupScript = "<script language='JavaScript'> alert('No es posible eliminar la habitación. Tiene camas asociadas.')</script>";
                ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript", popupScript);
            }
        }