Once per week in Generation II and once per day in Generations III, IV, VI, and VII, the player may take part in the Pokémon Lottery Corner. This involves the generation of a random 5 digit number, which is compared with the player's Pokémon's original Trainer's ID numbers. Depending on the game and the nature of the match-up of digits, the player can receive a prize.
A trainer ID is a number, and, as far as I know, the player has no control over what their trainer ID is. OT is the original trainer of a Pokemon. The Lottery Corner works by generating a random set of five numbers, instead of generating a random trainer ID. All trainer IDs work with the lottery. The method of obtaining the Pokemon doesn't matter.