It's kind of complicated, but here goes. . .
The first 14 teams to pick are the teams that didn't make the playoffs. Draft order is determined by team record over the previous season -- worst team picks first, 2nd worst picks second, etc. Except . . . there's a lottery ball. If your team's lottery ball is drawn then you can leapfrog forward 5 places and everybody you leapt over moves back one draft spot. This confusing rule was added to ensure that a team finishing last doesn't necessarily pick first in the draft -- some teams have been accused of playing very bad hockey in order to cinch up the #1 pick for next season. After the Stanley Cup is awarded, the final 16 teams are given their draft order based on their playoff performance.
As for the number of draft rounds, I think it depends on how many players are draft eligible that year. Divide that number of players by 30 (each draft round has 30 selections, one spot for each team) and you've got the number of draft rounds. There's often about 9 rounds but I've heard of draft years with 11th round selections.