コード例 #1
0
        public UPerfil cargardatos(URegistro datosSession)
        {
            UPerfil perfil = new UPerfil();

            perfil.Datos        = new URegistro();
            perfil.Datos.Nombre = datosSession.Nombre;
            perfil.Datos.Correo = datosSession.Correo;

            perfil.Datos.Telefono   = datosSession.Telefono;
            perfil.Datos.Usuario    = datosSession.Usuario;
            perfil.Datos.Fotoperfil = datosSession.Fotoperfil;
            perfil.Datos.Idestado   = datosSession.Idestado;
            perfil.Datos.Id         = datosSession.Id;

            if (perfil.Datos.Fotoperfil == null)
            {
                perfil.Datos.Fotoperfil = "~/Vew/img/perfilvacio.jpg";
            }

            if (perfil.Datos.Idestado == 1) //1 Es con menbresia, 0 sin membresia
            {
                var verificar = new DAOSeguridad().verificarvencimientomembresia(perfil.Datos.Id);
                if (verificar != null)
                {
                    perfil.Datos.Id       = datosSession.Id;
                    perfil.Datos.Idestado = 0;
                    new DAOSeguridad().actualizarmembresia(perfil.Datos);
                    perfil.URL1 = "Perfil.aspx";

                    perfil.Mensaje                = "Sin Membresia";
                    perfil.B_ComprarMembresia1    = true;
                    perfil.B_ActualizarMembresia1 = false;
                    perfil.B_AgregarHotel1        = false;
                    perfil.B_mishoteles1          = false;
                }
                else
                {
                    perfil.Mensaje                = "Con Membresia";
                    perfil.B_ComprarMembresia1    = false;
                    perfil.B_ActualizarMembresia1 = true;
                    perfil.B_AgregarHotel1        = true;
                    perfil.B_mishoteles1          = true;
                }
            }
            else
            {
                perfil.Mensaje = "Sin Membresia";

                perfil.B_ComprarMembresia1    = true;
                perfil.B_ActualizarMembresia1 = false;
                perfil.B_AgregarHotel1        = false;
                perfil.B_mishoteles1          = false;
            }
            return(perfil);
        }
コード例 #2
0
        public UPerfil subirFoto(FileUpload foto, URegistro session, string direccion, string imagen, string imagenEliminar)
        {
            UPerfil datos = new UPerfil();

            if (foto.HasFile)
            {
                string ext = System.IO.Path.GetExtension(foto.FileName);                   //obtiene la extencion del archivo
                ext = ext.ToLower();                                                       //minusculas

                int tam = foto.PostedFile.ContentLength;                                   //obtiene tamano archivo
                                                                                           //string fotoperfil;

                if ((ext == ".jpg" || ext == ".png" || ext == ".jpeg") && (tam < 1048576)) //menor a 1MB en bytes
                {
                    try
                    {
                        //imagen
                        foto.PostedFile.SaveAs(imagen);//mapea y guarda el archivo en la direccion
                    }
                    catch
                    {
                        datos.Mensaje = "*Verifique la imagen y cargue nuevamente";
                    }
                    datos.Mensaje = "*Imagen aceptada";
                    //actualiza foto de perfil
                    URegistro nuevodat = new URegistro();
                    nuevodat.Id         = session.Id;
                    nuevodat.Fotoperfil = direccion;
                    new DAOLogin().actualizarfoto(nuevodat);


                    if (File.Exists(imagenEliminar))
                    {
                        File.Delete(imagenEliminar);
                    }

                    session.Fotoperfil = nuevodat.Fotoperfil;
                    datos.Fotoperfil   = nuevodat.Fotoperfil;
                    datos.Mensaje      = "*Imagen cargada con exito";
                }
                else
                {
                    datos.Mensaje = "*Imagen no esta en formato correcto o es muy pesada";
                }
            }
            else
            {
                datos.Mensaje = "*Selecciona una imagen";
            }

            return(datos);
        }
