Example #1
0
        public void ObtenerUsuarioPorId(int id)
        {
            AccesoADatos.ConexionOracle conexion = new AccesoADatos.ConexionOracle();
            String query = String.Empty;
            String rol   = String.Empty;

            query = "SELECT u.IDUSUARIO,u.CEDULA,u.NOMBRECOMPLETO,u.USUARIOLOGIN,u.PASSWORDLOGIN" +
                    ",r.NOMBREROL FROM TABLA_USUARIO u inner join TABLA_ROLES_USUARIOS r " +
                    " on u.IDROLUSUARIO = r.IDROLUSUARIO" +
                    " where u.IDUSUARIO =" + id + " ";
            OracleDataReader reader = conexion.Query(query);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    txtNombreUsuario.Text = reader.GetString(3);
                    txtContraseña.Text    = reader.GetString(4);
                    txtCedula.Text        = reader.GetString(1);
                    txtNombre.Text        = reader.GetString(2);
                    llenarComboBoxRoles();
                    rol = reader.GetString(5);
                }
            }
            cbROL.Text = rol;
        }
Example #2
0
        public bool ValidarUsuario()
        {
            String cedula = String.Empty;
            String login  = String.Empty;

            ConexionOracleconCshar.AccesoADatos.ConexionOracle conexion = new AccesoADatos.ConexionOracle();
            String query = "SELECT CEDULA,USUARIOLOGIN FROM TABLA_USUARIO WHERE " +
                           " USUARIOLOGIN = upper('" + txtNombreUsuario.Text + "') or CEDULA = '" + txtCedula.Text + "'";

            OracleDataReader reader = conexion.Query(query);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    cedula = reader.GetString(0);
                    login  = reader.GetString(1);
                }
            }
            if (txtCedula.Text == cedula || txtNombreUsuario.Text.ToUpper() == login)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #3
0
        public void Llenarcampos()
        {
            AccesoADatos.ConexionOracle con = new AccesoADatos.ConexionOracle();
            string           query          = "Select * from Persona where Id =" + idPersonaEditar + "";
            OracleDataReader reader         = con.Query(query);

            if ((reader.HasRows))
            {
                while (reader.Read())
                {
                    txtNombre.Text = reader.GetString(1);
                    txtCedula.Text = reader.GetString(2);
                    dtpFecha.Value = reader.GetDateTime(3);
                }
            }
            lblIdPersona.Text = idPersonaEditar;
        }
Example #4
0
        public void IngresarAlSistema(String usuario, String contraseña)
        {
            AccesoADatos.ConexionOracle conexion = new AccesoADatos.ConexionOracle();
            string query = "";

            query = "SELECT * FROM MIGRACION.TABLA_USUARIO " +
                    "where USUARIOLOGIN = upper('" + usuario + "') and PASSWORDLOGIN = MY_HASH(upper('" + usuario + "'), '" + contraseña + "') ";

            try
            {
                if (ValidarCampos())
                {
                    OracleDataReader reader = conexion.Query(query);

                    if ((reader.HasRows))
                    {
                        while (reader.Read())
                        {
                            usuarioRegistro.idUsuario      = reader.GetInt32(0);
                            usuarioRegistro.Cedula         = reader.GetString(1);
                            usuarioRegistro.NombreCompleto = reader.GetString(2);
                            usuarioRegistro.idROL          = reader.GetInt32(5);
                        }
                        usuarioRegistro.NombreUsuario = txtUsuario.Text;
                        txtUsuario.Clear();
                        txtContraseña.Clear();
                        new frmPrincipal(usuarioRegistro).Show();
                        reader.Close();
                        this.Visible = false;
                    }
                    else if (txtUsuario.Text.Equals("admin") && txtContraseña.Text.Equals("admin"))
                    {
                        usuarioRegistro.idUsuario      = 0;
                        usuarioRegistro.Cedula         = "1";
                        usuarioRegistro.NombreCompleto = "Restaurador de BASE de Datos";
                        usuarioRegistro.idROL          = 2;
                        usuarioRegistro.NombreUsuario  = "Restaurador";
                        txtUsuario.Clear();
                        txtContraseña.Clear();
                        new frmPrincipal(usuarioRegistro).Show();
                        reader.Close();
                        this.Visible = false;
                    }
                    else
                    {
                        txtUsuario.Clear();
                        txtContraseña.Clear();
                        MessageBox.Show("Usuario no Registrado", "Error del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SeleccionPrimero();
                    }
                }
                else
                {
                    MessageBox.Show("Debe ingresar datos en los campos", "Error del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SeleccionPrimero();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Problemas al Realizar la Transaccion", "Error del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }