protected void Button1_Click(object sender, EventArgs e)
    {
        conexion conexionSQL = new conexion();

        conexionSQL.conectar();
        String       correo    = txtCorreo.Text;
        String       contra    = txtContra.Text;
        encriptacion enc       = new encriptacion();
        String       contraEnc = enc.encriptarContra(contra);
        int          resp      = conexionSQL.LoginUsuarios(correo, contraEnc);

        conexionSQL.desconectar();
        if (resp != 0)
        {
            switch (resp)
            {
            case 1:
                Session["codigoUsuario"] = conexionSQL.idUsuario;
                Session["tipoUsuario"]   = resp;
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "CorrectoAdmin();", true);
                break;

            case 2:
                Session["codigoUsuario"] = conexionSQL.idUsuario;
                Session["tipoUsuario"]   = resp;
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "CorrectoGestor();", true);
                break;

            case 3:
                Session["codigoUsuario"] = conexionSQL.idUsuario;
                Session["tipoUsuario"]   = resp;
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "CorrectoContador();", true);
                break;
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "Incorrecto();", true);
            txtContra.Text = null;
            txtCorreo.Text = null;
        }
    }
Esempio n. 2
0
    protected void guardarUsuario_Click(object sender, EventArgs e)
    {
        String nombre    = this.txtNombre.Text;
        String apellido  = this.txtApellidos.Text;
        String correo    = this.txtCorreo.Text;
        String fecha     = this.txtFechaN.Text;
        String tel       = this.txtTelefono.Text;
        String direccion = this.txtDireccion.Text;
        String duracion  = this.txtContra.Text;
        String dui       = this.txtDui.Text;
        String fechai    = this.fechaInicio.Text;
        String fechaf    = this.fechaFin.Text;
        int    univ      = int.Parse(ddlUniversidades.SelectedValue);
        int    carr      = int.Parse(ddlCarreras.SelectedValue);
        int    nivel     = int.Parse(ddlNivel.SelectedValue);
        int    beca      = int.Parse(this.ddlPrograma.SelectedValue);

        if (nombre != "")
        {
            if (apellido != "")
            {
                if (correo != "" && fecha != "" && tel != "" && direccion != "" && dui != "" && fechai != "" && fechaf != "")
                {
                    if (beca > 0 && nivel > 0 && carr > 0 && univ > 0)
                    {
                        conexion conexionSQL = new conexion();
                        conexionSQL.conectar();
                        generadorContra c         = new generadorContra();
                        String          contra    = c.generarContra();
                        encriptacion    enc       = new encriptacion();
                        String          contraEnc = enc.encriptarContra(contra);
                        String          codB      = conexionSQL.getCodigoB(beca);
                        int             codigo    = conexionSQL.codigoMax() + 1;
                        this.metodoCodigo(codB, codigo);
                        int resp = conexionSQL.agregarBecario(nombre, apellido, correo, contra, univ, nivel, carr, beca, fecha, fechai, fechaf, tel, direccion, this.codigoB, dui, duracion);
                        conexionSQL.desconectar();
                        if (resp > 0)
                        {
                            correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra);
                            if (enviarCo.Estado)
                            {
                                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
        }
    }
Esempio n. 3
0
 protected void guardarUsuario_Click(object sender, EventArgs e)
 {
     try
     {
         String nombre   = txtNombUsu.Text;
         String apellido = txtApelUsu.Text;
         String correo   = txtCorreUsu.Text;
         int    tipo     = int.Parse(ddlTipoUsu.SelectedValue);
         if (nombre != "")
         {
             if (apellido != "")
             {
                 if (correo != "")
                 {
                     if (tipo > 0)
                     {
                         conexion conexionSQL = new conexion();
                         conexionSQL.conectar();
                         generadorContra c         = new generadorContra();
                         String          contra    = c.generarContra();
                         encriptacion    enc       = new encriptacion();
                         String          contraEnc = enc.encriptarContra(contra);
                         int             resp      = conexionSQL.agregarUsuario(nombre, apellido, correo, contraEnc, tipo);
                         conexionSQL.desconectar();
                         if (resp > 0)
                         {
                             correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra);
                             if (enviarCo.Estado)
                             {
                                 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                             }
                             else
                             {
                                 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                             }
                         }
                         else
                         {
                             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                         }
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                     }
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                 }
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
             }
         }
         else
         {
             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
     }
 }