コード例 #3
0
    protected void B_SubirFoto_Click(object sender, EventArgs e)
    {
        string direccion;
        string imagen;
        string imagenEliminar;
        string nombreArchivo;
        string nombreArchivoEliminar;

        nombreArchivo         = ((URegistro)Session["usuario"]).Usuario + FU_FotoPerfil.FileName;
        nombreArchivoEliminar = ((URegistro)Session["usuario"]).Fotoperfil;
        direccion             = "~\\Vew\\imgusuarios\\" + nombreArchivo;
        imagen         = HttpContext.Current.Server.MapPath("~\\Vew\\imgusuarios\\") + nombreArchivo;
        imagenEliminar = HttpContext.Current.Server.MapPath(nombreArchivoEliminar);
        LPerfil logica = new LPerfil();
        UPerfil datos  = new UPerfil();

        datos = logica.subirFoto(FU_FotoPerfil, (URegistro)Session["usuario"], direccion, imagen, imagenEliminar);

        L_Pcargaimagen.Text = datos.Mensaje;
        fotoperfil.ImageUrl = datos.Fotoperfil;
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            UPerfil datos = new UPerfil();
            datos = new LPerfil().cargardatos(((URegistro)Session["usuario"]));

            L_Pnombre.Text   = datos.Datos.Nombre;
            L_Pcorreo.Text   = datos.Datos.Correo;
            L_Ptelefono.Text = datos.Datos.Telefono;
            L_Pusuariodatospersonales.Text = datos.Datos.Usuario;
            L_Pusuario.Text               = datos.Datos.Usuario;
            fotoperfil.ImageUrl           = datos.Datos.Fotoperfil;
            L_EstadoMembresia.Text        = datos.Mensaje;
            B_ComprarMembresia.Visible    = datos.B_ComprarMembresia1;
            B_ActualizarMembresia.Visible = datos.B_ActualizarMembresia1;
            B_AgregarHotel.Visible        = datos.B_AgregarHotel1;
            B_mishoteles.Visible          = datos.B_mishoteles1;
        }
        catch
        {
            Session.Remove("usuario");
            Session.Remove("visitarhotel");
            Response.Redirect("Login.aspx");
        }


        /*
         * try
         * {
         *  L_Pnombre.Text = ((Registro)Session["usuario"]).Nombre;
         *  L_Pcorreo.Text = ((Registro)Session["usuario"]).Correo;
         *
         *  L_Ptelefono.Text = ((Registro)Session["usuario"]).Telefono;
         *  L_Pusuariodatospersonales.Text = ((Registro)Session["usuario"]).Usuario;
         *  L_Pusuario.Text = ((Registro)Session["usuario"]).Usuario;
         *  fotoperfil.ImageUrl = ((Registro)Session["usuario"]).Fotoperfil;
         *  if (((Registro)Session["usuario"]).Fotoperfil == null)
         *  {
         *      fotoperfil.ImageUrl="~/Vew/img/perfilvacio.jpg";
         *  }
         *  //
         *  if (((Registro)Session["usuario"]).Idestado == 1) //1 Es con menbresia, 0 sin membresia
         *  {
         *      B_ComprarMembresia.Visible = false;
         *      B_ActualizarMembresia.Visible = true;
         *      B_AgregarHotel.Visible = true;
         *      L_EstadoMembresia.Text = "Con Membresia";
         *      var verificar = new DAOSeguridad().verificarvencimientomembresia(((Registro)Session["usuario"]).Id);
         *      if (verificar != null)
         *      {
         *          Registro usuario = new Registro();
         *          usuario.Id = ((Registro)Session["usuario"]).Id;
         *          usuario.Idestado = 0;
         *          new DAOSeguridad().actualizarmembresia(usuario);
         *          Response.Redirect("Perfil.aspx");
         *      }
         *  }
         *  else
         *  {
         *      B_ComprarMembresia.Visible = true;
         *      B_ActualizarMembresia.Visible = false;
         *      B_AgregarHotel.Visible = false;
         *      L_EstadoMembresia.Text = "Sin Membresia";
         *      B_mishoteles.Visible = false;
         *  }
         *  //
         * }
         * catch
         * {
         *  Session.Remove("usuario");
         *  Session.Remove("visitarhotel");
         *  Response.Redirect("Login.aspx");
         * }
         */
    }