Exemplo n.º 1
0
        public void Alta(Jugador unJugador)
        {
            SqlConnection conexion = new SqlConnection(Conexion.Cnn);
            SqlCommand comando = new SqlCommand("REG_JUGADOR", conexion);
            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@CI", unJugador.CI);
            comando.Parameters.AddWithValue("@NOMBRE", unJugador.NOM_COMPLETO);
            comando.Parameters.AddWithValue("@USUARIO", unJugador.USUARIO);
            comando.Parameters.AddWithValue("@PASS", unJugador.PASS);
            comando.Parameters.AddWithValue("@NOMBRE_PUBLICO", unJugador.NOM_PUBLICO);
            SqlParameter Retorno = new SqlParameter("@Retorno", SqlDbType.Int);
            Retorno.Direction = ParameterDirection.ReturnValue;
            comando.Parameters.Add(Retorno);
            try
            {
                conexion.Open();
                comando.ExecuteNonQuery();

                int devolucion = Convert.ToInt32(Retorno.Value);
                if (devolucion == -1)
                    throw new Exception("Ya hay un usuario registrado con esa cedula.");
                else if (devolucion == -2)
                    throw new Exception("Error al registrar el cliente.");
                else if (devolucion == -3)
                    throw new Exception("Error en la tarjeta de credito");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
        }
Exemplo n.º 2
0
 public Juegos(int pId, Jugador pUnJug, DateTime pFechaI, int pMovs, List<Contestada> pLisCont)
 {
     ID_JUEGO = pId;
     JUGADOR = pUnJug;
     F_INICIO = pFechaI;
     MOVS = pMovs;
     LIST_CON = pLisCont;
 }
Exemplo n.º 3
0
 public List<Juegos> ListarJuegosXJugador(Jugador unJug)
 {
     try
     {
         return PerFabrica.GetPerJuego().ListarJuegosXJugador(unJug);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        public Jugador Buscar(int pCi)
        {
            SqlConnection conexion = new SqlConnection(Conexion.Cnn);
            Jugador unJugador = null;
            SqlCommand comando = new SqlCommand("BUSCAR_JUGADOR", conexion);
            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@CI", pCi);

            try
            {
                conexion.Open();
                SqlDataReader dr = comando.ExecuteReader();
                if (dr.HasRows)
                {
                    dr.Read();
                    unJugador = new Jugador((int)dr["CI"], (string)dr["NOMBRE"],
                    (string)dr["USUARIO"], (string)dr["PASS"], (string)dr["NOMBRE_PUBLICO"]);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
            return unJugador;
        }
Exemplo n.º 5
0
        public Jugador Logueo(string pUsuario, string pPass)
        {
            SqlConnection conexion = new SqlConnection(Conexion.Cnn);
            Jugador unJugador = null;

            SqlCommand comando = new SqlCommand("LOGUEO_JUGADOR", conexion);
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@USUARIO", pUsuario);
            comando.Parameters.AddWithValue("@PASS", pPass);

            try
            {
                conexion.Open();
                SqlDataReader dr = comando.ExecuteReader();
                if (dr.HasRows)
                {
                    dr.Read();
                    unJugador = new Jugador((int)dr["CI"], (string)dr["NOMBRE"],
                        (string)dr["USUARIO"], (string)dr["PASS"], (string)dr["NOMBRE_PUBLICO"]);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
            return unJugador;
        }
Exemplo n.º 6
0
 public List<Juegos> ListarJuegosXJugador(Jugador UnJug)
 {
     List<Juegos> lista = new List<Juegos>();
     SqlConnection conexion = new SqlConnection(Conexion.Cnn);
     SqlCommand comando = new SqlCommand("ESTADISTICA_X_JUGADOR", conexion);
     comando.CommandType = System.Data.CommandType.StoredProcedure;
     Juegos juego = null;
     comando.Parameters.AddWithValue("@CI", UnJug.CI);
     try
     {
         conexion.Open();
         SqlDataReader dr = comando.ExecuteReader();
         if (dr.HasRows)
         {
             UnJug = PerJugador.GetInstancia().Buscar(UnJug.CI);
             while (dr.Read())
             {
                 juego = new Juegos((int)dr["ID_JUEGO"], PerJugador.GetInstancia().Buscar((int)dr["CI"]), Convert.ToDateTime(dr["FECHA_INICIO"]),
                 (int)dr["MOVIMIENTOS"], PerContestada.ListarPreguntasXJuego((int)dr["ID_JUEGO"]));
                 juego.F_FIN = Convert.ToDateTime(dr["FECHA_FIN"]);
                 lista.Add(juego);
             }
         }
         dr.Close();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         conexion.Close();
     }
     return lista;
 }
Exemplo n.º 7
0
        public Juegos Continuar_Juego(Jugador UnJug)
        {
            SqlConnection conexion = new SqlConnection(Conexion.Cnn);
            Juegos unJuego = null;
            Jugador unJugador = null;
            List<Contestada> listCon = null;
            SqlCommand command = new SqlCommand("CONTINUAR_JUEGO", conexion);
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@CI", UnJug.CI);

            try
            {
                if(conexion.State.ToString() == "Closed")
                    conexion.Open();
                SqlDataReader dr = command.ExecuteReader();
                if (dr.HasRows)
                {
                    dr.Read();
                    unJugador = PerFabrica.GetPerJugador().Buscar(Convert.ToInt32(dr["CI"]));
                    listCon = Persistencia.Clases_de_trabajo.PerContestada.ContestadasXJuego(Convert.ToInt32(dr["ID_JUEGO"]));
                    unJuego = new Juegos(Convert.ToInt32(dr["ID_JUEGO"]), unJugador, Convert.ToDateTime(dr["FECHA_INICIO"]), Convert.ToInt32(dr["MOVIMIENTOS"]), listCon);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
            return unJuego;
        }
Exemplo n.º 8
0
 public Juegos Continuar_Juego(Jugador UnJug)
 {
     return PerFabrica.GetPerJuego().Continuar_Juego(UnJug);
 }
Exemplo n.º 9
0
        public string XMLlistarJuegosXjugador(Jugador un_jug)
        {
            //obtengo datos
            List<Juegos> lista = PerFabrica.GetPerJuego().ListarJuegosXJugador(un_jug);

            //convierto a xml
            XmlDocument docXML = new XmlDocument();
            docXML.LoadXml("<?xml version='1.0' encoding='utf-8' ?> <Raiz> </Raiz>");
            XmlNode raiz = docXML.DocumentElement;

            //recorro la lista para crear los nodos
            foreach (Juegos j in lista)
            {
                XmlElement Juegos = docXML.CreateElement("Juegos");

                XmlElement idJuego = docXML.CreateElement("idJuego");
                idJuego.InnerText = j.ID_JUEGO.ToString();

                XmlElement ci = docXML.CreateElement("ci");
                ci.InnerText = j.JUGADOR.CI.ToString();

                XmlElement f_inicio = docXML.CreateElement("f_inicio");
                f_inicio.InnerText = j.F_INICIO.ToString("dd/MM/yy hh:MM:ss");

                XmlElement f_fin = docXML.CreateElement("f_fin");
                f_fin.InnerText = j.F_FIN.ToString("dd/MM/yyyy hh:MM:ss");

                XmlElement movs = docXML.CreateElement("movs");
                movs.InnerText = j.MOVS.ToString();

                Juegos.AppendChild(idJuego);
                Juegos.AppendChild(ci);
                Juegos.AppendChild(f_inicio);
                Juegos.AppendChild(f_fin);
                Juegos.AppendChild(movs);

                raiz.AppendChild(Juegos);
            }
            //retorno los datos en formato XML
            return docXML.OuterXml;
        }