Exemplo n.º 1
0
        ///Autentificacion y extracion de datos
        public UserDatos autentificacion(string Ausuario, string Apass)
        {
            UserDatos datos = null;

            try
            {
                if (IsConnect())
                {
                    string cadena = "select E.ID_ct,E.Nombre,E.Apellido,E.ID_scr from Usuario as U inner join Empleado as E on U.ID_user = E.Legajo  where ID_user = '******' and Pass = '******'; ";
                    cmd = new SqlCommand(cadena, conexion);
                    SqlDataReader registro = cmd.ExecuteReader();

                    if (registro.Read())
                    {
                        datos           = new UserDatos();
                        datos.ID_scr    = Convert.ToInt32(registro["ID_scr"]);
                        datos.Nombre    = registro["Nombre"].ToString();
                        datos.Apellido  = registro["Apellido"].ToString();
                        datos.Categoria = Convert.ToInt32(registro["ID_ct"]);
                    }
                    Close();
                    return(datos);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(datos);
        }
Exemplo n.º 2
0
 public int ObtenerUsuario(string usuario, string password)
 {
     try
     {
         if (usuario != vacio && password != vacio)
         {
             UserDatos datos = U_BD.autentificacion(usuario, password);
             if (datos != null)
             {
                 UserGlobal.DATOS = datos;
                 return(1);
             }
             else if (datos == null)
             {
                 return(-1);
             }
         }
     }
     catch (Exception ex) {
         Console.WriteLine(ex);
         UserGlobal.DATOS.Categoria = 9999;
     }
     return(0);
 }