Пример #1
0
    public static int Modificion(Registrado r)
    {
        SqlConnection cnn      = new SqlConnection(Conexion.STR);
        string        consulta = "ModificacionRegistrado";
        SqlCommand    comando  = new SqlCommand(consulta, cnn);

        comando.CommandType = CommandType.StoredProcedure;
        comando.Parameters.AddWithValue("@ci", r.Cedula);
        comando.Parameters.AddWithValue("@nombre", r.Nombre);
        comando.Parameters.AddWithValue("@sexo", r.Sexo);
        comando.Parameters.AddWithValue("@tarjeta", r.Tarjeta);
        SqlParameter retorno = new SqlParameter("retorno", SqlDbType.Int);

        retorno.Direction = ParameterDirection.ReturnValue;
        comando.Parameters.Add(retorno);
        int afectados = -1;

        try
        {
            cnn.Open();
            comando.ExecuteNonQuery();
            afectados = (int)comando.Parameters["retorno"].Value;
        }
        catch (Exception es)
        {
            throw new Exception("Problemas con la base de datos!!!!! " + es.Message);
        }
        finally
        {
            cnn.Close();
        }
        return(afectados);
    }
Пример #2
0
        public ActionResult BuscarUsuarioRegistrado(InformacionVM iVM)
        {//Se usa para eliminar un usuario
            UsuariosServicioCliente USC = new UsuariosServicioCliente();
            Registrado respuesta        = USC.BuscarUsuarioRegistrado(iVM.Registrado.DirCorreo);

            if (respuesta != null)
            {
                if (respuesta.DirCorreo == iVM.Registrado.DirCorreo)
                {
                    if (respuesta.Password == iVM.Registrado.Password)
                    {
                        //Vamos a pagina de ingreso
                        TempData["testmsg"] = "<script>alert('Ingreso Exitosamente');</script>";
                        return(RedirectToAction("Ingreso"));
                    }
                    else
                    {
                        TempData["testmsg"] = "<script>alert('Clave Incorrecta');</script>";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    //Nos quedamos en la pagina actual
                    TempData["testmsg"] = "<script>alert('Jugador No Registrado');</script>";
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                //Nos quedamos en la pagina actual
                TempData["testmsg"] = "<script>alert('Jugador No Registrado');</script>";
                return(RedirectToAction("Index"));
            }
        }
Пример #3
0
    public static List <Registrado> ListarRegistrados()
    {
        SqlConnection cnn     = new SqlConnection(Conexion.STR);
        SqlCommand    comando = new SqlCommand("ListarRegistrados", cnn);

        comando.CommandType = CommandType.StoredProcedure;
        try
        {
            cnn.Open();
            SqlDataReader     lector = comando.ExecuteReader();
            List <Registrado> lista  = new List <Registrado>();
            while (lector.Read())
            {
                long       ci       = (long)lector["cedula"];
                string     nombre   = (string)lector["nombre"];
                bool       sexo     = (bool)lector["sexo"];
                long       tarjeta  = (long)lector["tarjeta"];
                string     password = (string)lector["password"];
                Registrado r        = new Registrado(ci, nombre, password, sexo, tarjeta);
                lista.Add(r);
            }
            return(lista);
        }
        catch (Exception es)
        {
            throw new Exception("Problemas con la base de datos. " + es.Message);
        }
        finally
        {
            cnn.Close();
        }
    }
Пример #4
0
        public ActionResult Edit(int id)
        {
            Registrado u = null;

            SessionInitialize();
            RegistradoEN uEN = new RegistradoCAD(session).ReadOID(id);

            u = new AssemblerRegistrado().ConvertENToModelUI(uEN);
            SessionClose();
            return(View(u));
        }
Пример #5
0
 public Reserva()
 {
     id          = 0;
     fechaInicio = DateTime.Today;
     fechaFin    = DateTime.Today;
     precio      = 0;
     moneda      = "Pesos";
     cancelada   = false;
     cedula      = null;
     numero      = null;
     rut         = null;
 }
Пример #6
0
 public ActionResult Create(Registrado u)
 {
     try
     {
         RegistradoCEN pred = new RegistradoCEN();
         pred.New_(u.email, u.nombre, u.contrasenya, u.fecha_nac, u.telefono, DateTime.Today);
         // TODO: Add insert logic here
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #7
0
        public ActionResult Edit(Registrado u)
        {
            try
            {
                // TODO: Add update logic here
                RegistradoCEN uCEN = new RegistradoCEN();
                uCEN.Modify(u.id, u.email, u.nombre, u.contrasenya, u.fecha_nac, u.telefono, u.fecha_reg);


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #8
0
    public Reserva(int pId, DateTime pFinicio, DateTime pFfin, double pPrecio, string pMoneda, bool pCancelada,
                   Registrado pCedula, Habitacion pNumero, Habitacion pRut)
    {
        string mensaje = "";

        if (cedula == null)
        {
            mensaje = "Usuario no seleccionado";
        }
        if (numero == null)
        {
            mensaje = mensaje + "Habitación no seleccionada. ";
        }
        if (rut == null)
        {
            mensaje = mensaje + "Hotel no seleccionado. ";
        }
        if (fechaInicio < DateTime.Today)
        {
            mensaje = mensaje + "Fecha de inicio incorrecta. ";
        }
        if (fechaFin < DateTime.Today)
        {
            mensaje = mensaje + "Fecha final incorrecta. ";
        }
        if (precio <= 0)
        {
            mensaje = mensaje + "Precio inválido. ";
        }
        if (mensaje == "")
        {
            id          = pId;
            fechaInicio = pFinicio;
            fechaFin    = pFfin;
            precio      = pPrecio;
            moneda      = pMoneda;
            cancelada   = pCancelada;
            cedula      = pCedula;
            rut         = pRut;
            numero      = pNumero;
        }
        else
        {
            throw new Exception(mensaje);
        }
    }
        [ValidateAntiForgeryToken]  //IMPIDE LA FALSIFICACION DE UNA SOLICITUD
        public ActionResult Create(HttpPostedFileBase file, Registrado reg)
        {
            try
            {
                // TODO: Add insert logic here
                RegistradoCP cp = new RegistradoCP();

                RegistradoEN usuSingUp = cp.Nuevo_usuarioYcarrito(reg.Nombre, reg.Apellidos, reg.Edad, reg.FNacimiento, reg.Dni, reg.Contrasenya, reg.NUsuario, false);

                //ENCRIPTACION DE LA CONTRASENYA
                string encContra = Util.GetEncondeMD5(reg.Contrasenya);


                //WebSecurity.CreateUserAndAccount(reg.NUsuario, encContra);    //REGISTRO EN LA BDD LITE DE SQL SERVER
                //WebSecurity.Login(reg.NUsuario, encContra);                   //LOGIN

                //SUBIDA DE LA FOTO
                var path = "";

                if (file != null)
                {
                    if (file.ContentLength > 0)
                    {
                        //PARA UTILIZAR PATH SE NECESITA using System.IO
                        if ((Path.GetExtension(file.FileName).ToLower() == ".jpg") || (Path.GetExtension(file.FileName).ToLower() == ".png") ||
                            (Path.GetExtension(file.FileName).ToLower() == ".gif") || (Path.GetExtension(file.FileName).ToLower() == ".jpeg"))
                        {
                            path = Path.Combine(Server.MapPath("~/Content/Uploads/User_icons"), usuSingUp.Id + Path.GetExtension(file.FileName).ToLower());
                            file.SaveAs(path);
                        }
                    }
                }


                return(RedirectToAction("Index"));
            }
            catch
            {
                //NO SE SI HAY QUE PASAR reg A LA VISTA
                return(View(reg));
            }
        }
Пример #10
0
    public static Registrado BuscarRegistrado(long pCi)
    {
        string        nombre   = "";
        bool          sexo     = true;
        long          tarjeta  = 0;
        string        password = "";
        Registrado    r        = null;
        SqlConnection cnn      = new SqlConnection(Conexion.STR);
        string        consulta = "BuscarRegistrado";
        SqlCommand    comando  = new SqlCommand(consulta, cnn);

        comando.CommandType = CommandType.StoredProcedure;
        comando.Parameters.AddWithValue("@ci", pCi);
        SqlDataReader lector;

        try
        {
            cnn.Open();
            lector = comando.ExecuteReader();
            if (lector.Read())
            {
                nombre   = (string)lector["nombre"];
                sexo     = (bool)lector["sexo"];
                tarjeta  = (long)lector["tarjeta"];
                password = (string)lector["password"];
                r        = new Registrado(pCi, nombre, password, sexo, tarjeta);
            }
            return(r);
        }
        catch (Exception es)
        {
            throw new Exception("Problemas !!!! " + es.Message);
        }
        finally
        {
            cnn.Close();
        }
    }
Пример #11
0
    void RegisterBoard(int windowID)
    {
        GUI.Label(new Rect(40, 40, 500, 100), "Digite o nome do primeiro participante(lider)");
        nome1 = GUI.TextField(new Rect(25, 60, 375, 30), nome1);

        GUI.Label(new Rect(40, 100, 500, 100), "Digite o ra do primeiro participante(lider)");
        ra1 = GUI.TextField(new Rect(25, 120, 375, 30), ra1);

        GUI.Label(new Rect(40, 160, 500, 100), "Digite o nome do segundo participante");
        nome2 = GUI.TextField(new Rect(25, 180, 375, 30), nome2);

        GUI.Label(new Rect(40, 220, 500, 100), "Digite o ra do segundo participante");
        ra2 = GUI.TextField(new Rect(25, 240, 375, 30), ra2);

        GUI.Label(new Rect(40, 280, 500, 100), "Digite o nome do terceiro participante");
        nome3 = GUI.TextField(new Rect(25, 300, 375, 30), nome3);

        GUI.Label(new Rect(40, 335, 500, 100), "Digite o ra do terceiro participante");
        ra3 = GUI.TextField(new Rect(25, 360, 375, 30), ra3);

        if (GUI.Button(new Rect(25, 410, 175, 50), "Enviar"))
        {
            con             = new MySqlConnection(stConexao);
            cmd             = new MySqlCommand();
            cmd.CommandText = "INSERT INTO cadastro (nome1,ra1,nome2,ra2,nome3,ra3) VALUES ('" + nome1 + "','" + ra1 + "','" + nome2 + "','" + ra2 + "','" + nome3 + "','" + ra3 + "');";
            cmd.Connection  = con;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            //parte do hash

            cmd2             = new MySqlCommand();
            cmd2.CommandText = "SELECT * FROM cadastro ORDER BY ID DESC LIMIT 1;";
            cmd2.Connection  = con;
            con.Open();
            cmd2.ExecuteNonQuery();
            MySqlDataReader mySqlDreader;
            mySqlDreader = cmd2.ExecuteReader();
            while (mySqlDreader.Read())
            {
                id = Convert.ToInt32((mySqlDreader["id"]).ToString());
            }
            con.Close();

            //postoinicial

            if (id >= 5)
            {
                resto = id % 5;
                switch (resto)
                {
                case 0:
                    postoinicial = 5;
                    break;

                case 1:
                    postoinicial = 1;
                    break;

                case 2:
                    postoinicial = 2;
                    break;

                case 3:
                    postoinicial = 3;
                    break;

                case 4:
                    postoinicial = 4;
                    break;
                }
            }
            else if (id < 5)
            {
                switch (id)
                {
                case 1:
                    postoinicial = 1;
                    break;

                case 2:
                    postoinicial = 2;
                    break;

                case 3:
                    postoinicial = 3;
                    break;

                case 4:
                    postoinicial = 4;
                    break;
                }
            }

            //grupamento

            if (id > 3)
            {
                resto      = id / 3;
                grupamento = resto + 1;
            }

            else if (id <= 3)
            {
                grupamento = 1;
            }



            //liderfase2


            if (id % 3 == 0)
            {
                liderfase2 = 1;
            }
            else if (id % 3 != 0)
            {
                liderfase2 = 0;
            }

            hash = "00" + id.ToString() + "00" + grupamento.ToString() + postoinicial.ToString() + liderfase2.ToString();

            //Debug.Log(hash);



            cmd3             = new MySqlCommand();
            cmd3.CommandText = "INSERT INTO hash VALUES ('" + id + "','" + hash + "');";
            cmd3.Connection  = con;
            con.Open();
            cmd3.ExecuteNonQuery();
            con.Close();

            //fim do hash


            nome1 = "";
            ra1   = "";
            nome2 = "";
            ra2   = "";
            nome3 = "";
            ra3   = "";

            go          = GameObject.Find("Registrado");
            reg         = go.GetComponent <Registrado>();
            reg.enabled = true;
        }


        if (GUI.Button(new Rect(225, 410, 175, 50), "Home"))
        {
            Application.LoadLevel("Home");
        }
    }
        [ValidateAntiForgeryToken]  //IMPIDE LA FALSIFICACION DE UNA SOLICITUD
        public ActionResult Create(HttpPostedFileBase file, Registrado reg)
        {
            try
            {
                // TODO: Add insert logic here
                RegistradoCP  cp  = new RegistradoCP();
                RegistradoCEN cen = new RegistradoCEN();

                RegistradoEN usuSingUp = cp.Nuevo_usuarioYcarrito(reg.Nombre, reg.Apellidos, reg.Edad, reg.FNacimiento, reg.Dni, reg.Contrasenya, reg.NUsuario, false);

                //ENCRIPTACION DE LA CONTRASENYA
                string encContra = Util.GetEncondeMD5(reg.Contrasenya);


                string fbId = "";
                if (Session["FB"] != null)
                {
                    fbId = (string)Session["FB"];

                    //EN EL CASO QUE SE HAYA CONECTADO MEDIANTE FACEBOOK LE CAMBIO SU ID POR EL ID DE FACEBOOK
                    cen.Modify(usuSingUp.Id, reg.Nombre, reg.Apellidos, reg.Edad, reg.FNacimiento, fbId, reg.Contrasenya, reg.NUsuario, false);

                    //ELIMINO LA SESION
                    Session.Remove("FB");
                }


                //WebSecurity.CreateUserAndAccount(reg.NUsuario, encContra);    //REGISTRO EN LA BDD LITE DE SQL SERVER
                //WebSecurity.Login(reg.NUsuario, encContra);                   //LOGIN

                //SUBIDA DE LA FOTO
                var path = "";

                if (file != null)
                {
                    if (file.ContentLength > 0)
                    {
                        //PARA UTILIZAR PATH SE NECESITA using System.IO
                        if ((Path.GetExtension(file.FileName).ToLower() == ".jpg") || (Path.GetExtension(file.FileName).ToLower() == ".png") ||
                            (Path.GetExtension(file.FileName).ToLower() == ".gif") || (Path.GetExtension(file.FileName).ToLower() == ".jpeg"))
                        {
                            path = Path.Combine(Server.MapPath("~/Content/Uploads/User_icons"), usuSingUp.Id + Path.GetExtension(file.FileName).ToLower());
                            file.SaveAs(path);
                        }
                    }
                }
                System.Web.HttpContext.Current.Session["login"]     = usuSingUp.N_usuario;
                System.Web.HttpContext.Current.Session["idUsuario"] = usuSingUp.Id; //LO NECESITARE MÁS ADELANTE PARA OPERACIONES CON EL CARRITO
                System.Web.HttpContext.Current.Session["admin"]     = usuSingUp.Admin;
                System.Web.HttpContext.Current.Session["nCarrito"]  = 0;
                System.Web.HttpContext.Current.Session["foto"]      = "../../Images/Shut-up-and-take-my-money!.png";
                string iconoUsu = Path.Combine(Server.MapPath("~/Content/Uploads/User_icons"), usuSingUp.Id.ToString());
                if ((System.IO.File.Exists(iconoUsu + ".jpg")))
                {
                    Session["foto"] = "../../Content/Uploads/User_icons/" + usuSingUp.Id + ".jpg";
                }
                else if ((System.IO.File.Exists(iconoUsu + ".jpeg")))
                {
                    Session["foto"] = "../../Content/Uploads/User_icons/" + usuSingUp.Id + ".jpeg";
                }
                else if ((System.IO.File.Exists(iconoUsu + ".png")))
                {
                    Session["foto"] = "../../Content/Uploads/User_icons/" + usuSingUp.Id + ".png";
                }
                else if ((System.IO.File.Exists(iconoUsu + ".gif")))
                {
                    Session["foto"] = "../../Content/Uploads/User_icons/" + usuSingUp.Id + ".gif";
                }

                return(RedirectToAction("Login"));
            }
            catch
            {
                //NO SE SI HAY QUE PASAR reg A LA VISTA
                return(View(reg));
            }
        }
        [ValidateAntiForgeryToken]  //IMPIDE LA FALSIFICACION DE UNA SOLICITUD
        public ActionResult Login(Registrado reg)
        {
            try
            {
                // TODO: Add insert logic here
                RegistradoCEN cen = new RegistradoCEN();

                int  finalID = 0;
                bool admin   = false;
                IList <RegistradoEN> listEN = cen.get_IRegistradoCAD().ReadAll(0, -1);
                foreach (RegistradoEN rEN in listEN)
                {
                    if (rEN.N_usuario == reg.NUsuario)
                    {
                        finalID = rEN.Id;
                        admin   = rEN.Admin;
                        break;
                    }
                }

                //RegistradoEN en = cen.get_IRegistradoCAD().ReadOIDDefault(finalID);

                bool login = cen.Login(finalID, reg.Contrasenya, reg.NUsuario);

                if (login)
                {
                    System.Web.HttpContext.Current.Session["login"]     = reg.NUsuario;
                    System.Web.HttpContext.Current.Session["idUsuario"] = finalID; //LO NECESITARE MÁS ADELANTE PARA OPERACIONES CON EL CARRITO
                    System.Web.HttpContext.Current.Session["admin"]     = admin;
                    System.Web.HttpContext.Current.Session["foto"]      = "../../Images/Shut-up-and-take-my-money!.png";

                    //Cojo el numero de articulos en el carrito
                    SessionInitialize();
                    CarritoCAD carritoCAD = new CarritoCAD(session);
                    CarritoCEN carritoCEN = new CarritoCEN(carritoCAD);
                    CarritoEN  en         = carritoCEN.get_ICarritoCAD().ReadOIDDefault(finalID);

                    System.Web.HttpContext.Current.Session["nCarrito"] = en.LineaPedido.Count();
                    SessionClose();
                    //Cojo la foto de perfil
                    RegistradoCAD cad          = new RegistradoCAD();
                    RegistradoEN  registradoEN = cad.ReadOIDDefault(finalID);
                    Registrado    img          = new AssemblerRegistrado().ConvertENToModelUI(registradoEN);
                    string        idUsu        = img.Id.ToString();
                    string        iconoUsu     = Path.Combine(Server.MapPath("~/Content/Uploads/User_icons"), idUsu);
                    if ((System.IO.File.Exists(iconoUsu + ".jpg")))
                    {
                        Session["foto"] = "../../Content/Uploads/User_icons/" + img.Id + ".jpg";
                    }
                    else if ((System.IO.File.Exists(iconoUsu + ".jpeg")))
                    {
                        Session["foto"] = "../../Content/Uploads/User_icons/" + img.Id + ".jpeg";
                    }
                    else if ((System.IO.File.Exists(iconoUsu + ".png")))
                    {
                        Session["foto"] = "../../Content/Uploads/User_icons/" + img.Id + ".png";
                    }
                    else if ((System.IO.File.Exists(iconoUsu + ".gif")))
                    {
                        Session["foto"] = "../../Content/Uploads/User_icons/" + img.Id + ".gif";
                    }

                    return(RedirectToAction("../Home"));
                }
                else
                {
                    System.Web.HttpContext.Current.Session["errorAcces"] = true;
                    return(View(reg));
                }
            }
            catch
            {
                return(View(reg));
            }
        }
Пример #14
0
        public ActionResult Create()
        {
            Registrado reg = new Registrado();

            return(View(reg));
        }