Exemplo n.º 1
0
    protected void ButtonAgregar_Click(object sender, EventArgs e)
    {
        ProcsTableAdapter procesos  = new ProcsTableAdapter();
        FuncsTableAdapter funciones = new FuncsTableAdapter();
        SQLInjects        injects   = new SQLInjects();

        try
        {
            string correoUsuario = injects.Remover(TextBoxCorreo.Text);
            string nombreUsuario = injects.Remover(TextBoxNombre.Text);
            string hash          = PasswordHash.PasswordHash.CreateHash(correoUsuario + nombreUsuario);

            if ((bool)funciones.verificar_correo_registrado(correoUsuario))
            {
                labelMensajeModificacion.InnerHtml = "Este correo ya está registrado";
            }
            else
            {
                labelMensajeModificacion.InnerHtml = "Se está procesando su petición, espere por favor...";
                procesos.agregar_usuario(nombreUsuario, correoUsuario, hash);
                Correo correo = new Correo();


                correo.enviarMailCambioPass(correoUsuario, nombreUsuario, hash);
                labelMensaje.InnerHtml          = "Se le ha enviado un correo para crear una contraseña para su cuenta." + DateTime.Now;
                divModificacionUsuarios.Visible = false;
                divUsuarios.Visible             = true;
                GridViewUsuarios.DataBind();
            }
        }
        catch (Exception err)
        {
            labelMensajeModificacion.InnerHtml = "Ha ocurrido un error en el sistema, favor de contactar al administrador.";
        }
    }
Exemplo n.º 2
0
    protected void buttonAceptar_Click(object sender, EventArgs e)
    {
        SQLInjects        injects   = new SQLInjects();
        FuncsTableAdapter funciones = new FuncsTableAdapter();
        obtener_datos_validacion_usuarioTableAdapter sesion = new obtener_datos_validacion_usuarioTableAdapter();

        string correo      = injects.Remover(TextBoxCorreo.Text);
        string hashUsuario = "";

        try
        {
            hashUsuario = funciones.obtener_hash_usuario(correo);
            if (hashUsuario.Length < 5)
            {
                MostrarError("Los datos que ingresó son incorrectos, por favor inténtelo de nuevo.");
            }
            else
            if (PasswordHash.PasswordHash.ValidatePassword
                    (TextBoxPassword.Text, hashUsuario))
            {
                Session["ID"]     = sesion.GetData(hashUsuario)[0].id_usuario;
                Session["Nombre"] = sesion.GetData(hashUsuario)[0].nombre_usuario;
                Response.Redirect("./Inicio.aspx");
            }
            else
            {
                MostrarError("Los datos que ingresó son incorrectos, por favor inténtelo de nuevo.");
            }
        }
        catch (Exception err)
        {
            MostrarError("Usted no se ha registrado.");
        }
    }
Exemplo n.º 3
0
    protected void ButtonAgregar_Click(object sender, EventArgs e)
    {
        SQLInjects injects = new SQLInjects();

        string            nombre    = injects.Remover(TextBoxNombre.Text);
        string            apellido  = injects.Remover(TextBoxApellidos.Text);
        string            correo    = injects.Remover(TextBoxCorreo.Text);
        string            hash      = PasswordHash.PasswordHash.CreateHash(nombre + apellido);
        ProcsTableAdapter procesos  = new ProcsTableAdapter();
        FuncsTableAdapter funciones = new FuncsTableAdapter();

        try
        {
            Correo correoUsuario = new Correo();
            if ((bool)funciones.verificar_correo_registrado(correo))
            {
                labelCorreo.InnerHtml = "Correo Electrónico: (Este Correo ya se encuentra registrado)";
            }
            else
            {
                procesos.agregar_usuario(nombre, apellido, Convert.ToInt32(DropDownListEscuelas.SelectedValue), correo, hash, DropDownListNivelUsuario.SelectedValue, false, false);
                correoUsuario.enviarMailCambioPass(correo, nombre, hash);
                LabelMensaje.Text = "Usuario Agregado Correctamente";
                mostrarDivMensaje();
            }
        }
        catch (Exception err)
        {
            LabelMensaje.Text = "Error al agregar el usuario";
            mostrarDivMensaje();
        }
    }
