示例#1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var email = TextBox1.Text;
            var pass  = TextBox3.Text;


            var nombre    = TextBox2.Text;
            var apellidos = TextBox5.Text;
            var passconf  = TextBox4.Text;
            var roll      = DropDownList1.SelectedValue;
            var codpass   = 0;

            EnvioCorreo.Correo correo = new EnvioCorreo.Correo();

            var rand    = new Random();
            var numconf = (int)(rand.Next(1000000, 10000000));

            try
            {
                bd = new AccesoADatos.Datos();
                int resul;
                int a = bd.AbrirSesion();
                if (a == 0)
                {
                    resul = bd.registrar(nombre, apellidos, numconf, false, email, pass, codpass);
                }

                bd.cerrarConexion();
                var sol = correo.enviarEmail(email, numconf, "https://localhost:44394/Confirmar.aspx");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Hay algun dato mal insertado.');", true);
            }
        }
示例#2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            bd = new AccesoADatos.Datos();
            int a = bd.AbrirSesion();

            if (a == 0)
            {
                int b = bd.comprobarCorreoYContraseña(Correo.Text, Contra.Text);
                if (b == 1)//El inicio de sesion ha sido correcto!
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Inicio de sesion correcto.');", true);
                    Response.Redirect("http://www.google.com");
                }
                else if (b == 2)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Tienes que confirmar el correo :)');", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('El correo o contraseña es incorrecto.');", true);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Ha habido un problema (con la base de datos).');", true);
            }
            bd.cerrarConexion();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.Params["conf"]) && !string.IsNullOrEmpty(Request.Params["mail"]))
            {
                //Ha clicado desde el enlace
                AccesoADatos.Datos bd = new AccesoADatos.Datos();
                bd.AbrirSesion();

                var correo    = Request.Params["mail"].ToString();
                var numcof    = Request.Params["conf"].ToString();
                var numconfBD = bd.getNumcof(correo).ToString();
                System.Diagnostics.Debug.WriteLine(numconfBD + " " + numcof);
                bool estaconfirmado = bd.esConfirmado(correo);

                if (numcof == numconfBD && !estaconfirmado)
                {
                    bd.confirmarCorreo(correo);
                    div1.InnerHtml = "El usuario se ha registrado correctamente";
                }
                else if (numcof != numconfBD)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Numero de confirmacion incorrecta ');", true);
                    Response.Redirect("~/Inicio.aspx");
                }
                else if (estaconfirmado)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Este usuario ya esta registrado');", true);
                    Response.Redirect("~/Inicio.aspx");
                }
            }
        }
示例#4
0
        protected void Button2_Click1(object sender, EventArgs e)
        {
            try
            {
                AccesoADatos.Datos bd = new AccesoADatos.Datos();
                int a = bd.AbrirSesion();
                if (a == 0)
                {
                    int resul;
                    //Vamos a cambiar la contraseña.
                    if (Codigo.Text != "000000")
                    {
                        resul = bd.cambiarPass(Correo1.Text, Pass.Text, Codigo.Text);
                    }
                    else
                    {
                        resul = 0;
                    }

                    if (resul == 1)
                    {
                        //EL cambio se ha realizado de manera correcta.
                        Response.Write("<script language='javascript'>window.alert('La contraseña se ha cambiado correctamente.');window.location='Inicio.aspx';</script>");
                        //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('La contraseña se ha cambiado correctamente');", true);
                        //Response.Redirect("~/Inicio.aspx");
                    }
                    else if (resul == 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('El codigo o el correo no es correcto');", true);
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Ha habido un fallo." + resul + "');", true);
                    }
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Hay algun dato mal insertado.');", true);
            }
        }
示例#5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            AccesoADatos.Datos bd = new AccesoADatos.Datos();
            int a = bd.AbrirSesion();

            if (a == 0)
            {
                int resul = bd.CambiarContrasenaCorreo(Correo.Text, HttpContext.Current.Request.Url.AbsoluteUri);
                if (resul == 1)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('El correo se ha enviado de manera correcta.');", true);
                }
                else if (resul == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('El correo insertado no esta registrado.');", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Ha habido un problema al enviar el correo.');", true);
                }
            }
        }