protected void Page_Load(object sender, EventArgs e)
 {
     if (Application["arbolusuarios"] == null)
     {
         Application["arbolusuarios"] = new binario();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     if (Application["arbolusuarios"] != null)
     {
         graficador = new graficarusuarios();
         binario bin        = (binario)Application["arbolusuarios"];
         binario espejo     = bin.espejo();
         String  rutaimagen = graficador.graficar(espejo);
         arbol.ImageUrl = "/grafos/usuarios.dot.jpg";
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     //cerrar sesión al cargar la página
     logout();
     if (Application["arbolusuarios"] == null)
     {
         binario arbolusuarios = new binario();
         Application["arbolusuarios"] = arbolusuarios;
     }
     wslogin = new mainlogin();
     //Application["arbolusuarios"] = wslogin.prueba();
 }
示例#4
0
        protected void agregaruser(object sender, EventArgs e)
        {
            if (Application["arbolusuarios"] == null)
            {
                Application["arbolusuarios"] = new binario();
            }
            String  nick     = tbidnuevo.Text;
            String  pass     = tbpassnuevo.Text;
            String  email    = tbemail.Text;
            binario usertree = (binario)Application["arbolusuarios"];

            Application["arbolusuarios"] = userupdate.insertar(usertree, nick, email, 0, pass);//realizar la inserción en el arbol
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            binario usuarios = (binario)Application["arbolusuarios"];

            if (usuarios != null)
            {//insertar usuarios en el diccionario
                hasht diccionario = new hasht(usuarios);
                //generar grafo
                diccionario.graficar();
                tablahash.ImageUrl  = "/grafos/hash.dot.jpg";
                labelocupacion.Text = "Porcentaje de ocupación: " + diccionario.ocupacion.ToString();
                labelsize.Text      = "Tamaño de la tabla: " + diccionario.listado.Length.ToString();
            }
        }
        protected void login(object sender, EventArgs e)
        {
            String id_   = tbnombreuser.Text;
            String pass_ = tbpassuser.Text;
            bool   login = wslogin.Userlogin(id_, pass_);

            if (login == true)
            {
                binario usuarios = (binario)Application["arbolusuarios"];
                usuario user     = usuarios.buscar(id_, usuarios.raiz);
                Session["user"] = user;                                //almacenar variable de sesion
                Response.Redirect("~/master/userlogged/userini.aspx"); //cargar pagina de inicio
            }
        }
示例#7
0
 protected void eliminar(object sender, EventArgs e)
 {
     if (Application["arbolusuarios"] != null)
     {
         String  nick   = tbnewname.Text;
         usuario actual = (usuario)Application["actual"];
         if (actual != null)
         {
             binario bin = (binario)Application["arbolusuarios"];
             bin = userupdate.eliminar(bin, nick);
             Application["actual"]        = null;
             Application["arbolusuarios"] = bin;
         }
     }
 }
        protected void graficar(object sender, EventArgs e)
        {
            String  user = ddlusuarios.SelectedValue;
            binario bin  = (binario)Application["arbolusuarios"];

            if (bin != null)
            {
                usuario jugador = bin.buscar(user, bin.raiz);
                if (jugador != null)
                {
                    String ruta = graficador.graficar(jugador.contactos);
                    grafo.ImageUrl = "/grafos/contactos.dot.jpg";
                }
            }
        }
示例#9
0
 protected void actualizar(object sender, EventArgs e)
 {
     if (Application["arbolusuarios"] != null)
     {
         String  nuevonombre = tbnewname.Text;
         String  nuevopass   = tbnewpass.Text;
         String  nuevoemail  = tbemail.Text;
         usuario actual      = (usuario)Application["actual"];
         if (actual != null)
         {
             binario bin = (binario)Application["arbolusuarios"];
             bin = userupdate.actualizar(actual, nuevonombre, nuevopass, nuevoemail, 0, bin);
             Application["actual"]        = bin.buscar(nuevonombre, bin.raiz);
             Application["arbolusuarios"] = bin;
         }
     }
 }
示例#10
0
 protected void cargarlistajuegos(object sender, EventArgs e)
 {
     if (listajuegosup.HasFile)
     {
         String ruta = HttpContext.Current.Server.MapPath("~/cargas/") + listajuegosup.FileName; //obtener nombre de ruta
         listajuegosup.SaveAs(ruta);
         String entrada = File.ReadAllText(ruta);                                                //leer texto
         //obtener cada línea del texto
         String[] lineas = entrada.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
         //separa por comas
         //cargar informacion de contactos
         binario bin = (binario)Application["arbolusuarios"];
         if (bin != null)
         {
             for (int i = 1; i < lineas.Length; i++)
             {
                 String[] contenido = lineas[i].Split(',');
                 //ingresar el contenido
                 try
                 {
                     bin.insertarjuego(contenido[0].ToString(), contenido[1].ToString(), Int32.Parse(contenido[2].ToString()), Int32.Parse(contenido[3].ToString()), Int32.Parse(contenido[4].ToString()), Int32.Parse(contenido[5].ToString()));
                 }
                 catch (IndexOutOfRangeException ex) { String outex = ex.ToString(); }
             }
             Application["arbolusuarios"] = bin;
         }
         //cargar lista de juegos de la aplicacion
         listajuegos juegos = (listajuegos)Application["juegos"];
         if (juegos == null)
         {
             juegos = new listajuegos();
         }
         for (int i = 1; i < lineas.Length; i++)
         {
             String[] contenido = lineas[i].Split(',');
             //ingresar el contenido
             try
             {
                 juegos.insertar(contenido[0].ToString(), contenido[1].ToString(), Int32.Parse(contenido[2].ToString()), Int32.Parse(contenido[3].ToString()), Int32.Parse(contenido[4].ToString()), Int32.Parse(contenido[5].ToString()));
             }
             catch (IndexOutOfRangeException ex) { String outex = ex.ToString(); }
         }
         Application["juegos"] = juegos;//almacenar lista de juegos
     }
 }
        protected void cargarcontactos(object sender, EventArgs e)
        {
            if (contactosup.HasFile)
            {
                String ruta = HttpContext.Current.Server.MapPath("~/cargas/") + contactosup.FileName; //obtener nombre de ruta
                contactosup.SaveAs(ruta);
                String entrada = File.ReadAllText(ruta);                                              //leer texto
                //obtener cada línea del texto
                String[] lineas = entrada.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                binario  bin    = (binario)Application["arbolusuarios"];//obtener el arbol de usuarios
                if (bin == null)
                {
                    bin = new binario();
                }
                //separa por comas
                for (int i = 1; i < lineas.Length; i++)
                {
                    String[] contenido = lineas[i].Split(',');
                    //ingresar el contenido
                    try
                    {
                        String user     = contenido[0].ToString();
                        String contacto = contenido[1].ToString();
                        String pass     = contenido[2].ToString();
                        String email    = contenido[3].ToString();

                        usuario userpadre = bin.buscar(user, bin.raiz);
                        if (userpadre.contactos == null)
                        {
                            userpadre.contactos = new avl();
                        }
                        usuario nuevocontacto = bin.buscar(contacto, bin.raiz);
                        //si el nuevo contacto no existe, insertar el contacto en el arbol
                        if (nuevocontacto == null)
                        {
                            nuevocontacto = bin.insertar(contacto, pass, email, 0, bin.raiz);
                        }
                        userpadre.insertarcontacto(nuevocontacto);
                    }
                    catch (IndexOutOfRangeException ex) { String outex = ex.ToString(); }
                }
                Application["arbolusuarios"] = bin;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            if (Application["arbolusuarios"] != null)
            {
                graficador = new graficarusuarios();
                binario bin        = (binario)Application["arbolusuarios"];
                String  rutaimagen = graficador.graficar(bin);
                arbol.ImageUrl = "/grafos/usuarios.dot.jpg";
                int altura  = bin.altura(bin.raiz);
                int niveles = altura - 1;
                int hojas   = bin.hojas(0, bin.raiz);
                int ramas   = bin.ramas(0, bin.raiz);

                labelaltura.Text  = altura.ToString();
                labelniveles.Text = niveles.ToString();
                labelhojas.Text   = hojas.ToString();
                labelramas.Text   = ramas.ToString();
            }
        }
        protected void crearjuego(object sender, EventArgs e)
        {
            binario usuarios = (binario)Application["arbolusuarios"];

            if (usuarios != null)
            {
                String nick1 = tbjugador1.Text;
                String nick2 = tbjugador2.Text;
                //buscar usuarios
                usuario user1 = usuarios.buscar(nick1, usuarios.raiz);
                usuario user2 = usuarios.buscar(nick2, usuarios.raiz);
                //validar usuarios
                if (user1 != null)
                {
                    if (user2 != null)
                    {
                        int    x        = Int32.Parse(tbx.Text);
                        int    y        = Int32.Parse(tby.Text);
                        int    variante = Int32.Parse(ddlvariante.SelectedValue);
                        String tiempo   = tbtiempo.Text;
                        mo     tablero  = new mo(x, y, variante, tiempo);
                        tablero.user1          = user1.getnick();
                        tablero.user2          = user2.getnick();
                        Application["tablero"] = tablero;//almacenar el juego actual
                        labelmensaje.Text      = "La partida ha sido creada";
                    }
                    else
                    {
                        labelmensaje.Text = "No se encontró el segundo jugador";
                    }
                }
                else
                {
                    labelmensaje.Text = "No se encontró el primer jugador";
                }
            }
            else
            {
                labelmensaje.Text = "No hay usuarios en el sistema";
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     //mainlogin = new mainlogin();
     //mainlogin.pruebauser();//cargar arbol de jugadores
     graficador = new graficaravl();
     //obtener arbol de contactos
     if (!IsPostBack)//llenar la lista de usuarios una vez
     {
         binario bin = (binario)Application["arbolusuarios"];
         if (bin != null)
         {//cargar lista de contactos
             inorder     usuarios = new inorder(bin);
             nodoinorder temp     = usuarios.primero;
             while (temp != null)
             {
                 ddlusuarios.Items.Add(temp.user.getnick());
                 temp = temp.siguiente;
             }
         }
     }
     userupdate = new actualizarusuarios();
 }
        protected void insertar(object sender, EventArgs e)
        {
            if (Application["arbolusuarios"] == null)
            {
                Application["arbolusuarios"] = new binario();
            }
            String  usuarioactual = ddlusuarios.SelectedValue;
            String  nick          = tbidnuevo.Text;
            String  pass          = tbpassnuevo.Text;
            String  email         = tbemail.Text;
            binario usertree      = (binario)Application["arbolusuarios"];
            usuario user          = usertree.buscar(usuarioactual, usertree.raiz);
            //buscar contacto a insertar
            usuario contacto = usertree.buscar(nick, usertree.raiz);

            //crear el usuario si no existe
            if (contacto == null)
            {
                contacto = usertree.insertar(nick, pass, email, 0, usertree.raiz);
            }
            user.insertarcontacto(contacto);
            //almacenar el arbol
            Application["arbolusuarios"] = usertree;
        }
 protected void cargar(object sender, EventArgs e)
 {
     if (fileup.HasFile)
     {
         String ruta = HttpContext.Current.Server.MapPath("~/cargas/") + fileup.FileName; //obtener nombre de ruta
         fileup.SaveAs(ruta);
         String entrada = File.ReadAllText(ruta);                                         //leer texto
         //obtener cada línea del texto
         String[] lineas = entrada.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
         //separa por comas
         binario bin = (binario)Application["arbolusuarios"];
         for (int i = 1; i < lineas.Length; i++)
         {
             String[] contenido = lineas[i].Split(',');
             //ingresar el contenido
             try
             {
                 bin.insertar(contenido[0], contenido[1], contenido[2], Int32.Parse(contenido[3].ToString()), bin.raiz);
             }
             catch (IndexOutOfRangeException ex) { String outex = ex.ToString(); }
         }
         Application["arbolusuarios"] = bin;
     }
 }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            binario bin = (binario)Application["arbolusuarios"];

            if (bin != null)
            {                                            //obtener listado de usuarios
                inorder     usuarios    = new inorder(bin);
                topten      ganadas     = new topten(0); //top ten por unidades ganadas
                topten      porcentaje  = new topten(1); //top ten por porcentaje de unidades destruidas
                topten      contactos   = new topten(2); //top ten por cantidad de contactos
                topten      cantidad    = new topten(3); //top ten por cantidad de unidades destruidas
                nodoinorder tempinorder = usuarios.primero;
                while (tempinorder != null)
                {//insertar los elementos en los listados
                    ganadas.insertar(tempinorder);
                    porcentaje.insertar(tempinorder);
                    contactos.insertar(tempinorder);
                    cantidad.insertar(tempinorder);
                    tempinorder = tempinorder.siguiente;
                }
                //insertar los valores en las tablas
                int        cont = 1;
                nodotopten temp = ganadas.primero;
                //crear fila de cabecera
                TableRow  filahead = new TableRow();
                TableCell c1head   = new TableCell();
                TableCell c2head   = new TableCell();
                TableCell c3head   = new TableCell();
                c1head.Text = "Posición";                   //agregar numero de usuario
                c2head.Text = "Nombre del jugador";         //agregar nombre de usuario
                c3head.Text = "Cantidad de juegos ganados"; //agregar cantidad de ganados
                filahead.Cells.Add(c1head);
                filahead.Cells.Add(c2head);
                filahead.Cells.Add(c3head);
                tablaganadas.Rows.Add(filahead); //agregar la fila a la tabla
                while (cont < 11)
                {                                //insertar usuarios en la tabla de unidades ganadas
                    if (temp != null)
                    {
                        TableRow  fila = new TableRow();
                        TableCell c1   = new TableCell();
                        TableCell c2   = new TableCell();
                        TableCell c3   = new TableCell();
                        c1.Text = cont.ToString();              //agregar numero de usuario
                        c2.Text = temp.user.getnick();          //agregar nombre de usuario
                        c3.Text = temp.user.ganados.ToString(); //agregar cantidad de ganados

                        fila.Cells.Add(c1);
                        fila.Cells.Add(c2);
                        fila.Cells.Add(c3);
                        tablaganadas.Rows.Add(fila);

                        cont++;
                        temp = temp.siguiente;
                    }
                    else
                    {
                        break; //terminar el proceso si no hay mas elementos
                    }
                }

                //insertar los valores en las tablas
                cont = 1;
                temp = porcentaje.primero;
                //crear fila de cabecera
                TableRow  filahead2 = new TableRow();
                TableCell c1head2   = new TableCell();
                TableCell c2head2   = new TableCell();
                TableCell c3head2   = new TableCell();
                c1head2.Text = "Posición";                          //agregar numero de usuario
                c2head2.Text = "Nombre del jugador";                //agregar nombre de usuario
                c3head2.Text = "Porcentaje de unidades destruidas"; //agregar porcentaje de unidades
                filahead2.Cells.Add(c1head2);
                filahead2.Cells.Add(c2head2);
                filahead2.Cells.Add(c3head2);
                tabladestruidas.Rows.Add(filahead2); //agregar la fila a la tabla
                while (cont < 11)
                {                                    //insertar usuarios en la tabla de unidades ganadas
                    if (temp != null)
                    {
                        TableRow  fila = new TableRow();
                        TableCell c1   = new TableCell();
                        TableCell c2   = new TableCell();
                        TableCell c3   = new TableCell();
                        c1.Text = cont.ToString();                 //agregar numero de usuario
                        c2.Text = temp.user.getnick();             //agregar nombre de usuario
                        c3.Text = temp.user.porcentaje.ToString(); //agregar porcentaje

                        fila.Cells.Add(c1);
                        fila.Cells.Add(c2);
                        fila.Cells.Add(c3);
                        tabladestruidas.Rows.Add(fila);

                        cont++;
                        temp = temp.siguiente;
                    }
                    else
                    {
                        break; //terminar el proceso si no hay mas elementos
                    }
                }
                //tabla de contactos
                cont = 1;
                temp = contactos.primero;
                //crear fila de cabecera
                TableRow  filahead3 = new TableRow();
                TableCell c1head3   = new TableCell();
                TableCell c2head3   = new TableCell();
                TableCell c3head3   = new TableCell();
                c1head3.Text = "Posición";              //agregar numero de usuario
                c2head3.Text = "Nombre del jugador";    //agregar nombre de usuario
                c3head3.Text = "Cantidad de contactos"; //agregar porcentaje de unidades
                filahead3.Cells.Add(c1head3);
                filahead3.Cells.Add(c2head3);
                filahead3.Cells.Add(c3head3);
                tablacontactos.Rows.Add(filahead3); //agregar la fila a la tabla
                while (cont < 11)
                {                                   //insertar usuarios en la tabla de unidades ganadas
                    if (temp != null)
                    {
                        TableRow  fila = new TableRow();
                        TableCell c1   = new TableCell();
                        TableCell c2   = new TableCell();
                        TableCell c3   = new TableCell();
                        c1.Text = cont.ToString();                     //agregar numero de usuario
                        c2.Text = temp.user.getnick();                 //agregar nombre de usuario
                        c3.Text = temp.user.contactos.cont.ToString(); //agregar porcentaje

                        fila.Cells.Add(c1);
                        fila.Cells.Add(c2);
                        fila.Cells.Add(c3);
                        tablacontactos.Rows.Add(fila);

                        cont++;
                        temp = temp.siguiente;
                    }
                    else
                    {
                        break; //terminar el proceso si no hay mas elementos
                    }
                }
                //tabla por cantidad de unidades destruidas
                cont = 1;
                temp = cantidad.primero;
                //crear fila de cabecera
                TableRow  filahead4 = new TableRow();
                TableCell c1head4   = new TableCell();
                TableCell c2head4   = new TableCell();
                TableCell c3head4   = new TableCell();
                c1head4.Text = "Posición";                        //agregar numero de usuario
                c2head4.Text = "Nombre del jugador";              //agregar nombre de usuario
                c3head4.Text = "Cantidad de unidades destruidas"; //agregar porcentaje de unidades
                filahead4.Cells.Add(c1head4);
                filahead4.Cells.Add(c2head4);
                filahead4.Cells.Add(c3head4);
                tablamasdestruidas.Rows.Add(filahead4); //agregar la fila a la tabla
                while (cont < 11)
                {                                       //insertar usuarios en la tabla de unidades ganadas
                    if (temp != null)
                    {
                        TableRow  fila = new TableRow();
                        TableCell c1   = new TableCell();
                        TableCell c2   = new TableCell();
                        TableCell c3   = new TableCell();
                        c1.Text = cont.ToString();                 //agregar numero de usuario
                        c2.Text = temp.user.getnick();             //agregar nombre de usuario
                        c3.Text = temp.user.destruidos.ToString(); //agregar porcentaje

                        fila.Cells.Add(c1);
                        fila.Cells.Add(c2);
                        fila.Cells.Add(c3);
                        tablamasdestruidas.Rows.Add(fila);

                        cont++;
                        temp = temp.siguiente;
                    }
                    else
                    {
                        break; //terminar el proceso si no hay mas elementos
                    }
                }
            }
        }