Well I recently discovered an effective way to keep my dwarves inside. The drawback is they're rarely allowed to do anything outside so hunting and cutting trees is out of the question. I use a sort of airlock system.
W = wallgrate
L = lever
# = wall
* = weapon trap
###########
########## #########
W******** W rest of fortress...
W******** W
########## ####L L###
# trade # ####
# depot #
###########
Obviously my current fortress doesn't look exactly like that but it's the same concept. Only one set of wall grates are open at a time. For the majority of the time the outer gates are open and the inner gates are closed. This allows traders instant access to the depot once they show up. After the traders are all set up I close the outer gates and open the inner gates allowing trade to commence. A neat trick I found is to chain a dog or two near the trade depot. This gives invaders something to attack that isn't locked away in my fortress and so they wander straight into the weapon traps. When the traps need to be cleaned I simply cycle both gates and let my cleaners get to work in safety.
I could actually leave both gates open if I wanted but I would have to make sure everything outside the fortress was forbidden and I would have to keep a close eye on the weapon traps. If corpses start showing up in the traps I would need to close the outer gates immediately or risk cleaners getting caught in an ambush.
If you linked one set of your wall grates to a lever, [P]ulled the level, then linked the other set, would one close as the other opened?
Anything you link up to levers/pressure plates will sync up automatically (except gear assemblies). So, you couldn't link them to one lever that way.
HOWEVER, you could optimize the airlock to be operated by one lever by replacing the outer set of wall grates with a 2x1 raising drawbridge. The bridge starts lowered, and the grates start closed. Therefore, when the grates are open, the bridge is raised, and forms a wall. Then there will be no delay in switching the airlock, as there is only one lever.