Exemplo n.º 4
0
    protected void gridSalas_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("VerCaracteristicasSala"))
        {
            mostrarCaracteristicasSala();
            int         indice = Convert.ToInt32(e.CommandArgument);
            GridViewRow fila   = GridSalas.Rows[indice];
            int         idSala = Convert.ToInt32(HttpUtility.HtmlDecode(GridSalas.DataKeys[indice].Values["ID"].ToString()));
            labelNombreSala.Text    = HttpUtility.HtmlDecode(fila.Cells[1].Text);
            labelUbicacionSala.Text = HttpUtility.HtmlDecode(fila.Cells[2].Text);
            labelCapacidadSala.Text = HttpUtility.HtmlDecode(fila.Cells[3].Text);

            try
            {
                FuncsTableAdapter funciones = new FuncsTableAdapter();

                labelCaracteristicasSala.Text = funciones.ver_caracteristicas_sala(idSala);
            }
            catch (Exception err)
            {
            }
        }
        if (e.CommandName.Equals("SeleccionarSala"))
        {
            int indice = Convert.ToInt32(e.CommandArgument);
            Session["SalaSeleccionada"]       = Convert.ToInt32(HttpUtility.HtmlDecode(GridSalas.DataKeys[indice].Values["ID"].ToString()));
            Session["NombreSalaSeleccionada"] = HttpUtility.HtmlDecode(GridSalas.Rows[indice].Cells[1].Text);
            Session["UbicacionSala"]          = HttpUtility.HtmlDecode(GridSalas.Rows[indice].Cells[2].Text);
            Session["CapacidadSala"]          = HttpUtility.HtmlDecode(GridSalas.Rows[indice].Cells[3].Text);
            List <DateTime> listaFechas = (List <DateTime>)Session["FechasSeleccionadas"];
            regresar_horas_ocupadasTableAdapter           horasOcupadas = new regresar_horas_ocupadasTableAdapter();
            DataSetFuncs.regresar_horas_ocupadasDataTable horas;
            mostrarSeleccionHoras();
            for (int k = 0; k < listaFechas.Count; k++)
            {
                horas = horasOcupadas.GetData(listaFechas[k].Month + "/" + listaFechas[k].Day + "/" + listaFechas[k].Year, Convert.ToInt32(Session["SalaSeleccionada"]));
                for (int i = 0; i < horas.Rows.Count; i++)
                {
                    for (int j = 0; j < ListBoxHoras.Items.Count; j++)
                    {
                        if (Convert.ToInt32(ListBoxHoras.Items[j].Value) == horas[i].horas.Hours)
                        {
                            ListBoxHoras.Items[j].Enabled = false;
                        }
                    }
                }
            }
            if (Calendario.SelectedDate.Day == DateTime.Now.Day)
            {
                for (int i = 0; i < ListBoxHoras.Items.Count; i++)
                {
                    if (Convert.ToInt32(ListBoxHoras.Items[i].Value) <= DateTime.Now.Hour)
                    {
                        ListBoxHoras.Items[i].Enabled = false;
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    protected void buttonRegistro_Click(object sender, EventArgs e)
    {
        ProcsTableAdapter procesos  = new ProcsTableAdapter();
        FuncsTableAdapter funciones = new FuncsTableAdapter();
        string            hash      = "";
        SQLInjects        injects   = new SQLInjects();

        Correo correo = new Correo();

        //textBoxCorreo.Text += "@uaq.mx";
        if (textBoxNombre.Text.Equals(""))
        {
            MostrarError("Debe escribir su nombre");
        }
        else
        if (textBoxApellido.Text.Equals(""))
        {
            MostrarError("Debe escribir su apellido");
        }
        else
        if (textBoxCorreo.Text.Equals("") || textBoxCorreo.Text.Contains("@"))
        {
            MostrarError("Debe escribir su correo adecuadamente");
        }
        else
        if (textBoxPassword.Text.Equals(""))
        {
            MostrarError("Debe escribir una contraseña");
        }
        else
        if (textBoxPassword.Text.Equals(textBoxPasswordValidation.Text))
        {
            if ((bool)funciones.verificar_correo_registrado(injects.Remover(textBoxCorreo.Text + "@uaq.mx")))
            {
                MostrarError("El correo ya se encuentra registrado.");
            }
            else
            {
                hash = PasswordHash.PasswordHash.CreateHash(textBoxPassword.Text);
                string err = correo.enviarMailUsuario(textBoxCorreo.Text + "@uaq.mx", textBoxNombre.Text, hash);
                if (err[0] == 'E')
                {
                    MostrarError(err);
                }
                else
                {
                    procesos.agregar_usuario(injects.Remover(textBoxNombre.Text), injects.Remover(textBoxApellido.Text), 1,
                                             injects.Remover(textBoxCorreo.Text + "@uaq.mx"), hash, "U", false, false);
                    MostrarError("Su cuenta se ha registrado correctamente, le llegará una notificación a su correo");
                    camposTexto.Visible = false;
                }
            }
        }
        else
        {
            MostrarError("Las contraseñas no coinciden");
        }
    }
Exemplo n.º 6
0
    protected void buttonAceptar_Click(object sender, EventArgs e)
    {
        SQLInjects        injects   = new SQLInjects();
        FuncsTableAdapter funciones = new FuncsTableAdapter();
        obtener_datos_sesion_usuarioTableAdapter sesion = new obtener_datos_sesion_usuarioTableAdapter();
        ProcsTableAdapter procesos = new ProcsTableAdapter();

        string correo      = injects.Remover(TextBoxCorreo.Text);
        string hashUsuario = "";

        try
        {
            hashUsuario = funciones.obtener_hash_usuario(correo);
            if (hashUsuario.Length < 5)
            {
                MostrarError("Los datos que ingresó son incorrectos, por favor inténtelo de nuevo.");
            }
            else
            if (PasswordHash.PasswordHash.ValidatePassword
                    (TextBoxPassword.Text, hashUsuario))
            {
                if (sesion.GetData(hashUsuario, correo)[0].activacion_usuario)
                {
                    if (sesion.GetData(hashUsuario, correo)[0].acceso)
                    {
                        MostrarError("Acceso secundario detectado, se desactivará la cuenta temporalmente");
                        procesos.desactivar_cuenta_usuario(sesion.GetData(hashUsuario, correo)[0].clave_usuario);
                        procesos.validar_salida_usuario(sesion.GetData(hashUsuario, correo)[0].clave_usuario);
                    }
                    else
                    {
                        Session["Logged"]   = "Yes";
                        Session["Usuario"]  = sesion.GetData(hashUsuario, correo)[0].nombre_usuario;
                        Session["Permisos"] = sesion.GetData(hashUsuario, correo)[0].nivel_usuario;
                        Session["Correo"]   = correo;
                        Session["ID"]       = sesion.GetData(hashUsuario, correo)[0].clave_usuario;
                        procesos.validar_entrada_usuario(int.Parse(Session["ID"].ToString()));
                        Response.Redirect("../Principal/Inicio.aspx");
                    }
                }
                else
                {
                    MostrarError("Su cuenta aun no se encuentra activada.");
                }
            }
            else
            {
                MostrarError("Los datos que ingresó son incorrectos, por favor inténtelo de nuevo.");
            }
        }
        catch (Exception err)
        {
            MostrarError("Usted no se ha registrado.");
        }
    }
Exemplo n.º 7
0
 protected void GridViewSalas_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("ModificarSala"))
     {
         FuncsTableAdapter funciones = new FuncsTableAdapter();
         mostrarModificacionSalas();
         ButtonAceptarAgregarSala.Visible   = false;
         ButtonAceptarModificarSala.Visible = true;
         int         indice = Convert.ToInt32(e.CommandArgument);
         GridViewRow fila   = GridViewSalas.Rows[indice];
         labelID.Text                    = HttpUtility.HtmlDecode(GridViewSalas.DataKeys[indice].Values["ID"].ToString());
         TextBoxNombreSala.Text          = HttpUtility.HtmlDecode(fila.Cells[1].Text);
         TextBoxUbicacionSala.Text       = HttpUtility.HtmlDecode(fila.Cells[2].Text);
         TextBoxCapacidadSala.Text       = HttpUtility.HtmlDecode(fila.Cells[3].Text);
         TextBoxCaracteristicasSala.Text = funciones.ver_caracteristicas_sala(Convert.ToInt32(labelID.Text));
         labelTextoID.Visible            = true;
     }
 }
Exemplo n.º 8
0
    protected void buttonCambiarPass_Click(object sender, EventArgs e)
    {
        try
        {
            SQLInjects injects = new SQLInjects();

            string            correoUsuario = injects.Remover(TextBoxCorreoVerificacion.Text);
            FuncsTableAdapter funciones     = new FuncsTableAdapter();
            string            hash          = funciones.obtener_hash_usuario(correoUsuario);
            obtener_datos_validacion_usuarioTableAdapter datos = new obtener_datos_validacion_usuarioTableAdapter();
            string nombreUsuario = datos.GetData(hash)[0].nombre_usuario + " " + datos.GetData(hash)[0].apellido_usuario;

            Correo correo = new Correo();
            correo.enviarMailCambioPass(correoUsuario, nombreUsuario, hash);
            LabelMensaje.Text = "Se le ha enviado un correo para cambiar su contraseña.";
        }
        catch (Exception err)
        {
            LabelMensaje.Text = "Ocurrió un problema al enviar su correo, intente de nuevo más tarde.";
        }
    }
Exemplo n.º 9
0
        protected void ButtonAceptar_Click(object sender, EventArgs e)
        {
            SQLInjects        inject    = new SQLInjects();
            FuncsTableAdapter funciones = new FuncsTableAdapter();
            obtener_datos_validacion_usuarioTableAdapter datos_sesion = new obtener_datos_validacion_usuarioTableAdapter();
            ProcsTableAdapter procedimientos = new ProcsTableAdapter();
            string            nombre         = "";
            string            nivel          = "";
            string            area           = "";
            bool   acceso;
            string hash = "";
            bool   activado;
            bool   existe;
            int    id;

            try
            {
                string correo = inject.Remover(TextBoxUsuario.Text);
                existe = (bool)funciones.verificar_correo_registrado(correo);
                if (existe == false)
                {
                    error.Text          = "Correo o password incorrectos";
                    TextBoxUsuario.Text = "";
                }
                else
                {
                    hash = funciones.obtener_hash_usuario(correo);
                    if (PasswordHash.ValidatePassword(TextBoxPassword.Text, hash))
                    {
                        activado = datos_sesion.GetData(hash)[0].activacion_usuario;
                        if (funciones.comprobar_multiple_acceso(correo, hash) == 1)
                        {
                            acceso = true;
                        }
                        else
                        {
                            acceso = false;
                        }
                        id = datos_sesion.GetData(hash)[0].id_usuario;
                        if (acceso)
                        {
                            TextBoxUsuario.Text  = "";
                            TextBoxPassword.Text = "";
                            Session["Logged"]    = false;
                            Session["Usuario"]   = "";
                            Session["Permisos"]  = "";
                            Session["Area"]      = "";
                            Session["Activado"]  = "";
                            error.Text           = "Esta cuenta ha registrado un multiple acceso, esta cuenta ha sido desactivada por su seguridad";
                            procedimientos.desactivar_cuenta_usuario(id);
                            procedimientos.validar_salida_usuario(id);
                        }
                        else if (activado == false)
                        {
                            TextBoxUsuario.Text  = "";
                            TextBoxPassword.Text = "";
                            Session["Logged"]    = false;
                            Session["Usuario"]   = "";
                            Session["Permisos"]  = "";
                            Session["Area"]      = "";
                            Session["Activado"]  = "";
                            error.Text           = "Esta cuenta no esta activa";
                        }
                        else
                        {
                            nivel  = datos_sesion.GetData(hash)[0].nivel_usuario;
                            area   = datos_sesion.GetData(hash)[0].area_usuario;
                            nombre = datos_sesion.GetData(hash)[0].nombre_usuario;
                            procedimientos.validar_entrada_usuario(id);
                            if (funciones.comprobar_multiple_acceso(correo, hash) == 1)
                            {
                                acceso = true;
                            }
                            else
                            {
                                acceso = false;
                            }
                            Session["ID"]       = id;
                            Session["Logged"]   = acceso;
                            Session["Usuario"]  = nombre;
                            Session["Permisos"] = nivel;
                            Session["Area"]     = area;
                            Session["Activado"] = activado;
                            Response.Redirect("../Principal/Inicio.aspx");
                        }
                    }
                    else
                    {
                        error.Text          = "Correo o password incorrectos";
                        TextBoxUsuario.Text = "";
                    }
                }
            }
            catch (Exception ex) { error.Text = ex.ToString(); }
        }
Exemplo n.º 10
0
    protected void ButtonAgregarEvento_Click(object sender, EventArgs e)
    {
        ProcsTableAdapter procesos           = new ProcsTableAdapter();
        FuncsTableAdapter funciones          = new FuncsTableAdapter();
        List <DateTime>   fechaSeleccionada  = (List <DateTime>)Session["FechasSeleccionadas"];
        ArrayList         horasSeleccionadas = (ArrayList)Session["HorasSeleccionadas"];
        bool success = true;

        procesos.agregar_evento
        (
            (int)Session["ID"],
            (int)Session["SalaSeleccionada"],
            TextBoxNombreEvento.Text,
            CheckBoxGrabar.Checked,
            CheckBoxTransmitir.Checked,
            CheckBoxVideoConferencia.Checked,
            false
        );

        int idEvento = (int)funciones.obtener_id_evento_agregado
                       (
            (int)Session["SalaSeleccionada"],
            (int)Session["ID"],
            TextBoxNombreEvento.Text
                       );

        obtener_datos_validacion_usuarioTableAdapter datosUsuario = new obtener_datos_validacion_usuarioTableAdapter();

        var datosUsu = datosUsuario.GetData(funciones.obtener_hash_usuario(Session["Correo"].ToString()));


        for (int j = 0; j < fechaSeleccionada.Count; j++)
        {
            for (int i = 0; i < horasSeleccionadas.Count; i++)
            {
                TimeSpan horaSeleccionada = TimeSpan.FromHours(Convert.ToDouble(horasSeleccionadas[i]));
                try
                {
                    if (TextBoxNombreEvento.Text.Trim().Equals(""))
                    {
                        labelNombreEvento.InnerHtml = "Nombre del evento (escriba un nombre para el evento):";
                    }
                    else
                    {
                        procesos.agregar_detalle_evento
                        (
                            idEvento,
                            fechaSeleccionada[j],
                            horaSeleccionada
                        );
                    }
                }
                catch (Exception err)
                {
                    mostrarMensaje();
                    LabelMensaje.Text = "Ocurrió un error al agregar el evento";
                    success           = false;
                }
            }
        }

        if (success)
        {
            Correo correo = new Correo();
            obtener_administradoresTableAdapter admins = new obtener_administradoresTableAdapter();
            for (int i = 0; i < admins.GetData().Rows.Count; i++)
            {
                string nombreAdmin = admins.GetData()[i].nombre_usuario + " " + admins.GetData()[i].apellido_usuario;
                string correoAdmin = admins.GetData()[i].correo_usuario;
                correo.enviarEventoAdministrador
                (
                    correoAdmin,
                    nombreAdmin,
                    datosUsu[0].nombre_usuario,
                    datosUsu[0].apellido_usuario,
                    TextBoxNombreEvento.Text,
                    Session["NombreSalaSeleccionada"].ToString(),
                    fechaSeleccionada,
                    horasSeleccionadas,
                    idEvento.ToString()
                );
            }
            Session["NombreEvento"] = TextBoxNombreEvento.Text;
            Session["Solicitante"]  = datosUsu[0].nombre_usuario + " " + datosUsu[0].apellido_usuario;
            Session["HashEvento"]   = idEvento.ToString() + ":" + PasswordHash.PasswordHash.CreateHash(idEvento.ToString());
            horasSeleccionadas.Insert(0, -1);
            horasSeleccionadas.Add(-1);
            Session["HorasSeleccionadas"] = horasSeleccionadas;

            if (CheckBoxGrabar.Checked)
            {
                Session["Grabacion"] = "Si";
            }
            if (CheckBoxTransmitir.Checked)
            {
                Session["Streaming"] = "Si";
            }
            if (CheckBoxVideoConferencia.Checked)
            {
                Session["VideoConferencia"] = "Si";
            }
            mostrarMensaje();
            LabelMensaje.Text = "El evento ha sido registrado correctamente, imprima 3 copias de su solicitud para aprobar su registro. <br />"
                                + "El periodo de entrega de la solicitud es de 3 días, posterior a eso el registro se perderá y necesitará solicitarlo de nuevo.";
        }
    }